コード例 #1
0
ファイル: signals.py プロジェクト: edx/edx-proctoring
def on_attempt_changed(sender, instance, signal, **kwargs):  # pylint: disable=unused-argument
    """
    Archive the exam attempt whenever the attempt status is about to be
    modified. Make a new entry with the previous value of the status in the
    ProctoredExamStudentAttemptHistory table.
    """

    if signal is pre_save:
        if instance.id:
            # on an update case, get the original
            # and see if the status has changed, if so, then we need
            # to archive it
            original = sender.objects.get(id=instance.id)

            if original.status != instance.status:
                instance = original
            else:
                return
        else:
            return
    else:
        # remove the attempt on the backend
        # timed exams have no backend
        backend = get_backend_provider(name=instance.proctored_exam.backend)
        if backend:
            result = backend.remove_exam_attempt(instance.proctored_exam.external_id, instance.external_id)
            if not result:
                log.error('Failed to remove attempt %d from %s', instance.id, backend.verbose_name)
    models.archive_model(models.ProctoredExamStudentAttemptHistory, instance, id='attempt_id')
コード例 #2
0
def on_attempt_changed(sender, instance, signal, **kwargs):  # pylint: disable=unused-argument
    """
    Archive the exam attempt whenever the attempt status is about to be
    modified. Make a new entry with the previous value of the status in the
    ProctoredExamStudentAttemptHistory table.
    """

    if signal is pre_save:
        if instance.id:
            # on an update case, get the original
            # and see if the status has changed, if so, then we need
            # to archive it
            original = sender.objects.get(id=instance.id)

            if original.status != instance.status:
                instance = original
            else:
                return
        else:
            return
    else:
        # remove the attempt on the backend
        # timed exams have no backend
        backend = get_backend_provider(name=instance.proctored_exam.backend)
        if backend:
            result = backend.remove_exam_attempt(
                instance.proctored_exam.external_id, instance.external_id)
            if not result:
                log.error(u'Failed to remove attempt %d from %s', instance.id,
                          backend.verbose_name)
    models.archive_model(models.ProctoredExamStudentAttemptHistory,
                         instance,
                         id='attempt_id')
コード例 #3
0
ファイル: signals.py プロジェクト: edx/edx-proctoring
def on_review_policy_changed(sender, instance, signal, **kwargs):  # pylint: disable=unused-argument
    """
    Archiving all changes made to the Review Policy.
    Will only archive on update/delete, and not on new entries created.
    """
    if signal is pre_save:
        if instance.id:
            instance = sender.objects.get(id=instance.id)
        else:
            return
    models.archive_model(models.ProctoredExamReviewPolicyHistory, instance, id='original_id')
コード例 #4
0
ファイル: signals.py プロジェクト: raccoongang/edx-proctoring
def on_review_policy_changed(sender, instance, signal, **kwargs):  # pylint: disable=unused-argument
    """
    Archiving all changes made to the Review Policy.
    Will only archive on update/delete, and not on new entries created.
    """
    if signal is pre_save:
        if instance.id:
            instance = sender.objects.get(id=instance.id)
        else:
            return
    models.archive_model(models.ProctoredExamReviewPolicyHistory, instance, id='original_id')
コード例 #5
0
ファイル: signals.py プロジェクト: edx/edx-proctoring
def on_review_changed(sender, instance, signal, **kwargs):  # pylint: disable=unused-argument
    """
    Archiving all changes made to the Review.
    Will only archive on update/delete, and not on new entries created.
    """
    if signal is pre_save:
        if instance.id:
            # only for update cases
            instance = sender.objects.get(id=instance.id)
        else:
            # don't archive on create
            return
    models.archive_model(models.ProctoredExamSoftwareSecureReviewHistory, instance, id='review_id')
コード例 #6
0
ファイル: signals.py プロジェクト: raccoongang/edx-proctoring
def on_review_changed(sender, instance, signal, **kwargs):  # pylint: disable=unused-argument
    """
    Archiving all changes made to the Review.
    Will only archive on update/delete, and not on new entries created.
    """
    if signal is pre_save:
        if instance.id:
            # only for update cases
            instance = sender.objects.get(id=instance.id)
        else:
            # don't archive on create
            return
    models.archive_model(models.ProctoredExamSoftwareSecureReviewHistory, instance, id='review_id')
コード例 #7
0
def on_attempt_changed(sender, instance, signal, **kwargs):  # pylint: disable=unused-argument
    """
    Archive the exam attempt whenever the attempt status is about to be
    modified. Make a new entry with the previous value of the status in the
    ProctoredExamStudentAttemptHistory table.
    """

    if signal is pre_save:
        if instance.id:
            # on an update case, get the original
            # and see if the status has changed, if so, then we need
            # to archive it
            original = sender.objects.get(id=instance.id)

            if original.status != instance.status:
                instance = original
            else:
                return
        else:
            return
    models.archive_model(models.ProctoredExamStudentAttemptHistory, instance, id='attempt_id')