Commit b7e87326 by Will Daly

Merge pull request #319 from edx/will/assessment-package-refactor-2

Assessment app restructure (part 2)
parents 18a2a788 717140f2
......@@ -24,7 +24,7 @@ from openassessment.assessment.errors import (
)
from submissions import api as sub_api
logger = logging.getLogger("openassessment.assessment.peer_api")
logger = logging.getLogger("openassessment.assessment.api.peer")
PEER_TYPE = "PE"
......
......@@ -22,7 +22,7 @@ from openassessment.assessment.errors import (
# Assessments are tagged as "self-evaluation"
SELF_TYPE = "SE"
logger = logging.getLogger("openassessment.assessment.self_api")
logger = logging.getLogger("openassessment.assessment.api.self")
def create_assessment(submission_uuid, user_id, options_selected, rubric_dict, scored_at=None):
......
"""
Export errors from all modules defined in this package.
"""
# pylint:disable=W0401
from .peer import *
from .self import *
"""
Errors for the assessment app.
Errors for the peer assessment.
"""
import copy
......@@ -23,7 +23,7 @@ class PeerAssessmentRequestError(PeerAssessmentError):
"""
def __init__(self, field_errors):
Exception.__init__(self, repr(field_errors))
super(PeerAssessmentRequestError, self).__init__(repr(field_errors))
self.field_errors = copy.deepcopy(field_errors)
......@@ -45,28 +45,3 @@ class PeerAssessmentInternalError(PeerAssessmentError):
"""
pass
class SelfAssessmentError(Exception):
"""Generic Self Assessment Error
Raised when an error occurs while processing a request related to the
Self Assessment Workflow.
"""
pass
class SelfAssessmentRequestError(SelfAssessmentError):
"""
There was a problem with the request for a self-assessment.
"""
pass
class SelfAssessmentInternalError(SelfAssessmentError):
"""
There was an internal problem while accessing the self-assessment api.
"""
pass
"""
Errors for self-assessment
"""
class SelfAssessmentError(Exception):
"""Generic Self Assessment Error
Raised when an error occurs while processing a request related to the
Self Assessment Workflow.
"""
pass
class SelfAssessmentRequestError(SelfAssessmentError):
"""
There was a problem with the request for a self-assessment.
"""
pass
class SelfAssessmentInternalError(SelfAssessmentError):
"""
There was an internal problem while accessing the self-assessment api.
"""
pass
"""
Export serializers from each module in this package.
"""
# pylint: disable=W0401
from .base import *
from .peer import *
# coding=utf-8
"""
Serializers are created to ensure models do not have to be accessed outside the
scope of the Tim APIs.
Serializers common to all assessment types.
"""
from copy import deepcopy
import logging
......@@ -10,8 +9,6 @@ from django.core.cache import cache
from rest_framework import serializers
from openassessment.assessment.models import (
Assessment, AssessmentPart, Criterion, CriterionOption, Rubric,
AssessmentFeedback, AssessmentFeedbackOption,
PeerWorkflowItem, PeerWorkflow
)
......@@ -321,67 +318,3 @@ def rubric_from_dict(rubric_dict):
rubric = rubric_serializer.save()
return rubric
class AssessmentFeedbackOptionSerializer(serializers.ModelSerializer):
"""
Serialize an `AssessmentFeedbackOption` model.
"""
class Meta:
model = AssessmentFeedbackOption
fields = ('text',)
class AssessmentFeedbackSerializer(serializers.ModelSerializer):
"""
Serialize feedback in response to an assessment.
"""
assessments = AssessmentSerializer(many=True, default=None, required=False)
options = AssessmentFeedbackOptionSerializer(many=True, default=None, required=False)
class Meta:
model = AssessmentFeedback
fields = ('submission_uuid', 'feedback_text', 'assessments', 'options')
class PeerWorkflowSerializer(serializers.ModelSerializer):
"""Representation of the PeerWorkflow.
A PeerWorkflow should not be exposed to the front end of any question. This
model should only be exposed externally for administrative views, in order
to visualize the Peer Workflow.
"""
class Meta:
model = PeerWorkflow
fields = (
'student_id',
'item_id',
'course_id',
'submission_uuid',
'created_at',
'completed_at'
)
class PeerWorkflowItemSerializer(serializers.ModelSerializer):
"""Representation of the PeerWorkflowItem
As with the PeerWorkflow, this should not be exposed to the front end. This
should only be used to visualize the Peer Workflow in an administrative
view.
"""
class Meta:
model = PeerWorkflowItem
fields = (
'scorer',
'author',
'submission_uuid',
'started_at',
'assessment',
'scored'
)
"""
Serializers specific to peer assessment.
"""
from rest_framework import serializers
from .base import AssessmentSerializer
from openassessment.assessment.models import (
AssessmentFeedback, AssessmentFeedbackOption,
PeerWorkflow, PeerWorkflowItem
)
class AssessmentFeedbackOptionSerializer(serializers.ModelSerializer):
"""
Serialize an `AssessmentFeedbackOption` model.
"""
class Meta:
model = AssessmentFeedbackOption
fields = ('text',)
class AssessmentFeedbackSerializer(serializers.ModelSerializer):
"""
Serialize feedback in response to an assessment.
"""
assessments = AssessmentSerializer(many=True, default=None, required=False)
options = AssessmentFeedbackOptionSerializer(many=True, default=None, required=False)
class Meta:
model = AssessmentFeedback
fields = ('submission_uuid', 'feedback_text', 'assessments', 'options')
class PeerWorkflowSerializer(serializers.ModelSerializer):
"""Representation of the PeerWorkflow.
A PeerWorkflow should not be exposed to the front end of any question. This
model should only be exposed externally for administrative views, in order
to visualize the Peer Workflow.
"""
class Meta:
model = PeerWorkflow
fields = (
'student_id',
'item_id',
'course_id',
'submission_uuid',
'created_at',
'completed_at'
)
class PeerWorkflowItemSerializer(serializers.ModelSerializer):
"""Representation of the PeerWorkflowItem
As with the PeerWorkflow, this should not be exposed to the front end. This
should only be used to visualize the Peer Workflow in an administrative
view.
"""
class Meta:
model = PeerWorkflowItem
fields = (
'scorer',
'author',
'submission_uuid',
'started_at',
'assessment',
'scored'
)
......@@ -9,7 +9,7 @@ from mock import patch
from nose.tools import raises
from openassessment.test_utils import CacheResetTest
from openassessment.assessment import peer_api
from openassessment.assessment.api import peer as peer_api
from openassessment.assessment.models import (
Assessment, AssessmentPart, AssessmentFeedback,
PeerWorkflow, PeerWorkflowItem
......
......@@ -8,7 +8,7 @@ import datetime
import pytz
from openassessment.test_utils import CacheResetTest
from submissions.api import create_submission
from openassessment.assessment.self_api import (
from openassessment.assessment.api.self import (
create_assessment, submitter_is_finished, get_assessment
)
from openassessment.assessment.errors import SelfAssessmentRequestError
......
......@@ -2,7 +2,7 @@ import logging
from django.contrib.auth.decorators import login_required
from django.shortcuts import render_to_response
from openassessment.assessment.peer_api import get_assessments
from openassessment.assessment.api.peer import get_assessments
from submissions.api import SubmissionRequestError, get_submissions
log = logging.getLogger(__name__)
......
......@@ -7,7 +7,8 @@ from django.core.management.base import BaseCommand, CommandError
import loremipsum
from submissions import api as sub_api
from openassessment.workflow import api as workflow_api
from openassessment.assessment import peer_api, self_api
from openassessment.assessment.api import peer as peer_api
from openassessment.assessment.api import self as self_api
STEPS = ['peer', 'self']
......
......@@ -3,7 +3,8 @@ Tests for the management command that creates dummy submissions.
"""
from submissions import api as sub_api
from openassessment.assessment import peer_api, self_api
from openassessment.assessment.api import peer as peer_api
from openassessment.assessment.api import self as self_api
from openassessment.management.commands import create_oa_submissions
from django.test import TestCase
......
......@@ -7,7 +7,7 @@ import logging
from django.db import DatabaseError
from openassessment.assessment import peer_api
from openassessment.assessment.api import peer as peer_api
from openassessment.assessment.errors import PeerAssessmentError
from submissions import api as sub_api
from .models import AssessmentWorkflow, AssessmentWorkflowStep
......
......@@ -129,7 +129,8 @@ class AssessmentWorkflow(TimeStampedModel, StatusModel):
specific requirements in this dict.
"""
from openassessment.assessment import peer_api, self_api
from openassessment.assessment.api import peer as peer_api
from openassessment.assessment.api import self as self_api
# If we're done, we're done -- it doesn't matter if requirements have
# changed because we've already written a score.
......@@ -259,7 +260,8 @@ class AssessmentWorkflowStep(models.Model):
Returns an API associated with this workflow step. If no API is
associated with this workflow step, None is returned.
"""
from openassessment.assessment import peer_api, self_api
from openassessment.assessment.api import peer as peer_api
from openassessment.assessment.api import self as self_api
api = None
if self.name == AssessmentWorkflow.STATUS.self:
api = self_api
......
......@@ -7,8 +7,8 @@ from collections import defaultdict
from django.utils.translation import ugettext as _
from xblock.core import XBlock
from openassessment.assessment import peer_api
from openassessment.assessment import self_api
from openassessment.assessment.api import peer as peer_api
from openassessment.assessment.api import self as self_api
from openassessment.assessment.errors import SelfAssessmentError, PeerAssessmentError
from submissions import api as sub_api
......
......@@ -4,8 +4,8 @@ from django.utils.translation import ugettext as _
from webob import Response
from xblock.core import XBlock
from openassessment.assessment import peer_api
from openassessment.assessment.peer_api import (
from openassessment.assessment.api import peer as peer_api
from openassessment.assessment.errors import (
PeerAssessmentInternalError, PeerAssessmentRequestError,
PeerAssessmentWorkflowError
)
......
......@@ -4,7 +4,7 @@ from django.utils.translation import ugettext as _
from xblock.core import XBlock
from webob import Response
from openassessment.assessment import self_api
from openassessment.assessment.api import self as self_api
from openassessment.workflow import api as workflow_api
from submissions import api as submission_api
from .resolve_dates import DISTANT_FUTURE
......
......@@ -6,7 +6,8 @@ import copy
import json
from submissions import api as sub_api
from openassessment.workflow import api as workflow_api
from openassessment.assessment import peer_api, self_api
from openassessment.assessment.api import peer as peer_api
from openassessment.assessment.api import self as self_api
from .base import XBlockHandlerTestCase, scenario
......
......@@ -10,7 +10,7 @@ import mock
import datetime as dt
import pytz
import ddt
from openassessment.assessment import peer_api
from openassessment.assessment.api import peer as peer_api
from .base import XBlockHandlerTestCase, scenario
......
......@@ -7,7 +7,7 @@ import json
import datetime
import mock
import pytz
from openassessment.assessment import self_api
from openassessment.assessment.api import self as self_api
from openassessment.workflow import api as workflow_api
from .base import XBlockHandlerTestCase, scenario
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment