|
18 | 18 | # Third-party imports |
19 | 19 | # ------------------- |
20 | 20 | from psycopg2 import IntegrityError |
21 | | -from rs_grading import do_autograde, do_calculate_totals, do_check_answer, send_lti_grade |
22 | | -from db_dashboard import DashboardDataAnalyzer |
23 | 21 | import six |
24 | 22 | import bleach |
25 | 23 |
|
| 24 | +# Local application imports |
| 25 | +# ------------------------- |
| 26 | +from rs_grading import do_autograde, do_calculate_totals, do_check_answer, send_lti_grade, _get_lti_record, _try_to_send_lti_grade |
| 27 | +from db_dashboard import DashboardDataAnalyzer |
| 28 | + |
26 | 29 | logger = logging.getLogger(settings.logger) |
27 | 30 | logger.setLevel(settings.log_level) |
28 | 31 |
|
@@ -362,39 +365,6 @@ def _autograde(sid=None, student_rownum=None, question_name=None, enforce_deadli |
362 | 365 | return {'success': False, 'message': "Select an assignment before trying to autograde."} |
363 | 366 |
|
364 | 367 |
|
365 | | -def _get_assignment(assignment_id): |
366 | | - return db(db.assignments.id == assignment_id).select().first() |
367 | | - |
368 | | -def _try_to_send_lti_grade(student_row_num, assignment_id): |
369 | | - # try to send lti grades |
370 | | - assignment = _get_assignment(assignment_id) |
371 | | - if not assignment: |
372 | | - session.flash = "Failed to find assignment object for assignment {}".format(assignment_id) |
373 | | - return False |
374 | | - else: |
375 | | - grade = db( |
376 | | - (db.grades.auth_user == student_row_num) & |
377 | | - (db.grades.assignment == assignment_id)).select().first() |
378 | | - if not grade: |
379 | | - session.flash = "Failed to find grade object for user {} and assignment {}".format(auth.user.id, |
380 | | - assignment_id) |
381 | | - return False |
382 | | - else: |
383 | | - lti_record = _get_lti_record(session.oauth_consumer_key) |
384 | | - if (not lti_record) or (not grade.lis_result_sourcedid) or (not grade.lis_outcome_url): |
385 | | - session.flash = "Failed to send grade back to LMS (Coursera, Canvas, Blackboard...), probably because the student accessed this assignment directly rather than using a link from the LMS, or because there is an error in the assignment link in the LMS. Please report this error." |
386 | | - return False |
387 | | - else: |
388 | | - # really sending |
389 | | - # print("send_lti_grade({}, {}, {}, {}, {}, {}".format(assignment.points, grade.score, lti_record.consumer, lti_record.secret, grade.lis_outcome_url, grade.lis_result_sourcedid)) |
390 | | - send_lti_grade(assignment.points, |
391 | | - score=grade.score, |
392 | | - consumer=lti_record.consumer, |
393 | | - secret=lti_record.secret, |
394 | | - outcome_url=grade.lis_outcome_url, |
395 | | - result_sourcedid=grade.lis_result_sourcedid) |
396 | | - return True |
397 | | - |
398 | 368 | @auth.requires_login() |
399 | 369 | def student_autograde(): |
400 | 370 | """ |
@@ -728,9 +698,6 @@ def chooseAssignment(): |
728 | 698 |
|
729 | 699 | # The rest of the file is about the the spaced practice: |
730 | 700 |
|
731 | | -def _get_lti_record(oauth_consumer_key): |
732 | | - return db(db.lti_keys.consumer == oauth_consumer_key).select().first() |
733 | | - |
734 | 701 | def _get_course_practice_record(course_name): |
735 | 702 | return db(db.course_practice.course_name == course_name).select().first() |
736 | 703 |
|
@@ -893,7 +860,7 @@ def practice(): |
893 | 860 | flashcard.sub_chapter_label) |
894 | 861 | # If the student has any flashcards to practice and has not practiced enough to get their points for today or they |
895 | 862 | # have intrinsic motivation to practice beyond what they are expected to do. |
896 | | - if (available_flashcards_num > 0 and |
| 863 | + if (available_flashcards_num > 0 and |
897 | 864 | len(questions) > 0 and |
898 | 865 | (practiced_today_count != questions_to_complete_day or |
899 | 866 | request.vars.willing_to_continue or |
|
0 commit comments