Commit Graph

2 Commits

Author SHA1 Message Date
Adrian Packel c589d975c7 Don't murder database with post policies
closes GRADE-2274

Test plan:
- specs pass, migration runs

Change-Id: I2484ead5edef82cc0046ecdf09ab6e90c70b467f
Reviewed-on: https://gerrit.instructure.com/199358
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins
2019-06-27 20:24:37 +00:00
Adrian Packel 93fc19368b Set post policies for existing assignments
Set post policies on existing assignments and courses as appropriate,
and update the posted_at values of submissions belonging to the
asignments to match.

closes GRADE-1946

Test plan:

NOTE: This patchset will enable automatic creation of PostPolicy objects
for new assignments and courses. For your test data to be in the proper
form (i.e., with no PostPolicy objects attached), you should either
create it with a previous patchset or--if you use this patchset--delete
the resultant PostPolicy objects via the console.

(In the test plan below, a "manual post policy" refers to a PostPolicy
object for the specified course or assignment with post_manually set to
true, while an "automatic post policy" refers to one with post_manually
set to false.)

- Set up a course (C1) that:
  - Does *not* have a default_post_policy object (i.e., no PostPolicy
    object exists with course_id = C1 and assignment_id = nil)
  - Has the following assignments:
    - A non-moderated, non-anonymous assignment (A1)
    - A non-moderated, non-anonymous MUTED assignment (A2)
    - A moderated assignment (A3)
  - Assign grades for some (not all) submissions on each assignment
  - For A3, have the moderator do some moderating and then post
    all grades
- Set up a course (C2) that *does* have a default_post_policy
- Run the migration, and then check the following
  - For C1:
    - The course itself should have an automatic post policy created
    - For A1:
      - An automatic post policy should be created
      - The posted_at date of *graded* submissions should be set to
        their graded_at date
      - The posted_at date of ungraded submissions should be nil
    - For A2:
      - A manual post policy should be created
      - The posted_at date on all submissions should be nil
    - For A3:
      - A manual post policy should be created
      - The posted_at date on all submissions should be set to their
        graded_at time (which should be when grades were published)
  - C2, since it has a post policy already, should be ignored entirely,
    and all assignments within it should be ignored
- On further runs, C1 should be ignored since it has a post policy now

Testing new behavior:
- With the post policies flag NOT enabled, check that:
  - Muting an assignment assigns it a manual post policy
  - Unmuting an assignment assigns it an automatic post policy
    - ...UNLESS it is anonymous
  - Creating a new assignment should create a post policy for it
    - If anonymous/moderated, the policy should be manual
    - Otherwise it should default to the course's post policy
      (or to automatic if the course inexplicably has none)
  - Creating a new course should always create an automatic
    post policy for the course
- Check that the same behavior holds with the flag enabled

Change-Id: Ib2fbfc2342a1282c1a6942cc68b2aeccbbc73b70
Reviewed-on: https://gerrit.instructure.com/196237
Tested-by: Jenkins
Reviewed-by: Keith Garner <kgarner@instructure.com>
Reviewed-by: Gary Mei <gmei@instructure.com>
QA-Review: Gary Mei <gmei@instructure.com>
Product-Review: Keith Garner <kgarner@instructure.com>
2019-06-10 18:25:32 +00:00