def send_lti_grade(assignment, student, lti_record, db): # get total points for assignment, so can compute percentage to send to gradebook via LTI points = assignment.points grade = db((db.grades.auth_user == student.id) & (db.grades.assignment == assignment.id)).select().first() if grade and grade.lis_result_sourcedid and grade.lis_outcome_url and lti_record: # send it back to the LMS # have to send a percentage of the max score, rather than total points pct = grade.score / float(points) if points else 0.0 # print("score", score, points, pct) request = OutcomeRequest({ "consumer_key": lti_record.consumer, "consumer_secret": lti_record.secret, "lis_outcome_service_url": grade.lis_outcome_url, "lis_result_sourcedid": grade.lis_result_sourcedid }) resp = request.post_replace_result(pct) # print(resp) return pct elif grade and grade.lis_result_sourcedid and grade.lis_outcome_url: print("would have sent", grade.score / float(points) if points else 0.0) elif grade: print("nowhere to send", student.id) else: print("nothing to send", student.id) return "No grade sent"
def send_lti_grade(assignment_points, score, consumer, secret, outcome_url, result_sourcedid): pct = score / float(assignment_points) if score and assignment_points else 0.0 # print "pct", pct # send it back to the LMS # print("score", score, points, pct) request = OutcomeRequest({"consumer_key": consumer, "consumer_secret": secret, "lis_outcome_service_url": outcome_url, "lis_result_sourcedid": result_sourcedid}) resp = request.post_replace_result(pct) # print(resp) return pct
def new_request(self, defaults): opts = dict(defaults) opts.update({ 'consumer_key': self.consumer_key, 'consumer_secret': self.consumer_secret, 'lis_outcome_service_url': self.lis_outcome_service_url, 'lis_result_sourcedid': self.lis_result_sourcedid }) self.outcome_requests.append(OutcomeRequest(opts=opts)) self._last_outcome_request = self.outcome_requests[-1] return self._last_outcome_request
def new_request(self): opts = defaultdict(lambda: None) opts = { 'consumer_key': self.consumer_key, 'consumer_secret': self.consumer_secret, 'lis_outcome_service_url': self.lis_outcome_service_url, 'lis_result_sourcedid': self.lis_result_sourcedid } self.outcome_requests.append(OutcomeRequest(opts=opts)) self.last_outcome_request = self.outcome_requests[-1] return self.last_outcome_request