Exemple #1
0
 def test_get_team_submission_for_team_error(self, mocked_qs):
     """
     Test for error behavior within team_api.get_team_submission_for_team
     """
     mocked_qs.side_effect = Exception('!!!error!!!')
     with self.assertRaisesMessage(TeamSubmissionInternalError, 'caused error: !!!error!!!'):
         team_api.get_team_submission_for_team(COURSE_ID, ITEM_1_ID, TEAM_1_ID)
Exemple #2
0
 def test_get_team_submission_for_team_not_found(self):
     """
     Test that calling team_api.get_team_submission_for_team when there is no matching TeamSubmission will
     raise a TeamSubmissionNotFoundError
     """
     self._make_team_submission()
     with self.assertRaises(TeamSubmissionNotFoundError):
         team_api.get_team_submission_for_team(COURSE_ID, ITEM_1_ID, TEAM_2_ID)
Exemple #3
0
 def does_team_have_submission(self, team_id):
     try:
         student_item_dict = self.get_student_item_dict()
         get_team_submission_for_team(student_item_dict['course_id'],
                                      student_item_dict['item_id'], team_id)
         # If there's no submission, we will raise a TeamSubmissionNotFoundError
         return True
     except TeamSubmissionNotFoundError:
         return False
Exemple #4
0
 def test_get_team_submission_for_team(self):
     """
     Test that calling team_api.get_team_submission_for_team returns the expected team submission
     """
     team_submission = self._make_team_submission(create_submissions=True)
     team_submission_dict = team_api.get_team_submission_for_team(
         COURSE_ID, ITEM_1_ID, TEAM_1_ID)
     self.assertDictEqual(team_submission_dict,
                          TeamSubmissionSerializer(team_submission).data)
Exemple #5
0
    def get_team_submission_uuid(self):
        """
        Gets the uuid for the team submission for this user's team.

        Returns: team submission uuid if one exists, or
                 None if none exists or there was an error looking it up
        """
        if not self.has_team():
            return None

        student_item_dict = self.get_student_item_dict()
        try:
            team_submission = team_sub_api.get_team_submission_for_team(
                student_item_dict['course_id'],
                student_item_dict['item_id'],
                self.team.team_id
            )
        except (TeamSubmissionNotFoundError, TeamSubmissionInternalError):
            return None
        return team_submission['team_submission_uuid']
Exemple #6
0
    def clear_team_state(self, user_id, course_id, item_id,
                         requesting_user_id):
        """
        This is called from clear_student_state (which is called from the LMS runtime) when the xblock is a team
        assignment, to clear student state for an entire team for a given problem. It will cancel the workflow
        to remove it from the grading pools, and pass through to the submissions team API to orphan the team
        submission and individual submissions so that the team can create a new submission.
        """
        error_msg_base = 'Attempted to clear team state for anonymous user {} '.format(
            user_id)
        try:
            user_team = self.get_team_for_anonymous_user(user_id)
        except ObjectDoesNotExist:
            warning_msg = error_msg_base + 'but was unable to resolve to a real user'
            logger.warning(warning_msg)
            return

        if user_team is None:
            warning_msg = error_msg_base + 'but they are not on a team for course {} item {}.'.format(
                course_id, item_id)
            logger.warning(warning_msg)
            return

        from submissions import team_api as team_submissions_api

        try:
            team_submission = team_submissions_api.get_team_submission_for_team(
                course_id, item_id, user_team.team_id)
        except TeamSubmissionNotFoundError:
            warning_msg = error_msg_base + "course {} item {} but no team submission was found for team {}".format(
                course_id, item_id, user_team.team_id)
            logger.warning(warning_msg)

        # Remove the submission from grading pool
        self._cancel_team_workflow(team_submission['team_submission_uuid'],
                                   "Student and team state cleared",
                                   requesting_user_id)
        # Tell the submissions API to orphan the submissions to prevent them from being accessed
        team_submissions_api.reset_scores(
            team_submission['team_submission_uuid'])