def get_utorid_to_group(api: markusapi.Markus, assignment_id: int) -> Dict[str, dict]: """Return a mapping from utroid to MarkUs group record.""" return { group['group_name']: group for group in api.get_groups(assignment_id) }
def upload_result_files(api: markusapi.Markus, assignment_id: int, local_dir: str, result_file_name: str): """Upload local_dir/utorid/result_file_name into each student repo on MarkUs. """ groups = api.get_groups(assignment_id) for group in groups: group_id, utorid = group['id'], group['group_name'] upload_result_file(api, assignment_id, local_dir, result_file_name, utorid, group_id)
def upload_grades(api: markusapi.Markus, assignment_id: int, gf_file: TextIO, criteria: Dict[str, Tuple[str, float]], complete=True): """Upload grades. criteria maps test-name-in-gf-file to (criteria-name, out-of) on MarkUs. criteria on MarkUs needs to be set up beforehand. Can't find a way to upload it with API... TODO. if complete, set MarkUs submission status to "complete" """ gbook = gb.GradeBook.load_gf_file(gf_file, 'utorid', True) groups = api.get_groups(assignment_id) for group in groups: group_id, utorid = group['id'], group['group_name'] upload_grade(api, assignment_id, criteria, utorid, gbook, None, group_id, complete)
def get_submissions(api: markusapi.Markus, assignment_id: int, markus_files: List[str], local_dir: str, local_files: List[str]): """Download all submissions for assignment_id and store them locally. If markus_files is None, then download a zip file of entire submission. The name of the local zip file must be specified in local_files[0]. markus_files: names/paths of the files on MarkUs, for each student, to download. local_dir, local_files: write files locally in local_dir/utorid/local_file, for each student (utorid). """ groups = api.get_groups(assignment_id) for group in groups: group_id, utorid = group['id'], group['group_name'] get_submission(api, assignment_id, markus_files, local_dir, local_files, utorid, group_id)
in the assignment's marking scheme (punctuation included). Marks need to be valid numerics, or 'nil'. If the criterion is a Rubric, the mark just needs to be the rubric level, and will be multiplied by the weight automatically. """ d = {'My Criterion 1.': 1.0, 'My Criterion 2.': 'nil'} return d """ --------Ideally, nothing below need be touched-------- """ if __name__ == '__main__': # Initialize an instance of the API class api = Markus(API_KEY, ROOT_URL) print('Initialized Markus object successfully.') groups = api.get_groups(ASSIGNMENT_ID) for group in groups: group_name = group['group_name'] group_id = group['id'] try: with open(os.path.join(ROOT_DIR, group_name, FILE_NAME)) as open_file: file_contents = open_file.read() # Upload the feedback file try: response = api.upload_feedback_file( ASSIGNMENT_ID, group_id, FILE_NAME, file_contents) print( 'Uploaded feedback file for {}, Markus responded: {}'. format(group_name, response))
Criteria titles need to be properly formatted, as they appear in the assignment's rubric (punctuation included). Marks need to be valid numerics, or 'nil'. """ d = {} d['My Criteria 1.'] = 1.0 d['My Criteria 2.'] = 'nil' return d """ --------Ideally, nothing below need be touched-------- """ # Initialize an instance of the API class api = Markus(API_KEY, ROOT_URL) print('Initialized Markus object successfully.') group_names = api.get_groups(ASSIGNMENT_ID).keys() # Upload the test results. for group in group_names: with open(ROOT_DIR + '/' + group + '/' + FILE_NAME) as open_file: try: file_contents = open_file.read() api.upload_test_results(ASSIGNMENT_ID, group, FILE_NAME, file_contents) except: print('Error: uploading results for {} failed.'.format(locals())) print('Done uploading results.') # All test results files are now uploaded. # We now want to extract marks from each file. for group in group_names:
Criteria titles need to be properly formatted, as they appear in the assignment's marking scheme (punctuation included). Marks need to be valid numerics, or 'nil'. If the criterion is a Rubric, the mark just needs to be the rubric level, and will be multiplied by the weight automatically. """ d = {'My Criterion 1.': 1.0, 'My Criterion 2.': 'nil'} return d """ --------Ideally, nothing below need be touched-------- """ # Initialize an instance of the API class api = Markus(API_KEY, ROOT_URL) print('Initialized Markus object successfully.') groups = api.get_groups(ASSIGNMENT_ID) for group in groups: group_name = group['group_name'] group_id = group['id'] try: with open(ROOT_DIR + '/' + group_name + '/' + FILE_NAME) as open_file: file_contents = open_file.read() # Upload the feedback file try: response = api.upload_feedback_file(ASSIGNMENT_ID, group_id, FILE_NAME, file_contents) print('Uploaded feedback file for {}, Markus responded: {}'.format(group_name, response)) except: print('Error: uploading feedback file for {} failed'.format(group_name)) # Extract and upload marks from the feedback file try: