Пример #1
0
    def _cancel_team_workflow(self, team_submission_uuid, comments, requesting_user_id=None):
        """
        Internal helper method to cancel a team workflow using the team workflow API.

        If requesting_user is not provided, we will use the user to which this xblock is currently bound.
        """
        # Import is placed here to avoid model import at project startup.
        from openassessment.workflow import team_api as team_workflow_api
        try:
            if requesting_user_id is None:
                # The student_id is actually the bound user, which is the staff user in this context.
                requesting_user_id = self.get_student_item_dict()["student_id"]
            # Cancel the related workflow.
            team_workflow_api.cancel_workflow(
                team_submission_uuid,
                comments,
                requesting_user_id,
            )
            return {
                "success": True,
                'msg': self._(
                    "The team’s submission has been removed from grading. "
                    "The team receives a grade of zero unless you delete "
                    "a team member’s state for the problem to allow the team "
                    "to resubmit a response."
                )
            }
        except (
                AssessmentWorkflowError,
                AssessmentWorkflowInternalError
        ) as ex:
            msg = str(ex)
            logger.exception(msg)
            return {"success": False, 'msg': msg}
Пример #2
0
    def test_get_workflow_cancellation(self):
        # Given a cancelled workflow
        self._create_submission()
        team_api.create_workflow(self.team_submission_uuid)
        team_api.cancel_workflow(
            team_submission_uuid=self.team_submission_uuid,
            comments='cancelled',
            cancelled_by_id='my-id')

        # When I query for a cancelled flow
        cancellation = team_api.get_assessment_workflow_cancellation(
            self.team_submission_uuid)

        # Then I get serialized info from the cancellation
        self.assertEqual(cancellation['comments'], 'cancelled')
        self.assertEqual(cancellation['cancelled_by_id'], 'my-id')
Пример #3
0
    def test_cancel_workflow(self):
        # Given a workflow
        self._create_submission()
        team_workflow = team_api.create_workflow(self.team_submission_uuid)

        # When I cancel the workflow
        team_api.cancel_workflow(
            team_submission_uuid=self.team_submission_uuid,
            comments='cancelled',
            cancelled_by_id='my-id'
        )

        # The workflow status should be cancelled...
        team_workflow = team_api.get_workflow_for_submission(self.team_submission_uuid)
        self.assertTrue(team_api.is_workflow_cancelled(self.team_submission_uuid))
        self.assertEqual(team_workflow['status'], 'cancelled')

        # and the points/score should be 0
        self.assertEqual(team_workflow['score'], None)