def getTeamResults(req, courseId, assignmentId, teamname=None, locale=websutil.DEFAULT_LOCALE): """Get the results for a given team name. If the team name is empty, get the results of the current user's team.""" websutil.install_i18n(websutil.sanityCheckLocale(locale)) websutil.sanityCheckAssignmentId(assignmentId) websutil.sanityCheckCourseId(courseId) if teamname != None: websutil.sanityCheckUsername(teamname) req.content_type = 'text/html' strout = websutil.OutputString() # Check permission s = Session.Session(req) if s.is_new(): s.invalidate() return json.dumps({'errorType':websutil.ERR_AUTH, 'errorMessage':"", 'errorTrace':""}) try: s.load() current_user = s['username'] except: traceback.print_exc(file = strout) return json.dumps({'errorType' : websutil.ERR_EXCEPTION, 'errorMessage' : "", 'errorTrace' : strout.get()}) (hasTeam, current_team) = websutil.getAssignmentAccountName(courseId, assignmentId, current_user, strout) if teamname == None: if not hasTeam: # User is not part of any team for the assignment return json.dumps({'errorType' : websutil.ERR_OTHER, 'errorMessage' : "User is not part of any team for this assignment", 'errorTrace' : ""}) teamname = current_team # Reset the timeout s.save() return websutil.getResultsHelper(courseId, assignmentId, current_user, strout, teamname = teamname, currentTeam = current_team)
def getUserResults(req, courseId, assignmentId, username=None, locale=websutil.DEFAULT_LOCALE): """Get the individual results for a given username. If the username is empty, get the results of the current user.""" websutil.install_i18n(websutil.sanityCheckLocale(locale)) websutil.sanityCheckAssignmentId(assignmentId) websutil.sanityCheckCourseId(courseId) if username != None: websutil.sanityCheckUsername(username) req.content_type = 'text/html' strout = websutil.OutputString() # Check permission s = Session.Session(req) if s.is_new(): s.invalidate() return json.dumps({ 'errorType': websutil.ERR_AUTH, 'errorMessage': "", 'errorTrace': "" }) try: s.load() current_user = s['username'] except: traceback.print_exc(file=strout) return json.dumps({ 'errorType': websutil.ERR_EXCEPTION, 'errorMessage': "", 'errorTrace': strout.get() }) # Reset the timeout s.save() return websutil.getResultsHelper(courseId, assignmentId, current_user, strout, username=username)
def getUserResults(req, courseId, assignmentId, username=None, locale=websutil.DEFAULT_LOCALE): """Get the individual results for a given username. If the username is empty, get the results of the current user.""" websutil.install_i18n(websutil.sanityCheckLocale(locale)) websutil.sanityCheckAssignmentId(assignmentId) websutil.sanityCheckCourseId(courseId) if username != None: websutil.sanityCheckUsername(username) req.content_type = 'text/html' strout = websutil.OutputString() # Check permission s = Session.Session(req) if s.is_new(): s.invalidate() return json.dumps({'errorType':websutil.ERR_AUTH, 'errorMessage':"", 'errorTrace':""}) try: s.load() current_user = s['username'] except: traceback.print_exc(file = strout) return json.dumps({'errorType' : websutil.ERR_EXCEPTION, 'errorMessage' : "", 'errorTrace' : strout.get()}) # Reset the timeout s.save() return websutil.getResultsHelper(courseId, assignmentId, current_user, strout, username = username)