Commit c1583dbb by Vik Paruchuri

Properly load javascript, fix templates to work with xmodule, modify AJAX handlers

parent c2f64465
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
# and message container when they are empty # and message container when they are empty
# Can (and should be) expanded upon when our problem list # Can (and should be) expanded upon when our problem list
# becomes more sophisticated # becomes more sophisticated
class PeerGrading class @PeerGrading
constructor: () -> constructor: (element) ->
@peer_grading_container = $('.peer-grading') @peer_grading_container = $('.peer-grading')
@peer_grading_outer_container = $('.peer-grading-container') @peer_grading_outer_container = $('.peer-grading-container')
@ajax_url = peer_grading_container.data('ajax-url') @ajax_url = @peer_grading_container.data('ajax-url')
@error_container = $('.error-container') @error_container = $('.error-container')
@error_container.toggle(not @error_container.is(':empty')) @error_container.toggle(not @error_container.is(':empty'))
...@@ -14,7 +14,7 @@ class PeerGrading ...@@ -14,7 +14,7 @@ class PeerGrading
@message_container.toggle(not @message_container.is(':empty')) @message_container.toggle(not @message_container.is(':empty'))
@problem_button = $('.problem-button') @problem_button = $('.problem-button')
@problem_button.click show_results @problem_button.click @show_results
@problem_list = $('.problem-list') @problem_list = $('.problem-list')
@construct_progress_bar() @construct_progress_bar()
...@@ -35,7 +35,7 @@ class PeerGrading ...@@ -35,7 +35,7 @@ class PeerGrading
$.postWithPrefix "#{@ajax_url}problem", data, (response) => $.postWithPrefix "#{@ajax_url}problem", data, (response) =>
if response.success if response.success
@peer_grading_outer_container.after(response.html).remove() @peer_grading_outer_container.after(response.html).remove()
backend = new PeerGradingProblemBackend(@ajax_url, false)
new PeerGradingProblem(backend)
else else
@gentle_alert response.error @gentle_alert response.error
\ No newline at end of file
$(document).ready(() -> new PeerGrading())
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
# Should not be run when we don't have a location to send back # Should not be run when we don't have a location to send back
# to the server # to the server
# #
# PeerGradingProblemBackend - # PeerGradingProblemBackend -
# makes all the ajax requests and provides a mock interface # makes all the ajax requests and provides a mock interface
# for testing purposes # for testing purposes
# #
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
# handles the rendering and user interactions with the interface # handles the rendering and user interactions with the interface
# #
################################## ##################################
class PeerGradingProblemBackend class @PeerGradingProblemBackend
constructor: (ajax_url, mock_backend) -> constructor: (ajax_url, mock_backend) ->
@mock_backend = mock_backend @mock_backend = mock_backend
@ajax_url = ajax_url @ajax_url = ajax_url
...@@ -32,141 +32,140 @@ class PeerGradingProblemBackend ...@@ -32,141 +32,140 @@ class PeerGradingProblemBackend
mock: (cmd, data) -> mock: (cmd, data) ->
if cmd == 'is_student_calibrated' if cmd == 'is_student_calibrated'
# change to test each version # change to test each version
response = response =
success: true success: true
calibrated: @mock_cnt >= 2 calibrated: @mock_cnt >= 2
else if cmd == 'show_calibration_essay' else if cmd == 'show_calibration_essay'
#response = #response =
# success: false # success: false
# error: "There was an error" # error: "There was an error"
@mock_cnt++ @mock_cnt++
response = response =
success: true success: true
submission_id: 1 submission_id: 1
submission_key: 'abcd' submission_key: 'abcd'
student_response: ''' student_response: '''
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32. Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.
The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham. The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.
''' '''
prompt: ''' prompt: '''
<h2>S11E3: Metal Bands</h2> <h2>S11E3: Metal Bands</h2>
<p>Shown below are schematic band diagrams for two different metals. Both diagrams appear different, yet both of the elements are undisputably metallic in nature.</p> <p>Shown below are schematic band diagrams for two different metals. Both diagrams appear different, yet both of the elements are undisputably metallic in nature.</p>
<p>* Why is it that both sodium and magnesium behave as metals, even though the s-band of magnesium is filled? </p> <p>* Why is it that both sodium and magnesium behave as metals, even though the s-band of magnesium is filled? </p>
<p>This is a self-assessed open response question. Please use as much space as you need in the box below to answer the question.</p> <p>This is a self-assessed open response question. Please use as much space as you need in the box below to answer the question.</p>
''' '''
rubric: ''' rubric: '''
<table class="rubric"><tbody><tr><th>Purpose</th> <table class="rubric"><tbody><tr><th>Purpose</th>
<td> <td>
<input type="radio" class="score-selection" name="score-selection-0" id="score-0-0" value="0"><label for="score-0-0">No product</label> <input type="radio" class="score-selection" name="score-selection-0" id="score-0-0" value="0"><label for="score-0-0">No product</label>
</td> </td>
<td> <td>
<input type="radio" class="score-selection" name="score-selection-0" id="score-0-1" value="1"><label for="score-0-1">Unclear purpose or main idea</label> <input type="radio" class="score-selection" name="score-selection-0" id="score-0-1" value="1"><label for="score-0-1">Unclear purpose or main idea</label>
</td> </td>
<td> <td>
<input type="radio" class="score-selection" name="score-selection-0" id="score-0-2" value="2"><label for="score-0-2">Communicates an identifiable purpose and/or main idea for an audience</label> <input type="radio" class="score-selection" name="score-selection-0" id="score-0-2" value="2"><label for="score-0-2">Communicates an identifiable purpose and/or main idea for an audience</label>
</td> </td>
<td> <td>
<input type="radio" class="score-selection" name="score-selection-0" id="score-0-3" value="3"><label for="score-0-3">Achieves a clear and distinct purpose for a targeted audience and communicates main ideas with effectively used techniques to introduce and represent ideas and insights</label> <input type="radio" class="score-selection" name="score-selection-0" id="score-0-3" value="3"><label for="score-0-3">Achieves a clear and distinct purpose for a targeted audience and communicates main ideas with effectively used techniques to introduce and represent ideas and insights</label>
</td> </td>
</tr><tr><th>Organization</th> </tr><tr><th>Organization</th>
<td> <td>
<input type="radio" class="score-selection" name="score-selection-1" id="score-1-0" value="0"><label for="score-1-0">No product</label> <input type="radio" class="score-selection" name="score-selection-1" id="score-1-0" value="0"><label for="score-1-0">No product</label>
</td> </td>
<td> <td>
<input type="radio" class="score-selection" name="score-selection-1" id="score-1-1" value="1"><label for="score-1-1">Organization is unclear; introduction, body, and/or conclusion are underdeveloped, missing or confusing.</label> <input type="radio" class="score-selection" name="score-selection-1" id="score-1-1" value="1"><label for="score-1-1">Organization is unclear; introduction, body, and/or conclusion are underdeveloped, missing or confusing.</label>
</td> </td>
<td> <td>
<input type="radio" class="score-selection" name="score-selection-1" id="score-1-2" value="2"><label for="score-1-2">Organization is occasionally unclear; introduction, body or conclusion may be underdeveloped.</label> <input type="radio" class="score-selection" name="score-selection-1" id="score-1-2" value="2"><label for="score-1-2">Organization is occasionally unclear; introduction, body or conclusion may be underdeveloped.</label>
</td> </td>
<td> <td>
<input type="radio" class="score-selection" name="score-selection-1" id="score-1-3" value="3"><label for="score-1-3">Organization is clear and easy to follow; introduction, body and conclusion are defined and aligned with purpose.</label> <input type="radio" class="score-selection" name="score-selection-1" id="score-1-3" value="3"><label for="score-1-3">Organization is clear and easy to follow; introduction, body and conclusion are defined and aligned with purpose.</label>
</td> </td>
</tr></tbody></table> </tr></tbody></table>
''' '''
max_score: 4 max_score: 4
else if cmd == 'get_next_submission' else if cmd == 'get_next_submission'
response = response =
success: true success: true
submission_id: 1 submission_id: 1
submission_key: 'abcd' submission_key: 'abcd'
student_response: '''Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nec tristique ante. Proin at mauris sapien, quis varius leo. Morbi laoreet leo nisi. Morbi aliquam lacus ante. Cras iaculis velit sed diam mattis a fermentum urna luctus. Duis consectetur nunc vitae felis facilisis eget vulputate risus viverra. Cras consectetur ullamcorper lobortis. Nam eu gravida lorem. Nulla facilisi. Nullam quis felis enim. Mauris orci lectus, dictum id cursus in, vulputate in massa. student_response: '''Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nec tristique ante. Proin at mauris sapien, quis varius leo. Morbi laoreet leo nisi. Morbi aliquam lacus ante. Cras iaculis velit sed diam mattis a fermentum urna luctus. Duis consectetur nunc vitae felis facilisis eget vulputate risus viverra. Cras consectetur ullamcorper lobortis. Nam eu gravida lorem. Nulla facilisi. Nullam quis felis enim. Mauris orci lectus, dictum id cursus in, vulputate in massa.
Phasellus non varius sem. Nullam commodo lacinia odio sit amet egestas. Donec ullamcorper sapien sagittis arcu volutpat placerat. Phasellus ut pretium ante. Nam dictum pulvinar nibh dapibus tristique. Sed at tellus mi, fringilla convallis justo. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus tristique rutrum nulla sed eleifend. Praesent at nunc arcu. Mauris condimentum faucibus nibh, eget commodo quam viverra sed. Morbi in tincidunt dolor. Morbi sed augue et augue interdum fermentum. Phasellus non varius sem. Nullam commodo lacinia odio sit amet egestas. Donec ullamcorper sapien sagittis arcu volutpat placerat. Phasellus ut pretium ante. Nam dictum pulvinar nibh dapibus tristique. Sed at tellus mi, fringilla convallis justo. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus tristique rutrum nulla sed eleifend. Praesent at nunc arcu. Mauris condimentum faucibus nibh, eget commodo quam viverra sed. Morbi in tincidunt dolor. Morbi sed augue et augue interdum fermentum.
Curabitur tristique purus ac arcu consequat cursus. Cras diam felis, dignissim quis placerat at, aliquet ac metus. Mauris vulputate est eu nibh imperdiet varius. Cras aliquet rhoncus elit a laoreet. Mauris consectetur erat et erat scelerisque eu faucibus dolor consequat. Nam adipiscing sagittis nisl, eu mollis massa tempor ac. Nulla scelerisque tempus blandit. Phasellus ac ipsum eros, id posuere arcu. Nullam non sapien arcu. Vivamus sit amet lorem justo, ac tempus turpis. Suspendisse pharetra gravida imperdiet. Pellentesque lacinia mi eu elit luctus pellentesque. Sed accumsan libero a magna elementum varius. Nunc eget pellentesque metus. ''' Curabitur tristique purus ac arcu consequat cursus. Cras diam felis, dignissim quis placerat at, aliquet ac metus. Mauris vulputate est eu nibh imperdiet varius. Cras aliquet rhoncus elit a laoreet. Mauris consectetur erat et erat scelerisque eu faucibus dolor consequat. Nam adipiscing sagittis nisl, eu mollis massa tempor ac. Nulla scelerisque tempus blandit. Phasellus ac ipsum eros, id posuere arcu. Nullam non sapien arcu. Vivamus sit amet lorem justo, ac tempus turpis. Suspendisse pharetra gravida imperdiet. Pellentesque lacinia mi eu elit luctus pellentesque. Sed accumsan libero a magna elementum varius. Nunc eget pellentesque metus. '''
prompt: ''' prompt: '''
<h2>S11E3: Metal Bands</h2> <h2>S11E3: Metal Bands</h2>
<p>Shown below are schematic band diagrams for two different metals. Both diagrams appear different, yet both of the elements are undisputably metallic in nature.</p> <p>Shown below are schematic band diagrams for two different metals. Both diagrams appear different, yet both of the elements are undisputably metallic in nature.</p>
<p>* Why is it that both sodium and magnesium behave as metals, even though the s-band of magnesium is filled? </p> <p>* Why is it that both sodium and magnesium behave as metals, even though the s-band of magnesium is filled? </p>
<p>This is a self-assessed open response question. Please use as much space as you need in the box below to answer the question.</p> <p>This is a self-assessed open response question. Please use as much space as you need in the box below to answer the question.</p>
''' '''
rubric: ''' rubric: '''
<table class="rubric"><tbody><tr><th>Purpose</th> <table class="rubric"><tbody><tr><th>Purpose</th>
<td> <td>
<input type="radio" class="score-selection" name="score-selection-0" id="score-0-0" value="0"><label for="score-0-0">No product</label> <input type="radio" class="score-selection" name="score-selection-0" id="score-0-0" value="0"><label for="score-0-0">No product</label>
</td> </td>
<td> <td>
<input type="radio" class="score-selection" name="score-selection-0" id="score-0-1" value="1"><label for="score-0-1">Unclear purpose or main idea</label> <input type="radio" class="score-selection" name="score-selection-0" id="score-0-1" value="1"><label for="score-0-1">Unclear purpose or main idea</label>
</td> </td>
<td> <td>
<input type="radio" class="score-selection" name="score-selection-0" id="score-0-2" value="2"><label for="score-0-2">Communicates an identifiable purpose and/or main idea for an audience</label> <input type="radio" class="score-selection" name="score-selection-0" id="score-0-2" value="2"><label for="score-0-2">Communicates an identifiable purpose and/or main idea for an audience</label>
</td> </td>
<td> <td>
<input type="radio" class="score-selection" name="score-selection-0" id="score-0-3" value="3"><label for="score-0-3">Achieves a clear and distinct purpose for a targeted audience and communicates main ideas with effectively used techniques to introduce and represent ideas and insights</label> <input type="radio" class="score-selection" name="score-selection-0" id="score-0-3" value="3"><label for="score-0-3">Achieves a clear and distinct purpose for a targeted audience and communicates main ideas with effectively used techniques to introduce and represent ideas and insights</label>
</td> </td>
</tr><tr><th>Organization</th> </tr><tr><th>Organization</th>
<td> <td>
<input type="radio" class="score-selection" name="score-selection-1" id="score-1-0" value="0"><label for="score-1-0">No product</label> <input type="radio" class="score-selection" name="score-selection-1" id="score-1-0" value="0"><label for="score-1-0">No product</label>
</td> </td>
<td> <td>
<input type="radio" class="score-selection" name="score-selection-1" id="score-1-1" value="1"><label for="score-1-1">Organization is unclear; introduction, body, and/or conclusion are underdeveloped, missing or confusing.</label> <input type="radio" class="score-selection" name="score-selection-1" id="score-1-1" value="1"><label for="score-1-1">Organization is unclear; introduction, body, and/or conclusion are underdeveloped, missing or confusing.</label>
</td> </td>
<td> <td>
<input type="radio" class="score-selection" name="score-selection-1" id="score-1-2" value="2"><label for="score-1-2">Organization is occasionally unclear; introduction, body or conclusion may be underdeveloped.</label> <input type="radio" class="score-selection" name="score-selection-1" id="score-1-2" value="2"><label for="score-1-2">Organization is occasionally unclear; introduction, body or conclusion may be underdeveloped.</label>
</td> </td>
<td> <td>
<input type="radio" class="score-selection" name="score-selection-1" id="score-1-3" value="3"><label for="score-1-3">Organization is clear and easy to follow; introduction, body and conclusion are defined and aligned with purpose.</label> <input type="radio" class="score-selection" name="score-selection-1" id="score-1-3" value="3"><label for="score-1-3">Organization is clear and easy to follow; introduction, body and conclusion are defined and aligned with purpose.</label>
</td> </td>
</tr></tbody></table> </tr></tbody></table>
''' '''
max_score: 4 max_score: 4
else if cmd == 'save_calibration_essay' else if cmd == 'save_calibration_essay'
response = response =
success: true success: true
actual_score: 2 actual_score: 2
else if cmd == 'save_grade' else if cmd == 'save_grade'
response = response =
success: true success: true
return response return response
class @PeerGradingProblem
class PeerGradingProblem
constructor: (backend) -> constructor: (backend) ->
@prompt_wrapper = $('.prompt-wrapper') @prompt_wrapper = $('.prompt-wrapper')
@backend = backend @backend = backend
# get the location of the problem # get the location of the problem
@location = $('.peer-grading').data('location') @location = $('.peer-grading').data('location')
# prevent this code from trying to run # prevent this code from trying to run
# when we don't have a location # when we don't have a location
if(!@location) if(!@location)
return return
...@@ -208,7 +207,7 @@ class PeerGradingProblem ...@@ -208,7 +207,7 @@ class PeerGradingProblem
# Set up the click event handlers # Set up the click event handlers
@action_button.click -> history.back() @action_button.click -> history.back()
@calibration_feedback_button.click => @calibration_feedback_button.click =>
@calibration_feedback_panel.hide() @calibration_feedback_panel.hide()
@grading_wrapper.show() @grading_wrapper.show()
@is_calibrated_check() @is_calibrated_check()
...@@ -266,7 +265,7 @@ class PeerGradingProblem ...@@ -266,7 +265,7 @@ class PeerGradingProblem
submit_grade: () => submit_grade: () =>
data = @construct_data() data = @construct_data()
@backend.post('save_grade', data, @submission_callback) @backend.post('save_grade', data, @submission_callback)
########## ##########
# #
...@@ -301,7 +300,7 @@ class PeerGradingProblem ...@@ -301,7 +300,7 @@ class PeerGradingProblem
@render_calibration_feedback(response) @render_calibration_feedback(response)
else if response.error else if response.error
@render_error(response.error) @render_error(response.error)
else else
@render_error("Error saving calibration score") @render_error("Error saving calibration score")
# called after we submit a submission score # called after we submit a submission score
...@@ -330,8 +329,8 @@ class PeerGradingProblem ...@@ -330,8 +329,8 @@ class PeerGradingProblem
# show button if we have scores for all categories # show button if we have scores for all categories
@show_submit_button() @show_submit_button()
########## ##########
# #
# Rendering methods and helpers # Rendering methods and helpers
...@@ -344,7 +343,7 @@ class PeerGradingProblem ...@@ -344,7 +343,7 @@ class PeerGradingProblem
# load in all the data # load in all the data
@submission_container.html("<h3>Training Essay</h3>") @submission_container.html("<h3>Training Essay</h3>")
@render_submission_data(response) @render_submission_data(response)
# TODO: indicate that we're in calibration mode # TODO: indicate that we're in calibration mode
@calibration_panel.addClass('current-state') @calibration_panel.addClass('current-state')
@grading_panel.removeClass('current-state') @grading_panel.removeClass('current-state')
...@@ -428,12 +427,12 @@ class PeerGradingProblem ...@@ -428,12 +427,12 @@ class PeerGradingProblem
if score == actual_score if score == actual_score
calibration_wrapper.append("<p>Congratulations! Your score matches the actual score!</p>") calibration_wrapper.append("<p>Congratulations! Your score matches the actual score!</p>")
else else
calibration_wrapper.append("<p>Please try to understand the grading critera better to be more accurate next time.</p>") calibration_wrapper.append("<p>Please try to understand the grading critera better to be more accurate next time.</p>")
# disable score selection and submission from the grading interface # disable score selection and submission from the grading interface
$("input[name='score-selection']").attr('disabled', true) $("input[name='score-selection']").attr('disabled', true)
@submit_button.hide() @submit_button.hide()
render_interstitial_page: () => render_interstitial_page: () =>
@content_panel.hide() @content_panel.hide()
@interstitial_page.show() @interstitial_page.show()
...@@ -449,7 +448,7 @@ class PeerGradingProblem ...@@ -449,7 +448,7 @@ class PeerGradingProblem
@submit_button.show() @submit_button.show()
setup_score_selection: (max_score) => setup_score_selection: (max_score) =>
# first, get rid of all the old inputs, if any. # first, get rid of all the old inputs, if any.
@score_selection_container.html(""" @score_selection_container.html("""
<h3>Overall Score</h3> <h3>Overall Score</h3>
...@@ -460,7 +459,7 @@ class PeerGradingProblem ...@@ -460,7 +459,7 @@ class PeerGradingProblem
for score in [0..max_score] for score in [0..max_score]
id = 'score-' + score id = 'score-' + score
label = """<label for="#{id}">#{score}</label>""" label = """<label for="#{id}">#{score}</label>"""
input = """ input = """
<input type="radio" name="grade-selection" id="#{id}" value="#{score}"/> <input type="radio" name="grade-selection" id="#{id}" value="#{score}"/>
""" # " fix broken parsing in emacs """ # " fix broken parsing in emacs
...@@ -470,9 +469,7 @@ class PeerGradingProblem ...@@ -470,9 +469,7 @@ class PeerGradingProblem
$("input[name='score-selection']").change @graded_callback $("input[name='score-selection']").change @graded_callback
$("input[name='grade-selection']").change @graded_callback $("input[name='grade-selection']").change @graded_callback
#mock_backend = false
#ajax_url = $('.peer-grading').data('ajax_url')
mock_backend = false #backend = new PeerGradingProblemBackend(ajax_url, mock_backend)
ajax_url = $('.peer-grading').data('ajax_url') #$(document).ready(() -> new PeerGradingProblem(backend))
backend = new PeerGradingProblemBackend(ajax_url, mock_backend)
$(document).ready(() -> new PeerGradingProblem(backend))
...@@ -68,7 +68,6 @@ class PeerGradingModule(XModule): ...@@ -68,7 +68,6 @@ class PeerGradingModule(XModule):
system.set('location', location) system.set('location', location)
self.system = system self.system = system
self.peer_gs = peer_grading_service() self.peer_gs = peer_grading_service()
log.debug(self.system)
self.use_for_single_location = self.metadata.get('use_for_single_location', USE_FOR_SINGLE_LOCATION) self.use_for_single_location = self.metadata.get('use_for_single_location', USE_FOR_SINGLE_LOCATION)
if isinstance(self.use_for_single_location, basestring): if isinstance(self.use_for_single_location, basestring):
...@@ -108,7 +107,7 @@ class PeerGradingModule(XModule): ...@@ -108,7 +107,7 @@ class PeerGradingModule(XModule):
Needs to be implemented by child modules. Handles AJAX events. Needs to be implemented by child modules. Handles AJAX events.
@return: @return:
""" """
log.debug(get)
handlers = { handlers = {
'get_next_submission': self.get_next_submission, 'get_next_submission': self.get_next_submission,
'show_calibration_essay': self.show_calibration_essay, 'show_calibration_essay': self.show_calibration_essay,
...@@ -123,6 +122,8 @@ class PeerGradingModule(XModule): ...@@ -123,6 +122,8 @@ class PeerGradingModule(XModule):
d = handlers[dispatch](get) d = handlers[dispatch](get)
log.debug(d)
return json.dumps(d, cls=ComplexEncoder) return json.dumps(d, cls=ComplexEncoder)
def get_progress(self): def get_progress(self):
...@@ -149,14 +150,12 @@ class PeerGradingModule(XModule): ...@@ -149,14 +150,12 @@ class PeerGradingModule(XModule):
'error': if success is False, will have an error message with more info. 'error': if success is False, will have an error message with more info.
""" """
_check_post(request)
required = set(['location']) required = set(['location'])
success, message = _check_required(request, required) success, message = self._check_required(get, required)
if not success: if not success:
return _err_response(message) return _err_response(message)
grader_id = unique_id_for_user(request.user) grader_id = self.system.anonymous_student_id
p = request.POST location = get['location']
location = p['location']
try: try:
response = self.peer_gs.get_next_submission(location, grader_id) response = self.peer_gs.get_next_submission(location, grader_id)
...@@ -183,20 +182,20 @@ class PeerGradingModule(XModule): ...@@ -183,20 +182,20 @@ class PeerGradingModule(XModule):
success: bool indicating whether the save was a success success: bool indicating whether the save was a success
error: if there was an error in the submission, this is the error message error: if there was an error in the submission, this is the error message
""" """
_check_post(request)
required = set(['location', 'submission_id', 'submission_key', 'score', 'feedback', 'rubric_scores[]', 'submission_flagged']) required = set(['location', 'submission_id', 'submission_key', 'score', 'feedback', 'rubric_scores[]', 'submission_flagged'])
success, message = _check_required(request, required) success, message = self._check_required(get, required)
if not success: if not success:
return _err_response(message) return _err_response(message)
grader_id = unique_id_for_user(request.user) grader_id = self.system.anonymous_student_id
p = request.POST
location = p['location'] location = get['location']
submission_id = p['submission_id'] submission_id = get['submission_id']
score = p['score'] score = get['score']
feedback = p['feedback'] feedback = get['feedback']
submission_key = p['submission_key'] submission_key = get['submission_key']
rubric_scores = p.getlist('rubric_scores[]') rubric_scores = get['rubric_scores']
submission_flagged = p['submission_flagged'] submission_flagged = get['submission_flagged']
try: try:
response = self.peer_gs.save_grade(location, grader_id, submission_id, response = self.peer_gs.save_grade(location, grader_id, submission_id,
score, feedback, submission_key, rubric_scores, submission_flagged) score, feedback, submission_key, rubric_scores, submission_flagged)
...@@ -227,14 +226,14 @@ class PeerGradingModule(XModule): ...@@ -227,14 +226,14 @@ class PeerGradingModule(XModule):
total_calibrated_on_so_far - the number of calibration essays for this problem total_calibrated_on_so_far - the number of calibration essays for this problem
that this grader has graded that this grader has graded
""" """
_check_post(request)
required = set(['location']) required = set(['location'])
success, message = _check_required(request, required) success, message = self._check_required(get, required)
if not success: if not success:
return _err_response(message) return _err_response(message)
grader_id = unique_id_for_user(request.user) grader_id = self.system.anonymous_student_id
p = request.POST
location = p['location'] location = get['location']
try: try:
response = self.peer_gs.is_student_calibrated(location, grader_id) response = self.peer_gs.is_student_calibrated(location, grader_id)
...@@ -268,16 +267,15 @@ class PeerGradingModule(XModule): ...@@ -268,16 +267,15 @@ class PeerGradingModule(XModule):
'error': if success is False, will have an error message with more info. 'error': if success is False, will have an error message with more info.
""" """
_check_post(request)
required = set(['location']) required = set(['location'])
success, message = _check_required(request, required) success, message = self._check_required(get, required)
if not success: if not success:
return _err_response(message) return _err_response(message)
grader_id = unique_id_for_user(request.user) grader_id = self.system.anonymous_student_id
p = request.POST
location = p['location'] location = get['location']
try: try:
response = self.peer_gs.show_calibration_essay(location, grader_id) response = self.peer_gs.show_calibration_essay(location, grader_id)
return HttpResponse(response, mimetype="application/json") return HttpResponse(response, mimetype="application/json")
...@@ -311,20 +309,19 @@ class PeerGradingModule(XModule): ...@@ -311,20 +309,19 @@ class PeerGradingModule(XModule):
actual_score: the score that the instructor gave to this calibration essay actual_score: the score that the instructor gave to this calibration essay
""" """
_check_post(request)
required = set(['location', 'submission_id', 'submission_key', 'score', 'feedback', 'rubric_scores[]']) required = set(['location', 'submission_id', 'submission_key', 'score', 'feedback', 'rubric_scores[]'])
success, message = _check_required(request, required) success, message = self._check_required(get, required)
if not success: if not success:
return _err_response(message) return _err_response(message)
grader_id = unique_id_for_user(request.user) grader_id = self.system.anonymous_student_id
p = request.POST
location = p['location'] location = get['location']
calibration_essay_id = p['submission_id'] calibration_essay_id = get['submission_id']
submission_key = p['submission_key'] submission_key = get['submission_key']
score = p['score'] score = get['score']
feedback = p['feedback'] feedback = get['feedback']
rubric_scores = p.getlist('rubric_scores[]') rubric_scores = get['rubric_scores']
try: try:
response = self.peer_gs.save_calibration_essay(location, grader_id, calibration_essay_id, response = self.peer_gs.save_calibration_essay(location, grader_id, calibration_essay_id,
......
...@@ -48,6 +48,7 @@ class PeerGradingService(): ...@@ -48,6 +48,7 @@ class PeerGradingService():
'rubric_scores': rubric_scores, 'rubric_scores': rubric_scores,
'rubric_scores_complete': True, 'rubric_scores_complete': True,
'submission_flagged' : submission_flagged} 'submission_flagged' : submission_flagged}
log.debug(data)
return self.post(self.save_grade_url, data) return self.post(self.save_grade_url, data)
def is_student_calibrated(self, problem_location, grader_id): def is_student_calibrated(self, problem_location, grader_id):
...@@ -69,6 +70,7 @@ class PeerGradingService(): ...@@ -69,6 +70,7 @@ class PeerGradingService():
'feedback': feedback, 'feedback': feedback,
'rubric_scores[]': rubric_scores, 'rubric_scores[]': rubric_scores,
'rubric_scores_complete': True} 'rubric_scores_complete': True}
log.debug(data)
return self.post(self.save_calibration_essay_url, data) return self.post(self.save_calibration_essay_url, data)
def get_problem_list(self, course_id, grader_id): def get_problem_list(self, course_id, grader_id):
......
<section class="container peer-grading-container"> <section class="container peer-grading-container">
<div class="peer-grading" data-ajax_url="${ajax_url}"> <div class="peer-grading" data-ajax-url="${ajax_url}">
<div class="error-container">${error_text}</div> <div class="error-container">${error_text}</div>
<h1>Peer Grading</h1> <h1>Peer Grading</h1>
<h2>Instructions</h2> <h2>Instructions</h2>
......
<section class="container peer-grading-container"> <section class="container peer-grading-container">
<div class="peer-grading" data-ajax_url="${ajax_url}" data-location="${problem_location}"> <div class="peer-grading" data-ajax-url="${ajax_url}" data-location="${problem_location}">
<div class="error-container"></div> <div class="error-container"></div>
<section class="content-panel"> <section class="content-panel">
......
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