Skip to content

Commit

Permalink
Merge "Merge dev branch for quiz due date validation"
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit Code Review committed Feb 16, 2017
2 parents 99c0c03 + 2c2cfd4 commit 60e9740
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/coffeescripts/views/assignments/DueDateOverride.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ define [
multipleGradingPeriodsEnabled: @multipleGradingPeriodsEnabled
gradingPeriods: @gradingPeriods
userIsAdmin: _.contains(ENV.current_user_roles, "admin"),
postToSIS: @options.postToSIS
postToSIS: @options.postToSIS || data.postToSIS == '1'
})
rowErrors = dateValidator.validateDatetimes()
errors = _.extend(errors, rowErrors)
Expand Down
5 changes: 3 additions & 2 deletions app/controllers/quizzes/quizzes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,8 @@ def new

hash = {
:MAX_NAME_LENGTH_REQUIRED_FOR_ACCOUNT => max_name_length_required_for_account,
:MAX_NAME_LENGTH => max_name_length
:MAX_NAME_LENGTH => max_name_length,
:DUE_DATE_REQUIRED_FOR_ACCOUNT => AssignmentUtil.due_date_required_for_account?(@quiz),
}

js_env(hash)
Expand All @@ -277,7 +278,6 @@ def edit
return render_unauthorized_action if editing_restricted?(@quiz)
add_crumb(@quiz.title, named_context_url(@context, :context_quiz_url, @quiz))
@assignment = @quiz.assignment

@quiz.title = params[:title] if params[:title]
@quiz.due_at = params[:due_at] if params[:due_at]
@quiz.assignment_group_id = params[:assignment_group_id] if params[:assignment_group_id]
Expand All @@ -302,6 +302,7 @@ def edit
:ASSIGNMENT_OVERRIDES => assignment_overrides_json(@quiz.overrides_for(@current_user,
ensure_set_not_empty: true),
@current_user),
:DUE_DATE_REQUIRED_FOR_ACCOUNT => AssignmentUtil.due_date_required_for_account?(@quiz),
:QUIZ => quiz_json(@quiz, @context, @current_user, session),
:SECTION_LIST => sections.map { |section|
{
Expand Down
3 changes: 2 additions & 1 deletion public/javascripts/quizzes.js
Original file line number Diff line number Diff line change
Expand Up @@ -1815,7 +1815,8 @@ define([
var overrides = overrideView.getOverrides();
data['quiz[only_visible_to_overrides]'] = overrideView.containsSectionsWithoutOverrides();
var validationData = {
assignment_overrides: overrideView.getAllDates()
assignment_overrides: overrideView.getAllDates(),
postToSIS: data['quiz[post_to_sis]']
};
var errs = overrideView.validateBeforeSave(validationData,{});
if (_.keys(errs).length > 0) {
Expand Down
28 changes: 28 additions & 0 deletions spec/controllers/quizzes/quizzes_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,20 @@ def logged_out_survey_with_submission(user, questions, &block)
assert_unauthorized
end

it "js_env DUE_DATE_REQUIRED_FOR_ACCOUNT is true when AssignmentUtil.due_date_required_for_account? == true" do
user_session(@teacher)
AssignmentUtil.stubs(:due_date_required_for_account?).returns(true)
get 'new', :course_id => @course.id
expect(assigns[:js_env][:DUE_DATE_REQUIRED_FOR_ACCOUNT]).to eq(true)
end

it "js_env DUE_DATE_REQUIRED_FOR_ACCOUNT is false when AssignmentUtil.due_date_required_for_account? == false" do
user_session(@teacher)
AssignmentUtil.stubs(:due_date_required_for_account?).returns(false)
get 'new', :course_id => @course.id
expect(assigns[:js_env][:DUE_DATE_REQUIRED_FOR_ACCOUNT]).to eq(false)
end

it "should assign variables" do
user_session(@teacher)
get 'new', :course_id => @course.id
Expand Down Expand Up @@ -196,6 +210,20 @@ def logged_out_survey_with_submission(user, questions, &block)
expect(response).to render_template("new")
end

it "js_env DUE_DATE_REQUIRED_FOR_ACCOUNT is true when AssignmentUtil.due_date_required_for_account? == true" do
user_session(@teacher)
AssignmentUtil.stubs(:due_date_required_for_account?).returns(true)
get 'edit', :course_id => @course.id, :id => @quiz.id
expect(assigns[:js_env][:DUE_DATE_REQUIRED_FOR_ACCOUNT]).to eq(true)
end

it "js_env DUE_DATE_REQUIRED_FOR_ACCOUNT is false when AssignmentUtil.due_date_required_for_account? == false" do
user_session(@teacher)
AssignmentUtil.stubs(:due_date_required_for_account?).returns(false)
get 'edit', :course_id => @course.id, :id => @quiz.id
expect(assigns[:js_env][:DUE_DATE_REQUIRED_FOR_ACCOUNT]).to eq(false)
end

it "js_env MAX_NAME_LENGTH_REQUIRED_FOR_ACCOUNT is true when AssignmentUtil.name_length_required_for_account? == true" do
user_session(@teacher)
AssignmentUtil.stubs(:name_length_required_for_account?).returns(true)
Expand Down

0 comments on commit 60e9740

Please sign in to comment.