Commit 078b2a5b by Diana Huang

Fix up some minor state issues and

complete basic JS functionality for page
parent becffd4d
...@@ -132,7 +132,7 @@ def save_grade(request, course_id): ...@@ -132,7 +132,7 @@ def save_grade(request, course_id):
TODO: fill in this documentation TODO: fill in this documentation
""" """
_check_post(request) _check_post(request)
required = set(['location', 'grader_id', 'submission_id', 'submission_key', 'score', 'feedback']) required = set(['location', 'submission_id', 'submission_key', 'score', 'feedback'])
success, message = _check_required(request, required) success, message = _check_required(request, required)
if not success: if not success:
return _err_response(message) return _err_response(message)
...@@ -211,14 +211,14 @@ def save_calibration_essay(request, course_id): ...@@ -211,14 +211,14 @@ def save_calibration_essay(request, course_id):
""" """
_check_post(request) _check_post(request)
required = set(['location', 'calibration_essay_id', 'submission_key', 'score', 'feedback']) required = set(['location', 'submission_id', 'submission_key', 'score', 'feedback'])
success, message = _check_required(request, required) success, message = _check_required(request, required)
if not success: if not success:
return _err_response(message) return _err_response(message)
grader_id = request.user.id grader_id = request.user.id
p = request.POST p = request.POST
location = p['location'] location = p['location']
calibration_essay_id = p['calibration_essay_id'] calibration_essay_id = p['submission_id']
submission_key = p['submission_key'] submission_key = p['submission_key']
score = p['score'] score = p['score']
feedback = p['feedback'] feedback = p['feedback']
......
...@@ -16,7 +16,7 @@ class PeerGradingProblemBackend ...@@ -16,7 +16,7 @@ class PeerGradingProblemBackend
# change to test each version # change to test each version
response = response =
success: true success: true
calibrated: false calibrated: true
else if cmd == 'show_calibration_essay' else if cmd == 'show_calibration_essay'
#response = #response =
# success: false # success: false
...@@ -38,7 +38,12 @@ class PeerGradingProblemBackend ...@@ -38,7 +38,12 @@ class PeerGradingProblemBackend
prompt: 'Answer this question' prompt: 'Answer this question'
rubric: 'This is a rubric.' rubric: 'This is a rubric.'
max_score: 4 max_score: 4
else if cmd == 'save_calibration_essay'
response =
success: true
else if cmd == 'save_grade'
response =
success: true
return response return response
...@@ -61,13 +66,15 @@ class PeerGradingProblem ...@@ -61,13 +66,15 @@ class PeerGradingProblem
@submission_container = $('.submission-container') @submission_container = $('.submission-container')
@prompt_container = $('.prompt-container') @prompt_container = $('.prompt-container')
@rubric_container = $('.rubric-container') @rubric_container = $('.rubric-container')
@instructions_panel = $('.instructions-panel') @calibration_panel = $('.calibration-panel')
@grading_panel = $('.grading-panel')
@content_panel = $('.content-panel') @content_panel = $('.content-panel')
@error_container = $('.error-container') @error_container = $('.error-container')
@submission_key_input = $("input[name='submission-key']") @submission_key_input = $("input[name='submission-key']")
@essay_id_input = $("input[name='essay-id']") @essay_id_input = $("input[name='essay-id']")
@feedback_area = $('.feedback-area')
@score_selection_container = $('.score-selection-container') @score_selection_container = $('.score-selection-container')
@score = null @score = null
...@@ -94,11 +101,23 @@ class PeerGradingProblem ...@@ -94,11 +101,23 @@ class PeerGradingProblem
fetch_submission_essay: () => fetch_submission_essay: () =>
@backend.post('get_next_submission', {location: @location}, @render_submission) @backend.post('get_next_submission', {location: @location}, @render_submission)
submit_calibration_essay: ()-> construct_data: () =>
#TODO: onclick of the submit button. submits the calibration essay grade data =
score: @score
location: @location
submission_id: @essay_id_input.val()
submission_key: @submission_key_input.val()
feedback: @feedback_area.val()
return data
submit_grade: () -> submit_calibration_essay: ()=>
#TODO: onclick of the submit button. submits the grade data = @construct_data()
@backend.post('save_calibration_essay', data, @submission_callback)
submit_grade: () =>
data = @construct_data()
@backend.post('save_grade', data, @submission_callback)
########## ##########
...@@ -110,7 +129,7 @@ class PeerGradingProblem ...@@ -110,7 +129,7 @@ class PeerGradingProblem
if response.success if response.success
# check whether or not we're still calibrating # check whether or not we're still calibrating
if response.calibrated if response.calibrated
@fetch_submission() @fetch_submission_essay()
@calibration = false @calibration = false
else else
@fetch_calibration_essay() @fetch_calibration_essay()
...@@ -147,18 +166,55 @@ class PeerGradingProblem ...@@ -147,18 +166,55 @@ class PeerGradingProblem
# load in all the data # load in all the data
@submission_container.html("<h3>Calibration Essay</h3>") @submission_container.html("<h3>Calibration 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')
@grading_panel.removeClass('current-state')
# clear out all of the existing text
@calibration_panel.find('p').remove()
@grading_panel.find('p').remove()
# add in new text
@submit_button.click @submit_calibration_essay
else if response.error
@render_error(response.error)
else else
if response.error @render_error("An error occurred while retrieving the next calibration essay")
@render_error(response.error)
else render_submission: (response) =>
@render_error("An error occurred while contacting the grading server") if response.success
#TODO: fill this in
@submit_button.hide()
@submission_container.html("<h3>Submitted Essay</h3>")
@render_submission_data(response)
@calibration_panel.removeClass('current-state')
@grading_panel.addClass('current-state')
# clear out all of the existing text
@calibration_panel.find('p').remove()
@grading_panel.find('p').remove()
@submit_button.click @submit_grade
else if response.error
@render_error(response.error)
else
@render_error("An error occured when retrieving the next submission.")
make_paragraphs: (text) ->
paragraph_split = text.split(/\n\s*\n/)
new_text = ''
for paragraph in paragraph_split
new_text += "<p>#{paragraph}</p>"
return new_text
render_submission_data: (response) => render_submission_data: (response) =>
@content_panel.show() @content_panel.show()
@submission_container.append(response.student_response) @submission_container.append(@make_paragraphs(response.student_response))
@prompt_container.html(response.prompt) @prompt_container.html(response.prompt)
@rubric_container.html(response.rubric) @rubric_container.html(response.rubric)
@submission_key_input.val(response.submission_key) @submission_key_input.val(response.submission_key)
...@@ -168,10 +224,6 @@ class PeerGradingProblem ...@@ -168,10 +224,6 @@ class PeerGradingProblem
@action_button.hide() @action_button.hide()
render_submission: (response) =>
#TODO: fill this in
@submit_button.hide()
@render_submission_data(response)
render_error: (error_message) => render_error: (error_message) =>
@error_container.show() @error_container.show()
......
...@@ -82,6 +82,11 @@ div.peer-grading{ ...@@ -82,6 +82,11 @@ div.peer-grading{
margin-bottom:5px; margin-bottom:5px;
font-size: .8em; font-size: .8em;
} }
.current-state
{
background: #eee;
}
padding: 40px; padding: 40px;
} }
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