示例#1
0
    def test_get_credit_requirement(self):
        self.add_credit_course()
        requirements = [
            {
                "namespace": "grade",
                "name": "grade",
                "display_name": "Grade",
                "criteria": {
                    "min_grade": 0.8
                }
            }
        ]
        requirement = get_credit_requirement(self.course_key, "grade", "grade")
        self.assertIsNone(requirement)

        expected_requirement = {
            "course_key": self.course_key,
            "namespace": "grade",
            "name": "grade",
            "display_name": "Grade",
            "criteria": {
                "min_grade": 0.8
            }
        }
        set_credit_requirements(self.course_key, requirements)
        requirement = get_credit_requirement(self.course_key, "grade", "grade")
        self.assertIsNotNone(requirement)
        self.assertEqual(requirement, expected_requirement)
示例#2
0
    def test_get_credit_requirement(self):
        self.add_credit_course()
        requirements = [
            {
                "namespace": "grade",
                "name": "grade",
                "display_name": "Grade",
                "criteria": {
                    "min_grade": 0.8
                }
            }
        ]
        requirement = api.get_credit_requirement(self.course_key, "grade", "grade")
        self.assertIsNone(requirement)

        expected_requirement = {
            "course_key": self.course_key,
            "namespace": "grade",
            "name": "grade",
            "display_name": "Grade",
            "criteria": {
                "min_grade": 0.8
            }
        }
        api.set_credit_requirements(self.course_key, requirements)
        requirement = api.get_credit_requirement(self.course_key, "grade", "grade")
        self.assertIsNotNone(requirement)
        self.assertEqual(requirement, expected_requirement)
示例#3
0
    def test_set_credit_requirement_status(self):
        self.add_credit_course()
        requirements = [
            {
                "namespace": "grade",
                "name": "grade",
                "display_name": "Grade",
                "criteria": {
                    "min_grade": 0.8
                }
            },
            {
                "namespace": "reverification",
                "name": "i4x://edX/DemoX/edx-reverification-block/assessment_uuid",
                "display_name": "Assessment 1",
                "criteria": {}
            }
        ]

        set_credit_requirements(self.course_key, requirements)
        course_requirements = CreditRequirement.get_course_requirements(self.course_key)
        self.assertEqual(len(course_requirements), 2)

        requirement = get_credit_requirement(self.course_key, "grade", "grade")
        set_credit_requirement_status("staff", requirement, 'satisfied', {})
        course_requirement = CreditRequirement.get_course_requirement(
            requirement['course_key'], requirement['namespace'], requirement['name']
        )
        status = CreditRequirementStatus.objects.get(username="******", requirement=course_requirement)
        self.assertEqual(status.requirement.namespace, requirement['namespace'])
        self.assertEqual(status.status, "satisfied")

        set_credit_requirement_status(
            "staff", requirement, 'failed', {'failure_reason': "requirements not satisfied"}
        )
        status = CreditRequirementStatus.objects.get(username="******", requirement=course_requirement)
        self.assertEqual(status.requirement.namespace, requirement['namespace'])
        self.assertEqual(status.status, "failed")
示例#4
0
文件: views.py 项目: JudyFox/edXMOOC
def _set_user_requirement_status(attempt, namespace, status, reason=None):
    """Sets the status of a credit requirement for the user,
    based on a verification checkpoint.
    """
    checkpoint = None
    try:
        checkpoint = VerificationCheckpoint.objects.get(photo_verification=attempt)
    except VerificationCheckpoint.DoesNotExist:
        log.error("Unable to find checkpoint for user with id %d", attempt.user.id)

    if checkpoint is not None:
        course_key = checkpoint.course_id
        credit_requirement = get_credit_requirement(
            course_key, namespace, checkpoint.checkpoint_location
        )
        if credit_requirement is not None:
            try:
                set_credit_requirement_status(
                    attempt.user.username, credit_requirement, status, reason
                )
            except Exception:  # pylint: disable=broad-except
                # Catch exception if unable to add credit requirement
                # status for user
                log.error("Unable to add Credit requirement status for user with id %d", attempt.user.id)