예제 #1
0
파일: sga.py 프로젝트: moocitfrance/edx-sga
    def get_sorted_submissions(self):
        """returns student recent assignments sorted on date"""
        assignments = []
        submissions = submissions_api.get_all_submissions(
            self.course_id,
            self.block_id,
            ITEM_TYPE
        )

        for submission in submissions:
            if is_finalized_submission(submission_data=submission):
                filename, user_response = None, None
                if "filename" in submission['answer'].keys():
                    filename = submission['answer']['filename']
                if "user_response" in submission['answer'].keys():
                    user_response = submission['answer']['user_response']

                assignments.append({
                    'submission_id': submission['uuid'],
                    'filename': filename,
                    'user_response': user_response,
                    'timestamp': submission['submitted_at'] or submission['created_at']
                })

        assignments.sort(
            key=lambda assignment: assignment['timestamp'], reverse=True
        )
        return assignments
예제 #2
0
 def upload_allowed(self, submission_data=None):
     """
     Return whether student is allowed to upload an assignment.
     """
     submission_data = submission_data if submission_data is not None else self.get_submission(
     )
     return (not self.past_due() and self.score is None
             and not is_finalized_submission(submission_data))
예제 #3
0
 def get_student_data():
     # pylint: disable=no-member
     """
     Returns a dict of student assignment information along with
     annotated file name, student id and module id, this
     information will be used on grading screen
     """
     # Submissions doesn't have API for this, just use model directly.
     students = SubmissionsStudent.objects.filter(
         course_id=self.course_id, item_id=self.block_id)
     for student in students:
         submission = self.get_submission(student.student_id)
         if not submission:
             continue
         user = user_by_anonymous_id(student.student_id)
         student_module = self.get_or_create_student_module(user)
         state = json.loads(student_module.state)
         score = self.get_score(student.student_id)
         approved = score is not None
         if score is None:
             score = state.get('staff_score')
             needs_approval = score is not None
         else:
             needs_approval = False
         instructor = self.is_instructor()
         yield {
             'module_id':
             student_module.id,
             'student_id':
             student.student_id,
             'submission_id':
             submission['uuid'],
             'username':
             student_module.student.username,
             'fullname':
             student_module.student.profile.name,
             'filename':
             submission['answer']["filename"],
             'timestamp':
             submission['created_at'].strftime(
                 DateTime.DATETIME_FORMAT),
             'score':
             score,
             'approved':
             approved,
             'needs_approval':
             instructor and needs_approval,
             'may_grade':
             instructor or not approved,
             'annotated':
             force_text(state.get("annotated_filename", '')),
             'comment':
             force_text(state.get("comment", '')),
             'finalized':
             is_finalized_submission(submission_data=submission)
         }
예제 #4
0
파일: sga.py 프로젝트: mitodl/edx-sga
 def upload_allowed(self, submission_data=None):
     """
     Return whether student is allowed to upload an assignment.
     """
     submission_data = submission_data if submission_data is not None else self.get_submission()
     return (
         not self.past_due() and
         self.score is None and
         not is_finalized_submission(submission_data)
     )
예제 #5
0
파일: sga.py 프로젝트: mitodl/edx-sga
 def get_student_data():
     # pylint: disable=no-member
     """
     Returns a dict of student assignment information along with
     annotated file name, student id and module id, this
     information will be used on grading screen
     """
     # Submissions doesn't have API for this, just use model directly.
     students = SubmissionsStudent.objects.filter(
         course_id=self.course_id,
         item_id=self.block_id)
     for student in students:
         submission = self.get_submission(student.student_id)
         if not submission:
             continue
         user = user_by_anonymous_id(student.student_id)
         student_module = self.get_or_create_student_module(user)
         state = json.loads(student_module.state)
         score = self.get_score(student.student_id)
         approved = score is not None
         if score is None:
             score = state.get('staff_score')
             needs_approval = score is not None
         else:
             needs_approval = False
         instructor = self.is_instructor()
         yield {
             'module_id': student_module.id,
             'student_id': student.student_id,
             'submission_id': submission['uuid'],
             'username': student_module.student.username,
             'fullname': student_module.student.profile.name,
             'filename': submission['answer']["filename"],
             'timestamp': submission['created_at'].strftime(
                 DateTime.DATETIME_FORMAT
             ),
             'score': score,
             'approved': approved,
             'needs_approval': instructor and needs_approval,
             'may_grade': instructor or not approved,
             'annotated': force_text(state.get("annotated_filename", '')),
             'comment': force_text(state.get("comment", '')),
             'finalized': is_finalized_submission(submission_data=submission)
         }
예제 #6
0
파일: sga.py 프로젝트: mitodl/edx-sga
    def get_sorted_submissions(self):
        """returns student recent assignments sorted on date"""
        assignments = []
        submissions = submissions_api.get_all_submissions(
            self.course_id,
            self.block_id,
            ITEM_TYPE
        )

        for submission in submissions:
            if is_finalized_submission(submission_data=submission):
                assignments.append({
                    'submission_id': submission['uuid'],
                    'filename': submission['answer']["filename"],
                    'timestamp': submission['submitted_at'] or submission['created_at']
                })

        assignments.sort(
            key=lambda assignment: assignment['timestamp'], reverse=True
        )
        return assignments
예제 #7
0
def test_is_finalized_submission(submission_data, expected_value):
    """Test for is_finalized_submission"""
    assert is_finalized_submission(submission_data) is expected_value
예제 #8
0
def test_is_finalized_submission(submission_data, expected_value):
    """Test for is_finalized_submission"""
    assert is_finalized_submission(submission_data) is expected_value
예제 #9
0
파일: tasks.py 프로젝트: eduNEXT/edx-sga
 def final_submissions(submissions):
     for submission in submissions:
         if is_finalized_submission(submission_data=submission):
             yield submission