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