Commit c2f64465 by Vik Paruchuri

Fix HTML return

parent d8b94f91
......@@ -4,12 +4,18 @@
# becomes more sophisticated
class PeerGrading
constructor: () ->
@peer_grading_container = $('.peer-grading')
@peer_grading_outer_container = $('.peer-grading-container')
@ajax_url = peer_grading_container.data('ajax-url')
@error_container = $('.error-container')
@error_container.toggle(not @error_container.is(':empty'))
@message_container = $('.message-container')
@message_container.toggle(not @message_container.is(':empty'))
@problem_button = $('.problem-button')
@problem_button.click show_results
@problem_list = $('.problem-list')
@construct_progress_bar()
......@@ -22,6 +28,14 @@ class PeerGrading
bar_max = parseInt(problem.data('required')) + bar_value
progress_bar.progressbar({value: bar_value, max: bar_max})
)
show_results: (event) =>
location_to_fetch = $(event.target).data('location')
data = {'location' : location_to_fetch}
$.postWithPrefix "#{@ajax_url}problem", data, (response) =>
if response.success
@peer_grading_outer_container.after(response.html).remove()
else
@gentle_alert response.error
$(document).ready(() -> new PeerGrading())
......@@ -74,6 +74,10 @@ class PeerGradingModule(XModule):
if isinstance(self.use_for_single_location, basestring):
self.use_for_single_location = (self.use_for_single_location in TRUE_DICT)
self.ajax_url = self.system.ajax_url
if not self.ajax_url.endswith("/"):
self.ajax_url = self.ajax_url + "/"
def _err_response(self, msg):
"""
Return a HttpResponse with a json dump with success=False, and the given error message.
......@@ -108,11 +112,10 @@ class PeerGradingModule(XModule):
handlers = {
'get_next_submission': self.get_next_submission,
'show_calibration_essay': self.show_calibration_essay,
'save_post_assessment': self.message_post,
'is_student_calibrated': self.is_student_calibrated,
'save_grade': self.save_grade,
'save_calibration_essay' : self.save_calibration_essay,
'show_problem' : self.peer_grading_problem,
'problem' : self.peer_grading_problem,
}
if dispatch not in handlers:
......@@ -357,9 +360,8 @@ class PeerGradingModule(XModule):
error_text = "Could not get problem list"
success = False
ajax_url = self.system.ajax_url
return self.system.render_template('peer_grading/peer_grading.html', {
ajax_url = self.ajax_url
html = self.system.render_template('peer_grading/peer_grading.html', {
'course_id': self.system.course_id,
'ajax_url': ajax_url,
'success': success,
......@@ -368,6 +370,7 @@ class PeerGradingModule(XModule):
# Checked above
'staff_access': False, })
return html
def peer_grading_problem(self, get = None):
'''
......@@ -380,9 +383,8 @@ class PeerGradingModule(XModule):
else:
problem_location = self.system.location
ajax_url = self.system.ajax_url
return self.system.render_template('peer_grading/peer_grading_problem.html', {
ajax_url = self.ajax_url
html = self.system.render_template('peer_grading/peer_grading_problem.html', {
'view_html': '',
'problem_location': problem_location,
'course_id': self.system.course_id,
......@@ -390,6 +392,8 @@ class PeerGradingModule(XModule):
# Checked above
'staff_access': False, })
return {'html' : html, 'success' : True}
class PeerGradingDescriptor(XmlDescriptor, EditingDescriptor):
"""
Module for adding combined open ended questions
......
<section class="container">
<section class="container peer-grading-container">
<div class="peer-grading" data-ajax_url="${ajax_url}">
<div class="error-container">${error_text}</div>
<h1>Peer Grading</h1>
......@@ -22,7 +22,7 @@
%for problem in problem_list:
<tr data-graded="${problem['num_graded']}" data-required="${problem['num_required']}">
<td class="problem-name">
<a href="${ajax_url}problem?location=${problem['location']}">${problem['problem_name']}</a>
<a href="#problem" data-location="${problem['location']}" class="problem-button">${problem['problem_name']}</a>
</td>
<td>
${problem['num_graded']}
......
<section class="container">
<section class="container peer-grading-container">
<div class="peer-grading" data-ajax_url="${ajax_url}" data-location="${problem_location}">
<div class="error-container"></div>
......
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