def instructorCourseSettings(cid): ''' Function Type: View Function Template: instructor/courseSettings.html Purpose: Allows an instructor to manipulate the assignemnts of a course. Course settings, and the users and graders for a course. Inputs: cid: The object ID of the course being administered Template Parameters: course: The course specified by <cid> to be administered students: A list of user objects who are enrolled as students grutors: A list of user objects who are enrolled as grutors instrs: A list of user objects who are enrolled as instructorSaveSettings guserform: An AddUserCourseForm for adding grutors suserform: An AddUserCourseForm for adding students iuserform: An AddUserCourseForm for adding instructors settingsForm: A CourseSettingsForm for changing the settings of the course Forms Handled: None ''' try: c = Course.objects.get(id=cid) if not c in current_user.courseInstructor: abort(403) #Get the users for this course s = User.objects.filter(courseStudent=c) grutor = User.objects.filter(courseGrutor=c) i = User.objects.filter(courseInstructor=c) settingsForm = CourseSettingsForm() lateCalculators = getLateCalculators() settingsForm.latePolicy.choices = [(x,x) for x in lateCalculators.keys()] #Make sure all users have anonIds if c.anonymousGrading: c.ensureIDs() #TODO: Refactor forms to use javascript/AJAX return render_template("instructor/courseSettings.html",\ course=c, students=s, grutors=grutor, instrs=i,\ form=CreateAssignmentForm(), suserform=AddUserCourseForm(),\ guserform=AddUserCourseForm(), iuserform=AddUserCourseForm(), settingsForm=settingsForm) except Course.DoesNotExist: return abort(404)
def getStudentAssignmentScores(course, user): '''Generates a gradelist and runs it through the late calculator''' # Create a gradelist gl = [] for a in course.assignments: al = [] for p in sorted(a.problems, key=lambda x: x.name): sub = p.getLatestSubmission(user) if not sub == None: gradeData = {} gradeData['rawTotalScore'] = sub.grade.totalScore() gradeData['timeDelta'] = p.duedate - sub.submissionTime gradeData['isLate'] = sub.isLate gradeData['maxScore'] = p.totalPoints() al.append(gradeData) else: al.append(None) gl.append(al) lateCalculator = getLateCalculators()[course.lateGradePolicy] gl = lateCalculator(gl) return gl