Commit 92b7dbdc by Diana Huang

Refactor rubric JS so that we don't have to keep duplicating this code.

parent 1fde3c5e
class @Rubric
constructor: () ->
# finds the scores for each rubric category
@get_score_list: () =>
# find the number of categories:
num_categories = $('table.rubric tr').length
score_lst = []
# get the score for each one
for i in [0..(num_categories-2)]
score = $("input[name='score-selection-#{i}']:checked").val()
score_lst.push(score)
return score_lst
@get_total_score: () ->
score_lst = @get_score_list()
@check_complete: () ->
# check to see whether or not any categories have not been scored
num_categories = $('table.rubric tr').length
# -2 because we want to skip the header
for i in [0..(num_categories-2)]
score = $("input[name='score-selection-#{i}']:checked").val()
if score == undefined
return false
return true
class @CombinedOpenEnded class @CombinedOpenEnded
constructor: (element) -> constructor: (element) ->
@element=element @element=element
......
...@@ -239,7 +239,7 @@ class PeerGradingProblem ...@@ -239,7 +239,7 @@ class PeerGradingProblem
score_lst = [] score_lst = []
# get the score for each one # get the score for each one
for i in [0..(num_categories-1)] for i in [0..(num_categories-2)]
score = $("input[name='score-selection-#{i}']:checked").val() score = $("input[name='score-selection-#{i}']:checked").val()
score_lst.push(score) score_lst.push(score)
...@@ -315,17 +315,10 @@ class PeerGradingProblem ...@@ -315,17 +315,10 @@ class PeerGradingProblem
# called after a grade is selected on the interface # called after a grade is selected on the interface
graded_callback: (event) => graded_callback: (event) =>
@grade = $("input[name='grade-selection']:checked").val()
if @grade == undefined
return
# check to see whether or not any categories have not been scored # check to see whether or not any categories have not been scored
num_categories = $('table.rubric tr').length if Rubric.check_complete():
for i in [0..(num_categories-1)] # show button if we have scores for all categories
score = $("input[name='score-selection-#{i}']:checked").val() @show_submit_button()
if score == undefined
return
# show button if we have scores for all categories
@show_submit_button()
......
...@@ -232,35 +232,14 @@ class @StaffGrading ...@@ -232,35 +232,14 @@ class @StaffGrading
graded_callback: () => graded_callback: () =>
@grade = $("input[name='grade-selection']:checked").val() # show button if we have scores for all categories
if @grade == undefined if Rubric.check_complete()
return @state = state_graded
# check to see whether or not any categories have not been scored @submit_button.show()
num_categories = $('table.rubric tr').length
for i in [0..(num_categories-1)]
score = $("input[name='score-selection-#{i}']:checked").val()
if score == undefined
return
# show button if we have scores for all categories
@state = state_graded
@submit_button.show()
set_button_text: (text) => set_button_text: (text) =>
@action_button.attr('value', text) @action_button.attr('value', text)
# finds the scores for each rubric category
get_score_list: () =>
# find the number of categories:
num_categories = $('table.rubric tr').length
score_lst = []
# get the score for each one
for i in [0..(num_categories-1)]
score = $("input[name='score-selection-#{i}']:checked").val()
score_lst.push(score)
return score_lst
ajax_callback: (response) => ajax_callback: (response) =>
# always clear out errors and messages on transition. # always clear out errors and messages on transition.
@error_msg = '' @error_msg = ''
...@@ -285,8 +264,8 @@ class @StaffGrading ...@@ -285,8 +264,8 @@ class @StaffGrading
skip_and_get_next: () => skip_and_get_next: () =>
data = data =
score: @grade score: Rubric.get_total_score()
rubric_scores: @get_score_list() rubric_scores: Rubric.get_score_list()
feedback: @feedback_area.val() feedback: @feedback_area.val()
submission_id: @submission_id submission_id: @submission_id
location: @location location: @location
...@@ -299,8 +278,8 @@ class @StaffGrading ...@@ -299,8 +278,8 @@ class @StaffGrading
submit_and_get_next: () -> submit_and_get_next: () ->
data = data =
score: @grade score: Rubric.get_total_score()
rubric_scores: @get_score_list() rubric_scores: Rubric.get_score_list()
feedback: @feedback_area.val() feedback: @feedback_area.val()
submission_id: @submission_id submission_id: @submission_id
location: @location location: @location
......
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