Commit 58364384 by Victor Shnayder Committed by Victor Shnayder

hook up radio buttons, hide submit button till after grading

parent e910f60e
......@@ -4,7 +4,8 @@ get_random_int: (min, max) ->
return Math.floor(Math.random() * (max - min + 1)) + min
# states
state_grading = "have_data"
state_grading = "grading"
state_graded = "graded"
state_no_data = "no_data"
state_error = "error"
......@@ -82,8 +83,10 @@ class StaffGrading
# action handlers
@submit_button.click @submit
@correct_button.click () => @score = 1
@incorrect_button.click () => @score = 0
# TODO: hook up an event to the input changing, which updates
# @score (instead of the individual hacks)
$('#correct-radio').click @graded_callback
$('#incorrect-radio').click @graded_callback
# render intial state
@render_view()
......@@ -92,8 +95,13 @@ class StaffGrading
@get_next_submission()
set_button_text: (text) ->
@submit_button.prop('value', text)
set_button_text: (text) =>
@submit_button.attr('value', text)
graded_callback: (event) =>
@score = event.target.value
@state = state_graded
@render_view()
ajax_callback: (response) =>
# always clear out errors and messages on transition.
......@@ -138,6 +146,7 @@ class StaffGrading
render_view: () ->
# make the view elements match the state. Idempotent.
show_grading_elements = false
show_submit_button = true
@message_container.html(@message)
@error_container.html(@error_msg)
......@@ -149,6 +158,16 @@ class StaffGrading
@submission_container.html(@submission)
@rubric_container.html(@rubric)
show_grading_elements = true
# no submit button until user picks grade.
show_submit_button = false
# TODO: clean up with proper input-related logic
$('#correct-radio')[0].checked = false
$('#incorrect-radio')[0].checked = false
else if @state == state_graded
show_grading_elements = true
@set_button_text('Submit')
else if @state == state_no_data
......@@ -158,6 +177,7 @@ class StaffGrading
else
@error('System got into invalid state ' + @state)
@submit_button.toggle(show_submit_button)
@submission_wrapper.toggle(show_grading_elements)
@rubric_wrapper.toggle(show_grading_elements)
......@@ -167,12 +187,12 @@ class StaffGrading
if @state == state_error
@get_next_submission()
else if @state == state_grading
else if @state == state_graded
@submit_and_get_next()
else if @state == state_no_data
@get_next_submission()
else
@error('System got into invalid state ' + @state)
@error('System got into invalid state for submission: ' + @state)
# for now, just create an instance and load it...
......
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html> <head>
<title></title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<!-- <script src="http://code.jquery.com/jquery-latest.js"></script> -->
<script src="../../../admin/js/jquery.min.js"></script>
<script type="text/javascript" src="staff_grading.js"></script>
</head>
......@@ -32,8 +33,7 @@
<p>
<label for="correct-radio">Correct</label>
<input type="radio" name="score-selection" id="correct-radio" value="1">
<label for="correct-radio">Incorrect</label>
<label for="incorrect-radio">Incorrect</label>
<input type="radio" name="score-selection" id="incorrect-radio" value="0">
</p>
</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