My workbooks
‌
‌
‌
‌
‌
‌
‌
‌
‌
‌
‌
‌
‌
‌
Sign up
Beta
Spinner
# Start coding here... 
from urllib.request import urlopen
import json

# Get the course id from the end of the course link in teach
# settings>course details>course link
# https://app.datacamp.com/learn/courses/30565
campus_id='32340'

base_url=('https://campus-api.datacamp.com/api/courses/%s'%campus_id)
 
response = urlopen(base_url)
data_json = json.loads(response.read())
  
# test responses
# print('Chapter %s:'% data_json['chapters'][0]['number'] , data_json['chapters'][0]['title'])
#print( data_json['chapters'][0]['id'])
# print('Exercise %s:'%data_json['chapters'][0]['exercises'][0]['number'], data_json['chapters'][0]['exercises'][0]['title'])
# print(type(data_json['chapters']))


print('Please read the key below to understand _how_ to respond to the feedback provided. Some items will require you to take action while others only need some thought. **During this round of feedback, each item with an associated check box is an action item that should be implemented before moving to the next step in _Course Development_. As you implement the feedback, please click the _check boxes_ to indicate you addressed that feedback.** \n\n\n## Key \n\n:wrench: This **must** be fixed during this round of review. This change is necessary to create a good **DataCamp** course. \n\n:mag: This wasn’t exactly clear. This will need rephrasing or elaborating to fully and clearly convey your meaning. \n\n:thinking: This is something we should think about. There is no need to make changes now, but it may need updating by the end of *Development*. \n\n:star: Excellent work! \n\n ___ \n\n\n## General feedback')


for ch in data_json['chapters']:
    print('## Chapter %s:'% ch['number'] , ch['title'], '\n')
    
    exercise_url=(base_url+'/chapters/'+str(ch['id'])+'/exercises')    
    response_exercises = urlopen(exercise_url)
    ch_exercise_json = json.loads(response_exercises.read())
    
    
    for ex in ch_exercise_json:
        print('### Exercise %s:'%ex['number'], ex['title'],)
        Exercise_type=ex['type']
        
        
        if(Exercise_type=='PureMultipleChoiceExercise'):
            print('#### Exercise Title\n:star:\n\n#### Question\n:star:\n\n#### Hints\n:star:\n\n#### Possible answers\n:star:\n\n#### Feedback messages\n:star:\n\n')
           
        elif(Exercise_type=='NormalExercise'):
           print('#### Exercise Title\n:star:\n\n#### Context\n:star:\n\n#### Instructions\n:star:\n\n#### Hints\n:star:\n\n#### Sample code\n:star:\n\n#### Solution code\n:star:\n\n#### Success message\n:star:\n\n')
           
        elif(Exercise_type=='DragAndDropExercise'):
           print('#### Exercise Title\n:star:\n\n#### Context\n:star:\n\n#### Instructions\n:star:\n\n#### Hints\n:star:\n\n#### Zone names\n:star:\n\n#### Items\n:star:\n\n#### Incorrect messages\n:star:\n\n#### Success message\n:star:\n\n#### Failure message\n:star:\n\n')
         
        elif(Exercise_type=='ExplorableExercise'):
           print('#### Exercise Title\n:star:\n\n#### Context\n:star:\n\n#### App\n:star:\n\n#### Hints\n:star:\n\n#### Possible answers\n:star:\n\n#### Feedback messages\n:star:\n\n')
        
        elif(Exercise_type=='RemoteDesktopExercise'):
           print('#### Exercise Title\n:star:\n\n#### Context\n:star:\n\n#### Steps\n:star:\n\n#### Hints\n:star:\n\n#### Possible answers\n:star:\n\n#### Feedback messages\n:star:\n\n')
        
        elif(Exercise_type=='VideoExercise'):
            projector_url='https://projector.datacamp.com/api/videos/'+ ex['projector_key'] + '/transcript' 
            response_projector = urlopen(projector_url)
            projector_json = json.loads(response_projector.read())
            
            for slide in projector_json['slides']:
                print('###### slide %s -'% slide['number'], slide['title'],'\n:star:\n')
    
    
        else:
            print(Exercise_type,'\n')
            
            
    
    
    
    
  • AI Chat
  • Code