internationalize numbers in quizzes speedgrader
fixes QO-440 Test plan: As a teacher, create a quiz - ensure that at least one question has a decimal point value As a student, take the quiz As a teacher, visit the speedgrader page for the quiz - ensure that changing point values and fudge points works as expected - ensure page elements are updated correctly - ensure that values are saved correctly As the teacher, change your preferred language to one that uses a different format for decimal numbers (e.g., French) Visit the speedgrader page again - ensure... as above Change-Id: I996f0380cb991833a7b3943c6da2610e6329eefe Reviewed-on: https://gerrit.instructure.com/175512 Tested-by: Jenkins Reviewed-by: Omar Khan <okhan@instructure.com> QA-Review: Omar Khan <okhan@instructure.com> Product-Review: Kevin Dougherty III <jdougherty@instructure.com>
This commit is contained in:
parent
122ea64707
commit
abc54925e1
|
@ -66,11 +66,17 @@
|
|||
<% if user_answer %>
|
||||
<div class="user_points" <%= hidden(true) if (assessing || assessment_results) && question_type && question_type.entry_type == "none" %>>
|
||||
<% if editable %>
|
||||
<input class="question_input"
|
||||
name="question_score_<%= hash_get(question, :id) %>" placeholder="--"
|
||||
<input class="question_input_hidden" type="hidden"
|
||||
name="question_score_<%= hash_get(question, :id) %>"
|
||||
value="<%= point_value_for_input(user_answer, question).is_a?(Float) &&
|
||||
!point_value_for_input(user_answer, question).nan? &&
|
||||
n(round_if_whole(point_value_for_input(user_answer, question).round(2))) || ''
|
||||
round_if_whole(point_value_for_input(user_answer, question).round(2)) || ''
|
||||
%>" />
|
||||
<input class="question_input"
|
||||
placeholder="--"
|
||||
value="<%= point_value_for_input(user_answer, question).is_a?(Float) &&
|
||||
!point_value_for_input(user_answer, question).nan? &&
|
||||
render_score(point_value_for_input(user_answer, question)) || ''
|
||||
%>"
|
||||
autocomplete='off'/>
|
||||
<% else %>
|
||||
|
@ -86,17 +92,17 @@
|
|||
<% end %>
|
||||
<% end %>
|
||||
<% question[:points_possible] = 0 if question_type.answer_type == 'none' %>
|
||||
<%= t(:points_possible, "%{points_possible} pts", :points_possible => raw("<span class=\"points question_points\"> / #{round_if_whole(hash_get(question, :points_possible, "0"))}</span>")) %>
|
||||
<%= t(:points_possible, "%{points_possible} pts", :points_possible => raw("<span class=\"points question_points\"> / #{render_score(hash_get(question, :points_possible, "0"))}</span>")) %>
|
||||
<% if hash_get(user_answer, :score_before_regrade) %>
|
||||
<span class=user-regrade-points>
|
||||
<%= t('regraded_score', 'Regraded Score:') %>
|
||||
<%= render_score hash_get(user_answer, :points) %>
|
||||
<%= t(:points_possible, "%{points_possible} pts", :points_possible => raw("<span class=\"points question_points\"> / #{round_if_whole(hash_get(question, :points_possible, "0"))}</span>")) %>
|
||||
<%= t(:points_possible, "%{points_possible} pts", :points_possible => raw("<span class=\"points question_points\"> / #{render_score(hash_get(question, :points_possible, "0"))}</span>")) %>
|
||||
</span>
|
||||
<% end %>
|
||||
</div>
|
||||
<% else %>
|
||||
<%= t(:points_possible, "%{points_possible} pts", :points_possible => raw("<span class=\"points question_points\">#{round_if_whole(hash_get(question, :points_possible, "0"))}</span>")) %>
|
||||
<%= t(:points_possible, "%{points_possible} pts", :points_possible => raw("<span class=\"points question_points\">#{render_score(hash_get(question, :points_possible, "0"))}</span>")) %>
|
||||
<% end %>
|
||||
</span>
|
||||
</div>
|
||||
|
|
|
@ -141,8 +141,8 @@
|
|||
<% if editable %>
|
||||
<div class="update_scores_fudge">
|
||||
<label for="fudge_points_entry"><%= before_label(:fudge_points, "Fudge Points") %></label>
|
||||
<input type="hidden" name="fudge_points" value="<%= @submission.fudge_points || 0 %>">
|
||||
<input id="fudge_points_entry" type="number" step="any" name="fudge_points" value="<%= (!@submission.fudge_points || @submission.fudge_points == 0 ? '' : @submission.fudge_points) %>" placeholder="--" autocomplete='off' />
|
||||
<input id="fudge_points_input" type="hidden" name="fudge_points" value="<%= @submission.fudge_points || 0 %>">
|
||||
<input id="fudge_points_entry" type="text" value="<%= (!@submission.fudge_points || @submission.fudge_points == 0 ? '' : render_score(@submission.fudge_points)) %>" placeholder="--" autocomplete='off' />
|
||||
<%
|
||||
fudge_text = begin
|
||||
if @submission.quiz_points_possible == @quiz.points_possible || !@submission.quiz_points_possible || !@quiz.points_possible
|
||||
|
@ -155,7 +155,7 @@
|
|||
this box.
|
||||
TEXT
|
||||
:user => @submission.user.name,
|
||||
:difference => @quiz.points_possible - @submission.quiz_points_possible)
|
||||
:difference => render_score(@quiz.points_possible - @submission.quiz_points_possible))
|
||||
else
|
||||
t('labels.fudge_points_changed_points_quiz', <<-TEXT,
|
||||
Since %{user} took this quiz, the number of points possible
|
||||
|
@ -164,7 +164,7 @@
|
|||
this box.
|
||||
TEXT
|
||||
:user => @submission.user.name,
|
||||
:difference => @quiz.points_possible - @submission.quiz_points_possible)
|
||||
:difference => render_score(@quiz.points_possible - @submission.quiz_points_possible))
|
||||
end
|
||||
end
|
||||
%>
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
*/
|
||||
|
||||
import $ from 'jquery'
|
||||
import I18n from 'i18n!quizzes'
|
||||
import numberHelper from 'jsx/shared/helpers/numberHelper'
|
||||
import './jquery.instructure_misc_plugins' /* fragmentChange */
|
||||
import './jquery.templateData'
|
||||
import './vendor/jquery.scrollTo'
|
||||
|
@ -106,7 +108,9 @@ import 'compiled/behaviors/quiz_selectmenu'
|
|||
if (!ENV.GRADE_BY_QUESTION) {
|
||||
$question.addClass('modified_but_not_saved');
|
||||
}
|
||||
$question.find(".user_points :text").val(question.points).end()
|
||||
$question
|
||||
.find("#question_input_hidden").val(question.points).end()
|
||||
.find(".user_points :text").val(I18n.n(question.points)).end()
|
||||
.find(".question_neutral_comment .question_comment_text textarea").val(question.comments);
|
||||
}
|
||||
if(parentWindow.hasProperty('lastQuestionTouched') && !ENV.GRADE_BY_QUESTION) {
|
||||
|
@ -156,7 +160,7 @@ import 'compiled/behaviors/quiz_selectmenu'
|
|||
if (!ENV.GRADE_BY_QUESTION) {
|
||||
$question.addClass('modified_but_not_saved');
|
||||
}
|
||||
data.points = parseFloat($question.find(".user_points :text").val(), 10);
|
||||
data.points = numberHelper.parse($question.find(".user_points :text").val());
|
||||
data.comments = $question.find(".question_neutral_comment .question_comment_text textarea").val() || "";
|
||||
scoringSnapshot.update(question_id, data);
|
||||
}
|
||||
|
@ -184,14 +188,14 @@ import 'compiled/behaviors/quiz_selectmenu'
|
|||
var $total = $("#after_fudge_points_total");
|
||||
var total = 0;
|
||||
$(".display_question .user_points:visible").each(function() {
|
||||
var points = parseFloat($(this).find("input.question_input").val(), 10) || 0;
|
||||
var points = numberHelper.parse($(this).find("input.question_input").val()) || 0;
|
||||
points = Math.round(points * 100.0) / 100.0;
|
||||
total = total + points;
|
||||
});
|
||||
var fudge = (parseFloat($("#fudge_points_entry").val(), 10) || 0);
|
||||
var fudge = (numberHelper.parse($("#fudge_points_entry").val()) || 0);
|
||||
fudge = Math.round(fudge * 100.0) / 100.0;
|
||||
total = total + fudge;
|
||||
$total.text(total || "0");
|
||||
$total.text(I18n.n(total) || "0");
|
||||
},
|
||||
|
||||
questions: function(){
|
||||
|
@ -295,8 +299,8 @@ import 'compiled/behaviors/quiz_selectmenu'
|
|||
updateStatusFor: function($scoreInput){
|
||||
try{
|
||||
var questionId = $scoreInput.attr('name').split('_')[2];
|
||||
var scoreValue = $scoreInput.val();
|
||||
$('#quiz_nav_' + questionId).toggleClass('complete', (!isNaN(parseFloat(scoreValue))));
|
||||
var scoreValue = numberHelper.parse($scoreInput.val());
|
||||
$('#quiz_nav_' + questionId).toggleClass('complete', (!isNaN(scoreValue)));
|
||||
} catch(err) {
|
||||
// do nothing; if there's no status to update, continue with other execution
|
||||
}
|
||||
|
@ -413,12 +417,14 @@ import 'compiled/behaviors/quiz_selectmenu'
|
|||
var questionId = $question.attr('id');
|
||||
gradingForm.updateSnapshotFor($question);
|
||||
if($(this).hasClass('question_input')){
|
||||
$question.find('.question_input_hidden').val(numberHelper.parse($(this).val()) || '')
|
||||
quizNavBar.updateStatusFor($(this));
|
||||
}
|
||||
});
|
||||
|
||||
$("#fudge_points_entry").change(function() {
|
||||
var points = parseFloat($(this).val(), 10);
|
||||
var points = numberHelper.parse($(this).val());
|
||||
$("#fudge_points_input").val(points || '');
|
||||
gradingForm.addFudgePoints(points);
|
||||
});
|
||||
|
||||
|
|
|
@ -365,27 +365,36 @@ describe "speed grader" do
|
|||
end
|
||||
end
|
||||
|
||||
it 'should let you enter in a float for a quiz question point value', priority: "1", test_id: 369250 do
|
||||
init_course_with_students
|
||||
user_session(@teacher)
|
||||
quiz = seed_quiz_with_submission
|
||||
get "/courses/#{@course.id}/gradebook/speed_grader?assignment_id=#{quiz.assignment_id}"
|
||||
# In the left panel modify the grade to 0.5
|
||||
in_frame 'speedgrader_iframe', '.quizzes-speedgrader' do
|
||||
points_input = ff('#questions .user_points input')
|
||||
driver.execute_script("$('#questions .user_points input').focus()")
|
||||
replace_content(points_input[0], '0')
|
||||
replace_content(points_input[1], '.5')
|
||||
replace_content(points_input[2], '0')
|
||||
f('.update_scores button[type="submit"]').click
|
||||
wait_for_ajaximations
|
||||
context 'quizzes' do
|
||||
before(:once) do
|
||||
init_course_with_students
|
||||
end
|
||||
|
||||
let_once(:quiz) { seed_quiz_with_submission }
|
||||
|
||||
it 'should let you enter in a float for a quiz question point value', priority: "1", test_id: 369250 do
|
||||
user_session(@teacher)
|
||||
get "/courses/#{@course.id}/gradebook/speed_grader?assignment_id=#{quiz.assignment_id}"
|
||||
# In the left panel modify the grade to 0.5
|
||||
in_frame 'speedgrader_iframe', '.quizzes-speedgrader' do
|
||||
points_input = ff('#questions .user_points input.question_input')
|
||||
driver.execute_script("$('#questions .user_points input.question_input').focus()")
|
||||
replace_content(points_input[0], '2')
|
||||
driver.execute_script("$('#questions .user_points input.question_input')[0].blur()")
|
||||
replace_content(points_input[1], '.5')
|
||||
driver.execute_script("$('#questions .user_points input.question_input')[1].blur()")
|
||||
replace_content(points_input[2], '1')
|
||||
driver.execute_script("$('#questions .user_points input.question_input')[2].blur()")
|
||||
f('.update_scores button[type="submit"]').click
|
||||
wait_for_ajaximations
|
||||
end
|
||||
# Switch to the right panel
|
||||
# Verify that the grade is .5
|
||||
wait_for_ajaximations
|
||||
expect{f('#grading-box-extended')['value']}.to become('3.5')
|
||||
expect(f("#students_selectmenu-button")).to_not have_class("not_graded")
|
||||
expect(f("#students_selectmenu-button")).to have_class("graded")
|
||||
end
|
||||
# Switch to the right panel
|
||||
# Verify that the grade is .5
|
||||
wait_for_ajaximations
|
||||
expect{f('#grading-box-extended')['value']}.to become('0.5')
|
||||
expect(f("#students_selectmenu-button")).to_not have_class("not_graded")
|
||||
expect(f("#students_selectmenu-button")).to have_class("graded")
|
||||
end
|
||||
|
||||
context 'Crocodocable Submissions' do
|
||||
|
|
Loading…
Reference in New Issue