Beispiel #1
0
 def test_start_workflow_no_individual_submissions(self):
     submission = dict(self.MOCK_TEAM_SUBMISSION)
     submission['submission_uuids'] = []
     with self.assertRaises(AssessmentWorkflowInternalError):
         with self.mock_submissions_api_get(submission):
             TeamAssessmentWorkflow.start_workflow(
                 self.team_submission_uuid)
Beispiel #2
0
def create_workflow(team_submission_uuid):
    """
    A team submission should only be assessible by staff.  Therefore, unlike
    the analogous `create_workflow()` method for individual submissions,
    we don't accept `steps` or `on_init_params` as parameters to this function,
    since those are only used to indicate which assessment steps (e.g. "peer", "self")
    are to be included in the workflow.

    Raises:
        AssessmentWorkflowInternalError on error
    """
    try:
        team_workflow = TeamAssessmentWorkflow.start_workflow(team_submission_uuid)
        logger.info((
            "Started team assessment workflow for "
            "team submission UUID {uuid}"
        ).format(uuid=team_submission_uuid))
        return team_workflow
    except Exception:
        err_msg = (
            "An unexpected error occurred while creating "
            "the workflow for team submission UUID {uuid}"
        ).format(uuid=team_submission_uuid)
        logger.exception(err_msg)
        raise AssessmentWorkflowInternalError(err_msg)
Beispiel #3
0
    def test_update_from_assessments_old_and_new_points_equal(
            self, mock_set_team_score):
        """ There is already an equal score recorded in the submissions API """
        submissions_api_fake_score = {
            'annotations': [{
                'annotation_type':
                TeamAssessmentWorkflow.STAFF_ANNOTATION_TYPE
            }],
            'points_earned':
            9
        }
        assessment_api_fake_score = {
            "points_earned": 9,
            "points_possible": 10,
            "contributing_assessments": ['assessment_1_id'],
            "staff_id": 'staff_id',
        }
        with self.mock_submissions_api_get():
            workflow = TeamAssessmentWorkflow.start_workflow(
                self.team_submission_uuid)

        self.mock_assessment_api.assessment_is_finished.return_value = True
        self._update_from_assessments(workflow, submissions_api_fake_score,
                                      assessment_api_fake_score)
        workflow.refresh_from_db()

        self.assertEqual(workflow.status, TeamAssessmentWorkflow.STATUS.done)
        self.assertEqual(workflow._team_staff_step.assessment_completed_at,
                         now())  # pylint: disable=protected-access
        mock_set_team_score.assert_not_called()
Beispiel #4
0
 def test_get_steps_multiple_step_error(self):
     with self.mock_submissions_api_get():
         workflow = TeamAssessmentWorkflow.start_workflow(self.team_submission_uuid)
     AssessmentWorkflowStepFactory.create(workflow=workflow)
     workflow.refresh_from_db()
     with self.assertRaises(AssessmentWorkflowInternalError):
         workflow._get_steps()  # pylint: disable=protected-access
Beispiel #5
0
 def test_get_steps(self):
     with self.mock_submissions_api_get():
         workflow = TeamAssessmentWorkflow.start_workflow(
             self.team_submission_uuid)
     steps = workflow._get_steps()  # pylint: disable=protected-access
     self.assertEqual(len(steps), 1)
     self.assertEqual(steps[0].name,
                      TeamAssessmentWorkflow.TEAM_STAFF_STEP_NAME)
Beispiel #6
0
 def test_get_steps_wrong_type(self):
     with self.mock_submissions_api_get():
         workflow = TeamAssessmentWorkflow.start_workflow(self.team_submission_uuid)
     step = workflow._get_steps()[0]  # pylint: disable=protected-access
     step.name = 'peer'
     step.save()
     with self.assertRaises(AssessmentWorkflowInternalError):
         workflow._get_steps()  # pylint: disable=protected-access
Beispiel #7
0
    def test_start_workflow(self):
        with self.mock_submissions_api_get():
            team_workflow = TeamAssessmentWorkflow.start_workflow(self.team_submission_uuid)
        self.assertEqual(team_workflow.team_submission_uuid, self.team_submission_uuid)
        self.assertIn(team_workflow.submission_uuid, self.submission_uuids)
        self.assertEqual(team_workflow.status, TeamAssessmentWorkflow.STATUS.teams)
        self.assertEqual(team_workflow.course_id, self.course_id)
        self.assertEqual(team_workflow.item_id, self.item_id)

        step_names = [step.name for step in team_workflow.steps.all()]
        self.assertEqual(step_names, ['teams'])

        self.mock_assessment_api.on_init.assert_called_once()
Beispiel #8
0
    def test_update_from_assessments(self, old_score_points_earned,
                                     mock_set_team_score):
        """
        There is no score recorded in the submissions api, or the score is different than the one we
        have gotten from the assessment module
        """
        submissions_api_fake_score = None
        if old_score_points_earned:
            submissions_api_fake_score = {
                'annotations': [{
                    'annotation_type':
                    TeamAssessmentWorkflow.STAFF_ANNOTATION_TYPE
                }],
                'points_earned':
                old_score_points_earned
            }

        assessment_api_fake_score = {
            "points_earned": 9,
            "points_possible": 10,
            "contributing_assessments": ['assessment_1_id'],
            "staff_id": 'staff_id',
        }

        with self.mock_submissions_api_get():
            workflow = TeamAssessmentWorkflow.start_workflow(
                self.team_submission_uuid)

        self.mock_assessment_api.assessment_is_finished.return_value = True
        self._update_from_assessments(workflow, submissions_api_fake_score,
                                      assessment_api_fake_score)

        workflow.refresh_from_db()
        self.assertEqual(workflow.status, TeamAssessmentWorkflow.STATUS.done)
        self.assertEqual(workflow._team_staff_step.assessment_completed_at,
                         now())  # pylint: disable=protected-access
        mock_set_team_score.assert_called_with(
            self.team_submission_uuid,
            9,
            10,
            annotation_creator='staff_id',
            annotation_type=TeamAssessmentWorkflow.STAFF_ANNOTATION_TYPE,
            annotation_reason=
            'A staff member has defined the score for this submission')