Commit Graph

25 Commits

Author SHA1 Message Date
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
Jeremy Neander fd1a4097bb remove unused assignment_unmuted notification
closes TALLY-653
flag = none

With Post Policies, this notification is no longer sent.
If the build passes with this commit, it is likely safe
to merge. But a sanity check would be below.

test plan:
 1. Have a student with notifications enabled
 2. Mute an assignment in SRGB
 3. Assign the student to the muted assignment
 4. Unmute the assignment in SRGB
 5. Verify the world is not on fire

Change-Id: Ie1bc03b0ac8f0279f2b6ea91a6ce1a65963fc43c
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/228993
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Gary Mei <gmei@instructure.com>
Reviewed-by: Nick Pitrak <npitrak@instructure.com>
QA-Review: Robin Kuss <rkuss@instructure.com>
Product-Review: Jonathan Fenton <jfenton@instructure.com>
2020-03-06 20:52:31 +00:00
Adrian Packel 9972fe7428 Fix read-only error on posting submissions
With post policies active, we update an assignment's muted status
dynamically based on whether it has any remaining unposted submissions.
When the last student in a course took a quiz, we were attempting to set
the assignment's muted status to false, but another piece of code
attempted to save changes to the associated quiz, resulting in an error
to the effect that the quiz was marked as read-only. When we're only
muting/unmuting by way of posting/hiding submissions, don't attempt to
save changes to the quiz.

fixes GRADE-2306

Test plan:
- Have new gradebook/post policies enabled
- Have a course with a small number of students
- Create a quiz
  - Take the quiz with all but one student
  - As the last student, take the quiz (to switch the assignment's muted
    from true to false)
  - It should complete successfully and not cause an error

Change-Id: I8c97d02033f86158d66ce98b7ad9b32ce8edb43c
Reviewed-on: https://gerrit.instructure.com/201553
Reviewed-by: Derek Bender <djbender@instructure.com>
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Tested-by: Jenkins
Product-Review: Keith Garner <kgarner@instructure.com>
QA-Review: James Butters <jbutters@instructure.com>
2019-07-17 18:23:12 +00:00
Adrian Packel a896e5c425 Post/unpost individual submissions
For any assignment that is not manually posted (or muted, pre-post
policies), update a submission's posted_at date when an instructor
leaves a grade or (student-visible) comment, and subject the submission
to the standard posted/unposted workflow.

closes GRADE-1954

Test plan:
- Have a course with some assignments, including a manually-posted
  assignment (e.g., an anonymously-graded assignment)
- With the Post Policies feature flag ENABLED:
  - For an assignment with an associated manual post policy:
    - Issuing a grade or leaving a comment on a submission should not
      set the submission's posted_at date
  - For an auto-posting assignment (i.e., post_manually = false):
    - For an unposted submission (i.e., posted_at = nil):
      - Issuing a grade should set the posted_at date to now
      - Same with an instructor leaving a (non-draft/non-hidden) comment
      - A draft or non-instructor comment should not set posted_at
    - For an already-posted submission (posted_at != nil):
      - The above actions should leave the posted_at date as is
- With the Post Policies feature flag DISABLED:
  - Muted assignments should behave like manually posted assignments
    - (grading/commenting should *not* set posted_at)
  - Unmuted assignments should behave like auto-posted assignments
    - (grading/commenting *should* set posted_at)

Change-Id: I66bbd845d9fdca0c979a8a365b153377ee72fce9
Reviewed-on: https://gerrit.instructure.com/180613
Tested-by: Jenkins
Reviewed-by: Keith Garner <kgarner@instructure.com>
Reviewed-by: Gary Mei <gmei@instructure.com>
QA-Review: Adrian Packel <apackel@instructure.com>
Product-Review: Keith Garner <kgarner@instructure.com>
2019-02-07 15:40:38 +00:00
Adrian Packel 5e7f4f0324 Make muting compatible w/ post policies
Allow an assignment to post/unpost an arbitrary set of submissions, and
use this workflow for muting/unmuting. When post policies are enabled,
determine an assignment's muted? status based on whether it has any
unposted submissions (and update it as submissions are posted/unposted).
When the user manually mutes/unmutes an assignment, adjust its post
policy accordingly.

closes GRADE-1875

Test plan:
- For a course with the the Post Policies feature flag enabled:
  - Create some assignments to play around with
    - Creating an anonymous or moderated assignment (or changing an
      existing one) should automatically create an associated
      PostPolicy object with post_manually set to true
    - Otherwise, a PostPolicy should not automatically be created
    - (To check this, you'll need to look at assignment.post_policy
      in a console; it's not visible in the UI yet)
  - Muting an assignment (from the UI or using mute!) should:
    - Save a post_policy for the assignment with post_manually set to
      true (if not already set)
    - Set posted_at for all active submissions to nil
    - Do the usual other stuff like hiding submission comments
    - Have no effect if all submissions are already unposted
  - Unmuting an assignment (from the UI or using unmute!) should:
    - Save a post_policy for the assignment with post_manually set to
      false (if not already set)
    - Set posted_at for all active submissions to the current date
    - Do the usual other stuff like showing submission comments
    - Have no effect if all submissions are already posted
  - In a Rails console, find an assignment/some submissions to test with
    > assignment.post_submissions(submissions: submissions)
      - This should post the given submissions (i.e., set posted_at,
        show comments, etc.) but no others
    > assignment.unpost_submissions(submissions: submissions)
      - This should unpost only the given submissions
    - Both methods should update the assignment's muted attribute
      automatically:
      - Muted should be set to true if any active submissions on the
        assignment remain unposted, and false if all are posted
    - Note: setting the posted_at time on an individual submission
      will NOT auto-update the assignment's muted status (as of this
      patchset)

- For a course with the the Post Policies feature flag *disabled*:
  - Muting/unmuting an assignment should work as usual, and should
    *not* attempt to create a post policy on the assignment
    - It should, however, still set or unset the posted_at date on
      all the assignment's submissions
  - In a Rails console:
    - The muted? attribute should behave like before (i.e., it should
      not be dynamically updated if a subset of submissions is posted
      or unposted)

Change-Id: I317dee609fe92cf2832d36bff54511abeb72137c
Reviewed-on: https://gerrit.instructure.com/179361
Reviewed-by: Gary Mei <gmei@instructure.com>
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Tested-by: Jenkins
QA-Review: Gary Mei <gmei@instructure.com>
Product-Review: Keith Garner <kgarner@instructure.com>
2019-02-04 20:02:41 +00:00
Adrian Packel 5631524bf3 Show peer review comments when muted
When an peer review-based assignment is muted, show peer reviewers'
comments to the student.

fixes GRADE-1678

Test plan:
- Have a course with some students
- Create an assignment with online submissions and enable peer review
  - Assign some peer reviews
    - At least one student (S1) should be reviewed by multiple peers
- Mute the assignment
- Logged in as S1:
  - Submit something
  - Leave a comment
- As a teacher, comment on S1's submission without unmuting
- As the peer-reviewing students, comment on S1's submission
- The following should hold:
  - Peer reviewers should see their own comments and no one else's
  - The student being reviewed should see their own comments and all
    peer reviewers' comments
  - Teachers should see all comments
- Unmute the assignment
  - The student should now additionally see comments from the teacher
  - Peer reviewers should still only see their own comments

- Smoke test comment visibility with some other assignment types to
  make sure nothing has broken:
  - Moderated (with some comments by provisional graders)
  - Anonymous (muted and unmuted)
  - Non-anonymous (muted and unmuted)

Change-Id: I121bce0aef199729215704016edff44f162bf919
Reviewed-on: https://gerrit.instructure.com/175078
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: Jonathan Fenton <jfenton@instructure.com>
2019-01-17 21:50:12 +00:00
Keith Garner d230a5e11e hide existing teacher comments when muting assignment
If an assignment is muted after comments are already left, this
patchset make canvas hide the teacher comments during muting.

fixes GRADE-1084

test plan:
 - Have a course with a teacher, two students, and 2 assignments. Make
   one of the assignments a group assignment.
 - For the non-group assignment:
   - As a teacher, leave a comment on the submission for one student
     via the student submission page or speedgrader
   - As the student, visit the student submission page and note the
     teachers comment is present
   - Mute the assignment
   - As the student, visit the student submission page and note the
     teachers comment isn't present
 - Repeat the steps above for the group assignment checking both students

Change-Id: Ib51d92173cdf4cee467362636c7dd6db9f665563
Reviewed-on: https://gerrit.instructure.com/149999
Tested-by: Jenkins
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Spencer Olson <solson@instructure.com>
QA-Review: Anju Reddy <areddy@instructure.com>
Product-Review: Sidharth Oberoi <soberoi@instructure.com>
2018-05-16 17:38:13 +00:00
Landon Wilkins 5ba312a04d da licença part 32
add consistent license headers to all source files
(ruby, coffeescript, javascript)

except for vendor files

Change-Id: Ibb971e1256b9ebf4ed4b50efac991472abba82fc
Reviewed-on: https://gerrit.instructure.com/110058
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:01 +00:00
James Williams 56653b9072 update submission_comments_count after unmuting assignment
test plan:
* have a muted assignment with a submission
* as a teacher, make a submission comment
* unmute the assignment
* the submission comments should show on the
 student's conversations inbox page

closes #CNVS-18916

Change-Id: I05fcfdfb6c06ea71f4626d22e32bed32ee966dfa
Reviewed-on: https://gerrit.instructure.com/108166
Tested-by: Jenkins
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
QA-Review: Deepeeca Soundarrajan <dsoundarrajan@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
2017-04-17 15:15:53 +00:00
Cody Cutrer ce21af8ecf rails 5: find and fix lots of deprecation warnings [ci verbose]
refs CNVS-34843

Change-Id: Idd523c2a7c37325381d590f1ee70c406ace2a459
Reviewed-on: https://gerrit.instructure.com/105033
Tested-by: Jenkins
Reviewed-by: Rob Orton <rob@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2017-03-16 16:03:51 +00:00
James Williams 6d6aff57f5 fix stream item hiding with submission comments from students
test plan:
* create an assignment
* as a student,
 submit to the assignment and add a submission comment
* mute the assignment
* dashboard notifications for instructors should still be shown

* adding another submission comment while still muted should also
 show another dashboard notification

closes #CNVS-30670

Change-Id: I734ca0a53699bb6b0ba7bd6a76dc919b9ccf56d9
Reviewed-on: https://gerrit.instructure.com/86724
Tested-by: Jenkins
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
QA-Review: Heath Hales <hhales@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
2016-08-04 20:17:25 +00:00
James Williams 600165e7b2 rails4: deprecate Relation#all in favor of Relation#to_a
refs #CNVS-21596

Change-Id: I5dedaab90a2abe6bf288ff30401c9b31629b45b2
Reviewed-on: https://gerrit.instructure.com/59220
Tested-by: Jenkins
Reviewed-by: Cody Cutrer <cody@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
QA-Review: James Williams  <jamesw@instructure.com>
2015-07-24 21:28:14 +00:00
Jacob Fugal 7398702378 don't perform mute/unmute side effects w/o change
fixes CNVS-21979

particularly, if an assignment is already unmuted, don't trigger "just
unmuted" broadcast events when "unmute!" is called

test-plan:
 - have your account configured to receive unmute notification
 - edit an unmuted assignment in a published course you're enrolled in
 - save it with the "Mute" checkbox still off
 - don't receive an unmute notification

Change-Id: I948b5f1b2176e574ecf43fcde187019d7eadb50d
Reviewed-on: https://gerrit.instructure.com/58788
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
Tested-by: Jenkins
QA-Review: Ben Bolton <bbolton@instructure.com>
Product-Review: Matt Fairbourn <mfairbourn@instructure.com>
2015-07-19 02:26:34 +00:00
James Williams b8238e5e91 rails4: use preload instead of includes for context associations
also random spec file tweak

refs #CNVS-21596

Change-Id: Ia009265af517e7902cd915b48eb8d08d75ee1d74
Reviewed-on: https://gerrit.instructure.com/57828
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins
Product-Review: James Williams  <jamesw@instructure.com>
QA-Review: James Williams  <jamesw@instructure.com>
2015-07-08 13:03:29 +00:00
Joel Hough 38c0bfd032 remove old conversations and conversation submission comments
fixes CNVS-12330, CNVS-9234, CNVS-8099

before you check out
- configure a user to use old conversations

test plan
- ensure that everyone get new conversations, always, even if
 they explicitly told us that they really like old conversations
 better

- as a student with an existing conversation with a teacher,
 make an assignment submission and a submission comment
- as the teacher, ensure that your unread message count did not
 increase because of the submission comment

Change-Id: If5ae7143abbc5cf5e035f5ed9ea2e5728f70cd45
Reviewed-on: https://gerrit.instructure.com/34343
Reviewed-by: Braden Anderson <banderson@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Steven Shepherd <sshepherd@instructure.com>
Product-Review: Joel Hough <joel@instructure.com>
2014-05-12 23:38:34 +00:00
Cody Cutrer 2ce439e40c support using a scope as a condition
just like Rails 3

Change-Id: I1a93a63a61ca553676533d303f03f2ee773b0371
Reviewed-on: https://gerrit.instructure.com/25702
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2013-10-30 20:02:30 +00:00
Simon Williams d96ba9c601 finish removing course.publish_grades_immediately
this was removed from the UI in Mar 2011 but was never completely ripped out.
we'd like to remove it now since it was adding extra complexity for no benefit.

closes CNVS-5929
refs #3974

test plan:
- create/update/delete an assignment from the index page, and the show page
- grade an assignment (with and without muting)
- test assignment notifications (with and without muting)
  - creating an assignment
  - editing an assignment
  - changing a due date (after 3 hours of being edited)
  - grading an assignment

Change-Id: Ie455bed41154018b5bd2c9c0e69e1e3285a0ac09
Reviewed-on: https://gerrit.instructure.com/20778
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
Product-Review: Simon Williams <simon@instructure.com>
QA-Review: Simon Williams <simon@instructure.com>
2013-06-04 18:11:08 +00:00
Cody Cutrer 5ffbcbeb05 arel-ify lib
excluding api_find, which needs more work

refs CNVS-4706

Change-Id: I013d0660ff2b8dbe2abf6a5c973bd1203f432f99
Reviewed-on: https://gerrit.instructure.com/18921
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: Clare Hetherington <clare@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2013-04-01 19:12:22 +00:00
Cody Cutrer e8e81deb5b Cross-shard conversations
fixes CNVS-1171

test plan:
 * full conversations regression test
 * initiate a conversation with a user from another shard
 * reply to that conversation from both the sender and the
   receiver
 * repeat for a group conversation involving two or more
   shards
 * repeat for huge batch conversations with hundreds of
   users and two or more shards
 * known NOT working yet:
   * re-using the correct cross-shard private conversation
   * probably the tagging of messages with Course x,
     Group y, etc.

Change-Id: I52549039875941cd518077cea4e28bfd2bc10dbf
Reviewed-on: https://gerrit.instructure.com/16523
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: Clare Hetherington <clare@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
2013-01-31 17:11:48 -07:00
Cody Cutrer bdbeeb992d cross shard dashboards
two major pieces:
 * use context_type/context_id instead of context_code for
   three relations so that sharding extensions will
   automatically work
 * deserialize stream item data as actual AR objects instead
   of OpenObject (for similar reasons)

test plan:
 * run the predeploy migration, but not the postdeploy one
 * view your dashboard on a shard other than your home shard;
   it should be identical to your home shard
 * view courses that you are enrolled in with the same id but on
   different shards. the activity stream should have the correct
   data for the course in that shard, for both courses (i.e.
   no mixing of data from the two shards)
 * do actions that generate new stream items, and verify the new
   items appear correctly for the above two steps
 * run the postdeploy migration, wait for the job to finish, then
   repeat the test plan

Change-Id: I8d5fcadb8d971acf7388a12e9151a3e927751f44
Reviewed-on: https://gerrit.instructure.com/15462
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
2012-11-29 17:36:24 -07:00
Joe Tanner 5e4d2787dd dashboard caching of recent_stream_items, closes #11396
Change-Id: Ib84785c76addc15734162560e6a9de352aa7618f
Reviewed-on: https://gerrit.instructure.com/14998
Reviewed-by: Jon Jensen <jon@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
2012-11-11 21:56:28 -07:00
Jon Jensen 0b1655e76d conversation messages for submission comments, fixes #5443
this commit makes submission first-class citizens in conversations. this
means that when submission comments are added/deleted, or assignments are
unmuted, conversations and messages will be updated accordingly

the main impacts in the ui are:

1. submissions can be deleted from conversations. if a new comment is
   added, they will reappear
2. submissions factor into the message total for the conversation. each
   submission counts as a single message, even if there are multiple
   comments
3. submission messages affect unread-ness, and are reflected in the
   timestamp and text in the conversation preview

test plan:

1. confirm submissions appear in the appropriate conversations, i.e.
   * submissions with no comments should not appear in any conversations
   * submissions where there are comments but not by instructors:
     * should appear in each instructor's private conversation with the
       submitter
     * should not appear in the submitter's private conversations with
       anyone
   * submissions where there are comments by instructors:
     * should appear in each commenting instructor's private conversation
       with the submitter
     * should appear in submitter's private conversations with each
       commenting instructor
   adding or removing submission comments should update private
   conversations accordingly (e.g. when one teacher comments on a
   submission, it should be removed from the other teachers' private
   conversations with the submitter).
2. for each scenario above where the submission comments are added and
   appear in conversations, ensure that the submission as a whole behaves
   like a single conversation message, i.e.
   * the unread conversations count is incremented and the private
     conversation is marked as unread (if it didn't exist or was already
     read)
   * the latest submission comment and timestamp should be reflected in
     the conversation pane on the left side
   * you can delete the submission from the conversation. if new comments
     are posted on the submission, the submission should reappear in the
     conversation (provided it still matches the criteria in 1.). note
     that submission can not be forwarded to other conversations.
3. submissions should differ from traditional conversation messages in
   that:
   * they should not trigger conversation notifications
   * they should not create/bump conversation stream items. if a
     conversation has non-submission messages, the submission and its
     comments should appear in the stream item, but they should not
     cause it to jump to the top

migration:

existing submissions/comments will be migrated in, but not necessarily
through a traditional rails migration. to bring in those messages, run
the following from the rails console:

 Submission.find_each{ |s| s.create_or_update_conversations!(:migrate) }

Change-Id: I06dcb8728402a6c4c613d445b80432a1f2973b73
Reviewed-on: https://gerrit.instructure.com/8086
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Jacob Fugal <jacob@instructure.com>
2012-01-20 15:56:32 -07:00
Zach Wily efa93fc18d hide existing stream items when an assignment is muted
test plan:
 * As a teacher, create a graded assignment. Grade a student.
 * As the student, see that the notification is in your dashboard stream
 * As the teacher, mute the assignment
 * As the student, see that the notification is no longer in your stream
 * As the teacher, unmute the assignment
 * As the student, see tha the notification is back in your stream

Change-Id: I70484f0c7b7ffb6e2deb4014e3ecf4f2eec4f96c
Reviewed-on: https://gerrit.instructure.com/7424
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Zach Wily <zach@instructure.com>
2011-12-11 16:56:49 -07:00
Zach Pendleton 9572eb1fa2 add "mute" function to assignments. fixes #5101
"Mute Assignment" links in gradebook and speedgrader
stop all announcements, emails, and stream items for grades
and comments from appearing until the teacher unmutes the
assignment.

Change-Id: Id74b305b568ff86e2a0e6f9319cfa40bb98b1bcd
Reviewed-on: https://gerrit.instructure.com/5779
Reviewed-by: Jon Jensen <jon@instructure.com>
Tested-by: Zach Pendleton <zachp@instructure.com>
2011-09-30 17:28:25 -06:00