Correctly read extra time in quiz moderate popup

Correctly displays previously configured additional time grants via
the quiz moderation dialog.

Fixes CNVS-18358

test plan:
- Create moderated quiz
- Grant 13 extra minutes on the quiz
- Ensure that when the moderate quiz dialog is subsequently invoked,
  the setting persists.

Change-Id: I056716e814701b2b11ae7c2761588be7c6227f8b
Reviewed-on: https://gerrit.instructure.com/54647
Tested-by: Jenkins
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Simon Williams <simon@instructure.com>
Product-Review: Cameron Sutter <csutter@instructure.com>
This commit is contained in:
Coraline Ehmke 2015-05-19 19:41:11 -05:00 committed by Ryan Taylor
parent de9773e9ae
commit dcedcb1793
3 changed files with 44 additions and 22 deletions

View File

@ -161,7 +161,7 @@
<div class="field extra_time">
<label for="extra_time">
<%= t('extra_time_on_every_attempt', 'Extra time on every attempt:') %>
<em class="note"><%= t(:global_extra_attempt_time, "everyone already gets %{count} minute", :count => @quiz.time_limit) %></em>
<em class="note"><%= t(:global_extra_attempt_time, "everyone already gets %{count} minutes", :count => @quiz.time_limit) %></em>
</label>
<span class="input">
<input id="extension_extra_time" type="text" name="extra_time" title="<%= t('titles.extra_quiz_minutes', "additional minutes on each attempt") %>"/>

View File

@ -15,6 +15,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define([
'i18n!quizzes.moderate',
'jquery' /* $ */,
@ -229,7 +230,7 @@ define([
var data = {
manually_unlocked: $student.hasClass('manually_unlocked') ? '1' : '0',
extra_attempts: parseInt($student.find(".extra_attempts").text(), 10) || "",
extra_time: parseInt($student.find(".extra_time").text(), 10) || ""
extra_time: parseInt($student.find(".extra_time_allowed").text().replace(/[^\d]/g, ''), 10) || ""
};
var name = $student.find(".student_name").text();
$("#moderate_student_form").fillFormData(data);

View File

@ -244,29 +244,50 @@ describe "quizzes" do
expect(pick_count_field).to have_attribute(:value, "999")
end
it "should moderate quiz" do
student = user_with_pseudonym(:active_user => true, :username => 'student@example.com', :password => 'qwerty')
@course.enroll_user(student, "StudentEnrollment", :enrollment_state => 'active')
@context = @course
q = quiz_model
q.time_limit = 20
q.generate_quiz_data
q.save!
describe "moderation" do
get "/courses/#{@course.id}/quizzes/#{q.id}/moderate"
f('.moderate_student_link').click
before do
student = user_with_pseudonym(:active_user => true, :username => 'student@example.com', :password => 'qwerty')
@course.enroll_user(student, "StudentEnrollment", :enrollment_state => 'active')
@context = @course
@quiz = quiz_model
@quiz.time_limit = 20
@quiz.generate_quiz_data
@quiz.save!
end
# validates data
f('#extension_extra_attempts').send_keys('asdf')
submit_form('#moderate_student_form')
expect(f('.attempts_left').text).to eq '1'
it "should moderate quiz" do
get "/courses/#{@course.id}/quizzes/#{@quiz.id}/moderate"
f('.moderate_student_link').click
# validates data
f('#extension_extra_attempts').send_keys('asdf')
submit_form('#moderate_student_form')
expect(f('.attempts_left').text).to eq '1'
# valid values
f('#extension_extra_attempts').clear()
f('#extension_extra_attempts').send_keys('2')
submit_form('#moderate_student_form')
wait_for_ajax_requests
expect(f('.attempts_left').text).to eq '3'
end
it "should preserve extra time values" do
get "/courses/#{@course.id}/quizzes/#{@quiz.id}/moderate"
f('.moderate_student_link').click
# initial data entry
f('#extension_extra_time').send_keys('13')
submit_form('#moderate_student_form')
wait_for_ajax_requests
# preserve values between moderation invocations
expect(f('.extra_time_allowed').text).to eq 'gets 13 extra minutes on each attempt'
f('.moderate_student_link').click
expect(f('#extension_extra_time').attribute('value')).to eq '13'
end
# valid values
f('#extension_extra_attempts').clear()
f('#extension_extra_attempts').send_keys('2')
submit_form('#moderate_student_form')
wait_for_ajax_requests
expect(f('.attempts_left').text).to eq '3'
end
it "should indicate when it was last saved" do