Commit Graph

28 Commits

Author SHA1 Message Date
Jackson Howe 2b78c852ce Separate page/discussion visibility scopes (flagged)
Each differentiable object has a visible_to_students_in_course_with_da
scope which is used by the DifferentiableAssignment module to determine
what learning objects a student should see. Each differentiable also has
a visible_ids_by_user class method, which is used in modules for the
same purpose. These methods used to be shared by DiscussionTopic and
WikiPage in the Submittable module because they were very similar. Now
that they're becoming more complex with 1st-class support for
differentiation, it makes sense for these scopes to live in their own
models.

The changes to Submittable and DiscussionTopic are primarily moving
the scopes from Submittable to DiscussionTopic. The changes in
WikiPage provide support for WikiPage assignment overrides - if a page
has an assignment (because it is part of mastery paths), then read the
assignment's overrides. Otherwise, read the page's overrides.

Note: this commit does not yet guard directly-differentiated pages
and ungraded discussions.

This reverts commit df5b751592.

refs LF-1050
flag = differentiated_modules

Test plan:
 - Regression test creating pages with and without "allow in mastery
   paths" - ensure that all students who should have access do
 - Regression test creating graded and ungraded discussions, including
   ungraded section-differentiated discussions

Change-Id: I775d6fa7036189aca16b484ff55795cb001f6f81
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/346493
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jason Gillett <jason.gillett@instructure.com>
QA-Review: Jason Gillett <jason.gillett@instructure.com>
Product-Review: Jackson Howe <jackson.howe@instructure.com>
2024-05-01 15:59:38 +00:00
Sarah Gerard df5b751592 Revert "Separate page/discussion visibility scopes"
This reverts commit 32ee8e6c53.

Reason for revert: performance issues with wiki_page_student_visibilities

Change-Id: I0d0726ee973985272f8589365a15308db063b697
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/345735
Reviewed-by: Ryan Norton <rnorton@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Sarah Gerard <sarah.gerard@instructure.com>
Product-Review: Sarah Gerard <sarah.gerard@instructure.com>
2024-04-26 18:36:50 +00:00
Jackson Howe 32ee8e6c53 Separate page/discussion visibility scopes
Each differentiable object has a visible_to_students_in_course_with_da
scope which is used by the DifferentiableAssignment module to determine
what learning objects a student should see. Each differentiable also has
a visible_ids_by_user class method, which is used in modules for the
same purpose. These methods used to be shared by DiscussionTopic and
WikiPage in the Submittable module because they were very similar. Now
that they're becoming more complex with 1st-class support for
differentiation, it makes sense for these scopes to live in their own
models.

The changes to Submittable and DiscussionTopic are primarily moving
the scopes from Submittable to DiscussionTopic. The changes in
WikiPage provide support for WikiPage assignment overrides - if a page
has an assignment (because it is part of mastery paths), then read the
assignment's overrides. Otherwise, read the page's overrides.

This is not flagged because there are no functional changes other than
reading a page's overrides, and no WikiPage overrides exist without the
flag.

Note: this commit does not yet guard directly-differentiated pages
and ungraded discussions.

refs LF-1050
flag = none

Test plan:
 - Regression test creating pages with and without "allow in mastery
   paths" - ensure that all students who should have access do
 - Regression test creating graded and ungraded discussions, including
   ungraded section-differentiated discussions

Change-Id: I107171d0d48d4bba1f44b7953869dd3f25450664
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/345529
Reviewed-by: Sarah Gerard <sarah.gerard@instructure.com>
QA-Review: Sarah Gerard <sarah.gerard@instructure.com>
Product-Review: Jackson Howe <jackson.howe@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
2024-04-19 14:36:17 +00:00
Spencer Olson 1c51d4ebe7 prevent checkpoints from creating their own discussion topics
closes VICE-4024
flag=discussion_topics

Test Plan:
- specs pass

Change-Id: Id318d6e4dcbc977a1b4a1859bb397cd7088b6e9a
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/335836
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Keith Garner <kgarner@instructure.com>
Reviewed-by: Omar Soto-Fortuño <omar.soto@instructure.com>
Product-Review: Omar Soto-Fortuño <omar.soto@instructure.com>
QA-Review: Chawn Neal <chawn.neal@instructure.com>
2023-12-21 19:10:32 +00:00
Spencer Olson e67f851130 add SubAssignment model
closes VICE-3943
flag=discussion_checkpoints

Test Plan:
- specs pass
- Create an assignment, old quiz, new quiz and graded discussion
 assigned to multiple students and ensure each can be submitted
 to by the assigned students.
- Sanity check that the submissions can be viewed and graded
 within Speedgrader

Change-Id: I058a4093ee8bd00d8d7186fb6ada2dd5ba37d016
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/334399
Reviewed-by: Omar Soto-Fortuño <omar.soto@instructure.com>
Product-Review: Omar Soto-Fortuño <omar.soto@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Spencer Olson <solson@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
2023-12-19 16:13:47 +00:00
Spencer Olson 96f0bbee15 fix n+1s in DiscussionTopicsController#index
refs VICE-3893
flag=none

Fixes N+1s that happen in the following methods:
- DiscussionTopic#unread_count
- DiscussionTopic#subscribed?
- DiscussionTopic#low_level_locked_for?
- Submittable#for_assignment?

Test Plan:
1. Verify you can load the discussion topics index

Change-Id: Ib7f6d855b9f308f0150004e89bb5fc5bb02db68c
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/331641
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Drake Harper <drake.harper@instructure.com>
Product-Review: Drake Harper <drake.harper@instructure.com>
Reviewed-by: Omar Soto-Fortuño <omar.soto@instructure.com>
2023-10-31 20:50:55 +00:00
Jacob Burroughs 7dcc507d0a Rubocop for ruby 3.1
[skip-stages=Flakey]

Change-Id: I6abefdfa9fed6dd4525c8786e93efa548b3710f2
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/319603
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Isaac Moore <isaac.moore@instructure.com>
QA-Review: Jacob Burroughs <jburroughs@instructure.com>
Product-Review: Jacob Burroughs <jburroughs@instructure.com>
Build-Review: Jacob Burroughs <jburroughs@instructure.com>
Migration-Review: Jacob Burroughs <jburroughs@instructure.com>
2023-06-06 16:44:26 +00:00
Jackson Howe f3aa9a9f78 Consider only relevant discussions when evaluating CMPs
Context module progressions should only consider items that a user
is able to view when evaluating a module's completion status. Ungraded
discussions can be posted to only certain sections within a course, so
only discussions in section(s) where the student is enrolled should be
considered. This is normally the case, however, when evaluating all of
the progressions within a course, we cache the item visibilities to
prevent recalculating the same thing repeatedly (see
ContextModule#evaluate_all_progressions). This codepath is not
frequently followed, but is, for example, when a module itelf is
edited. In the caching process, we get all of the sections (and
associated discussions) visible to a list of users. This was an issue
becuase the list of users might contain users with different section
visibilities. This patchset considers section visibilities for each
user in the list individually, ensuring that module progressions
evaluate appropriately for all users.

closes LS-3245
flag = none

Test plan:
 - Create a course with 2 sections
 - Create a module in the course
 - Create 2 discussions in the module - both ungraded; assign one to
   the first section, and one to the second section
 - Create a page in the module
 - Edit module requirements - set "contribute to the page" on both
   discussions and "view" on the page
 - Enroll a student in one of the sections and publish the course
 - As the student, view the page and reply to the visible discussion
 - Expect the module to be marked as completed
 - As the teacher, create a new (empty) module, move it to the top of
   the page, then delete it
 - As the student, view the modules page; expect the module to still
   be marked as completed

Change-Id: I4d9a57dae0cf521a46953f4c5217df7358b08835
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/296104
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Luis Oliveira <luis.oliveira@instructure.com>
Reviewed-by: Luis Oliveira <luis.oliveira@instructure.com>
Product-Review: Jackson Howe <jackson.howe@instructure.com>
2022-07-14 13:51:37 +00:00
Eric Saupe 0605e741b6 Republish course paces if items become graded
There are a number of models in a course that can either be graded or
non-graded. If a teacher switches these between graded and non-graded
it can affect course paces that are for graded assignments. This commit
republishes course paces that are affected by these types of models
switching modes.

fixes LS-3060
flag=course_paces

test plan:
- Have a course with a published course pace
- Add an ungraded discussion to a module
- Verify the course pace has not changed
- Edit the discussion and make it graded
- Verify the course pace has updated with the new item and has was
republished
- Edit the discussion and make it ungraded
- Verify the course pace no longer has the discussion and was published
- Repeat this with other objects that may be ungraded like quizzes,
wiki pages, etc. (A note on WikiPages, they will only update if Mastery
Paths is enabled)

Change-Id: I541aa5f9620ae15ff9f01bab5396b536eb88b015
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/289879
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Robin Kuss <rkuss@instructure.com>
QA-Review: Robin Kuss <rkuss@instructure.com>
Product-Review: Eric Saupe <eric.saupe@instructure.com>
2022-04-19 20:58:11 +00:00
Cody Cutrer c2cba46851 RuboCop: Style/StringLiterals, Style/StringLiteralsInInterpolation
[skip-stages=Flakey]

auto-corrected

Change-Id: I4a0145abfd50f126669b20f3deaeae8377bac24d
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/279535
Tested-by: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
Migration-Review: Cody Cutrer <cody@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
2021-11-25 14:03:06 +00:00
Cody Cutrer e73cf9ddf4 RuboCop: Style/HashSyntax
[skip-stages=Flakey]

auto-corrected

Change-Id: I9371a61046aee6b148f89dd434114a8ba2b1188c
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/279533
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
Migration-Review: Cody Cutrer <cody@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
2021-11-25 14:02:35 +00:00
Cody Cutrer ff99d18138 RuboCop: Style/RedundantSelf
[skip-stages=Flakey]

auto-corrected

Change-Id: I5f26ad1f8210a74c2198b514235d5134dcd0dae1
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/279070
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
Migration-Review: Cody Cutrer <cody@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
2021-11-20 16:41:21 +00:00
Cody Cutrer 5851dc6497 RuboCop: Style/EachWithObject
auto-corrected

Change-Id: I3f1a71b7b521b9cd7ddc37f4460d83855c93001f
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/278777
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-11-18 21:37:54 +00:00
Cody Cutrer 3512a9557e RuboCop: Style/SafeNavigation
[skip-stages=Flakey]

auto-corrected

Change-Id: I0a907a6fa6229f05b4f756faf53a8dd2b18ea0c5
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/278213
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-11-16 06:36:38 +00:00
Cody Cutrer dbd8c46655 RuboCop: Lint
[skip-stages=Flakey]

auto corrections applied:
 * Lint/AmbiguousOperator
 * Lint/AmbiguousOperatorPrecedence
 * Lint/AmbiguousRegexpLiteral
 * Lint/DeprecatedClassMethods
 * Lint/DeprecatedOpenSSLConstant
 * Lint/NonDeterministicRequireOrder
 * Lint/ParenthesesAsGroupedExpression
 * Lint/RedundantRequireStatement
 * Lint/RedundantSafeNavigation
 * Lint/RedundantSplatExpansion
 * Lint/RedundantStringCoercion
 * Lint/RedundantWithIndex
 * Lint/SendWithMixinArgument
 * Lint/SymbolConversion

Change-Id: I222ec19978033544513bb99755994d109435abad
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/274551
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-09-29 03:38:23 +00:00
Cody Cutrer c65d57737a RuboCop: Layout lib
Change-Id: I0655d9a9d750f2debd6378b03d8ddc1403ebc31b
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/274158
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-09-22 20:01:52 +00:00
Cody Cutrer 06763dd519 add # frozen_string_literal: true for lib
Change-Id: I59b751cac52367a89e03f572477f0cf1d607b405
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/251155
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2020-10-27 20:49:50 +00:00
Aaron Hsu 29d4828fe0 fix context modules discussion visibilities when removing dtv
fixes COMMS-1874

Test Plan
- Create a course with multiple sections
- Add students to those sections
- Create a discussion assigned to everyone
- Create a module
- Add the discussion to the module
- Edit the discussion from being visible to everyone to only specific sections
- As a user not in the section assigned to the discussion access the modules page
- Notice you cannot see the discussion in the module anymore
- Play with edge cases

Change-Id: I1e3330dc4ab297fef76adbf5e9c0ca93bab6cfd8
Reviewed-on: https://gerrit.instructure.com/180669
Reviewed-by: Landon Gilbert-Bland <lbland@instructure.com>
QA-Review: Steven Burnett <sburnett@instructure.com>
Tested-by: Jenkins
Product-Review: Steven Burnett <sburnett@instructure.com>
2019-02-12 14:13:42 +00:00
Venk Natarajan a7c805a7f7 Only show discussions for proper sections in module.
Fixes COMMS-1323

Test Plan:
* Have a course with >= 2 sections.
* Have a section specific discussion and a non-specific one.
* Add these to a module.
* Have a student in each of the sections.
* MAKE SURE YOUR RAILS CACHE IS CLEARED, BECAUSE WE
  CACHE VISIBILITIES AND SO PREVIOUS WRONGNESS MAY
  PERSIST
* TO BE SAFE RESTART YOUR RAILS SERVER TOO
* Only the student in the right section should see the
  section specific discussion.
* Both should see the non-specific discussion.

Change-Id: I8d126ceb49fc4bcb0899e06699fae6ea71d75831
Reviewed-on: https://gerrit.instructure.com/159231
Tested-by: Jenkins
Reviewed-by: Landon Gilbert-Bland <lbland@instructure.com>
QA-Review: Steven Burnett <sburnett@instructure.com>
Product-Review: Venk Natarajan <vnatarajan@instructure.com>
2018-08-02 21:18:26 +00:00
Cody Cutrer bbdad8a755 rails 5.1: fix several moar deprecation warnings
Change-Id: I2534413c14b5dfbcab19c7c0ce983e1e78d61eab
Reviewed-on: https://gerrit.instructure.com/144710
Tested-by: Jenkins
Reviewed-by: Rob Orton <rob@instructure.com>
Product-Review: Rob Orton <rob@instructure.com>
QA-Review: Rob Orton <rob@instructure.com>
2018-03-23 22:03:15 +00:00
Cody Cutrer f49d5c68b0 rails 5.1: fix several deprecation warnings
refs CORE-1196

 * avoid calling saving in an after_save callback. things just get weird
 * enable logging of deprecation warnings in specs (so that you can
   use the log to figure out which spec caused it)

Change-Id: I64804f7b02e4edee0650caa6346cc58bcbe69628
Reviewed-on: https://gerrit.instructure.com/144667
Tested-by: Jenkins
Reviewed-by: Rob Orton <rob@instructure.com>
Product-Review: Rob Orton <rob@instructure.com>
QA-Review: Rob Orton <rob@instructure.com>
2018-03-23 19:19:34 +00:00
Cody Cutrer 75c7538888 drop rails 4.2
also, allow rails 5.1

Change-Id: If480c2a2c01a7578552dc70f4bdcf3a46df40e7b
Reviewed-on: https://gerrit.instructure.com/115654
Tested-by: Jenkins
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Reviewed-by: Tyler Pickett <tpickett@instructure.com>
2017-06-27 15:29:51 +00:00
Landon Wilkins e26843ff95 da licença part 34
add consistent license headers to all source files
(ruby, coffeescript, javascript)

except for vendor files

Change-Id: Ic6b3be7861a2c91d76889c1740f964e401638e04
Reviewed-on: https://gerrit.instructure.com/110061
Tested-by: Jenkins
Reviewed-by: Jon Jensen <jon@instructure.com>
Product-Review: Jon Jensen <jon@instructure.com>
QA-Review: Jon Jensen <jon@instructure.com>
2017-04-27 22:00:30 +00:00
Cody Cutrer a9e5f73d77 rails 5: various selenium fixes
refs CNVS-34865

Change-Id: Id0d2b6b7876942eae7eaed4ba00aac2dce59c323
Reviewed-on: https://gerrit.instructure.com/104647
Tested-by: Jenkins
Reviewed-by: Simon Williams <simon@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2017-03-10 17:41:36 +00:00
James Williams f23f3b0ff2 remove rails 4.0 support
Change-Id: Id1900160375644ea33badaa9d9f9185fab6b81ac
Reviewed-on: https://gerrit.instructure.com/92726
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins
Product-Review: James Williams  <jamesw@instructure.com>
QA-Review: James Williams  <jamesw@instructure.com>
2016-10-25 17:17:22 +00:00
Christian Prescott 4a7227c050 Fix modules ignoring page assignment override behavior
Filters pages from set of assignments rendered in modal
Filters pages from displayed content tags according to differentiated
assignments behavior

refs CYOE-263

Test Plan:
1. Create a wiki page, via pages index or modules + button
2. Ensure page can be added to module and is visible to students
3. Check edit page, "mastery paths content"
4. Ensure the page is no longer visible to students in modules, until
   they are assigned it via an override.
5. Open the "add item to module" modal. Ensure the page does not appear
   in the assignments section, only under pages.

Change-Id: I822d53dc562476ef422f4a3ee6004e0d1e132246
Reviewed-on: https://gerrit.instructure.com/87418
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Tested-by: Jenkins
QA-Review: Jahnavi Yetukuri <jyetukuri@instructure.com>
Product-Review: Christian Prescott <cprescott@instructure.com>
2016-08-17 16:26:45 +00:00
James Williams a274377c22 rails 4.2: fix wiki_page_spec
refs #CNVS-26056

Change-Id: Ife03a54b6b0e1fa6eda737f2002f57caec6dcf1e
Reviewed-on: https://gerrit.instructure.com/77702
Tested-by: Jenkins
Reviewed-by: Christian Prescott <cprescott@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
QA-Review: James Williams  <jamesw@instructure.com>
2016-04-22 18:39:44 +00:00
Christian Prescott eaa52716da Add WikiPage assignment type
refs CYOE-67

Test Plan
0. `rake db:migrate` and compile assets. Enable the conditional release
   feature flag in course settings.
1. Create a published WikiPage, assignment-free. Ensure it is visible
   to errybody.
2. With the API, create an assignment with submission type 'wiki_page'.
   A new page will be created for the assignment.
```sh
curl "http://canvas.dev:3000/api/v1/courses/1/assignments" \
-H "Content-Type: application/json" -H "Authorization: Bearer <token>" \
-X POST -d '{"assignment": {"name": "Page Asg", "published":true, \
"submission_types":["wiki_page"]}}'
```
3. Ensure the assignment is assigned to "Everyone" and the page is
   visible to all.
4. Assign the assignment to a specific student or section. Ensure the
   page is visible only to the assigned set.
```sh
curl "http://canvas.dev:3000/api/v1/courses/1/assignments/13" \
-H "Content-Type: application/json" -H "Authorization: Bearer <token>" \
-X PUT -d '{"assignment": {"only_visible_to_overrides": true }}'
curl "http://canvas.dev:3000/api/v1/courses/1/assignments/13/overrides" \
-H "Content-Type: application/json" -H "Authorization: Bearer <token>" \
-X POST -d '{"assignment_override": {"student_ids":[126]}}'
```
5. Ensure the DA behavior also applies to WikiPage#show and update and edit.
6. Ensure API behavior matches docs for Assignment and Page endpoints.
7. Ensure no regressions in non-page assignments, with and without CR
   feature flag. Ensure no regressions in discussion topics and
   announcements, including assigned discussions.

Change-Id: Ie53c6ffa4e4533cedd54f10aee3ba0b8a27aa4d5
Reviewed-on: https://gerrit.instructure.com/75139
Reviewed-by: Matt Berns <mberns@instructure.com>
Tested-by: Jenkins
QA-Review: Michael Hargiss <mhargiss@instructure.com>
Product-Review: Christian Prescott <cprescott@instructure.com>
2016-04-21 17:25:15 +00:00