def run_updater(): asgn_key = request.json['full_asgn'] qn = request.json['qn'] code = request.json['code'] with locked_file(temp_filename, 'w') as f: f.write(code) try: import userupdater reload(userupdater) except SyntaxError as e: err = f'ERROR: SyntaxError in updater\nLine: {e.lineno}' return err try: q = Assignment(asgn_key).questions[int(qn) - 1] except AssertionError as e: return f'Assertion failed while loading assignment: {e.args[0]}' try: q.magic_update(userupdater.updater) except AssertionError as e: return f'AssertionError in magic_update: {e.args[0]}' except Exception as e: return f'Exception running updater function: {e}' return 'Success'
def load_rubric(mini_name, qn): qndx = int(qn) - 1 rubric_path = os.path.join(rubric_base_path, mini_name, f'q{qn}.json') if not os.path.exists(rubric_path): return 'null' else: with locked_file(rubric_path) as f: rubric = json.load(f) started = False for asgn in asgn_data['assignments']: data = asgn_data['assignments'][asgn] if (fatd(asgn) == mini_name and data['grading_started']): cls_asgn = Assignment(asgn) qn = cls_asgn.questions[qndx] # grading has started if any handin is extracted started = any([h.extracted for h in qn.handins]) break return json.dumps({'started': started, 'rubric': rubric})
def determine_grade(raw_grade: RawGrade, late: bool, asgn: Assignment) -> Grade: """ given a raw grade (i.e. category -> float dictionary), determine the student's full grade (i.e. category -> string dictionary) :param raw_grade: a raw grade (defined in custom_types) :type raw_grade: RawGrade :param asgn: the Assignment for which to determine the grade :type asgn: Assignment :param late: whether or not the student handed in the assignment late :type late: bool :returns: The grade to give the student (following spec from custom_types) :rtype: Grade **Example**: >>> determine_grade({"Functionality": 20, "Design": 12}, "Homework1") 32 >>> determine_grade({"Functionality": 12, "Design": 4}, "Homework 6") {"Functionality": "Check Plus", "Design": "Check Minus"} """ max_grades = asgn.max_grades() # cat -> max possible grade final_grade = {} for cat in raw_grade: if raw_grade[cat] is None: final_grade[cat] = "No handin" continue max_grade = max_grades[cat] grade_val = max(raw_grade[cat], 0) final_grade[cat] = f"{grade_val} / {max_grade}" return final_grade
default=[], help= "one or more types to have the solver declare, for example: Foo,var,Bar. Format is (typeName, memberName, memberType)" ) args = parser.parse_args() parallel = args.parallel verbosity = args.verbosity tmp = [x.split(',', 1) for x in list(set(args.var))] variables = [Variable(y[0], y[1]) for y in tmp] variables += [ Constant(y[0], y[1], y[2]) for y in [x.split(',', 2) for x in args.const] ] variables += [ Assignment(y[0], y[1], y[2]) for y in [x.split(',', 2) for x in args.assign] ] expr = args.expr funcCallDef = { y[1]: [y[0]] for y in [x.split(',', 1) for x in args.funcCallDef] } for x in [x.split(',', 1) for x in args.funcCallExpr]: funcCallDef[x[0]].append(x[1]) funcCalls = [FuncCall(v[0], k, v[1:]) for k, v in funcCallDef.items()] dataTypes = {}