def get_answers(course): course_id = course['id'] for problemset in course['problemsets']: problemset_id = problemset['id'] question_set = problemset['questions'] questions = [q['id'] for q in question_set] answers = JBoxCourseHomework.get_problemset_metadata( course_id, problemset_id, questions, True) answers_file = '_'.join([course_id, problemset_id, 'answers']) with open(answers_file, 'w') as f: f.write(json.dumps(answers, indent=4)) print("\tanswer file %s created" % (answers_file, ))
def get_report(course, ascsv=False): course_id = course['id'] for problemset in course['problemsets']: problemset_id = problemset['id'] question_set = problemset['questions'] questions = [q['id'] for q in question_set] report = JBoxCourseHomework.get_report(course_id, problemset_id, questions) report_file = '_'.join([course_id, problemset_id, 'report']) with open(report_file, 'w') as f: if ascsv: report_as_csv(f, report) else: f.write(json.dumps(report, indent=4)) print("\treport file %s created" % (report_file, ))