Move controller query service to xmodule side to prepare for ETA message displays
This commit is contained in:
@@ -1,79 +0,0 @@
|
||||
import logging
|
||||
from xmodule.open_ended_grading_classes.grading_service_module import GradingService
|
||||
|
||||
from xmodule.x_module import ModuleSystem
|
||||
from mitxmako.shortcuts import render_to_string
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ControllerQueryService(GradingService):
|
||||
"""
|
||||
Interface to staff grading backend.
|
||||
"""
|
||||
def __init__(self, config):
|
||||
config['system'] = ModuleSystem(None, None, None, render_to_string, None)
|
||||
super(ControllerQueryService, self).__init__(config)
|
||||
self.url = config['url'] + config['grading_controller']
|
||||
self.login_url = self.url + '/login/'
|
||||
self.check_eta_url = self.url + '/get_submission_eta/'
|
||||
self.is_unique_url = self.url + '/is_name_unique/'
|
||||
self.combined_notifications_url = self.url + '/combined_notifications/'
|
||||
self.grading_status_list_url = self.url + '/get_grading_status_list/'
|
||||
self.flagged_problem_list_url = self.url + '/get_flagged_problem_list/'
|
||||
self.take_action_on_flags_url = self.url + '/take_action_on_flags/'
|
||||
|
||||
def check_if_name_is_unique(self, location, problem_id, course_id):
|
||||
params = {
|
||||
'course_id': course_id,
|
||||
'location': location,
|
||||
'problem_id': problem_id
|
||||
}
|
||||
response = self.get(self.is_unique_url, params)
|
||||
return response
|
||||
|
||||
def check_for_eta(self, location):
|
||||
params = {
|
||||
'location': location,
|
||||
}
|
||||
response = self.get(self.check_eta_url, params)
|
||||
return response
|
||||
|
||||
def check_combined_notifications(self, course_id, student_id, user_is_staff, last_time_viewed):
|
||||
params = {
|
||||
'student_id': student_id,
|
||||
'course_id': course_id,
|
||||
'user_is_staff': user_is_staff,
|
||||
'last_time_viewed': last_time_viewed,
|
||||
}
|
||||
log.debug(self.combined_notifications_url)
|
||||
response = self.get(self.combined_notifications_url, params)
|
||||
return response
|
||||
|
||||
def get_grading_status_list(self, course_id, student_id):
|
||||
params = {
|
||||
'student_id': student_id,
|
||||
'course_id': course_id,
|
||||
}
|
||||
|
||||
response = self.get(self.grading_status_list_url, params)
|
||||
return response
|
||||
|
||||
def get_flagged_problem_list(self, course_id):
|
||||
params = {
|
||||
'course_id': course_id,
|
||||
}
|
||||
|
||||
response = self.get(self.flagged_problem_list_url, params)
|
||||
return response
|
||||
|
||||
def take_action_on_flags(self, course_id, student_id, submission_id, action_type):
|
||||
params = {
|
||||
'course_id': course_id,
|
||||
'student_id': student_id,
|
||||
'submission_id': submission_id,
|
||||
'action_type': action_type
|
||||
}
|
||||
|
||||
response = self.post(self.take_action_on_flags_url, params)
|
||||
return response
|
||||
@@ -1,12 +0,0 @@
|
||||
def convert_seconds_to_human_readable(seconds):
|
||||
if seconds < 60:
|
||||
human_string = "{0} seconds".format(seconds)
|
||||
elif seconds < 60 * 60:
|
||||
human_string = "{0} minutes".format(round(seconds/60,1))
|
||||
elif seconds < (24*60*60):
|
||||
human_string = "{0} hours".format(round(seconds/(60*60),1))
|
||||
else:
|
||||
human_string = "{0} days".format(round(seconds/(60*60*24),1))
|
||||
|
||||
eta_string = "{0}".format(human_string)
|
||||
return eta_string
|
||||
@@ -1,7 +1,7 @@
|
||||
from django.conf import settings
|
||||
from xmodule.open_ended_grading_classes import peer_grading_service
|
||||
from staff_grading_service import StaffGradingService
|
||||
from open_ended_grading.controller_query_service import ControllerQueryService
|
||||
from xmodule.open_ended_grading_classes.controller_query_service import ControllerQueryService
|
||||
import json
|
||||
from student.models import unique_id_for_user
|
||||
from courseware.models import StudentModule
|
||||
@@ -93,7 +93,8 @@ def peer_grading_notifications(course, user):
|
||||
|
||||
|
||||
def combined_notifications(course, user):
|
||||
controller_qs = ControllerQueryService(settings.OPEN_ENDED_GRADING_INTERFACE)
|
||||
system = ModuleSystem(None, None, None, render_to_string, None)
|
||||
controller_qs = ControllerQueryService(settings.OPEN_ENDED_GRADING_INTERFACE, system)
|
||||
student_id = unique_id_for_user(user)
|
||||
user_is_staff = has_access(user, course, 'staff')
|
||||
course_id = course.id
|
||||
|
||||
@@ -11,7 +11,8 @@ from django.core.urlresolvers import reverse
|
||||
from student.models import unique_id_for_user
|
||||
from courseware.courses import get_course_with_access
|
||||
|
||||
from controller_query_service import ControllerQueryService
|
||||
from xmodule.x_module import ModuleSystem
|
||||
from xmodule.open_ended_grading_classes.controller_query_service import ControllerQueryService, convert_seconds_to_human_readable
|
||||
from xmodule.open_ended_grading_classes.grading_service_module import GradingServiceError
|
||||
import json
|
||||
from student.models import unique_id_for_user
|
||||
@@ -22,13 +23,13 @@ from xmodule.modulestore.django import modulestore
|
||||
from xmodule.modulestore import search
|
||||
|
||||
from django.http import HttpResponse, Http404, HttpResponseRedirect
|
||||
import open_ended_grading_util
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
template_imports = {'urllib': urllib}
|
||||
|
||||
controller_qs = ControllerQueryService(settings.OPEN_ENDED_GRADING_INTERFACE)
|
||||
system = ModuleSystem(None, None, None, render_to_string, None)
|
||||
controller_qs = ControllerQueryService(settings.OPEN_ENDED_GRADING_INTERFACE, system)
|
||||
|
||||
"""
|
||||
Reverses the URL from the name and the course id, and then adds a trailing slash if
|
||||
@@ -158,7 +159,7 @@ def student_problem_list(request, course_id):
|
||||
eta_string = "N/A"
|
||||
if eta_available:
|
||||
try:
|
||||
eta_string = open_ended_grading_util.convert_seconds_to_human_readable(int(problem_list[i]['eta']))
|
||||
eta_string = convert_seconds_to_human_readable(int(problem_list[i]['eta']))
|
||||
except:
|
||||
#This is a student_facing_error
|
||||
eta_string = "Error getting ETA."
|
||||
|
||||
Reference in New Issue
Block a user