Merge pull request #1529 from MITx/feature/vik/oe-messages
Feature/vik/oe messages
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
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
|
||||
from grading_service_module import GradingService
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@@ -11,8 +8,8 @@ class ControllerQueryService(GradingService):
|
||||
"""
|
||||
Interface to staff grading backend.
|
||||
"""
|
||||
def __init__(self, config):
|
||||
config['system'] = ModuleSystem(None, None, None, render_to_string, None)
|
||||
def __init__(self, config, system):
|
||||
config['system'] = system
|
||||
super(ControllerQueryService, self).__init__(config)
|
||||
self.url = config['url'] + config['grading_controller']
|
||||
self.login_url = self.url + '/login/'
|
||||
@@ -77,3 +74,16 @@ class ControllerQueryService(GradingService):
|
||||
|
||||
response = self.post(self.take_action_on_flags_url, params)
|
||||
return response
|
||||
|
||||
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
|
||||
@@ -663,17 +663,21 @@ class OpenEndedModule(openendedchild.OpenEndedChild):
|
||||
Output: Rendered HTML
|
||||
"""
|
||||
#set context variables and render template
|
||||
eta_string = None
|
||||
if self.state != self.INITIAL:
|
||||
latest = self.latest_answer()
|
||||
previous_answer = latest if latest is not None else self.initial_display
|
||||
post_assessment = self.latest_post_assessment(system)
|
||||
score = self.latest_score()
|
||||
correct = 'correct' if self.is_submission_correct(score) else 'incorrect'
|
||||
if self.state == self.ASSESSING:
|
||||
eta_string = self.get_eta()
|
||||
else:
|
||||
post_assessment = ""
|
||||
correct = ""
|
||||
previous_answer = self.initial_display
|
||||
|
||||
|
||||
context = {
|
||||
'prompt': self.prompt,
|
||||
'previous_answer': previous_answer,
|
||||
@@ -686,6 +690,7 @@ class OpenEndedModule(openendedchild.OpenEndedChild):
|
||||
'child_type': 'openended',
|
||||
'correct': correct,
|
||||
'accept_file_upload': self.accept_file_upload,
|
||||
'eta_message' : eta_string,
|
||||
}
|
||||
html = system.render_template('open_ended.html', context)
|
||||
return html
|
||||
|
||||
@@ -23,6 +23,7 @@ from xmodule.xml_module import XmlDescriptor
|
||||
from xmodule.modulestore import Location
|
||||
from capa.util import *
|
||||
from peer_grading_service import PeerGradingService
|
||||
import controller_query_service
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
@@ -106,8 +107,10 @@ class OpenEndedChild(object):
|
||||
# completion (doesn't matter if you self-assessed correct/incorrect).
|
||||
self._max_score = static_data['max_score']
|
||||
self.peer_gs = PeerGradingService(system.open_ended_grading_interface, system)
|
||||
self.controller_qs = controller_query_service.ControllerQueryService(system.open_ended_grading_interface,system)
|
||||
|
||||
self.system = system
|
||||
|
||||
self.location_string = location
|
||||
try:
|
||||
self.location_string = self.location_string.url()
|
||||
@@ -438,14 +441,14 @@ class OpenEndedChild(object):
|
||||
error_string = ("You need to peer grade {0} more in order to make another submission. "
|
||||
"You have graded {1}, and {2} are required. You have made {3} successful peer grading submissions.")
|
||||
try:
|
||||
response = self.peer_gs.get_data_for_location(location, student_id)
|
||||
response = self.peer_gs.get_data_for_location(self.location_string, student_id)
|
||||
count_graded = response['count_graded']
|
||||
count_required = response['count_required']
|
||||
student_sub_count = response['student_sub_count']
|
||||
success = True
|
||||
except:
|
||||
#This is a dev_facing_error
|
||||
log.error("Could not contact external open ended graders for location {0} and student {1}".format(location,student_id))
|
||||
log.error("Could not contact external open ended graders for location {0} and student {1}".format(self.location_string,student_id))
|
||||
#This is a student_facing_error
|
||||
error_message = "Could not contact the graders. Please notify course staff."
|
||||
return success, allowed_to_submit, error_message
|
||||
@@ -457,3 +460,24 @@ class OpenEndedChild(object):
|
||||
error_message = error_string.format(count_required-count_graded, count_graded, count_required, student_sub_count)
|
||||
return success, allowed_to_submit, error_message
|
||||
|
||||
def get_eta(self):
|
||||
response = self.controller_qs.check_for_eta(self.location_string)
|
||||
try:
|
||||
response = json.loads(response)
|
||||
except:
|
||||
pass
|
||||
|
||||
success = response['success']
|
||||
if isinstance(success, basestring):
|
||||
success = (success.lower()=="true")
|
||||
|
||||
if success:
|
||||
eta = controller_query_service.convert_seconds_to_human_readable(response['eta'])
|
||||
eta_string = "Please check back for your response in at most {0}.".format(eta)
|
||||
else:
|
||||
eta_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,12 +23,14 @@ from xmodule.modulestore.django import modulestore
|
||||
from xmodule.modulestore import search
|
||||
|
||||
from django.http import HttpResponse, Http404, HttpResponseRedirect
|
||||
from mitxmako.shortcuts import render_to_string
|
||||
|
||||
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
|
||||
@@ -150,6 +153,18 @@ def student_problem_list(request, course_id):
|
||||
problem_url_parts = search.path_to_location(modulestore(), course.id, problem_list[i]['location'])
|
||||
problem_url = generate_problem_url(problem_url_parts, base_course_url)
|
||||
problem_list[i].update({'actual_url': problem_url})
|
||||
eta_available = problem_list[i]['eta_available']
|
||||
if isinstance(eta_available, basestring):
|
||||
eta_available = (eta_available.lower() == "true")
|
||||
|
||||
eta_string = "N/A"
|
||||
if eta_available:
|
||||
try:
|
||||
eta_string = convert_seconds_to_human_readable(int(problem_list[i]['eta']))
|
||||
except:
|
||||
#This is a student_facing_error
|
||||
eta_string = "Error getting ETA."
|
||||
problem_list[i].update({'eta_string' : eta_string})
|
||||
|
||||
except GradingServiceError:
|
||||
#This is a student_facing_error
|
||||
|
||||
@@ -15,7 +15,12 @@
|
||||
% elif state in ['done', 'post_assessment'] and correct == 'incorrect':
|
||||
<span class="incorrect" id="status_${id}"></span> <p>Incorrect. </p>
|
||||
% elif state == 'assessing':
|
||||
<span class="grading" id="status_${id}">Submitted for grading.</span>
|
||||
<span class="grading" id="status_${id}">Submitted for grading.
|
||||
% if eta_message is not None:
|
||||
${eta_message}
|
||||
% endif
|
||||
</span>
|
||||
|
||||
% endif
|
||||
|
||||
% if hidden:
|
||||
|
||||
@@ -27,7 +27,8 @@
|
||||
<tr>
|
||||
<th>Problem Name</th>
|
||||
<th>Status</th>
|
||||
<th>Type of Grading</th>
|
||||
<th>Grader Type</th>
|
||||
<th>ETA</th>
|
||||
</tr>
|
||||
%for problem in problem_list:
|
||||
<tr>
|
||||
@@ -40,6 +41,9 @@
|
||||
<td>
|
||||
${problem['grader_type']}
|
||||
</td>
|
||||
<td>
|
||||
${problem['eta_string']}
|
||||
</td>
|
||||
</tr>
|
||||
%endfor
|
||||
</table>
|
||||
|
||||
@@ -43,8 +43,8 @@
|
||||
<p>Please include some written feedback as well.</p>
|
||||
<textarea name="feedback" placeholder="Feedback for student"
|
||||
class="feedback-area" cols="70" ></textarea>
|
||||
<p class="flag-student-container">Flag this submission for review by course staff (use if the submission contains inappropriate content): <input type="checkbox" class="flag-checkbox" value="student_is_flagged"></p>
|
||||
<p class="answer-unknown-container">I do not know how to grade this question: <input type="checkbox" class="answer-unknown-checkbox" value="answer_is_unknown"></p>
|
||||
<div class="flag-student-container"> <input type="checkbox" class="flag-checkbox" value="student_is_flagged"> Flag this submission for review by course staff (use if the submission contains inappropriate content) </div>
|
||||
<div class="answer-unknown-container"> <input type="checkbox" class="answer-unknown-checkbox" value="answer_is_unknown"> I do not know how to grade this question </div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user