Commit d680d1c1 by Stephen Sanchez

Switching over to use a Django Rest Framework setup for the initial prototype of Peer Grading

parent 73755ca8
"""
Common Grading contains a set of shared grading classes across Peer, Self, Instructor, and Machine Learning.
"""
""" """
New Peer Grading XModule. Shared services and logic for open ended grading modules.
""" """
__author__ = 'stephensanchez'
from django.db import models
MAX_LENGTH = 1028
class PeerGradedEssay(models.Model):
student_id = models.CharField(max_length=MAX_LENGTH, db_index=True)
problem_id = models.CharField(max_length=MAX_LENGTH, default="")
essay_body = models.CharField(max_length=MAX_LENGTH, default="")
grades = models.CharField(max_length=MAX_LENGTH, default="")
status = models.CharField(max_length=MAX_LENGTH, default="")
class PeerGradingStatus(models.Model):
student_id = models.CharField(max_length=MAX_LENGTH, db_index=True)
problem_id = models.CharField(max_length=MAX_LENGTH, default="")
grading_status = models.CharField(max_length=MAX_LENGTH, default="")
\ No newline at end of file
#What do we need, exactly?
\ No newline at end of file
from django.conf.urls import patterns, url
# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()
urlpatterns = patterns('peer_grading.views',
url(r'^submit_peer_essay', 'submit_peer_essay'),
)
"""
RESTful interface for all Peer Grading Workflow. Covers all requests made for Peer Grading.
"""
import json
import logging
from django.http import HttpResponse
log = logging.getLogger(__name__)
_INTERFACE_VERSION = 0
def submit_peer_essay(request):
response = {'version': _INTERFACE_VERSION,
'success': True,
'message': "Nothing happened."}
return HttpResponse(json.dumps(response), mimetype="application/json")
from rest_framework import serializers
from models import PeerGradingStatus, PeerGradedEssay
class PeerGradedEssaySerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = PeerGradedEssay
fields = ('student_id', 'problem_id', 'essay_body', 'grades', 'status')
class PeerGradingStatusSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = PeerGradingStatus
fields = ('student_id', 'problem_id', 'grading_status')
\ No newline at end of file
...@@ -4,15 +4,15 @@ DEBUG = True ...@@ -4,15 +4,15 @@ DEBUG = True
TEMPLATE_DEBUG = DEBUG TEMPLATE_DEBUG = DEBUG
ADMINS = ( ADMINS = (
# ('Your Name', 'your_email@example.com'), ('admin', 'admin'),
) )
MANAGERS = ADMINS MANAGERS = ADMINS
DATABASES = { DATABASES = {
'default': { 'default': {
'ENGINE': 'django.db.backends.', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. 'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': '', # Or path to database file if using sqlite3. 'NAME': 'timdb', # Or path to database file if using sqlite3.
'USER': '', # Not used with sqlite3. 'USER': '', # Not used with sqlite3.
'PASSWORD': '', # Not used with sqlite3. 'PASSWORD': '', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. Not used with sqlite3. 'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
...@@ -118,12 +118,17 @@ INSTALLED_APPS = ( ...@@ -118,12 +118,17 @@ INSTALLED_APPS = (
'django.contrib.sites', 'django.contrib.sites',
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.staticfiles', 'django.contrib.staticfiles',
# Uncomment the next line to enable the admin: 'django.contrib.admin',
# 'django.contrib.admin', 'django.contrib.admindocs',
# Uncomment the next line to enable admin documentation: 'rest_framework',
# 'django.contrib.admindocs', 'peer_grading'
) )
REST_FRAMEWORK = {
'DEFAULT_PERMISSIONS_CLASSES': ('rest_framework.permissions.IsAdminUser',),
'PAGINATE_BY': 10
}
# A sample logging configuration. The only tangible logging # A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to # performed by this configuration is to send an email to
# the site admins on every HTTP 500 error when DEBUG=False. # the site admins on every HTTP 500 error when DEBUG=False.
......
from django.conf.urls import patterns, url, include
from rest_framework import routers
from peer_grading.views import PeerGradedEssayViewSet, PeerGradingStatusViewSet
router = routers.DefaultRouter()
router.register(r'peergradedessay', PeerGradedEssayViewSet)
router.register(r'peergradingstatus', PeerGradingStatusViewSet)
# Interface for communicating with the Peer Grading Module in LMS.
urlpatterns = patterns('',
url(r'^', include(router.urls)),
url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework'))
)
"""
Interface for all Peer Grading Workflow. Covers all requests made for Peer Grading.
"""
import json
from rest_framework import viewsets
from rest_framework.response import Response
from models import PeerGradedEssay, PeerGradingStatus
from serializers import PeerGradedEssaySerializer, PeerGradingStatusSerializer
class PeerGradedEssayViewSet(viewsets.ModelViewSet):
queryset = PeerGradedEssay.objects.all()
serializer_class = PeerGradedEssaySerializer
def create(self, request, *args, **kwargs):
"""
Submit an essay to be graded. This specifically requests that the given essay should be graded by peers.
@param self: Self.
@param request: Student, Question, and Essay information will be passed through via an HTTP Request.
@return: Once an essay has been submitted, the student's status for beginning peer grading should be immediately
returned. See student_status for more information.
"""
response = {'success': True,
'message': "Nothing happened."}
return Response(json.dumps(response))
def retrieve(self, request, *args, **kwargs):
"""
Retrieves an essay for grading. This may be a calibration essay if the student requires calibration. If not, they
will begin to grade actual essays for the particular question.
@param self: Self.
@param request: An HTTP Request with the student information, and location information, allowing the retrieval of
an appropriate essay to grade.
@return: Response will contain essay grading information, or student status information regarding why an essay could
not be retrieved.
"""
pass
def get(self, request):
"""
Notification message to determine if the submitted essay for a student is still being processed (graded) or has been
fully graded, in which case the grade can be returned.
@param self: Self.
@param request: An HTTP request for the grade of a particular submission. Requires student and question information.
@return: The requested grade, or status of the submission.
"""
pass
def update(self, request, *args, **kwargs):
"""
Grading Updates from Peer Reviews.
@param request:
@param args:
@param kwargs:
@return:
"""
pass
class PeerGradingStatusViewSet(viewsets.ModelViewSet):
queryset = PeerGradingStatus.objects.all()
serializer_class = PeerGradingStatusSerializer
def get(self, request):
"""
Check to see if the student is ready to grade essays. In order to determine if the student can begin grading,
the follow criteria must be met:
1) The student has submitted an essay.
2) The instructor has graded enough enough calibration essays.
3) The student has graded enough calibration essays.
4) There essays available to be graded.
@param self: Self.
@param request: An HTTP Request containing the student information and the location of this particular open ended
question.
@return: A JSON response indicating the state of grading for this particular. The student may be given instruction
based on this status.
"""
pass
import logging
from x_module import XModule
from xmodule.raw_module import RawDescriptor
log = logging.getLogger(__name__)
class PeerGradingFields(object):
"""
@todo We'll need some Peer Grading Fields to define what information we want to pass to the grading workflow.
"""
pass
class PeerGradingModule(PeerGradingFields, XModule):
_VERSION = 0
class PeerGradingDescriptor(PeerGradingFields, RawDescriptor):
"""
Module for adding peer grading questions
"""
# TODO What is a descriptor?
pass
import logging
log = logging.getLogger(__name__)
class PeerGradingService(object):
"""
Interface with the grading controller for peer grading
TODO: Create service communication with views. ?
"""
def __init__(self, config, system):
config['system'] = system
self.url = config['url'] + config['peer_grading']
self.login_url = self.url + '/login/'
self.submit_peer_essay = self.url + '/submit_peer_essay/'
self.request_grade = self.url + '/request_grade/'
self.grade_essay = self.url + '/grade_essay/'
self.student_status = self.url + '/student_status/'
self.system = system
djangorestframework==2.3.5
\ No newline at end of file
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