canvas-lms/lib/grading_period_helper.rb

33 lines
1017 B
Ruby
Raw Normal View History

# frozen_string_literal: true
#
# Copyright (C) 2016 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# 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/>.
prevent assignment & group deletion in closed periods Assignments which have been assigned for at least one student in a closed grading period must not be deletable, except by admins. The same applies to assignment groups and quizzes. closes CNVS-30897 test plan: A. create or select: a. an account b. an enrollment term for the account c. a grading period set for that term with: * a closed grading period * an open grading period d. a course with that enrollment term e. two students (1 & 2) for the course f. three assignment groups (1, 2, 3) g. an assignment (A) in group 1 * due for everyone in the closed grading period h. an assignment (B) in group 1 * due for student 1 in the open grading period * due for student 2 after the open grading period i. an assignment (C) in group 2 * due for student 1 in the closed grading period * due for student 2 in the open grading period j. an assignment (D) in group 2 * due for student 1 after the open grading period * for student 2 without a due date k. an assignment (E) in group 3 * due for everyone in the open grading period B. as a Teacher in the course 1. visit the course assignments page a. verify assignment A cannot be deleted b. verify assignment B can be deleted c. verify assignment C cannot be deleted d. verify assignment D can be deleted e. verify assignment E can be deleted f. verify assignment group 1 cannot be deleted g. verify assignment group 2 cannot be deleted h. verify assignment group 3 can be deleted 2. visit the edit assignment page for each assignment a. verify assignment A cannot be deleted b. verify assignment B can be deleted c. verify assignment C cannot be deleted d. verify assignment D can be deleted e. verify assignment E can be deleted C. as an Admin 1. visit the course assignments page a. verify assignment A can be deleted b. verify assignment B can be deleted c. verify assignment C can be deleted d. verify assignment D can be deleted e. verify assignment E can be deleted f. verify assignment group 1 can be deleted g. verify assignment group 2 can be deleted h. verify assignment group 3 can be deleted 2. visit the edit assignment page for each assignment a. verify assignment A can be deleted b. verify assignment B can be deleted c. verify assignment C can be deleted d. verify assignment D can be deleted e. verify assignment E can be deleted D. create or select: a. an account b. an enrollment term for the account c. a grading period set for that term with: * a closed grading period * an open grading period d. a course with that enrollment term e. two students (1 & 2) for the course f. three assignment groups (1, 2, 3) g. a quiz (A) in group 1 * due for everyone in the closed grading period h. a quiz (B) in group 1 * due for student 1 in the open grading period * due for student 2 after the open grading period i. a quiz (C) in group 2 * due for student 1 in the closed grading period * due for student 2 in the open grading period j. a quiz (D) in group 2 * due for student 1 after the open grading period * for student 2 without a due date k. a quiz (E) in group 3 * due for everyone in the open grading period B. as a Teacher in the course 1. visit the course quizzes page a. verify quiz A cannot be deleted b. verify quiz B can be deleted c. verify quiz C cannot be deleted d. verify quiz D can be deleted e. verify quiz E can be deleted f. verify assignment group 1 cannot be deleted g. verify assignment group 2 cannot be deleted h. verify assignment group 3 can be deleted 2. visit the show quiz page for each quiz a. verify quiz A cannot be deleted b. verify quiz B can be deleted c. verify quiz C cannot be deleted d. verify quiz D can be deleted e. verify quiz E can be deleted 3. visit the edit quiz page for each quiz a. verify quiz A cannot be deleted b. verify quiz B can be deleted c. verify quiz C cannot be deleted d. verify quiz D can be deleted e. verify quiz E can be deleted C. as an Admin 1. visit the course quizzes page a. verify quiz A can be deleted b. verify quiz B can be deleted c. verify quiz C can be deleted d. verify quiz D can be deleted e. verify quiz E can be deleted f. verify assignment group 1 can be deleted g. verify assignment group 2 can be deleted h. verify assignment group 3 can be deleted 2. visit the show quiz page for each quiz a. verify quiz A can be deleted b. verify quiz B can be deleted c. verify quiz C can be deleted d. verify quiz D can be deleted e. verify quiz E can be deleted 3. visit the edit quiz page for each quiz a. verify quiz A can be deleted b. verify quiz B can be deleted c. verify quiz C can be deleted d. verify quiz D can be deleted e. verify quiz E can be deleted Change-Id: I2176904e9de96b61f31c9972c4c35b2b72367c54 Reviewed-on: https://gerrit.instructure.com/88608 Tested-by: Jenkins Reviewed-by: Spencer Olson <solson@instructure.com> Reviewed-by: Derek Bender <djbender@instructure.com> QA-Review: KC Naegle <knaegle@instructure.com> Product-Review: Christi Wruck
2016-08-18 05:11:53 +08:00
module GradingPeriodHelper
def self.date_in_closed_grading_period?(date, periods)
prevent assignment group movement in closed periods Assignments which have been assigned for at least one student in a closed grading period must not be moveable between assignment groups, except by admins. closes CNVS-30915 test plan: A. create or select: a. an account b. an enrollment term for the account c. a grading period set for that term with: * a closed grading period * an open grading period d. a course with that enrollment term e. two students (1 & 2) for the course f. three assignment groups (1, 2, 3) g. an assignment (A) in group 1 * due for everyone in the closed grading period h. an assignment (B) in group 1 * due for student 1 in the open grading period * due for student 2 after the open grading period i. an assignment (C) in group 2 * due for student 1 in the closed grading period * due for student 2 in the open grading period j. an assignment (D) in group 2 * due for student 1 after the open grading period * for student 2 without a due date k. an assignment (E) in group 3 * due for everyone in the open grading period B. as a Teacher in the course, visit the course assignments page a. verify assignment A cannot be moved b. verify assignment B can be moved c. verify assignment C cannot be moved d. verify assignment D can be moved e. verify assignment E can be moved C. as an Admin, visit the course assignments page a. verify assignment A can be moved b. verify assignment B can be moved c. verify assignment C can be moved d. verify assignment D can be moved e. verify assignment E can be moved Change-Id: I93a7f0f9391b493041172ed159136990c51d6a6a Reviewed-on: https://gerrit.instructure.com/91744 Tested-by: Jenkins Reviewed-by: Derek Bender <djbender@instructure.com> Reviewed-by: Neil Gupta <ngupta@instructure.com> QA-Review: Alex Morris <amorris@instructure.com> Product-Review: Christi Wruck
2016-09-17 01:54:19 +08:00
return false if periods.empty?
prevent assignment & group deletion in closed periods Assignments which have been assigned for at least one student in a closed grading period must not be deletable, except by admins. The same applies to assignment groups and quizzes. closes CNVS-30897 test plan: A. create or select: a. an account b. an enrollment term for the account c. a grading period set for that term with: * a closed grading period * an open grading period d. a course with that enrollment term e. two students (1 & 2) for the course f. three assignment groups (1, 2, 3) g. an assignment (A) in group 1 * due for everyone in the closed grading period h. an assignment (B) in group 1 * due for student 1 in the open grading period * due for student 2 after the open grading period i. an assignment (C) in group 2 * due for student 1 in the closed grading period * due for student 2 in the open grading period j. an assignment (D) in group 2 * due for student 1 after the open grading period * for student 2 without a due date k. an assignment (E) in group 3 * due for everyone in the open grading period B. as a Teacher in the course 1. visit the course assignments page a. verify assignment A cannot be deleted b. verify assignment B can be deleted c. verify assignment C cannot be deleted d. verify assignment D can be deleted e. verify assignment E can be deleted f. verify assignment group 1 cannot be deleted g. verify assignment group 2 cannot be deleted h. verify assignment group 3 can be deleted 2. visit the edit assignment page for each assignment a. verify assignment A cannot be deleted b. verify assignment B can be deleted c. verify assignment C cannot be deleted d. verify assignment D can be deleted e. verify assignment E can be deleted C. as an Admin 1. visit the course assignments page a. verify assignment A can be deleted b. verify assignment B can be deleted c. verify assignment C can be deleted d. verify assignment D can be deleted e. verify assignment E can be deleted f. verify assignment group 1 can be deleted g. verify assignment group 2 can be deleted h. verify assignment group 3 can be deleted 2. visit the edit assignment page for each assignment a. verify assignment A can be deleted b. verify assignment B can be deleted c. verify assignment C can be deleted d. verify assignment D can be deleted e. verify assignment E can be deleted D. create or select: a. an account b. an enrollment term for the account c. a grading period set for that term with: * a closed grading period * an open grading period d. a course with that enrollment term e. two students (1 & 2) for the course f. three assignment groups (1, 2, 3) g. a quiz (A) in group 1 * due for everyone in the closed grading period h. a quiz (B) in group 1 * due for student 1 in the open grading period * due for student 2 after the open grading period i. a quiz (C) in group 2 * due for student 1 in the closed grading period * due for student 2 in the open grading period j. a quiz (D) in group 2 * due for student 1 after the open grading period * for student 2 without a due date k. a quiz (E) in group 3 * due for everyone in the open grading period B. as a Teacher in the course 1. visit the course quizzes page a. verify quiz A cannot be deleted b. verify quiz B can be deleted c. verify quiz C cannot be deleted d. verify quiz D can be deleted e. verify quiz E can be deleted f. verify assignment group 1 cannot be deleted g. verify assignment group 2 cannot be deleted h. verify assignment group 3 can be deleted 2. visit the show quiz page for each quiz a. verify quiz A cannot be deleted b. verify quiz B can be deleted c. verify quiz C cannot be deleted d. verify quiz D can be deleted e. verify quiz E can be deleted 3. visit the edit quiz page for each quiz a. verify quiz A cannot be deleted b. verify quiz B can be deleted c. verify quiz C cannot be deleted d. verify quiz D can be deleted e. verify quiz E can be deleted C. as an Admin 1. visit the course quizzes page a. verify quiz A can be deleted b. verify quiz B can be deleted c. verify quiz C can be deleted d. verify quiz D can be deleted e. verify quiz E can be deleted f. verify assignment group 1 can be deleted g. verify assignment group 2 can be deleted h. verify assignment group 3 can be deleted 2. visit the show quiz page for each quiz a. verify quiz A can be deleted b. verify quiz B can be deleted c. verify quiz C can be deleted d. verify quiz D can be deleted e. verify quiz E can be deleted 3. visit the edit quiz page for each quiz a. verify quiz A can be deleted b. verify quiz B can be deleted c. verify quiz C can be deleted d. verify quiz D can be deleted e. verify quiz E can be deleted Change-Id: I2176904e9de96b61f31c9972c4c35b2b72367c54 Reviewed-on: https://gerrit.instructure.com/88608 Tested-by: Jenkins Reviewed-by: Spencer Olson <solson@instructure.com> Reviewed-by: Derek Bender <djbender@instructure.com> QA-Review: KC Naegle <knaegle@instructure.com> Product-Review: Christi Wruck
2016-08-18 05:11:53 +08:00
if date.nil?
prevent assignment group movement in closed periods Assignments which have been assigned for at least one student in a closed grading period must not be moveable between assignment groups, except by admins. closes CNVS-30915 test plan: A. create or select: a. an account b. an enrollment term for the account c. a grading period set for that term with: * a closed grading period * an open grading period d. a course with that enrollment term e. two students (1 & 2) for the course f. three assignment groups (1, 2, 3) g. an assignment (A) in group 1 * due for everyone in the closed grading period h. an assignment (B) in group 1 * due for student 1 in the open grading period * due for student 2 after the open grading period i. an assignment (C) in group 2 * due for student 1 in the closed grading period * due for student 2 in the open grading period j. an assignment (D) in group 2 * due for student 1 after the open grading period * for student 2 without a due date k. an assignment (E) in group 3 * due for everyone in the open grading period B. as a Teacher in the course, visit the course assignments page a. verify assignment A cannot be moved b. verify assignment B can be moved c. verify assignment C cannot be moved d. verify assignment D can be moved e. verify assignment E can be moved C. as an Admin, visit the course assignments page a. verify assignment A can be moved b. verify assignment B can be moved c. verify assignment C can be moved d. verify assignment D can be moved e. verify assignment E can be moved Change-Id: I93a7f0f9391b493041172ed159136990c51d6a6a Reviewed-on: https://gerrit.instructure.com/91744 Tested-by: Jenkins Reviewed-by: Derek Bender <djbender@instructure.com> Reviewed-by: Neil Gupta <ngupta@instructure.com> QA-Review: Alex Morris <amorris@instructure.com> Product-Review: Christi Wruck
2016-09-17 01:54:19 +08:00
periods.sort_by(&:end_date).last.closed?
prevent assignment & group deletion in closed periods Assignments which have been assigned for at least one student in a closed grading period must not be deletable, except by admins. The same applies to assignment groups and quizzes. closes CNVS-30897 test plan: A. create or select: a. an account b. an enrollment term for the account c. a grading period set for that term with: * a closed grading period * an open grading period d. a course with that enrollment term e. two students (1 & 2) for the course f. three assignment groups (1, 2, 3) g. an assignment (A) in group 1 * due for everyone in the closed grading period h. an assignment (B) in group 1 * due for student 1 in the open grading period * due for student 2 after the open grading period i. an assignment (C) in group 2 * due for student 1 in the closed grading period * due for student 2 in the open grading period j. an assignment (D) in group 2 * due for student 1 after the open grading period * for student 2 without a due date k. an assignment (E) in group 3 * due for everyone in the open grading period B. as a Teacher in the course 1. visit the course assignments page a. verify assignment A cannot be deleted b. verify assignment B can be deleted c. verify assignment C cannot be deleted d. verify assignment D can be deleted e. verify assignment E can be deleted f. verify assignment group 1 cannot be deleted g. verify assignment group 2 cannot be deleted h. verify assignment group 3 can be deleted 2. visit the edit assignment page for each assignment a. verify assignment A cannot be deleted b. verify assignment B can be deleted c. verify assignment C cannot be deleted d. verify assignment D can be deleted e. verify assignment E can be deleted C. as an Admin 1. visit the course assignments page a. verify assignment A can be deleted b. verify assignment B can be deleted c. verify assignment C can be deleted d. verify assignment D can be deleted e. verify assignment E can be deleted f. verify assignment group 1 can be deleted g. verify assignment group 2 can be deleted h. verify assignment group 3 can be deleted 2. visit the edit assignment page for each assignment a. verify assignment A can be deleted b. verify assignment B can be deleted c. verify assignment C can be deleted d. verify assignment D can be deleted e. verify assignment E can be deleted D. create or select: a. an account b. an enrollment term for the account c. a grading period set for that term with: * a closed grading period * an open grading period d. a course with that enrollment term e. two students (1 & 2) for the course f. three assignment groups (1, 2, 3) g. a quiz (A) in group 1 * due for everyone in the closed grading period h. a quiz (B) in group 1 * due for student 1 in the open grading period * due for student 2 after the open grading period i. a quiz (C) in group 2 * due for student 1 in the closed grading period * due for student 2 in the open grading period j. a quiz (D) in group 2 * due for student 1 after the open grading period * for student 2 without a due date k. a quiz (E) in group 3 * due for everyone in the open grading period B. as a Teacher in the course 1. visit the course quizzes page a. verify quiz A cannot be deleted b. verify quiz B can be deleted c. verify quiz C cannot be deleted d. verify quiz D can be deleted e. verify quiz E can be deleted f. verify assignment group 1 cannot be deleted g. verify assignment group 2 cannot be deleted h. verify assignment group 3 can be deleted 2. visit the show quiz page for each quiz a. verify quiz A cannot be deleted b. verify quiz B can be deleted c. verify quiz C cannot be deleted d. verify quiz D can be deleted e. verify quiz E can be deleted 3. visit the edit quiz page for each quiz a. verify quiz A cannot be deleted b. verify quiz B can be deleted c. verify quiz C cannot be deleted d. verify quiz D can be deleted e. verify quiz E can be deleted C. as an Admin 1. visit the course quizzes page a. verify quiz A can be deleted b. verify quiz B can be deleted c. verify quiz C can be deleted d. verify quiz D can be deleted e. verify quiz E can be deleted f. verify assignment group 1 can be deleted g. verify assignment group 2 can be deleted h. verify assignment group 3 can be deleted 2. visit the show quiz page for each quiz a. verify quiz A can be deleted b. verify quiz B can be deleted c. verify quiz C can be deleted d. verify quiz D can be deleted e. verify quiz E can be deleted 3. visit the edit quiz page for each quiz a. verify quiz A can be deleted b. verify quiz B can be deleted c. verify quiz C can be deleted d. verify quiz D can be deleted e. verify quiz E can be deleted Change-Id: I2176904e9de96b61f31c9972c4c35b2b72367c54 Reviewed-on: https://gerrit.instructure.com/88608 Tested-by: Jenkins Reviewed-by: Spencer Olson <solson@instructure.com> Reviewed-by: Derek Bender <djbender@instructure.com> QA-Review: KC Naegle <knaegle@instructure.com> Product-Review: Christi Wruck
2016-08-18 05:11:53 +08:00
else
periods.any? do |period|
period.in_date_range?(date) && period.closed?
end
end
end
end