Updated html and javascript for new pages as well
as a fix for the peer grading service
This commit is contained in:
@@ -65,6 +65,7 @@ class PeerGradingService(GradingService):
|
||||
return response
|
||||
|
||||
|
||||
_service = None
|
||||
def peer_grading_service():
|
||||
"""
|
||||
Return a peer grading service instance--if settings.MOCK_PEER_GRADING is True,
|
||||
|
||||
@@ -18,14 +18,27 @@ class PeerGradingProblemBackend
|
||||
success: true
|
||||
calibrated: false
|
||||
else if cmd == 'show_calibration_essay'
|
||||
#response =
|
||||
# success: false
|
||||
# error: "There was an error"
|
||||
response =
|
||||
success: true
|
||||
submission_id: 1
|
||||
submission_key: 'abcd'
|
||||
student_response: 'I am a fake response'
|
||||
student_response: 'I am a fake calibration response'
|
||||
prompt: 'Answer this question'
|
||||
rubric: 'This is a rubric.'
|
||||
max_score: 4
|
||||
else if cmd == 'get_next_submission'
|
||||
response =
|
||||
success: true
|
||||
submission_id: 1
|
||||
submission_key: 'abcd'
|
||||
student_response: 'I am a fake student response'
|
||||
prompt: 'Answer this question'
|
||||
rubric: 'This is a rubric.'
|
||||
max_score: 4
|
||||
|
||||
|
||||
|
||||
return response
|
||||
@@ -48,35 +61,51 @@ class PeerGradingProblem
|
||||
@submission_container = $('.submission-container')
|
||||
@prompt_container = $('.prompt-container')
|
||||
@rubric_container = $('.rubric-container')
|
||||
@instructions_panel = $('.instructions-panel')
|
||||
@content_panel = $('.content-panel')
|
||||
|
||||
@error_container = $('.error-container')
|
||||
|
||||
@submission_key_input = $("input[name='submission-key']")
|
||||
@essay_id_input = $("input[name='essay-id']")
|
||||
|
||||
@score_selection_container = $('.score-selection-container')
|
||||
@score = null
|
||||
|
||||
@submit_button = $('.submit-button')
|
||||
@action_button = $('.action-button')
|
||||
|
||||
@action_button.click -> document.location.reload(true)
|
||||
|
||||
@is_calibrated_check()
|
||||
|
||||
|
||||
##########
|
||||
#
|
||||
# Ajax calls to the backend
|
||||
#
|
||||
##########
|
||||
is_calibrated_check: () =>
|
||||
@backend.post('is_student_calibrated', {}, @calibration_check_callback)
|
||||
@backend.post('is_student_calibrated', {location: @location}, @calibration_check_callback)
|
||||
|
||||
|
||||
fetch_calibration_essay: ()=>
|
||||
fetch_calibration_essay: () =>
|
||||
@backend.post('show_calibration_essay', {location: @location}, @render_calibration)
|
||||
|
||||
render_calibration: (response) =>
|
||||
if response.success
|
||||
#TODO: fill this in
|
||||
fetch_submission_essay: () =>
|
||||
@backend.post('get_next_submission', {location: @location}, @render_submission)
|
||||
|
||||
@submission_container.html("<h3>Calibration Essay</h3>")
|
||||
@submission_container.append(response.student_response)
|
||||
@prompt_container.html(response.prompt)
|
||||
@rubric_container.html(response.rubric)
|
||||
submit_calibration_essay: ()->
|
||||
#TODO: onclick of the submit button. submits the calibration essay grade
|
||||
|
||||
else
|
||||
@error_container.show()
|
||||
@error_container.html(response.error)
|
||||
|
||||
render_submission: (response) ->
|
||||
#TODO: fill this in
|
||||
submit_grade: () ->
|
||||
#TODO: onclick of the submit button. submits the grade
|
||||
|
||||
|
||||
##########
|
||||
#
|
||||
# Callbacks for various events
|
||||
#
|
||||
##########
|
||||
calibration_check_callback: (response) =>
|
||||
if response.success
|
||||
# check whether or not we're still calibrating
|
||||
@@ -86,6 +115,89 @@ class PeerGradingProblem
|
||||
else
|
||||
@fetch_calibration_essay()
|
||||
@calibration = true
|
||||
else if response.error
|
||||
@render_error(response.error)
|
||||
else
|
||||
@render_error("Error contacting the grading service")
|
||||
|
||||
|
||||
submission_callback: (response) =>
|
||||
if response.success
|
||||
@is_calibrated_check()
|
||||
else
|
||||
if response.error
|
||||
@render_error(response.error)
|
||||
else
|
||||
@render_error("Error occurred while submitting grade")
|
||||
|
||||
graded_callback: (event) =>
|
||||
@score = event.target.value
|
||||
@show_submit_button()
|
||||
|
||||
|
||||
|
||||
##########
|
||||
#
|
||||
# Rendering methods and helpers
|
||||
#
|
||||
##########
|
||||
render_calibration: (response) =>
|
||||
if response.success
|
||||
|
||||
# load in all the data
|
||||
@submission_container.html("<h3>Calibration Essay</h3>")
|
||||
@render_submission_data(response)
|
||||
|
||||
# TODO: indicate that we're in calibration mode
|
||||
|
||||
else
|
||||
if response.error
|
||||
@render_error(response.error)
|
||||
else
|
||||
@render_error("An error occurred while contacting the grading server")
|
||||
|
||||
render_submission_data: (response) =>
|
||||
@content_panel.show()
|
||||
@submission_container.append(response.student_response)
|
||||
@prompt_container.html(response.prompt)
|
||||
@rubric_container.html(response.rubric)
|
||||
@submission_key_input.val(response.submission_key)
|
||||
@essay_id_input.val(response.submission_id)
|
||||
@setup_score_selection(response.max_score)
|
||||
@submit_button.hide()
|
||||
@action_button.hide()
|
||||
|
||||
|
||||
render_submission: (response) =>
|
||||
#TODO: fill this in
|
||||
@submit_button.hide()
|
||||
@render_submission_data(response)
|
||||
|
||||
render_error: (error_message) =>
|
||||
@error_container.show()
|
||||
@error_container.html(error_message)
|
||||
@content_panel.hide()
|
||||
|
||||
show_submit_button: () =>
|
||||
@submit_button.show()
|
||||
|
||||
setup_score_selection: (max_score) =>
|
||||
# first, get rid of all the old inputs, if any.
|
||||
@score_selection_container.html('Choose score: ')
|
||||
|
||||
# Now create new labels and inputs for each possible score.
|
||||
for score in [0..max_score]
|
||||
id = 'score-' + score
|
||||
label = """<label for="#{id}">#{score}</label>"""
|
||||
|
||||
input = """
|
||||
<input type="radio" name="score-selection" id="#{id}" value="#{score}"/>
|
||||
""" # " fix broken parsing in emacs
|
||||
@score_selection_container.append(input + label)
|
||||
|
||||
# And now hook up an event handler again
|
||||
$("input[name='score-selection']").change @graded_callback
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
<div class="error-container"></div>
|
||||
<div class="message-container"></div>
|
||||
|
||||
<section class="content-panel">
|
||||
<div class="instructions-panel">
|
||||
<div class="calibration-panel">
|
||||
<h3>Calibration</h3>
|
||||
@@ -68,7 +69,10 @@
|
||||
<input type="button" value="Submit" class="submit-button" name="show"/>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
</section>
|
||||
<input type="button" value="Reload page" class="action-button" name="reload" />
|
||||
</div>
|
||||
</section>
|
||||
|
||||
Reference in New Issue
Block a user