Commit Graph

1404 Commits

Author SHA1 Message Date
Jon Willesen aca2b1e51b show feedback when old feedback pill is present
This also refactors the user_learning_object_scopes and a few other
things to use named parameters instead of opts hashes. I was having
trouble following where all the options were being used and the
conversion made it more clear, as well as uncovering some issues where
the wrong opts were being used in tests.

fixes ADMIN-1191

test plan:
- create an assignment due 6 weeks ago.
- submit the assignment as a student
- add a submission comment as the teacher
- in the rails console, update the submission's dates to be 5 weeks ago:
  - created_at, updated_at, and last_comment_at
- also update created_at and updated_at of the submission comment to
be 5 weeks ago.
- as the stuent, open the dashboard list view and scroll bac to the
assignment. It should show the feedback pill and the feedback (before it
didn't show the feedback).

Change-Id: I42a8bd003269b7940737e555e554e9854e48611a
Reviewed-on: https://gerrit.instructure.com/164609
Tested-by: Jenkins
Reviewed-by: Mysti Sadler <mysti@instructure.com>
QA-Review: Anju Reddy <areddy@instructure.com>
Product-Review: Jon Willesen <jonw+gerrit@instructure.com>
2018-09-24 16:22:06 +00:00
Derek Bender 8fcbb94141 fix comment visibilities for speed grader
fixes: GRADE-1599

test plan:
 - given an anonymous assignment
 - given at least one TA is enrolled
 - given at least one student
 - given the student has submitted their homework with a comment
 - given Speed Grader page as the TA
 - when a grade is left by the TA
 - then the student's submission comment is not deanonymized and is
   still authored by a string like "Student 1"

Change-Id: Id2b348b550e9cedee74bf4223ae452a2a56d833d
Reviewed-on: https://gerrit.instructure.com/164742
Tested-by: Jenkins
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
Reviewed-by: Adrian Packel <apackel@instructure.com>
QA-Review: James Butters <jbutters@instructure.com>
Product-Review: Sidharth Oberoi <soberoi@instructure.com>
2018-09-20 16:09:45 +00:00
Mysti Sadler 2646d017c9 Prevent n+1 on discussion topic participants
refs ADMIN-1302

Test plan
- Load the /api/v1/planner/items API
  and make sure you don't have a bunch of
  discussion topic participants queries at
  the end that all say "limit 1"

Change-Id: I7d0971b4cb994cfccbd9aabd664fb5701a0df152
Reviewed-on: https://gerrit.instructure.com/164539
Tested-by: Jenkins
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
QA-Review: Anju Reddy <areddy@instructure.com>
Product-Review: Mysti Sadler <mysti@instructure.com>
2018-09-14 23:16:57 +00:00
Mysti Sadler e74ad11295 Ensure peer reviews without review or everyone date show up
fixes ADMIN-1398

Test plan
- Set up an assignment that is available to only
  overrides, with no everyone else date
- The assignment should be set up to allow peer
  reviews, but not have a peer review assignment
  date set
- Set up at least 2 students on the assignment
- Create peer reviews for the student you want
  to test with and ensure that student has a due
  date in their override
- The other student should either have a very
  different due date or no due date so you
  can verify the item comes in with the correct
  date
- Load up planner and ensure you see the peer
  review show up
- If you check the API, I noticed that the
  peer reviews are coming in in the wrong
  order, but this problem exists on master

Change-Id: Ifa0f52cb65052cb7f4fdbfe4f25d139bb92eea6d
Reviewed-on: https://gerrit.instructure.com/164313
Tested-by: Jenkins
Reviewed-by: Dan Minkevitch <dan@instructure.com>
QA-Review: Anju Reddy <areddy@instructure.com>
Product-Review: Mysti Sadler <mysti@instructure.com>
2018-09-14 23:16:40 +00:00
Jeremy Stanley d84c8e4f17 remove unused blank_avatar_fallback param
neither the web app nor the mobile apps use it

refs ADMIN-1426

test plan: specs

Change-Id: I73b31a396fe75a21501ed6f30ed5134d6e84846b
Reviewed-on: https://gerrit.instructure.com/163306
Tested-by: Jenkins
Reviewed-by: Carl Kibler <ckibler@instructure.com>
Reviewed-by: Mysti Sadler <mysti@instructure.com>
Reviewed-by: Steven Burnett <sburnett@instructure.com>
QA-Review: Mysti Sadler <mysti@instructure.com>
Product-Review: Jeremy Stanley <jeremy@instructure.com>
2018-09-14 20:24:19 +00:00
Nate Armstrong 4a88da2d10 Fix user can_change_avatar permission when locked
Refs MBL-11195

Test plan:
* Enable user avatars on an account
* As a student, upload an avatar
* As an admin, lock the avatar from /accounts/self/avatars
* As the student view /api/v1/users/self
* The can_change_avatar permission should be 'false'

Change-Id: Iad5194c44f2daee532208d71b6e1a5c9d5274a36
Reviewed-on: https://gerrit.instructure.com/164360
Tested-by: Jenkins
Reviewed-by: Matthew Sessions <msessions@instructure.com>
Product-Review: Matthew Sessions <msessions@instructure.com>
QA-Review: Matthew Sessions <msessions@instructure.com>
2018-09-14 15:53:31 +00:00
Rob Orton 58c30f8848 add created_at to courses api
fixes CORE-1876

test plan
 - course object in api should have created_at

Change-Id: I6894337e54afbb39af893a2ffad20b55f7b23776
Reviewed-on: https://gerrit.instructure.com/164115
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins
Product-Review: Rob Orton <rob@instructure.com>
QA-Review: Rob Orton <rob@instructure.com>
2018-09-13 20:01:24 +00:00
Michael Brewer-Davis 872ceb9750 fix save now destroying description
closes QO-397

Test plan:
- create quiz with non-trivial description and
  one or more questions
- save and publish quiz
- edit quiz, making changes to only quiz questions
- save question changes, but use "Cancel" button
  to avoid saving overall quiz attributes
- on quiz show page, click "Save Now" to save quiz
- verify that description is unchanged
- reload page
- verify that description is unchanged

Change-Id: I8b7e910fd38831c035de6c9e058ec430efabe75d
Reviewed-on: https://gerrit.instructure.com/163670
Reviewed-by: James Williams  <jamesw@instructure.com>
Tested-by: Jenkins
QA-Review: Jim Simon <jsimon@instructure.com>
Product-Review: Kevin Dougherty <jdougherty@instructure.com>
2018-09-10 22:33:38 +00:00
Mysti Sadler bdd71cc47e Use slimmed down json for plannables
fixes ADMIN-1302

Test plan
- Load up the planner and ensure each kind of
  item displays properly (ungraded discussion,
  graded discussion, wiki page, ungraded quiz,
  graded quiz, assignment, assignment with
  varied due dates, calendar event, planner
  note, peer review)
- Load up the sidebar to do list and ensure the
  items  show properly there as well
- Ensure you can open a planner note and
  have all the data you'd expect to see
  in the tray
- Ensure peer review titles show up correctly
  and their dates show up as "reminder"
- Ensure you can drag and drop discussion/
  wiki items on the calendar without issues

Change-Id: I4ea0d4829d8ea87a11c6867eb11805bcfaab6101
Reviewed-on: https://gerrit.instructure.com/162662
Reviewed-by: Carl Kibler <ckibler@instructure.com>
QA-Review: Carl Kibler <ckibler@instructure.com>
Product-Review: Mysti Sadler <mysti@instructure.com>
Tested-by: Jenkins
2018-09-10 19:26:13 +00:00
James Williams 56e8fd7f6d fix due date change detection when overrides are sent in via api
test plan
* due date changed notifications should be sent for
assignments older than 3 hours

closes #COMMS-1394

Change-Id: I97744a8cb9bf5c17138ef40a96128abe6de47be5
Reviewed-on: https://gerrit.instructure.com/163754
Tested-by: Jenkins
Reviewed-by: Steven Burnett <sburnett@instructure.com>
Product-Review: Steven Burnett <sburnett@instructure.com>
QA-Review: Steven Burnett <sburnett@instructure.com>
2018-09-10 17:40:38 +00:00
Dan Minkevitch 2578de0bb7 Remove author details from anonymous submission reviews
For planner item feedback details

Closes ADMIN-1378

Test Plan:
* In a course with at least two students in it
  and is published, with Student Planner enabled.
* Create a new assignment with peer reviews enabled
  and anonymous checkbox checked for them and put a
  due date in the future
* Set the two students as reviewers for each
  other's submissions
* Submit as both students in the course
* As the first student leave a comment on the
  second student's submission
* As the second student go to your dashboard and click
  the three dots in the top right to switch to list view
* You should not see the reviewer's profile picture by
  their comment on the assignment listed in the list
  view

Change-Id: I9fb5af4bc474e8a46440ae7ec799b667fa61672c
Reviewed-on: https://gerrit.instructure.com/163089
Tested-by: Jenkins
Reviewed-by: Mysti Sadler <mysti@instructure.com>
QA-Review: Anju Reddy <areddy@instructure.com>
Product-Review: Dan Minkevitch <dan@instructure.com>
2018-09-10 16:30:15 +00:00
Jon Willesen 0866f2d9dd fix dismissing opportunities in list view
I added assignment_id to the PlannerOverride json so that we can easily
link a plannable to its associated assignment, if it has one. Before we
were just assuming that the override was on the assignment, but now
we've standardized to have the override on the assignment's associated
object, if it has one. Since opportunities loads assignments, we needed
a way to easily navigate from the override back to the assignment so the
opportunities menu could update the proper data.

fixes ADMIN-1214

test plan:
- Create a student with missing assignments of several types:
  - regular assignments
  - discussions
  - quizzes
- The student should be able to dismiss all of these types of
assignments from the opportunities menu
- Undismiss the opportunities in the rails console so they show up again
  for example:
  PlannerOverride.
    where(user: <student>, dismissed: true).
    update_all(dismissed: false)
- This will repopulate the opportunities drop down. The student should
  still be able to dismiss all the opportunities.
- Dismiss opportunities very quickly, as described in the Jira ticket.
  There should be no errors.

Change-Id: Ia96dd9d8c970e330d07b5a185a4f8b1195a7ee43
Reviewed-on: https://gerrit.instructure.com/161248
Reviewed-by: Mysti Sadler <mysti@instructure.com>
Tested-by: Jenkins
QA-Review: Anju Reddy <areddy@instructure.com>
Product-Review: Mysti Sadler <mysti@instructure.com>
2018-09-06 21:35:32 +00:00
Mysti Sadler e81a4a3781 Fix HTML URL for peer reviews
fixes ADMIN-1413

Test plan
- Set up an assignment with a peer
  review for your test user
- Load up api/v1/planner/items
  and ensure the html url for the
  peer review takes you to the
  submission you are supposed to
  review

Change-Id: I31c31de5e3a0b643b76760f9bb245bef7864f4c0
Reviewed-on: https://gerrit.instructure.com/163372
Tested-by: Jenkins
Reviewed-by: Carl Kibler <ckibler@instructure.com>
Reviewed-by: Jon Willesen <jonw+gerrit@instructure.com>
QA-Review: Jon Willesen <jonw+gerrit@instructure.com>
Product-Review: Mysti Sadler <mysti@instructure.com>
2018-09-06 17:29:10 +00:00
Nick Houle 6380d03308 Add workflow_state to Attachment API response
Refs: GOOF-443

Test plan:
- Query the Attachment API and confirm the `workflow_state`
  attribute exists in the response

Change-Id: Ie079a70cf30fff255707164cd8881797de5a8c44
Reviewed-on: https://gerrit.instructure.com/162190
Reviewed-by: Michael Guymon <mguymon@instructure.com>
Tested-by: Jenkins
Reviewed-by: Rob Orton <rob@instructure.com>
QA-Review: Deepeeca Soundarrajan <dsoundarrajan@instructure.com>
Product-Review: Josh Orr <jgorr@instructure.com>
2018-09-05 19:28:18 +00:00
Jeremy Stanley 1a1389666d don't use fallback avatar in planner
ENV.current_user.avatar_is_fallback will be set if the
avatar_image_url is a fallback and not set by the user,
so projects that don't want to display fallbacks can
distinguish these cases

test plan:
 - as a student with no avatar image, create a personal
   ToDo in the planner dashboard
 - the circle icon on the item should have your initials,
   not the generic gray face icon

fixes ADMIN-1086

Change-Id: I30cdf579dc74491d5af8c98770227da6c3bddd7a
Reviewed-on: https://gerrit.instructure.com/157262
Tested-by: Jenkins
Reviewed-by: Mysti Sadler <mysti@instructure.com>
QA-Review: Ed Schiebel <eschiebel@instructure.com>
Product-Review: Jeremy Stanley <jeremy@instructure.com>
2018-09-05 19:05:18 +00:00
Jeremy Stanley 05ffd7f1b0 fix blueprint history with syllabus sync
sync exceptions due to downstream changes work just fine.
but history won't load if there are _no_ exceptions. 🤦

test plan:
 - have a blueprint course syncing to associated courses
 - change the syllabus body in the blueprint (and not in any
   of the associated courses, so the change goes to all of them)
 - ensure the sync history loads

fixes ADMIN-1346

Change-Id: I85cd22d072b3ec87b2831b5410a00d098d2d23ba
Reviewed-on: https://gerrit.instructure.com/162664
Reviewed-by: James Williams  <jamesw@instructure.com>
Tested-by: Jenkins
QA-Review: Carl Kibler <ckibler@instructure.com>
Product-Review: Jeremy Stanley <jeremy@instructure.com>
2018-09-04 16:13:30 +00:00
Ryan Shaw 4a7295c72c Include context_name in planner item response
Closes: CORE-1779

this is so we can not have to load all the possible courses on the
Student planner on page load just so we can join them to course_ids
From planner_item api responses to show course names for planner items.
Because right now, for people that have many courses it is more
Work to get all possible courses than it is to get the actual planner 
items.


Test plan:
* make a request to api/v1/planner_items, the returned
  response should include context_name and context_image for items
  That are linked to a context

Change-Id: I69f8560f19b2a46bc94915d4a9e13623b518b291
Reviewed-on: https://gerrit.instructure.com/162035
Reviewed-by: James Williams  <jamesw@instructure.com>
Reviewed-by: Mysti Sadler <mysti@instructure.com>
Tested-by: Jenkins
Product-Review: Ryan Shaw <ryan@instructure.com>
QA-Review: Ryan Shaw <ryan@instructure.com>
2018-08-29 22:20:52 +00:00
James Williams 8f4842aba0 precalculate sis permissions for course_json
[ci no-cached-dist]

Change-Id: I5d51bc4a3843df63dc06edf45c4c260da99ae2d1
Reviewed-on: https://gerrit.instructure.com/162337
Tested-by: Jenkins
Reviewed-by: Cody Cutrer <cody@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
QA-Review: James Williams  <jamesw@instructure.com>
2018-08-29 16:12:20 +00:00
Keith T. Garner ac5f3d12e3 remove unneeded work when looking for assignment representatives
Some work was being done that didn't need to be done since we just
wanted the assignment representatives. Further, this work caused an
error since the shape of the objects didn't match. This patchset
removes the unneeded code.

fixes GRADE-1509

test plan:
 - Have a course with some students and students assigned to groups
 - Create a group assignment
 - As a members of on group, submit to the assignment
 - As that same student, visit the submissions detail page and leave a comment
 - Ensure an error dialog doesn't appear and the comment is left

Change-Id: I1d60d7b908b1a889c50576b7677c4a6f8767f095
Reviewed-on: https://gerrit.instructure.com/162180
Tested-by: Jenkins
Reviewed-by: Derek Bender <djbender@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
QA-Review: Keith T. Garner <kgarner@instructure.com>
Reviewed-by: Spencer Olson <solson@instructure.com>
2018-08-28 18:02:58 +00:00
Cody Cutrer 20179e2b06 use a strand-per-domain for file downloads
closes GOOF-543

each of these slightly different jobs really should be on the same
strand, because they're all calling Attachment#clone_url at their core

Change-Id: I241ca0fd47b696dba17164f8ecbb07f41912e2f3
Reviewed-on: https://gerrit.instructure.com/162278
Reviewed-by: James Williams  <jamesw@instructure.com>
Tested-by: Jenkins
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2018-08-28 16:46:32 +00:00
James Williams 77e35d5650 skip permissions for quizzes on planner index
Change-Id: I73cfb0bc9201a4089914ca2b8f0070c78d6ee641
Reviewed-on: https://gerrit.instructure.com/162174
Tested-by: Jenkins
Reviewed-by: Mysti Sadler <mysti@instructure.com>
Reviewed-by: Dan Minkevitch <dan@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
QA-Review: James Williams  <jamesw@instructure.com>
2018-08-28 12:28:52 +00:00
Derek Bender 1190cbad6b anonymize status endpoint
closes: GRADE-1351

test plan:
- given an anonymous-moderated-assignment
- given a rubric on the assignment
- given a student with a submission for the moderated assignment
- given comments, grades, rubric assessments including grades
  and comments
- when the following API is requested as an admin or final grader:

    /api/v1/courses/<course-id>/assignments/<assignment-id> \
      /anonymous_provisional_grades/status? \
      anonymous_id=<student-anonymous-id>&last_updated_at=nil

- then all identifying information (e.g. user_id) is no longer present

Change-Id: I5a053df9c257ebf152b22b6d9bafaabcdf96788c
Reviewed-on: https://gerrit.instructure.com/161485
Reviewed-by: Gary Mei <gmei@instructure.com>
Tested-by: Jenkins
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
QA-Review: Spencer Olson <solson@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-08-27 17:46:21 +00:00
Dan Minkevitch 9892cc0faf API: Peer Reviews on Planner
Refs ADMIN-191
Closes ADMIN-1305

Test Plan:
* With student planner enabled
* Having an assignment with submissions
* As a student (reviewer) that's assigned as a
  peer reviewer to another student's submission
* GET /api/v1/planner_items
* The peer review task should be included in the
  results, with the `plannable_type` set as
  "assessment_request" and the `plannable` being
  the submitting student's submission
* The `assignment` object should be present on
  the `plannable` submission

Change-Id: Ifcba8b2631c6ab28f73791962bc739b2b25e5016
Reviewed-on: https://gerrit.instructure.com/157513
Tested-by: Jenkins
Reviewed-by: Mysti Sadler <mysti@instructure.com>
QA-Review: Anju Reddy <areddy@instructure.com>
Product-Review: Dan Minkevitch <dan@instructure.com>
2018-08-25 20:14:44 +00:00
James Williams bf43c9cbee skip permissions processing for discussions in planner api
Change-Id: I15546091f9c79219b6cba422724279fa808b2738
Reviewed-on: https://gerrit.instructure.com/161972
Tested-by: Jenkins
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
QA-Review: James Williams  <jamesw@instructure.com>
2018-08-24 15:27:48 +00:00
James Williams 299abd2496 precalculate permissions for tabs via course index
Change-Id: I9b130ec24fccb072fe31f38f33d703415198189c
Reviewed-on: https://gerrit.instructure.com/161882
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins
Product-Review: James Williams  <jamesw@instructure.com>
QA-Review: James Williams  <jamesw@instructure.com>
2018-08-24 01:07:44 +00:00
Cody Cutrer 4219b131e2 preload lots of things used in Courses#index API
Change-Id: I8c8914a38d74983e0ff255b5a388e2785f128a99
Reviewed-on: https://gerrit.instructure.com/161604
Tested-by: Jenkins
Reviewed-by: James Williams  <jamesw@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2018-08-23 15:30:01 +00:00
Derek Bender 3865d53ef3 add submission comment pdf exporter
scores are shown, not grades.

closes: GRADE-1457

Test Plan:
  Note: the new endpoint is of the form:

    /submissions/:submssion_id/comments.pdf

 - given a submission with many submission comments
 - given SpeedGrader page
 - when the link for Export Submission Comments is clicked
 - then a pdf of submission comments is displayed

 - given a user that cannot Read Grades
 - when accessing a pdf url
 - then the response is unauthorized

 - given a user that cannot Read Comments
 - when accessing a pdf url
 - then the response is unauthorized

 - given an assignment that is anonymous
 - when on the SpeedGrader page
 - then the link for Export Submission Comments is not displayed
 - then hitting the pdf url returns unauthorized

 - also test with group assignments

Change-Id: I529fe170a3de6f8a1c8f28ae20a3346c5676a97e
Reviewed-on: https://gerrit.instructure.com/158888
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
QA-Review: Derek Bender <djbender@instructure.com>
Product-Review: Sidharth Oberoi <soberoi@instructure.com>
Tested-by: Jenkins
2018-08-23 00:43:26 +00:00
James Williams 41e901b7a1 allow imported sis csvs to be downloaded
after filtering out passwords of course

test plan:
* with the sis imports refactor feature flag on,
 upload some zips and csvs to sis imports,
 including some users.csv files with passwords
* view the sis imports API index and show
 endpoints
* should be able to use the urls in the new
 "csv_attachments" attribute to download versions
 of the imported files without passwords

closes #CORE-1655

Change-Id: I31e34d42f4abf2597efd6066dabea6f230632855
Reviewed-on: https://gerrit.instructure.com/158899
Tested-by: Jenkins
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Reviewed-by: Rob Orton <rob@instructure.com>
Product-Review: Rob Orton <rob@instructure.com>
2018-08-18 03:02:29 +00:00
Cody Cutrer ecde94dd98 slave stream item summary
Change-Id: I02b424b4289196f362efbc9a804131b8dba27caf
Reviewed-on: https://gerrit.instructure.com/161025
Reviewed-by: Rob Orton <rob@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins
2018-08-16 15:04:17 +00:00
James Williams 945013200e preload some more things
for planner and calendar events api

also apparently the except(:preload) makes it so
the inverse association for course on enrollments isn't set

Change-Id: Id490aa6b76c7c0b283a6c4a8be13ef2e5d4d9707
Reviewed-on: https://gerrit.instructure.com/160897
Tested-by: Jenkins
Reviewed-by: Mysti Sadler <mysti@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
QA-Review: James Williams  <jamesw@instructure.com>
2018-08-16 14:50:22 +00:00
Spencer Olson b766794156 add slot_taken to moderation_graders
closes GRADE-1426

Test Plan:
1. Before running migrations, make sure you have some moderation_grader
   records.
2. Run migrations. Verify 1) the moderation_graders table now has a
   slot_taken column, and 2) the existing moderation_grader records have
   slot_taken set to true.
3. Create a moderated assignment, then log in as a provisional grader.
4. Verify there are no moderation_grader records for the provisional
   grader for that assignment.

   assignment.moderation_graders.find_by(user: provisional_grader)
   => nil

5. Visit SpeedGrader, but don't grade or comment. Verify a moderation
   grader record has been created for the provisional grader, and verify
   it has slot_taken set to false.

   grader =
   	assignment.moderation_graders.find_by(user: provisional_grader)
   grader.slot_taken?
   => false

6. Leave a submission comment or a grade in SpeedGrader. Verify the
   moderation grader record for the provisional grader has been updated
   with slot_taken set to true.

   grader.reload.slot_taken?
   => true

7. Verify you can roll the migration back. The slot_taken column should
   be removed.

Change-Id: I94fafc259df5022ed1af27d3457d8df87947153e
Reviewed-on: https://gerrit.instructure.com/159544
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins
QA-Review: Jeremy Neander <jneander@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-08-15 20:01:19 +00:00
Mysti Sadler 6f7062a96e Standardize where planner overrides live
closes ADMIN-143

Test plan
- Have a graded quiz, discussion and wiki page
- Try to create planner overrides for the
  assignments for all of them
- Ensure the planner override gets created for
  the quiz/discussion/wiki page instead
- Have a group discussion
- Try to create a planner override for one of
  the child topics
- Ensure the planner override gets created for
  the parent topic
- Have an announcement and create a planner
  override for it
- Make an api call for the override and ensure
  it shows up as "announcement" in the type
  instead of discussion_topic

Change-Id: I7940f27508453cdc03366eda10d59e5ca1fbf110
Reviewed-on: https://gerrit.instructure.com/156904
Tested-by: Jenkins
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
QA-Review: Anju Reddy <areddy@instructure.com>
Product-Review: Mysti Sadler <mysti@instructure.com>
2018-08-15 19:06:34 +00:00
James Williams ff93ce42ad return latest conversation messages in stream item api
test plan:
* send a message to another user
* make a couple replies
* view /api/v1/users/self/activity_stream
* it should include 3 of the latest messages

closes #COMMS-1374

Change-Id: Iccff8c8a665ee8883aa61b7ebafaaceaf3060f41
Reviewed-on: https://gerrit.instructure.com/160748
Reviewed-by: Steven Burnett <sburnett@instructure.com>
Product-Review: Steven Burnett <sburnett@instructure.com>
QA-Review: Steven Burnett <sburnett@instructure.com>
Tested-by: Jenkins
2018-08-14 19:45:24 +00:00
Jeremy Stanley 33e82b00c9 blueprint courses: add subscriptions_index
this endpoint allows a teacher to retrieve the blueprint course that
their course is subscribed to, if any

test plan:
 - render API docs
 - use "List blueprint subscriptions" to retrieve subscription information
   for an associated course. ensure:
   - an array containing one element is returned when the course
     is associated with a blueprint
   - an empty array is returned otherwise
   - an unauthorized error is returned if a user without manage rights
     on the course attempts the API call

closes ADMIN-1323

Change-Id: I297bd136fd6b5fc4645d1794d162f2c0b1c4a6e8
Reviewed-on: https://gerrit.instructure.com/159521
Tested-by: Jenkins
Reviewed-by: Dan Minkevitch <dan@instructure.com>
QA-Review: Anju Reddy <areddy@instructure.com>
Product-Review: Jeremy Stanley <jeremy@instructure.com>
2018-08-13 21:37:55 +00:00
Cody Cutrer 6d82a64c24 moar preloads
refs CORE-1541

Change-Id: I51967c0eebcd4dc6f9282dd9e8b3934dafb62aca
Reviewed-on: https://gerrit.instructure.com/160315
Reviewed-by: Rob Orton <rob@instructure.com>
Tested-by: Jenkins
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2018-08-10 17:28:38 +00:00
James Williams 360c1c6d3a strip hosts and verifiers from links in quiz content
test plan:
* try to include an absolute link to a file with a verifier
 in a quiz description or quiz question text
* view the content as a student
* it should have stripped the domain and verifier
 from the link

closes #CORE-1377 #CORE-1666

Change-Id: I16390003ba482f42bb49362f1d99838c8674ae27
Reviewed-on: https://gerrit.instructure.com/159596
Tested-by: Jenkins
Reviewed-by: Clay Diffrient <cdiffrient@instructure.com>
QA-Review: Tucker McKnight <tmcknight@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
2018-08-09 12:29:18 +00:00
Sara Chadwick bd17729f0b Let students reply to admins
Fixes COMMS-846

Test plan:
- Have a course with a student, in which your admin account is not enrolled
- From the course's People page, click on a students names
- Send a message to the student
- Masquerade as the student and attempt to reply
- Make sure the admin recieves the reply

Change-Id: Ic4ee1c13803cb9d006d4710285b46d984834b472
Reviewed-on: https://gerrit.instructure.com/159894
Tested-by: Jenkins
Reviewed-by: Landon Gilbert-Bland <lbland@instructure.com>
Product-Review: Steven Burnett <sburnett@instructure.com>
QA-Review: Steven Burnett <sburnett@instructure.com>
2018-08-08 20:15:55 +00:00
Derek Bender 1cf78b8335 add anonymous_id in api for admins
requested by the University of Hertfordshire

closes: GRADE-1453

test plan
- as an admin, anonymous_id is now included submission objects
- if not an admin, anonymous_id is not present

Change-Id: I36f853a6c178b2e386af4705e70d8ebf589e4755
Reviewed-on: https://gerrit.instructure.com/158742
Reviewed-by: Spencer Olson <solson@instructure.com>
Reviewed-by: Gary Mei <gmei@instructure.com>
Tested-by: Jenkins
QA-Review: James Butters <jbutters@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-08-08 15:59:21 +00:00
Cody Cutrer d39c0b6fd2 moar preloads
found by API specs

refs CORE-1541

Change-Id: I6a4cf04a121a5cd41673561fc57f0f55e5001440
Reviewed-on: https://gerrit.instructure.com/159903
Tested-by: Jenkins
Reviewed-by: Rob Orton <rob@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2018-08-08 05:22:30 +00:00
Derek Bender 1fd3045c20 add sis id to course users api for admins
test plan:
- as an account admin
- /api/v1/courses/:id/users now includes `sis_user_id`
- as any user that doesn't have read_sis/manage_sis credentials,
  sis_user_id is not present

Change-Id: I91c0cba69600ddf589682c43c4bfee4b382b9c6f
Reviewed-on: https://gerrit.instructure.com/158850
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
Tested-by: Jenkins
Reviewed-by: Spencer Olson <solson@instructure.com>
QA-Review: Derek Bender <djbender@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-08-06 21:06:03 +00:00
Jeremy Stanley 1966f31381 add syllabus to blueprint sync history
test plan (ADMIN-51):
 - have a blueprint syncing to multiple associated courses
 - change the syllabus text in the blueprint and in one associated course
 - in the blueprint, the "Unsynced Changes" should include the syllabus
   and the Sync button should be present
 - perform a sync
 - the syllabus text should be updated in courses where the syllabus
   was not changed downstream
 - the sync history in the blueprint course should show the syllabus
   was synced, and should show the exception in the course whose
   syllabus was changed downstream
 - the sync history in the associated courses should show that the
   syllabus was changed and indicate whether this change was applied
   (course settings / Blueprint information in the right sidebar)

test plan (ADMIN-1283)
 - have a blueprint and associated course that are syncing
   a syllabus body
 - detach the associated course and attach it to a different
   blueprint
 - the associated course's syllabus body should be overwritten
   with the new blueprint's syllabus body after a sync happens
 - changing the syllabus body in the associated course should
   prevent future syncs from overwriting the syllabus

also regression test:
 - course settings (e.g. tab order) are copied to a newly added
   course
 - course settings are overwritten in child courses if the
   "copy course settings" box is checked

fixes ADMIN-51
fixes ADMIN-1283

Change-Id: I44f7086746f279059d5bb86e177ceb8f18a15e56
Reviewed-on: https://gerrit.instructure.com/158247
Tested-by: Jenkins
Reviewed-by: James Williams  <jamesw@instructure.com>
QA-Review: Luke Kingsley <lkingsley@instructure.com>
Product-Review: Jeremy Stanley <jeremy@instructure.com>
2018-07-30 19:49:07 +00:00
Derek Bender e15aa37067 extract submission serializer shared code
closes: GRADE-1312

test plan: specs pass

Change-Id: I274ae211ab55d7c0a135c609f9917df5ccc2c716
Reviewed-on: https://gerrit.instructure.com/157760
Tested-by: Jenkins
Reviewed-by: Adrian Packel <apackel@instructure.com>
Reviewed-by: Gary Mei <gmei@instructure.com>
QA-Review: Derek Bender <djbender@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-07-23 16:22:46 +00:00
Keith Garner 350bcb6632 add anonymous instructor annotations support to submission api
fixes GRADE-1368

test plan:
 - Have a course with a student, teacher, and an assignment configured
   for anonymous instructor annotations
 - From a mobile app leave annotations as the teacher
 - View the submission as a student, confirm that annotations are
   anonymized

Change-Id: Iee6e21136f6f7456d088aa9bdc118a94f8be2f38
Reviewed-on: https://gerrit.instructure.com/157157
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Tested-by: Jenkins
Reviewed-by: Spencer Olson <solson@instructure.com>
Reviewed-by: Derek Bender <djbender@instructure.com>
Reviewed-by: Adrian Packel <apackel@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
QA-Review: Keith T. Garner <kgarner@instructure.com>
2018-07-12 23:23:34 +00:00
Ed Schiebel a8a5490534 Have planner deal with media comments.
When we detect a media comment, replace the default "This is a media
comment." with "You have media feedback."

closes: ADMIN-1090

test plan:
  - course with assignment, student submits answer, teacher grades and
    leaves a comment
  > expect student's planner item to show the first line of the comment
  - teacher adds a media comment
  > expect student's planner item to say "You have media feedback."
    you may have to setup nororious. See
    https://instructure.atlassian.net/wiki/spaces/ENG/pages/45645850/Setting+Up+Notorious
    for instructions.  You may also have to fiddle with browser settings
    to get permission to use the mic and/or camera.

Change-Id: Idb688be7e50e66cec0ac52ef6338a3f4cdfe01f9
Reviewed-on: https://gerrit.instructure.com/155791
Tested-by: Jenkins
Reviewed-by: Jon Willesen <jonw+gerrit@instructure.com>
QA-Review: Deepeeca Soundarrajan <dsoundarrajan@instructure.com>
Product-Review: Christi Wruck
2018-07-12 18:37:07 +00:00
Han Yan 274ac9f2a0 allow non-siteadmins to fetch audit_info for a content_migration
refs QUIZ-4921

test plan:
- in local Canvas, register a course, and import a CC package
- as siteadmin, go to /api/v1/course/<course_id>/content_migrations
  it should list the content_migrations for the course
- pick id for a content_migration and fetch
  /api/v1/course/<course_id>/content_migrations/<content_migration_id>
  you should be able to see `audit_info` section
- add a teacher to the course
- login as the teacher, and fetch
  /api/v1/course/<course_id>/content_migrations/<content_migration_id>
  the teacher should NOT see `audit_info` section
- as the same teacher, fetch
  /api/v1/course/<course_id>/content_migrations/<content_migration_id>?include[]=audit_info
  the teacher can see `audit_info` section

Change-Id: I1086eb92986bb9788d643123014c73556c1540d4
Reviewed-on: https://gerrit.instructure.com/157024
Tested-by: Jenkins
Reviewed-by: Dan Minkevitch <dan@instructure.com>
QA-Review: Robin Kuss <rkuss@instructure.com>
Product-Review: John Corrigan <jcorrigan@instructure.com>
2018-07-11 22:44:34 +00:00
Michael Guymon c7a0ba68d6 Add Delayed Job homework submission for url uploads.
Add a Delayed Job Worker that reuses the
Services::SubmitHomeworkService to submit the url uploads after
copying the url from the source. Sends an email for success or failure
of the job. This will be used when InstFS is not enabled.

Based on work from GOOF-435 for the InstFS to support reliable
url uploads.

fixes: GOOF-461, GOOF-462

Test Plan:

* Disable InstFS
* Submit an assignment from Google/Office
* Get an alert with info about submission
* Job enqueued to process the upload.
* When job finishes, the assignment will be submitted.

Change-Id: I63d0f5f9b5dd01cc53bcfffe6f8d952cd6e2c078
Reviewed-on: https://gerrit.instructure.com/155104
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Josh Orr <jgorr@instructure.com>
Tested-by: Jenkins
QA-Review: Tyler Belnap <tyler@instructure.com>
Product-Review: Jesse Poulos <jpoulos@instructure.com>
2018-07-11 20:59:40 +00:00
Nick Houle 8cdf400ba7 Implement Inst-fs capture callback for url uploads.
Adds an alert when the student submits stating that the upload is
processing and an email will be sent.

THe FilesController#api_capture called by InstFS, when the upload
processing is finished, uses Services::SubmitHomeworkService#submit
to submit the assignment.

Update the JS to prevent the browser from submitting the url upload
assignment twice. Passes the submit_assignment parameter to provide
backwards compatibilty, so the old JS can still double submit.

fixes: GOOF-449, GOOF-450, GOOF-435

Test Plan:
* Submit a file from the Google Drive, will see a pop up.
* Check the xhr for the request, the submit_assignment param will be true
* InstFS callback will cause the assignment to be submitted.

Change-Id: I5f49b8ef642fe5913bf0c2f282de8d697dcf1ce1
Reviewed-on: https://gerrit.instructure.com/154757
Reviewed-by: Nick Houle <nhoule@instructure.com>
QA-Review: Tyler Belnap <tyler@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Product-Review: Jesse Poulos <jpoulos@instructure.com>
Tested-by: Jenkins
Reviewed-by: Josh Orr <jgorr@instructure.com>
2018-07-10 19:56:27 +00:00
Spencer Olson c5ee434ff5 make anonymous grading checks consider muted status
Unmuting an anonymous assignment will now cause that assignment to show
in the UI as though it is not anonymous. In addition, posting grades for
a moderated anonymous assignment will now cause that assignment to show
in the UI as though it is not anonymous.

closes GRADE-1310
closes GRADE-1313

Test Plan:
1. Verify unmuting an anonymous assignment causes that assignment to no
   longer be anonymized in the UI. You can do this by spot checking
   gradebook (old/new/individual) and SpeedGrader. In addition,
   re-muting an unmuted anonymous assignment should cause the assignment
   to become anonymized in the UI.
2. Verify posting grades for a moderated, anonymous assignment causes
   that assignment to no longer be anonymized in the UI (even if the
   assignment is muted).

Change-Id: I113c61b4e7fa0eb8909448d8ba7cffb22600e17c
Reviewed-on: https://gerrit.instructure.com/156151
Reviewed-by: Gary Mei <gmei@instructure.com>
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
QA-Review: James Butters <jbutters@instructure.com>
Tested-by: Jenkins
Product-Review: Sidharth Oberoi <soberoi@instructure.com>
2018-07-10 16:24:26 +00:00
Sara Chadwick b61422a144 Fix API call when changing due date for overriden assignments
Fixes COMMS-1240

Test plan:
- Create an assignment with an override for a specific section, and
  nothing for "everyone else"
- Perform an API call to change the overall date (ask Sara for deetz)
- Check that there is now an "everyone else" override, with the new
  due date that was specified
- Verify that there were no side-effects
- Verify that other, related calls haven't been messed up

Test plan:

Change-Id: I56451e03392b4ded47b5d7047ad8363045daf1c9
Reviewed-on: https://gerrit.instructure.com/156425
Tested-by: Jenkins
Reviewed-by: Venk Natarajan <vnatarajan@instructure.com>
Product-Review: Steven Burnett <sburnett@instructure.com>
QA-Review: Steven Burnett <sburnett@instructure.com>
2018-07-09 21:35:41 +00:00
Augusto Callejas 466088fc8a Use default ratings and points
closes OUT-2218

test plan:
  - in a new course, import the CSV file attached to the JIRA ticket
  - align the newly created outcome to an assignment
  - submit to the assignment
  - confirm that a score appears in the LMGB
  - confirm that a score appears in the sLMGB

Change-Id: I5d013b2e74369a23c9922059734c86d0328dea08
Reviewed-on: https://gerrit.instructure.com/155468
Reviewed-by: Frank Murphy <fmurphy@instructure.com>
Tested-by: Jenkins
QA-Review: Dariusz Dzien <ddzien@instructure.com>
Product-Review: Sidharth Oberoi <soberoi@instructure.com>
2018-07-05 21:04:54 +00:00
Sara Chadwick fc16a5fb90 Change Activity Stream API to contain missing attributes
Fixes COMMS-1139

Test Plan:
- Send a new conversation to your main user
- Using https://lti-tool-provider-example.herokuapp.com/xml_builder,
  create a new collaboration. Set the collaboration section to
  content_item_selection_request
- Go to http://localhost:3000/api/v1/users/self/activity_stream and
  verify that the message for the collaboration object is the collab's
  description.
- Also verify that the title of the conversation object is the subject

Change-Id: If1fecd634ecf3e3af89055b5e0f958c83f419d27
Reviewed-on: https://gerrit.instructure.com/155673
Tested-by: Jenkins
Reviewed-by: Landon Gilbert-Bland <lbland@instructure.com>
QA-Review: Steven Burnett <sburnett@instructure.com>
Product-Review: Sara Chadwick <schadwick@instructure.com>
2018-06-29 17:07:21 +00:00
Simon Williams 87a5b6032f allow creating developer keys that only work against test clusters
Some production installations have a beta or test environment that is
refreshed with data from production, and is used as a place to test
integrations or new features. In that case, you may want to create
a developer key that only works against this test instance, which has
traditionally meant making the following tradeoff:
- Create the key in the test instance directly, which means it will be
  removed the next time the data is refreshed
- Create the key in production, which means the key works against the
  production instance as well

This new functionality allows the best of both worlds: create the key in
production for persistance, but only allow it to function against a test
cluster.

To enable test cluster functionality, you need a plugin that overrides
`ApplicationController.test_cluster?` to return appropriately for the
environment.

To see the functionality, you need to set:
  `Setting.set("dev_key_test_cluster_checks_enabled", true)`

closes PLAT-3392
[ci no-db-snapshot]

test plan:
- First ensure that all existing developer key functionality works and
no new functionality appears without any action taken
- Then set Setting.set("dev_key_test_cluster_checks_enabled", true), you
should see the new option available in the new dev key UI
- Create a key with and without the new option checked. Access tokens
from the key without it check should still work normally. Tokens from
the key with it checked should not work
- Now manually override `ApplicationController.test_cluster?` to be
true.
- Tokens from both keys should now work

Change-Id: I5bbb46782d19c26a7b703834aaa507b0cb10039a
Reviewed-on: https://gerrit.instructure.com/153035
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Weston Dransfield <wdransfield@instructure.com>
Tested-by: Jenkins
QA-Review: August Thornton <august@instructure.com>
Product-Review: Karl Lloyd <karl@instructure.com>
2018-06-29 15:50:08 +00:00
Mysti Sadler a6bf7c4386 Preload information for discussion topics for planner
closes ADMIN-1155
refs ADMIN-1031

Test plan
- Set up some discussion topics
- Load /api/v1/planner/items for those topics
  and ensure you don't have to load
  discussion_topic_participants for each one

Change-Id: I92aea7516bea0ec2b1e7406470c6d0f545b0123f
Reviewed-on: https://gerrit.instructure.com/154274
Tested-by: Jenkins
Reviewed-by: Carl Kibler <ckibler@instructure.com>
QA-Review: Deepeeca Soundarrajan <dsoundarrajan@instructure.com>
Product-Review: Mysti Sadler <mysti@instructure.com>
2018-06-28 19:40:15 +00:00
Michael Guymon 4905ae6237 Increase the job priority for url uploads.
Student homework submissions from the Google Drive LTI are
failing when the Delay Job queue is backed up. The browser sends two
requests for the submission. The first request clones the url and the
second submits the file for the assignment. If the first request takes a
long time, the student will close their browser, prevent the second
request from happening and stopping the submission.

This increases the priority of url submissions to high, so they will be
priortized by the Delayed Job workers.

refs: GOOF-434

Test Plan: Submit an online homework submission from Google or Office.
The Delayed Job record created will have a priority of zero (lower is
better).

Change-Id: I72d583b22c83a8e058497ba6d965fd992bf05ffd
Reviewed-on: https://gerrit.instructure.com/153745
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins
QA-Review: Mark McDermott <mmcdermott@instructure.com>
Product-Review: Jesse Poulos <jpoulos@instructure.com>
2018-06-28 19:19:31 +00:00
Matt Sessions 11d6856cba Change alert titles to match correct wording
Refs MBL-10742

Test Plan:
 - Create a threshold for each type for an observer-student
   pairing
 - Generate an alert for each threshold type
 - The title should match the ticket
 - Threshold Types:
   - course_grade_low
   - course_grade_high
   - assignment_grade_low
   - assignment_grade_high
   - assignment_missing
   - course_announcement
   - institution_announcement
 - For assignment grade thresholds have multiple
   assignments that have different display grade as
   types and ensure it puts the correct grade in the
   alert title

Change-Id: Ia971e707c8da73b09066c5f23a742fe60a64be8f
Reviewed-on: https://gerrit.instructure.com/155341
Tested-by: Jenkins
Reviewed-by: Layne Moseley <lmoseley@instructure.com>
QA-Review: Layne Moseley <lmoseley@instructure.com>
Product-Review: Matthew Sessions <msessions@instructure.com>
2018-06-27 14:01:04 +00:00
Nate Armstrong dd0c3c8cda Add missing observer alert json fields
* Adds html_url for assignment_missing alerts
* Always includes action_date field

Refs MBL-10730

Test plan:
* Create an assignment_missing alert for an observer
* View alerts via api `/api/v1/users/self/observer_alerts/:userID`
* Verify that action_date field is present
* Verify that html_url field is present

Change-Id: I1276d6467b392ffaa9f919440ec7635ebd925895
Reviewed-on: https://gerrit.instructure.com/155092
Reviewed-by: Matthew Sessions <msessions@instructure.com>
Product-Review: Matthew Sessions <msessions@instructure.com>
QA-Review: Matthew Sessions <msessions@instructure.com>
Tested-by: Jenkins
2018-06-25 20:59:15 +00:00
Jeremy Stanley 39bdab8baa make planner items link to submission if present
test plan:
 - enable planner
 - have assignments and graded discussions
 - ensure these link to the assignment or discussion
   on a student's planner
 - ensure after the student submits and/or the teacher
   grades the item, the planner links to the submission
   page where the student can see feedback

fixes ADMIN-179

Change-Id: I4bbe2f11c8c95899b6fda6d0935dc9bc48a66d39
Reviewed-on: https://gerrit.instructure.com/154256
Tested-by: Jenkins
Reviewed-by: Dan Minkevitch <dan@instructure.com>
QA-Review: Ed Schiebel <eschiebel@instructure.com>
Product-Review: Jeremy Stanley <jeremy@instructure.com>
2018-06-25 20:41:35 +00:00
Keith Garner e12263fcee skip grade calc when creating assignment in gradebook upload
This adds a calculate_grades parameter to the assignment creation api
that defaults to true. When set to false, after an assignment is
created the DueDateCacher will run but not force a grade calculation
for the course. The gradebook upload process is the first user of this
parameter to avoid a race condition between the creation of the
assignment during a gradebook upload and the subsequent grade
calculation after the submissions are updated with scores.

fixes GRADE-1229

test plan:
 - Create a course with some assignments and some students
 - Export the gradebook
 - In the CSV add a new assignment and grade the students for that new
   assignment
 - Import the gradebook
 - After import is completed check the canvas logs and confirm that
   the grade calculator doesn't run after the call to the assignment
   api but does run after the call to submission bulk update

Change-Id: Ibf52a119e3ad34b95786b6e171f585431111feb8
Reviewed-on: https://gerrit.instructure.com/154077
Tested-by: Jenkins
Reviewed-by: Gary Mei <gmei@instructure.com>
Reviewed-by: Jeremy Neander <jneander@instructure.com>
QA-Review: James Butters <jbutters@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-06-21 13:51:05 +00:00
Mysti Sadler cd569cda41 Preload assignment objects
refs ADMIN-1031
closes ADMIN-1136

Test plan
- Ensure /api/v1/planner/items call runs
- It shouldn't have to load individual
  SQL queries for content tags for assignments
  or for assignment overrides or to get
  assignments from quiz/wiki/discussions

Change-Id: I7720944df118f158b444330842bdb2c2780f053b
Reviewed-on: https://gerrit.instructure.com/153422
Tested-by: Jenkins
Reviewed-by: Dan Minkevitch <dan@instructure.com>
QA-Review: Dan Minkevitch <dan@instructure.com>
Product-Review: Mysti Sadler <mysti@instructure.com>
2018-06-20 19:13:29 +00:00
Jeremy Neander 4626c6cbc3 add existing custom grades to moderation page
refs GRADE-1002

test plan:
 A. Setup
    1. Set up a course with a moderated assignment
    2. Log in as various instructors and grade some students
    3. Log in as the final grader
    4. Visit SpeedGrader and grade some students

 B. Verify without Grader Anonymity
    1. Ensure the final grader can see grader names
    2. Visit the Moderation Page
    3. Verify the final grader's grades are visible
       * They appear in the Select menu only
       * e.g. "9.8 (Custom)"
    4. Verify the final grader's grades can be selected

 C. Verify with Grader Anonymity
    1. Ensure the final grader cannot see grader names
    2. Visit the Moderation Page
    3. Verify the final grader's grades are visible
    4. Verify the final grader's grades can be selected

 D. Verify as an Admin (w & w/o Grader Anonymity)
    1. Visit the Moderation Page
    2. Verify the final grader's grades are visible
    3. Verify the final grader's grades can be selected

Change-Id: I7ded82f9663be9bea74598c3fa4d71146ffb25cd
Reviewed-on: https://gerrit.instructure.com/153784
Reviewed-by: Spencer Olson <solson@instructure.com>
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
QA-Review: Anju Reddy <areddy@instructure.com>
Tested-by: Jenkins
Product-Review: Sidharth Oberoi <soberoi@instructure.com>
2018-06-19 19:00:12 +00:00
Han Yan e09645c979 question_types missing from quizzes API
closes QO-374

test plan:
- in Canvas, create a course and a quiz
- in browser, request /api/v1/courses/<course_id>/quizzes/<quiz_id>
- check response, question_types should be included

Change-Id: Ib49767203a882497c8c7e1d2c330c542a9405403
Reviewed-on: https://gerrit.instructure.com/153933
Tested-by: Jenkins
Reviewed-by: Omar Khan <okhan@instructure.com>
QA-Review: Michael Hargiss <mhargiss@instructure.com>
Product-Review: Gentry Beckmann <gbeckmann@instructure.com>
2018-06-19 14:45:05 +00:00
Adrian Packel 9d89795983 Replace old anonymous-grading course flag checks
Remove the old Anonymous Grading course flag; update checks for it to
instead look at whether a given assignment (or quiz) is anonymous.

closes GRADE-957

Test plan:

Course flag:
- Check that the relevant course flags are now 'Anonymous Grading (OLD)'
  (which should not be able to be enabled) and 'Anonymous Grading' (the
  "new" setting previously called Anonymous Marking)
- The old flag should be hidden for any course or account that does not
  have a value in the database for it already

Assignments:
- Create an anonymous assignment and a non-anonymous assignment
- Test the assignments:
  - SpeedGrader: student names should be visible for the non-anonymous
    assignment only
  - Log in as a student and upload submissions for the assignments
    created above; as a teacher, download them and make sure that the
    anonymous assignment does not include the students' names in
    its filenames

Anonymous surveys:
- Create two quizzes with a type of Graded (or Ungraded) Survey, and
  enable anonymous submissions for one of them but not the other
- Log in as one or more students and answer both surveys
- As a teacher, open the "Moderate This Survey" link for each survey:
  - Student names should be shown for the non-anonymous survey but
    replaced by "Student 1" and so forth for the anonymous survey
  - The history page (accessible by clicking the name of a student who
    has filled out the survey) should show the student's name for the
    non-anonymous survey but only "Student" for the anonymous survey

Change-Id: Iaa0bc4e40b938056b8e9dfd6d13aff7e6b2ee7bd
Reviewed-on: https://gerrit.instructure.com/152985
Tested-by: Jenkins
Reviewed-by: Spencer Olson <solson@instructure.com>
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
QA-Review: Anju Reddy <areddy@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-06-18 16:16:33 +00:00
Mysti Sadler 0c8dc7f058 Stop loading rubric associations for planner items API
refs ADMIN-1031

Test plan
- Set up an assignment, a graded discussion topic and a
  graded wiki page (that requires conditional release...
  so maybe we'll want to get them involved for qa)
- Run the API call and ensure you don't get any SQL
  calls for `SQL RubricAssociation Load` from the
  api/v1/planner/items call (in the server logs)
- Probably also try a graded quiz, but I don't think
  it loaded a rubric association for that

Change-Id: I67c71526eb02d7d40afc444e6b985ee388acc85a
Reviewed-on: https://gerrit.instructure.com/152529
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
QA-Review: Deepeeca Soundarrajan <dsoundarrajan@instructure.com>
Tested-by: Jenkins
Product-Review: Mysti Sadler <mysti@instructure.com>
2018-06-14 20:33:16 +00:00
Spencer Olson 23a1844903 add grader anonymity checkboxes
Adds the "Graders can view each other's comments", "Final Grader can
view other grader names", and "Graders cannot view each other's names"
checkboxes.

closes GRADE-1206

Test Plan:

Note: Any interactions between checkboxes and/or conditions that cause
checkboxes to be hidden/revealed/disabled/enabled will be tackled in
follow-up commits to this one. This commit is just the bare-bones
addition of three new checkboxes, and the ability to persist those
checkboxes' settings.

1. In a course, enable Anonymous Marking and Moderated Grading.
2. Create or edit an assignment, and verify the following two
   new checkboxes are available in the "Moderated Grading" section:
   "Graders can view each other's comments" and "Final grader can view
   other grader names". For new assignments, both of these checkboxes
   should default to being checked.
3. In the "Anonymous Grading" section, verify there is a checkbox for
   "Graders cannot view each other's names". The "Graders cannot view
   each other's names" checkbox should default to being unchecked.
4. Verify the checked settings of the checkboxes persist after saving
   the assignment. For the "Graders cannot view each other's names"
   checkbox state to be persisted as checked, the "Graders can view
   each other's comments" checkbox must also be checked.

Cosmetic Updates:
- The bold "Grade Anonymously" text has been removed from the "Graders
  cannot see student names" checkbox.
- Grammar update to the "Number of Graders" validation message when
  the input value exceeds the maximum graders, and the maximum grader
  count is 1. Changed from "There are currently 1 available graders" to
  "There is currently 1 available grader".

Change-Id: I143be77ef3f594acbc67428f20fe986138e56e87
Reviewed-on: https://gerrit.instructure.com/152729
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Tested-by: Jenkins
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
QA-Review: James Butters <jbutters@instructure.com>
Product-Review: Sidharth Oberoi <soberoi@instructure.com>
2018-06-13 22:03:39 +00:00
Matthew Berns e924133cb8 add hide_points to json response on lmgb
closes OUT-2300

test plan (dev-qa):
- create a new outcome
- create a new rubric and align the outcome
- align the rubric to a new assignment, ensure you
  choose the box to remove points from rubric
- assess a student
- go to the LMGB
- the outcome_rollups response should include a
  hide_points field in the json
- hide_points should be 'true' on the rollup for the new outcome
  with the newly created outcome
- attach the newly create outcome to a different assignment, one
  that doesn't have its points hidden on the rubric association
- assess the student
- return to lmgb
- hide_points should be 'false' for the rollup on the new outcome

Change-Id: I0f9accb4ff0cc76f40c08ce08e21091e35df6af8
Reviewed-on: https://gerrit.instructure.com/153547
Tested-by: Jenkins
Reviewed-by: Michael Brewer-Davis <mbd@instructure.com>
Reviewed-by: Augusto Callejas <acallejas@instructure.com>
Product-Review: Michael Brewer-Davis <mbd@instructure.com>
QA-Review: Michael Brewer-Davis <mbd@instructure.com>
2018-06-13 21:58:49 +00:00
Neil Gupta 6a659fbaa8 stop using anonymous moderated marking feature flag
fixes GRADE-976

test plan:
* Make sure the AMM flag is off
* All AMM features should be visible and work
* The Anonymous Marking and Moderated feature flags should be visible
* Toggling the AMM feature flag should do nothing

Change-Id: Ie0c52c23748389c6f5df5b85e8580bdf474c0a52
Reviewed-on: https://gerrit.instructure.com/152067
Reviewed-by: Adrian Packel <apackel@instructure.com>
Tested-by: Jenkins
Reviewed-by: Derek Bender <djbender@instructure.com>
QA-Review: James Butters <jbutters@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-06-12 20:58:47 +00:00
Mysti Sadler 07e31e0ad7 Only call submission_statuses_for once
refs ADMIN-1031

Test plan
- Set up some assignments in varying
  states of submission/grade/whatever
- Load /api/v1/planner/items for a user
  and ensure it doesn't make all 6 of the
  submission queries for every assignment

Change-Id: If22c3a3d74849c4bfdab401ce2da2caa07cda527
Reviewed-on: https://gerrit.instructure.com/152710
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Tested-by: Jenkins
QA-Review: Luke Kingsley <lkingsley@instructure.com>
Product-Review: Mysti Sadler <mysti@instructure.com>
2018-06-11 21:56:49 +00:00
Landon Gilbert-Bland eba5a00495 Finish up permission tray
Fixes COMMS-1159 COMMS-1129

Test Plan:
  * On the edit permission tray:
    - Notice that no notifications are displayed onBlur when you didn't
      change the role name
    - Notice that no notifications are displayed onBlur when you have a
      totally empty role name
    - If you change the role name to a new name that is not currently
      being used it pops up with a success message on blur
    - If you change the role name to a new name that is currently
      being used it pops up with an error message on blur
    - It no longer displayes the `changeBaseRole` dropdown menu
  * On the permission tray:
    - Notice that the `Changed By` field is gone, as we are not storing
      that information in the database
    - Notice that the `Assigned To` field is also gone.
    - If you change the role name, insure it will update the last
      changed date in the permission tray.
    - (once Sara's commit is in), notice that when you change a
      permission (role_override), the last changed date of the
      permission will also be updated
    - Make sure the last changed date is properly localized
  * Make sure the permissions tray works for account roles and course
    roles (using the tab switchet at the top of the page)

Change-Id: I9102d33b7a684c1a3b7f5a6fe4a67ecf678af8b0
Reviewed-on: https://gerrit.instructure.com/153013
Reviewed-by: Steven Burnett <sburnett@instructure.com>
Tested-by: Jenkins
QA-Review: Venk Natarajan <vnatarajan@instructure.com>
Product-Review: Landon Gilbert-Bland <lbland@instructure.com>
2018-06-11 21:19:44 +00:00
Mysti Sadler 8199ff9fc2 Preload Planner Overrides
refs ADMIN-1031

Test plan
- Set up a couple of planner items
  and make sure there are some overrides
  to check for (mark as complete or dismiss
  opportunities)
- Run the api/v1/planner/items call and ensure
  you don't get a planner_override sql call for
  every item

Change-Id: I8b4f468e3cb6177ced2aee3abec810a75d9aec9e
Reviewed-on: https://gerrit.instructure.com/152697
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Tested-by: Jenkins
QA-Review: Luke Kingsley <lkingsley@instructure.com>
Product-Review: Mysti Sadler <mysti@instructure.com>
2018-06-11 21:18:51 +00:00
Ed Schiebel 2729cabecd Include feedback in planner items
- skinnied down the feedback in the api to just the comment we want
- updated planner to show the feedback if it exists

closes ADMIN-1022

test plan
  - create an assignment, have the student submit an entry, have the
    teacher grade it and include a comment that's long enough that it
    gets truncated in the planner
  > expect the comment to show up with the item in the planner
  > expect the comment to be truncated with an ellipsis in desktop
    and tablet view

Change-Id: Ie540c6b11a95422fae3723f9a78e6bf68dbf10e9
Reviewed-on: https://gerrit.instructure.com/151377
Tested-by: Jenkins
Reviewed-by: Jon Willesen <jonw+gerrit@instructure.com>
QA-Review: Luke Kingsley <lkingsley@instructure.com>
Product-Review: Jon Willesen <jonw+gerrit@instructure.com>
2018-06-05 14:47:33 +00:00
Jacob Fugal 7f301937ea legacy api claims in inst-fs jwts for API clients
fixes RECNVS-471
fixes RECNVS-479

allows API requests from access tokens issued by whitelisted developer
keys to receive additional claims in the JWTs of inst-fs links in the
response. these additional claims are a workaround to cause inst-fs to
accept the link as if authenticated despite the client not having an
inst-fs session or presenting inst-fs with the access token.

updated API clients will need to present their API token when accessing
inst-fs links. once the clients associated with a developer key are
updated, the developer key will be removed from the whitelist. this is
only a temporary workaround.

test-plan:
- have inst-fs configured and enabled with your canvas instance
- generate a new access token for your user
- in the rails console of your canvas instance, set:
  Setting.set('instfs.whitelist_all_developer_keys', 'true')
- using something without a session, like postman, POST to
  /api/v1/courses/:course_id/files with a valid preflight and
  authenticated via the access token (e.g. using the `Authorization`
  header)
  - the `upload_url` in the response should be an inst-fs link
  - the `upload_url` should include a `token` query parameter with a JWT
    as the value
  - decoding the JWT from the `upload_url`, it should include
    `legacy_api_developer_key_id` and a `legacy_api_root_account_id`
    claims
- in the rails console of your canvas instance:
  Setting.remove('instfs.whitelist_all_developer_keys')
- repeat the upload preflight attempt from above
- this time, the JWT should not include the `legacy_api_*` claims

Change-Id: I911d18c031d9ba90de808e260e4644beaef69ff9
Reviewed-on: https://gerrit.instructure.com/151690
Tested-by: Jenkins
Reviewed-by: Jonathan Featherstone <jfeatherstone@instructure.com>
QA-Review: Collin Parrish <cparrish@instructure.com>
Product-Review: Jacob Fugal <jacob@instructure.com>
2018-06-04 17:04:06 +00:00
Cameron Sutter 080beef78d allow all observers
closes MBL-10561

test plan:
- go through all the observer_alerts & observer_alert_thresholds
  endpoints and use them with a course observer

Change-Id: I64b14746969727b69b047139fdceecb89f4c123a
Reviewed-on: https://gerrit.instructure.com/151107
Reviewed-by: Matthew Sessions <msessions@instructure.com>
Tested-by: Jenkins
QA-Review: Taylor Wilson <twilson@instructure.com>
Product-Review: Taylor Wilson <twilson@instructure.com>
2018-06-02 01:57:34 +00:00
Michael Brewer-Davis a84bd0f18e show quiz info in new student lmgb
closes OUT-2235

Test plan:
- Enable non-scoring rubrics
- Create a question bank aligned to an outcome
- Create a quiz using questions from the question
  bank
- As a student, take the quiz
- Go to the student lmgb
- Verify that the outcome result for the quiz
  shows the quizzes icon, and shows the name
  of the quiz rather than the name of the quiz bank

Change-Id: I413bb936c182485dbcc3d01c34fbb5f292856548
Reviewed-on: https://gerrit.instructure.com/150948
Reviewed-by: Augusto Callejas <acallejas@instructure.com>
Tested-by: Jenkins
QA-Review: Dariusz Dzien <ddzien@instructure.com>
Product-Review: Sidharth Oberoi <soberoi@instructure.com>
2018-06-01 22:17:51 +00:00
Neil Gupta 9b7ec59ee6 anonymize gradeable students endpoint
fixes GRADE-898 GRADE-1023

test plan:
1. create a course with 3 teachers and 1 student
2. create an anonymously graded and moderated assignment with 2 graders
3. as a teacher, give the student a provisional grade
4. as another teacher, give the student another provisional grade
5. as the final grader, visit the grade moderation page
6. inspect the API responses, there should be no identifiable ids or
  names in the responses
7. select a final grade
8. make sure the API request and response when selecting the final grade
  is also anonymous

Change-Id: I083673e29d4b49c1d97cedad46571bccc622a8a2
Reviewed-on: https://gerrit.instructure.com/151134
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: Keith T. Garner <kgarner@instructure.com>
2018-05-31 22:30:25 +00:00
Michael Brewer-Davis f27490c001 filter hidden outcome results in student lmgb
closes OUT-2236

Test plan:
- create two assignments with rubrics
- for one of the rubrics, set "Don't post Outcomes results to Learning
  Mastery Gradebook" to true.  For the other, leave unchecked.
- assess a student on each assignment using the rubric
- visit the student learning mastery gradebook
- verify that the assignment with "Don't post" selected is NOT
  included in the gradebook
- verify that the assignment without "Don't post" selected
  is included

Change-Id: I2ea3a9fb170e2f8ef626d0166b6dfabaeb6bc38f
Reviewed-on: https://gerrit.instructure.com/150977
Reviewed-by: Augusto Callejas <acallejas@instructure.com>
Reviewed-by: Frank Murphy <fmurphy@instructure.com>
Tested-by: Jenkins
QA-Review: Andrew Porter <hporter-c@instructure.com>
Product-Review: Sidharth Oberoi <soberoi@instructure.com>
2018-05-31 22:06:12 +00:00
Han Yan f9676125bb Qti import from Canvas to Quizzes.Next
refs QUIZ-4415

test plan:
- cr
- Quiz.Next CC import is not ready for test with only this patch
- regression on `Import Content`, to make sure:
  1) `Qti .zip file` import works
  2) `Common Catridge 1.x Package` import works

Change-Id: Iba2818a2b864020b6c59ef55e02f122b996e4c40
Reviewed-on: https://gerrit.instructure.com/149978
Reviewed-by: Andrew Butterfield <abutterfield@instructure.com>
Tested-by: Jenkins
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
QA-Review: David Tan <dtan@instructure.com>
Product-Review: Han Yan <hyan@instructure.com>
2018-05-31 16:57:32 +00:00
Jeremy Neander eed2cca7f5 create simple version of new moderation page
refs GRADE-964
refs GRADE-877
refs GRADE-1024

test plan:
 A. Setup
    1. Enable Anonymous Moderated Marking
    2. Select or create a course
       a. with Anonymous Marking enabled
       b. with three instructors (A, B, and C)
       c. with at least one student
    3. Select or create an assignment
       a. with Moderated Grading
       b. with instructor A as the final grader
    4. Select or create an assignment
       a. with Moderated Grading
       b. with Anonymous Grading
       c. with instructor A as the final grader
    5. As each instructor (B and C)
       a. give at least one student a provisional grade
          on each assignment (using SpeedGrader)
       * This SHOULD create a new moderation_grader for each user
         and for each assignment

 B. Verify the Non-Anonymous Assignment
    1. Log in or act as instructor A
    2. Visit the moderation page for the assignment
    3. Verify the assignment title is visible on the page
    4. Open the browser console
    5. View the contents of ENV.GRADERS
    6. Verify for both instructors B and C:
       a. user_id is present
       b. anonymous_id is NOT present
       c. grader_name is present

 B. Verify the Anonymous Assignment
    1. Log in or act as instructor A
    2. Visit the moderation page for the assignment
    3. Verify the assignment title is visible on the page
    4. Open the browser console
    5. View the contents of ENV.GRADERS
    6. Verify for both instructors B and C:
       a. anonymous_id is present
       b. user_id is present
       c. grader_name is NOT present

Change-Id: Id69f926972c1daaf8d7db5257f66b92e30a914fa
Reviewed-on: https://gerrit.instructure.com/151149
Reviewed-by: Derek Bender <djbender@instructure.com>
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
Tested-by: Jenkins
QA-Review: Indira Pai <ipai@instructure.com>
Product-Review: Sidharth Oberoi <soberoi@instructure.com>
2018-05-30 21:21:22 +00:00
Derek Bender b57cb8cbae add anonymous provisional grades controller
When loading or selecting a student in SpeedGrader, an ajax call is made
to obtain the provisional grade status for that student. This provides a
way to perform this request anonymously.

closes GRADE-1128

test plan
- given an anonymously graded and moderated assignment
- given some students assigned to said assignment
- when visiting speed grader
- then the page loads provisional grades endpoint which can be viewed in
  the dev tools on the network tab. The URL looks like:

  /api/v1/courses/1/assignments/1/anonymous_provisional_grades/status

Change-Id: Ib3d3a7b58fc8fa044d240dee0c1bef08b80384d0
Reviewed-on: https://gerrit.instructure.com/151607
Tested-by: Jenkins
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Spencer Olson <solson@instructure.com>
QA-Review: Indira Pai <ipai@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-05-30 17:40:14 +00:00
Augusto Callejas 3e2fdfd225 Outcome proficiency endpoints
closes OUT-1855, OUT-2214

test plan:
  - create an access token, which will be used below
    to perform HTTP requests, see:
    https://canvas.instructure.com/doc/api/file.oauth.html#using-access-tokens
  - using a tool like Postman, set an outcome proficiency
    for an account. perform a POST request at the endpoint
    `http://canvas.docker/api/v1/accounts/1/outcome_proficiency`
    with a `Content-Type` header value `application/json`
    and body with content like:

    {
      "ratings": [
        {
            "description": "great work",
            "points": 10,
            "mastery": true,
            "color": "00ff00"
        }
      ]
    }

  - retrieve the saved proficiency by performing GET request
    at the endpoint
    `http://canvas.docker/api/v1/accounts/1/outcome_proficiency`.
    it should match the proficiency created above.
  - update the proficiency by doing another POST request, but
    with multiple ratings, like:

    {
      "ratings": [
        {
            "description": "great work",
            "points": 10,
            "mastery": true,
            "color": "00ff00"
        },
        {
            "description": "bad work",
            "points": 0,
            "mastery": false,
            "color": "ff0000"
        }
      ]
    }
  - do a GET request to confirm the above changes were saved
  - do several other POST requests with multiple ratings
    that contain either multiple mastery ratings or none.
    these requests should fail with a 422 status code
    and an error message that contains `Only one rating can have mastery`.

Change-Id: Ib301c0394a99dbf55d7d85ceef28a95075faaec2
Reviewed-on: https://gerrit.instructure.com/150095
Reviewed-by: Frank Murphy <fmurphy@instructure.com>
Tested-by: Jenkins
Reviewed-by: Rob Orton <rob@instructure.com>
Reviewed-by: Matt Berns <mberns@instructure.com>
QA-Review: Andrew Porter <hporter-c@instructure.com>
Product-Review: Michael Brewer-Davis <mbd@instructure.com>
2018-05-29 22:20:03 +00:00
Mysti Sadler 03e6825862 Refactor planner items endpoint to prepare for calendar
Adds the `context_codes` param to the planner/items
endpoint to allow filtering for contexts like the
existing calendar endpoint allows.

This is primarily for laying the foundation
so that the planner items endpoint
can be used for both the planner and the calendar
since they share the same data.

closes ADMIN-930

Test Plan:
* Ensure planner APIs still return things correctly
  without context codes
* Send various context_codes to the API and ensure
  only items from that/those context_codes are returned

Change-Id: I3747ef82c382ca56b80ea97e740b70072179057b
Reviewed-on: https://gerrit.instructure.com/147880
Tested-by: Jenkins
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
QA-Review: Luke Kingsley <lkingsley@instructure.com>
Product-Review: Mysti Sadler <mysti@instructure.com>
2018-05-24 17:33:46 +00:00
Marc Phillips 489b5d6ecf Add require_scopes field to DevKey Management
Can now set whether a developer key require scopes or not.
Legacy behavior of scopes is to allow dev keys to have
access to all endpoints, this allows for the continuing
behavior.

Fixes: PLAT-3345

Test Plan:
 - Go to a create/upate a key
 - Notice the require scopes checkbox
 - Click the require scopes checkbox so that it is
   toggled off
 - Scopes ui should be removed and saving the key
   persists the state
 - attempt to access an endpoint using the changed
   endpoint that had scopes, it should be able to act
   like a legacy key
 - go back to the key management modal and flip the
   require scopes back to on.
 - attempt to access an endpoint that does not have a
   scope for the dev key, should fail
 - for a legacy key, the scopes ui should be off when
   first editing.

Change-Id: I0a53ff8a44b80081b518d780a8288f4cc4c36027
Reviewed-on: https://gerrit.instructure.com/150216
QA-Review: August Thornton <august@instructure.com>
Reviewed-by: Weston Dransfield <wdransfield@instructure.com>
Product-Review: Jesse Poulos <jpoulos@instructure.com>
Tested-by: Jenkins
2018-05-23 22:23:17 +00:00
Jeremy Stanley ca8d3de8af check :read_email_addresses permission in a few places
when this permission was created, we verified that it prevented
students from getting at other users' emails, but we failed to
anticipate taking it away from teachers and account admins

test plan:
 - create custom teacher and account admin roles that deny
   the "See other users' primary email address" permission
 - create a student with an email address (and to avoid confusion,
   ensure the student's name and login are not the email address)
 - ensure these users don't see the student's email in the following
   places:
   - /users/X (accessible only to the account admin)
   - /courses/X/users/Y (test with "Enable Profiles" on and off
     in account settings)
   - /api/v1/users/X/profile
   - other places that you might think of

fixes ADMIN-1049

Change-Id: Ie2a482df337f7e4baed1b71e14456f199aa8b595
Reviewed-on: https://gerrit.instructure.com/150293
Reviewed-by: Mysti Sadler <mysti@instructure.com>
QA-Review: Mysti Sadler <mysti@instructure.com>
Tested-by: Jenkins
Product-Review: Jeremy Stanley <jeremy@instructure.com>
2018-05-18 20:04:31 +00:00
Cameron Sutter a124defc21 get alerts by student
closes MBL-10123

test plan:
- with a user_observation_link and an observer_alert_threshold
  make observer_alerts in the rails console
- hit the endpoint
  /users/:user_id/observer_alerts/:student_id
- it should return all alerts for that observer/student

Change-Id: I01fe71e3414d63cedc0e02eaed4e0d8822f80fcf
Reviewed-on: https://gerrit.instructure.com/150143
Reviewed-by: Matthew Sessions <msessions@instructure.com>
Tested-by: Jenkins
QA-Review: Taylor Wilson <twilson@instructure.com>
Product-Review: Cameron Sutter <csutter@instructure.com>
2018-05-17 21:56:34 +00:00
Frank Murphy f2deabd4ac React Rubric component
Fixes OUT-2215

Test Plan
- Enable the non-scoring rubrics feature flag (note that due to caching
  you may need to wait for the feature to be truly enabled)
- Create a rubric with several criterion (outcomes and non-outcomes)
- Verify that the component looks correct in the LMGB assignments page
  for a given student:
  - Verify the Outcome icon is present next to criterion that are used
    for outcomes.
  - Verify the threshold for mastery points is displayed on outcomes
    criterion.
  - Create an assignment with a points-scale rubric. Assign points.
    Verify that the right columns are selected when graded.
  - Add comments to the points-scale rubric assignment. Verify they are
    displayed in the criterion heading.
  - Create a comment with newlines. Verify the line breaks are preserved
    when displaying the comment.
  - Create an outcome with a very long description. Use it in a rubric.
    Verify the "show long description" button is there and works
    properly.
  - Create an assignment with free-form comments. Grade an assignment,
    entering some free form comments. Verify the comments are presented
    instead of the points scale when displayed in LMGB.
  - Align to an assignment with total points hidden. Verify the total
    points are not present.

Change-Id: I305649237bdfaacc5001b75de3965bc12ff81298
Reviewed-on: https://gerrit.instructure.com/149468
Reviewed-by: Matt Berns <mberns@instructure.com>
QA-Review: Dariusz Dzien <ddzien@instructure.com>
Tested-by: Jenkins
Product-Review: Michael Brewer-Davis <mbd@instructure.com>
2018-05-16 22:33:53 +00:00
Michael Brewer-Davis 217477b119 Replace erb rubric with react
Change-Id: I55a371a34db75208d54d8370eba2718cc224ff8a
Reviewed-on: https://gerrit.instructure.com/148437
Reviewed-by: Michael Brewer-Davis <mbd@instructure.com>
Reviewed-by: Frank Murphy <fmurphy@instructure.com>
Tested-by: Jenkins
Product-Review: Michael Brewer-Davis <mbd@instructure.com>
QA-Review: Michael Brewer-Davis <mbd@instructure.com>
2018-05-16 21:51:34 +00:00
Omar Khan 96e7f9187e Only include quiz question_types in api responses
The Quiz#question_types method is expensive for large quizzes. It's
currently called every time a quiz is serialized, even though we only
need the question_types attribute in API responses (I believe it's used
by the mobile app).

This commit moves the question_types attribute to a separate
QuizApiSerializer that is only used in API responses.

Fixes QO-356
Fixes QO-357

Test plan:

- Create several huge quizzes (tens of thousands of questions across
  multiple question groups)
- Open the quizzes list page
- Check that the page loads reasonably quickly

Change-Id: Id18a32fc47f20cd24cb178e972f49e8984bfe53e
Reviewed-on: https://gerrit.instructure.com/149829
Reviewed-by: James Williams  <jamesw@instructure.com>
Tested-by: Jenkins
QA-Review: David Tan <dtan@instructure.com>
Product-Review: Omar Khan <okhan@instructure.com>
2018-05-15 20:12:16 +00:00
Xander Moffatt 2b9ccc7970 upload avatar images across shards
* tell user if avatar isn't properly saved after 5 seconds

closes RECNVS-421

test plan:
* (this needs to be on a cross-shard platform to work)
* enable instfs and User Avatars (in Admin > Settings)
* go to user profiles
* upload an avatar images
* verify that it goes through instfs
* and that it doesn't GET `/users/self/avatars` for more than 5 seconds

Change-Id: I5572d32a047479ff1b7e822e94c1729db7c6954c
Reviewed-on: https://gerrit.instructure.com/149618
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Tested-by: Jenkins
QA-Review: Collin Parrish <cparrish@instructure.com>
Product-Review: Jacob Fugal <jacob@instructure.com>
2018-05-11 19:21:15 +00:00
Mysti Sadler 759d7eda16 Move planner items to its own controller
closes ADMIN-1033

Test plan
- Ensure api/v1/planner/items and
  api/v1/planner/overrides(/:id)
  work as expected
- Specs pass

Change-Id: I4a1d5f8f81bb2bdd2eace8c61bc807d2f0457cdf
Reviewed-on: https://gerrit.instructure.com/149265
Tested-by: Jenkins
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Reviewed-by: Carl Kibler <ckibler@instructure.com>
QA-Review: Deepeeca Soundarrajan <dsoundarrajan@instructure.com>
Product-Review: Mysti Sadler <mysti@instructure.com>
2018-05-11 16:18:50 +00:00
Spencer Olson 12a3513bef moderated assignments: add grader count input
closes GRADE-974

Test Plan:
1. Enable Anonymous Moderated Marking at the account level.
2. Create a new assignment moderated assignment and verify there is
   an input to enter the number of graders.
3. Verify the default value for the input is 2, or if the class has
   <= 2 active instructors the default is 1.
4. Verify the following validations with the input:
   a. Clearing out the value and then tabbing away from the input
      results in an error message showing below the input.
   b. Entering 0 into the input results in an error message showing
      below the input.
   c. You can only enter positive, whole numbers.
   d. Entering a number > 10 results in a hint showing below the input.
   e. Entering a number > the number of active instructors in the
      course results in a hint showing below the input.
   f. Trying to save the assignment when there is invalid data in the
      input results in the assignment not being saved and an error
      tooltip showing for the input. Note that the cases covered in
      steps d and e above are not considered invalid, and therefore
      the assignment should still save successfully.
5. Verify you can save the assignment when you enter a valid grader
   count. Reload the page and verify the grader count has persisted.
6. Repeat steps 2-5, but update an assignment instead of creating a
   new one.
7. Verify you can set the grader_count on an assignment when creating
   it via the API (you must also set moderated_grading to true).

   POST /api/v1/courses/:id/assignments

8. Verify you can update the grader_count on an existing moderated
   assignment via the API.

   PUT /api/v1/courses/:course_id/assignments/:id

9. Disable Anonymous Moderated Marking at the account level. In a
   course, create or update an assignment and verify there is no
   'Number of graders' input.

Change-Id: I50d52a11051c60b59b06176ddd6bf975a567ee24
Reviewed-on: https://gerrit.instructure.com/148747
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Derek Bender <djbender@instructure.com>
Tested-by: Jenkins
QA-Review: James Butters <jbutters@instructure.com>
Product-Review: Sidharth Oberoi <soberoi@instructure.com>
2018-05-11 15:38:46 +00:00
Cameron Sutter a3f3ec6e81 add observer alert threshold CRUD
closes MBL-10122

test plan:
- do CRUD operations on the observer_alert_threshold endpoints
  /users/<id>/observer_alert_threshold[?student_id=<id>]
  and
  /users/<id>/observer_alert_threshold/<id>

Change-Id: I2c5c7700adaedd4a2068a61568217219b763339e
Reviewed-on: https://gerrit.instructure.com/149147
Reviewed-by: Matthew Sessions <msessions@instructure.com>
Product-Review: Matthew Sessions <msessions@instructure.com>
QA-Review: Matthew Sessions <msessions@instructure.com>
Tested-by: Jenkins
2018-05-10 20:25:01 +00:00
Dan Minkevitch 2391cd2d58 Add comment data to planner/items API
Closes ADMIN-1020

Test Plan:
* With student planner enabled
* As a student
* With a recent submission that has comments/feedback
* GET `api/v1/planner/items`, passing the parameters
  necessary to include the assignment for the aforementioned
  submission
* The response should include the assignment with a
  `submissions.feedback` key whose value is an array
  of hashes of submission comments containing
  the comment, author name, and author avatar url

Change-Id: Ib288330bd276e3c32f994e1cb2a178ecb3eb2ca3
Reviewed-on: https://gerrit.instructure.com/149562
Reviewed-by: Ed Schiebel <eschiebel@instructure.com>
Reviewed-by: Mysti Sadler <mysti@instructure.com>
Reviewed-by: Carl Kibler <ckibler@instructure.com>
Tested-by: Jenkins
QA-Review: Deepeeca Soundarrajan <dsoundarrajan@instructure.com>
Product-Review: Dan Minkevitch <dan@instructure.com>
2018-05-10 20:03:21 +00:00
Spencer Olson 6d2d2c648e backend: select final grader for moderated assignments
closes GRADE-973

Test Plan:
1. Enable Anonymous Moderated Marking at the account level.
2. Create a teacher in a course.
2. In the course, create a new moderated assignment.
3. In a rails console, assign the teacher as the final grader for the
   assignment.

   teacher = User.find(<teacher-id>)
   assignment = Assignment.find(<assignment-id>)
   assignment.update!(final_grader: teacher)

4. Deactivate the teacher's enrollment. Then, in a rails console,
   verify the assignment is valid and it still has the teacher
   assigned as the final grader.

   assignment.reload
   assignment.valid? # should return true
   assignment.final_grader_id # should return the teacher's ID

5. Reactivate the teacher's enrollment and then conclude it. Then, in
   a rails console, verify the assignment is valid and it still has the
   teacher assigned as the final grader.

   assignment.reload
   assignment.valid? # should return true
   assignment.final_grader_id # should return the teacher's ID

6. Unconclude the teacher's enrollment. Enroll the teacher in the
   course a second time, now as a TA. Then, delete the 'teacher'
   enrollment (leaving only the 'TA' enrollment). In a rails console,
   verify the assignment is valid and it still has the teacher assigned
   as the final grader.

   assignment.reload
   assignment.valid? # should return true
   assignment.final_grader_id # should return the teacher's ID

7. Delete the 'TA' enrollment for the teacher. Then, in a rails
   console, verify the assignment is valid and its final grader has
   been set to nil.

   assignment.reload
   assignment.valid? # should return true
   assignment.final_grader_id # should return nil

8. Verify the assignment's final_grader_id can be set to a valid
   final grader via the API.

   PUT /api/v1/courses/:course_id/assignments/:id?assignment[final_grader_id]=<valid-teacher-id>
     => should be successful

9. Verify that trying to set a student's ID as the final grader results
   in an error stating that the user does not have permission to select
   final grade.

   PUT /api/v1/courses/:course_id/assignments/:id?assignment[final_grader_id]=<a-student-id>
     => should return an error

Change-Id: If33ee8136a3ce9fe4588fa95e3aa7ecb91d7de60
Reviewed-on: https://gerrit.instructure.com/148549
Tested-by: Jenkins
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Adrian Packel <apackel@instructure.com>
QA-Review: Anju Reddy <areddy@instructure.com>
Product-Review: Sidharth Oberoi <soberoi@instructure.com>
2018-05-07 00:52:08 +00:00
wdransfield 6bfcac8e4f Allow setting developer key scopes via API
Closes PLAT-3313

Test Plan:
* Verify you can set scopes for developer keys in the
  create and update actions.
* Verify you can only specify valid scopes
* Verify developer key scopes are returned in JSON
  responses of API requests
* Verify the API token scoping FF must be enabled
  for these changes to work.

Change-Id: I2151c4ac98ae35287c5db6ea56887ba18a83d709
Reviewed-on: https://gerrit.instructure.com/148627
Tested-by: Jenkins
Reviewed-by: Andrew Butterfield <abutterfield@instructure.com>
Reviewed-by: Stewie aka Nicholas Stewart <nstewart@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: Weston Dransfield <wdransfield@instructure.com>
2018-05-03 21:39:20 +00:00
Mysti Sadler 2fe733666f Add calendar events to planner ui
closes ADMIN-971

Test plan
- Ensure calendar items from courses,
  groups, user and appointments show up
  on the planner with correct info
- Ensure all day events show up properly
- Ensure events group up with to do items
- Ensure item links to calendar and goes to
  the event (and opens it) when you click
  the link

Change-Id: I1a2ae654df785b0e2e8c010456ab6c666e0deabc
Reviewed-on: https://gerrit.instructure.com/148505
Tested-by: Jenkins
Reviewed-by: Ed Schiebel <eschiebel@instructure.com>
Reviewed-by: Carl Kibler <ckibler@instructure.com>
QA-Review: Ed Schiebel <eschiebel@instructure.com>
Product-Review: Christi Wruck
2018-05-03 00:27:25 +00:00
Jared Crystal 9bc71a7891 return correct versions of questions for quiz submissions
fixes QO-340

test plan:
 - to be tested in mobile app (or in browser + postman)
 - Create a quiz with an essay question
 - As a student, start taking the quiz
 - As a teacher, update the question to be a file upload question
   (can also change point value, question stem, title, etc)
 - As the student, resume the quiz on the app
   (or hit /api/v1/quiz_submissions/YOUR_QUIZ_SUBMISSION_ID/questions)
 - the question type should still be essay
 - other question details should reflect the original question from
   when you started the quiz as the student

Change-Id: Ie6be814d4b8c3b154cdb79f79766c5ac0a04bf45
Reviewed-on: https://gerrit.instructure.com/147893
Reviewed-by: Mark Grant <mgrant@instructure.com>
Tested-by: Jenkins
QA-Review: Sven Thirion <sthirion@instructure.com>
Product-Review: Kevin Dougherty <jdougherty@instructure.com>
2018-05-01 17:58:02 +00:00
Jeremy Neander 36d2ee1705 prevent unmuting some anonymous moderated assignments
closes GRADE-959

test plan:
 A. Setup
    1. Set Anonymous Moderated Marking to "ON"
       * Root Account Level Feature Flag
    2. Set Anonymous Marking to "ON"
       * Root Account > Course Level Feature Flag
    3. Create an anonymous Assignment

 B. Verify in New Gradebook
    1. Visit New Gradebook
    2. Mute the assignment from above
    3. Verify the option to Unmute is disabled
    4. Verify other assignments can be muted and unmuted

 C. Verify in Old Gradebook
    1. Visit Old Gradebook
    2. Mute the assignment from above
    3. Verify the option to Unmute is disabled
    4. Verify other assignments can be muted and unmuted

Change-Id: Iafcf18db396b4150efeb415aba5e3cb55dcfffa3
Reviewed-on: https://gerrit.instructure.com/148100
Tested-by: Jenkins
Reviewed-by: Adrian Packel <apackel@instructure.com>
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
QA-Review: Indira Pai <ipai@instructure.com>
Product-Review: Sidharth Oberoi <soberoi@instructure.com>
2018-05-01 17:10:43 +00:00
James Williams 2b70f8f403 don't include test/completed students in section/topic counts
test plan:
* the announcements index should not include test
 students or completed students in the user counts
 on the tooltips

closes #COMMS-1093

Change-Id: I2104f63e5ded6578b3bc80a187668337361ca5c0
Reviewed-on: https://gerrit.instructure.com/148572
Tested-by: Jenkins
Reviewed-by: Steven Burnett <sburnett@instructure.com>
QA-Review: Aaron Kc Hsu <ahsu@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
2018-05-01 12:31:24 +00:00
Mysti Sadler 382e7bc756 API changes to add calendar events to planner
closes ADMIN-970

Test plan
- Add some calendar events, including a course
  event, a user event, a group event and an
  appointment group appointment
- Go to /api/v1/planner/items and ensure all
  of the items show up with the appropriate
  info

Change-Id: I5b0dc6402a98c5018d3597a3474d6a4a68ad3ae7
Reviewed-on: https://gerrit.instructure.com/148244
Tested-by: Jenkins
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
QA-Review: Deepeeca Soundarrajan <dsoundarrajan@instructure.com>
Product-Review: Mysti Sadler <mysti@instructure.com>
2018-04-30 17:16:56 +00:00
wdransfield 290809bd36 Fix disabled control on binding create
Fixes PLAT-3299

Test Plan:
- Create a site admin devleoper key and set it to 'allow' and 'visible'
- From a root account view the inherited key and set its workflow state
  to 'off'
- Verify the workflow state control is not disabled
- Verify key inheritance and workflow state is properly displayed

Change-Id: I7602ae0a570125f9022ee697c8369e11d662a473
Reviewed-on: https://gerrit.instructure.com/148252
Reviewed-by: Marc Alan Phillips <mphillips@instructure.com>
Tested-by: Jenkins
QA-Review: August Thornton <august@instructure.com>
Product-Review: Weston Dransfield <wdransfield@instructure.com>
2018-04-27 13:32:06 +00:00
Cody Cutrer 41794a9383 rename AccountAuthorizationConfig* to AuthenticationProvider*
I couldn't take it anymore. it was driving me crazy

Change-Id: Ib40addff56e98a6e0a6d80f246c208e0ce0cb762
Reviewed-on: https://gerrit.instructure.com/148026
Tested-by: Jenkins
Reviewed-by: James Williams  <jamesw@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2018-04-26 16:03:47 +00:00
Omar Khan 6cce67989b Add duplicated_successfully to assignment update
Closes QUIZ-3761

Test plan:

- Log in as admin or teacher
- Create an API access token by following the instructions here:
  https://community.canvaslms.com/docs/DOC-10806-4214724194
- Make a note of the token
- Create a Quizzes.Next assignment
- Go back to the assignments page
- Click the kebab menu on the assignment and click 'Duplicate'
- Find the id of the new, duplicating assignment. You can do this by
  running `Assignment.last.id` in a canvas rails console. Make a note of
  this id
- Notify canvas that the assignment has duplicated successfully by
  running:

    curl -v -XPUT \
      -H 'Authorization: Bearer <token>' \
      -H 'Content-Type: application/json' \
      -d '{"assignment": {"duplicated_successfully": true}}' \
      http://canvas.docker/api/v1/courses/<course_id>/assignments/<id>

  where <token> is the API access token created earlier, <course_id> is
  the id of the course, and <id> is the id of the duplicating assignment
  you made a note of earlier.
- Refresh the assignments page
- Check that the assignment is now in the "unpublished" state
- Repeat these steps, but this time with

    {"assignment": {"duplicated_successfully": false}}

  as the request body
- Refresh the assignments page
- Check that the assignment is now in the "failed_to_duplicate" state

Change-Id: Ief72eb84fc711207bea43c66b866710489235280
Reviewed-on: https://gerrit.instructure.com/147483
Tested-by: Jenkins
Reviewed-by: Jeff Belser <jbelser@instructure.com>
Product-Review: Jeff Belser <jbelser@instructure.com>
2018-04-24 19:15:02 +00:00
Rob Orton 3d894486c0 optionally include account object in course api
refs gh-1273

test plan
 - course api include account should work

Change-Id: If4dbd24c70fdb5f9502cd65b031466334b7b9c0d
Reviewed-on: https://gerrit.instructure.com/146762
Tested-by: Jenkins
Reviewed-by: Spencer Olson <solson@instructure.com>
QA-Review: Tucker McKnight <tmcknight@instructure.com>
Product-Review: Rob Orton <rob@instructure.com>
2018-04-18 23:29:38 +00:00
Marc Phillips a2d39f1350 Hide Inherited Dev Key Information
Removes all but the name, workflow_state, and id of the inherited
developer keys. Also addes the developers key that are inherited
to a different tab.

closes PLAT-3244, PLAT-3207, PLAT-3247

Test Plan:
 - Go to the Developer Key page for site admin and create a few keys
    - One with off, one with on, and one with allow
    - Make sure that the feature flag is turned on
    - Click the visibility (eye) icon to enable visibility of each
 - Go to the developer key page for a root admin
    - Note that the inherited tab has the three keys
    - If key is on, should be set to on in the inherited tab and can't 
      change
    - If key is off, shoudl be set to off in the inherited tab and can't
      change
    - If allowed, should be set to allowed and can change
      - Change this key in the root page to on or off, refresh, note
        that state persists
      - Go back to site admin page, change the allow to on or off
      - Go back to the root page and note that the state has been
        overridden and can't change
 - Create a key for the root account and refresh page
    - Note that the root account keys are still in the main tab
 - Create more than 11 root account keys, refresh page, and note that
   it is now paginated
     - Click the show more button, all the remaining keys should appear
 - Go back to the site admin page, create more than 11 keys
 - Go back to the root admin page, click on the inherited tab, and see
   that the show more button appears
     - Click the show more button; all the keys should appear
 - Go back to the site admin page and turn off the visibility of all the
   keys
 - Go back to the root admin page, click on the inherited tab, and note
   that none of the keys are now visible

Change-Id: Ib666cb33636b1582108dcc4a8822c8625c633157
Reviewed-on: https://gerrit.instructure.com/145427
Reviewed-by: Stewie aka Nicholas Stewart <nstewart@instructure.com>
Product-Review: Marc Alan Phillips <mphillips@instructure.com>
Tested-by: Jenkins
QA-Review: August Thornton <august@instructure.com>
2018-04-18 21:43:24 +00:00
Cameron Sutter f30fd7ca39 group_id in discussions api
closes MBL-10278

test plan:
- fetch a group discussion from the discussion index & show api endpoints
- the attribute "group_topic_children" should return an array of:
  {id: <id>, group_id: <group_id}

Change-Id: Ibf095ae64e2bd906758e6641c49f2766399e2c7f
Reviewed-on: https://gerrit.instructure.com/147207
Tested-by: Jenkins
Reviewed-by: James Williams  <jamesw@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Taylor Wilson <twilson@instructure.com>
Product-Review: Gentry Beckmann <gbeckmann@instructure.com>
2018-04-17 23:59:03 +00:00
Rob Orton e5d201e1f0 doc: add missing optional include to course api
fixes gh-1273

test plan
 - rake doc:api should work

Change-Id: I5dcc154eca68c789395ffe9f0297d04b66821823
Reviewed-on: https://gerrit.instructure.com/146733
Reviewed-by: Spencer Olson <solson@instructure.com>
Tested-by: Jenkins
Product-Review: Rob Orton <rob@instructure.com>
QA-Review: Rob Orton <rob@instructure.com>
2018-04-11 23:27:19 +00:00
Michael Jasper 8b68669aa7 Add instfs_uuid to attachment api calls
closes RECNVS-404

test plan:
 - a request for an attachment which includes `?include[]=instfs_uuid`
   returns the instfs_uuid property for the attachment

Change-Id: If2ecaf43807be1a4f1c0489dc30af6e5ef7c4e76
Reviewed-on: https://gerrit.instructure.com/145949
Reviewed-by: Jacob Fugal <jacob@instructure.com>
QA-Review: Collin Parrish <cparrish@instructure.com>
Tested-by: Jenkins
Product-Review: Michael Jasper <mjasper@instructure.com>
2018-04-09 18:47:37 +00:00
Jeremy Stanley 7bfe0ac4b6 fix user_search permissions
test plan:
 - enable the "Account Course and User Search" feature
 - ensure "See other users' primary email address"
   permission is required to find by email address
 - ensure "Read SIS data" or "Manage SIS data" is
   required to find by SIS ID
 - ensure "View login ids for users" is required
   to find by login ID
 - ensure you can find users by canvas ID and name
   in the same search (where one user's name matches
   another user's ID)

also:
 - ensure students cannot use the include[]=email
   option in the "List users in course" API to
   retrieve email addresses of other students
   (unless granted "See other users' primary
   email address" permission)

fixes ADMIN-836

Change-Id: I9c0a1ba9a643632047f42dc010822b6e5035d0d4
Reviewed-on: https://gerrit.instructure.com/143915
Reviewed-by: Mysti Sadler <mysti@instructure.com>
QA-Review: Deepeeca Soundarrajan <dsoundarrajan@instructure.com>
Product-Review: Matt Goodwin <mattg@instructure.com>
Tested-by: Jenkins
2018-04-09 17:19:56 +00:00
wdransfield 0d02c912f7 Don't do binding query without FF enabled
Closes PLAT-3256

Test Plan:
- Turn off all developer key feature flags.
- Visit the /developer_keys page and
  verify no queries for developer key account
  bindings occur.

Change-Id: I06b6783f29f227e446346b00a8c5431ccaf6b306
Reviewed-on: https://gerrit.instructure.com/145887
Product-Review: August Thornton <august@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Tested-by: Jenkins
Reviewed-by: Nathan Mills <nathanm@instructure.com>
2018-04-04 20:28:59 +00:00
Brent Burgoyne ce3379a3ac add success include param for upload preflight
refs CORE-20

test plan:
- test file upload api with success_include[]=avatar on the preflight
  request
- the final response on success should include the avatar property
- test with local storage, s3, and InstFS

Change-Id: I974197944d0f84ad0b89a628ab8604f50cdec45e
Reviewed-on: https://gerrit.instructure.com/144456
Reviewed-by: Ryan Shaw <ryan@instructure.com>
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Tested-by: Jenkins
QA-Review: Tucker McKnight <tmcknight@instructure.com>
Product-Review: Brent Burgoyne <bburgoyne@instructure.com>
2018-04-04 19:45:50 +00:00
Aaron Kc Hsu 4d3dbe196e Add last attended date to enrollments API endpoint
fixes COMMS-1024

Test Plan
* make sure profiles are off and avatars
* go to a student enrolled in a course
* find the student enrollment on a course
example /courses/11/users/2
* Click more details and add a last attended date to the user
* use the api such as the bottom to get all enrollments for
the course
* curl http://localhost:3000/api/v1/courses/11/enrollments
or do something to get the request.. you can visit the url
with canvas running
* make sure that date you set shows up

Change-Id: Idf3dbd39192f1fe3c6088c8fc45a4112994b3419
Reviewed-on: https://gerrit.instructure.com/145253
Reviewed-by: Steven Burnett <sburnett@instructure.com>
Reviewed-by: Venk Natarajan <vnatarajan@instructure.com>
QA-Review: Landon Gilbert-Bland <lbland@instructure.com>
Product-Review: Aaron Kc Hsu <ahsu@instructure.com>
Tested-by: Jenkins
2018-04-02 16:05:39 +00:00
Jacob Fugal 9265aa5c56 return progress from legacy upload via url
fixes RECNVS-401

the javascript has already been adapted to expect a progress instead of
the file status blob, that's what causes the bug. give it what it
expects. the progress results are populated during Attachment#clone_url,
and the progress is flagged completed once the worker successfully
completes the job.

test-plan:
 - with inst-fs turned off in the account
 - have a course with the Google Drive LTI tool enabled
 - have a file upload assignment in that course
 - as a student in the course, click "Submit Assignment" on the file
   upload assignment
 - choose the Google Drive tab, authorize a google account, select a
   file from the drive, and click submit.
 - submit the assignment with the selected file; the submission should
   go through without error (will give an error at this point without
   this commit)
 - click the link to download the submission; should download

Change-Id: I43e991f419a9f81359145d9f40899ecc82675da0
Reviewed-on: https://gerrit.instructure.com/145403
Reviewed-by: Michael Jasper <mjasper@instructure.com>
Tested-by: Jenkins
Reviewed-by: Andrew Huff <ahuff@instructure.com>
QA-Review: Collin Parrish <cparrish@instructure.com>
Product-Review: Jacob Fugal <jacob@instructure.com>
2018-03-30 20:56:22 +00:00
wdransfield ed4fec7627 Allow setting developer key binding state
Closes PLAT-3196, PLAT-3210, PLAT-3017

Test Plan:
- Create a developer key in site admin
- Verify in the DB a DeveloperKeyAccountBinding is
  created for that key and associated to the site
  admin account. The workflow state of the binding
  should be 'allow'
- Set the developer key visible to true
- Navigate to a root account.
- Verify the site admin key is visible and set to 'allow'
- In the root account UI change the visiblity to 'on'
- Refresh the page and verify the change persisted
- In the site admin UI turn the developer key to 'off'
- In the root account UI verify the key is now set to 'off'
  and the control is disabled.
- In the site admin account UI set the status to 'allow'
- In the root account verify the key status has been
  changed back to 'on' and is no longer disabled.
- Create a key in the root account and verify you can
  succesfully change its binding status to 'allow', 'off',
  and 'on'
- Try any other combinations of keys and states you can think of.
  The binding state set at the site admin level shoud always override
  the state set in the root account.
- Turn off the dev key rewrite feature flags and verify the old UI
  works as before

Change-Id: I50e92e75447529ece7a27a5b9f4b0009f8d1288e
Reviewed-on: https://gerrit.instructure.com/144248
Tested-by: Jenkins
Reviewed-by: Stewie aka Nicholas Stewart <nstewart@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: Karl Lloyd <karl@instructure.com>
2018-03-30 16:13:53 +00:00
Jeremy Stanley 781c79cd1f use `page_id` as WikiPage idAttribute
rather than `url`, which can clash with Backbone's cid

test plan:
 - create a course containing Pages named "C1", "C2", ..., "C9"
 - ensure all pages appear on the Pages index,
   without needing to re-sort the list
 - regression test creating and editing wiki pages from the UI

fixes ADMIN-903

Change-Id: I6fcada03eb843625370f211cca23f15a73580629
Reviewed-on: https://gerrit.instructure.com/145081
Tested-by: Jenkins
Reviewed-by: Dan Minkevitch <dan@instructure.com>
QA-Review: Deepeeca Soundarrajan <dsoundarrajan@instructure.com>
Product-Review: Jeremy Stanley <jeremy@instructure.com>
2018-03-29 15:36:35 +00:00
Matt Sessions 94d34bf283 Add includes to show discussion
Refs MBL-9902

The show discussion endpoint did not
accept any include parameters. Added
all_dates, sections, sections_user_count,
and overrides

Test Plan:
 - Create a discussion that is section specific
   and has a due date and has overrides
 - Hit /courses/:courseID/discussions/:discussionID
 - It should just give you back the discussion with the
   assignment
 - Include ?include[]=all_dates
 - It should include all_dates on the assignment
 - Include ?include[]=overrides
 - It should include overrides on the assignment
 - Include ?include[]=sections
 - It should include sections on the discussion
 - Include ?include[]=sections&include[]=sections_user_count
 - It should include the user count on the section
 - Hit /courses/:courseID/discussions
 - It should not include the overrides on the assignment
 - Include ?include[]=overrides
 - It should include the overrides on the assignment

Change-Id: I41820dc47720152ef6494d1b0a3428e07272e645
Reviewed-on: https://gerrit.instructure.com/145060
Tested-by: Jenkins
Reviewed-by: Cameron Sutter <csutter@instructure.com>
QA-Review: Landon Gilbert-Bland <lbland@instructure.com>
Product-Review: Matthew Sessions <msessions@instructure.com>
2018-03-28 16:00:19 +00:00
Omar Khan db95fee9b1 Add duplicating states to Assignment model
Closes QUIZ-3753

Test plan:

- Create an assignment
- Click on the assignment's kebab menu and select 'Duplicate'
- Open a rails console with:
  `docker-compose run --rm web bundle exec rails console`
- In the rails console, fetch the duplicate assignment:
  `assignment = Assignment.last`
- Put the assignment in the 'duplicating' state:
  `assignment.update!(workflow_state: 'duplicating')`
- Refresh the assignment list, check that a spinner and 'Making a copy'
  text appear as per the mockup
- Put the assignment in the 'failed_to_duplicate' state:
  `assignment.update!(workflow_state: 'failed_to_duplicate')`
- Refresh the assignment list, check that a 'Something went wrong'
  message, 'Retry' and 'Cancel' buttons appear as per the mockup
- Click the 'Cancel' button, check that assignment disappears
- Repeat the above steps and click the 'Retry' button, check that it
  duplicates the assignment

Change-Id: Id594395d27dc05c07e621974875281341fa4390a
Reviewed-on: https://gerrit.instructure.com/144512
Tested-by: Jenkins
Reviewed-by: Steve Kacsmark <skacsmark@instructure.com>
QA-Review: Michael Hargiss <mhargiss@instructure.com>
Product-Review: Kevin Dougherty <jdougherty@instructure.com>
2018-03-28 15:55:32 +00:00
Dan Minkevitch d482af4ddc Remove duplicate teacher entries for course API
Fixes ADMIN-829

Test Plan:
* Turn on the new Course and User search feature option
  at the account level
* Create a course with multiple sections and enroll two
  teachers in one of the sections
* Add one of the teachers as a teacher to the second section
* View the Courses page at the account level and notice the
  Show More link is not displayed under the list of teachers
  for the course

Change-Id: If8fce197b5e0c3edb93027f04769476e1e7e0d7f
Reviewed-on: https://gerrit.instructure.com/144170
Tested-by: Jenkins
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Product-Review: Dan Minkevitch <dan@instructure.com>
QA-Review: Dan Minkevitch <dan@instructure.com>
2018-03-20 21:42:55 +00:00
Rob Orton 75b43f1b2e remove old unused setting
Change-Id: Ia1477ba32f8424f3e5e00e4fb69136b3b1aaea53
Reviewed-on: https://gerrit.instructure.com/144172
Tested-by: Jenkins
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Product-Review: Rob Orton <rob@instructure.com>
QA-Review: Rob Orton <rob@instructure.com>
2018-03-20 19:05:46 +00:00
Jacob Fugal 2bdca4957e consider request host when choosing oauth host
fixes RECNVS-361

instead of just using Attachment.current_root_account.domain

to facilitate the change, all generation of non-public links to external
file storage go through a FileAuthenticator instance that holds the
necessary information about the current user and oauth host

test-plan:
[locally]
- smoke test file uploads and downloads, there should be no impact on
  behavior, just a refactor
[once on beta]
- enable inst-fs in your sandbox
- logout of canvas
- open network logging in your browser dev tools and log back in to
  canvas
- identify the requests related to the inst-fs login pixel and
  corresponding oauth redirects
- the oauth should have occurred against your beta sandbox, not your
  production sandbox
- attempt to upload a file; should be successful

Change-Id: Ic859b707908baef84f5ee4dba29f18bdd841abcc
Reviewed-on: https://gerrit.instructure.com/143930
Tested-by: Jenkins
Reviewed-by: Michael Jasper <mjasper@instructure.com>
QA-Review: Collin Parrish <cparrish@instructure.com>
Product-Review: Jacob Fugal <jacob@instructure.com>
2018-03-20 04:25:18 +00:00
Adrian Packel 7517bc628c Add anonymous grading assignment field
Add an "anonymous grading" field to the Assignment object, and add a
checkbox for it in the assignment UI that appears when the feature flags
for anonymous moderated marking (the base flag) and AMM-related
anonymous grading are enabled.

closes GRADE-949

Test plan:
  * Run the attached migration and make sure there are no errors.
    Afterward, open up a database console and check that there
    are no values in the new column:

    > select * from assignments where anonymous_grading is null;

    The above query should return zero rows.
  * Make sure that undoing the migration using db:migrate:down
    properly deletes the new column (remember to re-run the
    migration before continuing!).
  * Enable Anonymous Moderated Marking at the account level if not
    already enabled. Create a new course and turn on the new
    Anonymous Marking flag for it.
  * Create an assignment and edit it.
  * There should be an "anonymous grading" checkbox on the edit page,
    and if you check (or uncheck) it its value should persist between
    views of the page.
  * Check that if you turn the new anonymous grading flag off for the
    course and edit the assignment again, the checkbox is no longer
    present.

Change-Id: Ie8955644d78243008bdcd51a05689c093d5d8a8b
Reviewed-on: https://gerrit.instructure.com/143402
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins
Reviewed-by: Shahbaz Javeed <sjaveed@instructure.com>
Reviewed-by: Derek Bender <djbender@instructure.com>
Reviewed-by: Spencer Olson <solson@instructure.com>
QA-Review: Indira Pai <ipai@instructure.com>
Product-Review: Sidharth Oberoi <soberoi@instructure.com>
2018-03-19 17:47:56 +00:00
Stewie (Nicholas Stewart) f764613419 Add dev key visible to api
Refs: PLAT-3184

Test Plan:  Visible attribute should be in the dev key api

Change-Id: I0bfb76d9d0c40434ea12495dd1b24b32e5d6e4b3
Reviewed-on: https://gerrit.instructure.com/142847
Tested-by: Jenkins
Reviewed-by: Weston Dransfield <wdransfield@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: Stewie aka Nicholas Stewart <nstewart@instructure.com>
2018-03-19 15:49:29 +00:00
Mysti Sadler a242a38e50 Order planner queries by overridden due dates
fixes ADMIN-131

Test plan
- Set up user with several assignments with
  as many types of overrides as possible
- (User in multiple sections with different
  due dates, user with an ad-hoc override,
  overrides that don't override the due date, etc)
- Ensure the API returns the items in the correct
  order (assuming the user has a due date for the
  item)
- Check the same with ungraded quizzes
- Ensure the plannable_date is the correct date
  for the user
- Turn off Canvas Planner and check to make sure
  the to do list works correctly

Change-Id: Ie38900ac645804867823ed24b59f228cefef7f51
Reviewed-on: https://gerrit.instructure.com/142412
Tested-by: Jenkins
QA-Review: Deepeeca Soundarrajan <dsoundarrajan@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Product-Review: Mysti Sadler <mysti@instructure.com>
2018-03-13 19:09:19 +00:00
Andrew Huff c15f938cb7 canvas upload via url
closes RECNVS-329

test plan: (joint with g/142642)

Change-Id: I32df18bdc91451e67bb83fbcc68b3f0629444ad6
Reviewed-on: https://gerrit.instructure.com/142732
Reviewed-by: Jacob Fugal <jacob@instructure.com>
QA-Review: Collin Parrish <cparrish@instructure.com>
Tested-by: Jenkins
Product-Review: Jacob Fugal <jacob@instructure.com>
2018-03-11 19:37:47 +00:00
Jacob Fugal cfc4e74055 use api_attachment_preflight with /files/pending
fixes RECNVS-237

simplify FilesController#create_pending (which corresponds to the
POST /files/pending route) to do its preflight setup through
api_attachment_preflight. this makes it consistent with other preflight
endpoints, particularly so inst-fs gets used when enabled.

cascaded implications:
* FilesController#create for local uploads is removed in favor of
  FilesController#api_create + FilesController#api_create_success
* FilesController#s3_success for s3 uploads is removed in favor of
  FilesController#api_create_success
* FilesController#render_attachment_json is removed (was only used by
  the previous two removed methods) in favor of the attachment_json
  returned by #api_create_success
* JavaScript performing uploads through /files/pending now expects an
  {<attachment fields>} shaped response in line with
  attachment_json
* JavaScript performing uploads through /files/pending now expects a
  'content-type' field in the response instead of 'content_type', in
  line with attachment_json

as part of the cleanup, the duplicate_handling parameter was renamed to
on_duplicate to match other preflight endpoints, and the size parameter
was added to the request for quota checking

test-plan:
- generally, uploads that go through /files/pending:
  - still work
  - work with instfs
- specifically, the uploads that go through /files/pending are:
  - uploading an image as an avatar in the user profile
  - submitting an assignment via file upload
  - conversation messages with attached files
  - uploading a file to an eportfolio
  - upload image from wiki sidebar (w/o RCE enabled)
  - upload files from wiki sidebar (w/o RCE enabled)
- of particular interest to confirm beyond just "appears to work" are:
  - attachment(s) are associated with conversation message correctly
    after upload
  - attachment(s) are associated with submission correctly after upload
  - images uploaded to eportfolio are recognized as images
  - video files uploaded via wiki sidebar are recognized as video
  - image files uploaded via wiki sidebar are recognized as images

Change-Id: I463b3746e8e99a5e503df302664122bf364771c1
Reviewed-on: https://gerrit.instructure.com/141859
Tested-by: Jenkins
QA-Review: Collin Parrish <cparrish@instructure.com>
Reviewed-by: Jonathan Featherstone <jfeatherstone@instructure.com>
Product-Review: Jacob Fugal <jacob@instructure.com>
2018-03-09 23:16:14 +00:00
Jacob Fugal 7a2323afee include progress results in progress_json
refs RECNVS-331

allows simplifying course link validator to use progress_json

test-plan: N/A

Change-Id: I88bf27298773a40cf9bec0152093bbc8da9bed40
Reviewed-on: https://gerrit.instructure.com/142641
Tested-by: Jenkins
Reviewed-by: James Williams  <jamesw@instructure.com>
QA-Review: Collin Parrish <cparrish@instructure.com>
Product-Review: Jacob Fugal <jacob@instructure.com>
2018-03-09 23:12:53 +00:00
Shahbaz Javeed 04349fe757 run DueDateCacher only once for some bulk operations
closes GRADE-927

test plan:
* Create a course with an assignment and a quiz
* Enroll three students in the course
* For the assignment
  - Add two overrides with one student in each and ensure the
    "Everyone Else" group isn't present in any overrides
  - Observe the Rails logs while saving this to ensure DueDateCacher
    runs only once
  - Verify DueDateCacher only runs for the assignment and recalculates
    grades at the same time
  - Edit the assignment and submit without any changes
  - Verify DueDateCacher does not run
* For the quiz
  - Add two overrides with one student in each and ensure the
    "Everyone Else" group isn't present in any overrides
  - Observe the Rails logs while saving this to ensure DueDateCacher
    runs only once
  - Verify DueDateCacher only runs for the assignment and recalculates
    grades at the same time
  - Edit the assignment and submit without any changes
  - Verify DueDateCacher does not run
* For the Course
  - From the Course settings page, Copy the course with the following
    settings:
    > Change the start date to one year out
    > Choose "Shift dates" for the Date adjustment
  - Observe the Rails logs while saving this to ensure DueDateCacher
    runs only once
  - Verify DueDateCacher only runs for the course

Change-Id: Ia97620132f3f1ccc42668610deb125e67c45bd9a
Reviewed-on: https://gerrit.instructure.com/142197
Reviewed-by: Spencer Olson <solson@instructure.com>
Tested-by: Jenkins
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
QA-Review: Indira Pai <ipai@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-03-08 19:45:59 +00:00
Jacob Fugal e60143748d user real user when available in instfs JWTs
refs RECNVS-264

but still pass the @current_user for access and upload JWTs, so that it
can go in a separate claim if its different

test-plan:
- smoke test an inst-fs upload. should still work

Change-Id: I4be9cd4049c83848e69aae37500ae9f4b96392b4
Reviewed-on: https://gerrit.instructure.com/142334
Tested-by: Jenkins
Reviewed-by: Michael Jasper <mjasper@instructure.com>
QA-Review: Jonathan Featherstone <jfeatherstone@instructure.com>
Product-Review: Jacob Fugal <jacob@instructure.com>
2018-03-06 20:44:27 +00:00
Augusto Callejas 412e49baee Outcome import creation/status endpoints
closes OUT-1534

Scheduling of outcome import jobs will occur in a separate PS,
after this merges and OUT-1997 is merged too.

test plan:
  - start up canvas
  - generate api docs:
    > docker-compose run --rm web bundle exec rake doc:api
  - load api docs in http://canvas.docker/doc/api/index.html
  - read over the "Outcomes CSV Format" and make sure it reads well
  - read over the "Outcomes Import" and make sure it reads well
  - obtain an access token:
    https://community.canvaslms.com/docs/DOC-10806-4214724194
  - request an outcome import, replace "canvas-path" and "token" values:
    curl -F attachment=@<canvas-path>/spec/lib/outcomes/fixtures/demo.csv \
         -F 'import_type=instructure_csv' \
         -H "Authorization: Bearer <token>" \
         http://canvas.docker/api/v1/accounts/1/outcome_imports
  - in a rails console, confirm that the import was accepted:
    > docker-compose run --rm web bin/rails console
    % pp OutcomeImport.last
    # confirm that the import is in the 'created' state, associated with
      your user and associated with an account context
    # note the "id" value for later use
    % pp OutcomeImport.last.attachment
    # confirm that the attachment is in the 'processed' state and has
      the filename "test_outcomes_1.csv" passed in above
  - request the status of the outcome import (should return a message
    saying "The specified resource does not exist"):
    curl -H "Authorization: Bearer <token>" \
         http://canvas.docker/api/v1/accounts/1/outcome_imports/latest
  - back in the rails console created above, manually transition
    the import to "importing":
    % OutcomeImport.last.job_started
  - run the above curl command again, and this time the latest outcome
    import should be returned, in the 'importing' state
  - run the above curl command again, replacing "latest" with the "id"
    value obtained above. it should return the same response as the
    previous step.

Change-Id: Ice7d67b625b443cec70f531f2e673face6d6fbeb
Reviewed-on: https://gerrit.instructure.com/142024
Reviewed-by: Neil Gupta <ngupta@instructure.com>
Reviewed-by: Frank Murphy <fmurphy@instructure.com>
Tested-by: Jenkins
QA-Review: Frank Murphy <fmurphy@instructure.com>
Product-Review: Neil Gupta <ngupta@instructure.com>
2018-03-05 19:22:03 +00:00
Rob Orton 9c06bf6d91 add timestamps to account report api
fixes CORE-1076

test plan
 - specs should pass

Change-Id: Id0b88c21a606a69ec5663864f4303ba95101c14a
Reviewed-on: https://gerrit.instructure.com/142386
Reviewed-by: James Williams  <jamesw@instructure.com>
Tested-by: Jenkins
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Rob Orton <rob@instructure.com>
2018-03-02 16:19:19 +00:00
Michael Jasper a891136f20 Add host claim to inst-fs JWT
refs RECNVS-313

test-plan:
- with inst-fs enabled, do the following:
  - login, upload a file, access a file
- in each case the JWT serialized in the url should contain a
  `host` claim which is the oauth host (domain of the root account)

Change-Id: I05e833407bfd6a3d6cb0dcb95d42d446e314d224
Reviewed-on: https://gerrit.instructure.com/141584
Tested-by: Jenkins
Reviewed-by: Jacob Fugal <jacob@instructure.com>
QA-Review: Collin Parrish <cparrish@instructure.com>
Product-Review: Michael Jasper <mjasper@instructure.com>
2018-02-28 17:32:59 +00:00
Cody Cutrer 8b47dfcd8f transpose cross-shard links in api_user_content
fixes CORE-763

test plan:
 * set up two accounts, on different shards, and a user associated with both
 * create a course on shard 2 and create a wiki page for the front page.
 * create a module in that course
 * as the content of the front page, embed an image from the course, and
   link to the module
 * using the domain of shard 1, go to /api/v1/courses/<id of shard 2>~<id the course>/front_page
 * inspect the links in the returned body element. they should be using the
   first account's domain, but should contain (short) global ids. there should
   4 - the 'regular' URL for the image and the link, and a data-api-endpoint for each.
 * exercise all 4 URLs. the HTML ones should redirect to account 2's domain,
   and the API URLs should return a result directly

Change-Id: I10aa0fc1dc003a781d04ec5b230ede6aeba64fb9
Reviewed-on: https://gerrit.instructure.com/141664
Reviewed-by: Rob Orton <rob@instructure.com>
Tested-by: Jenkins
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2018-02-27 16:57:45 +00:00
Nate Collings cbd207736b add read_only to custom_gradebook_columns
Test Plan:

1 - Run the migrations and validate that the
    `read_only` column exists on the
    `custom_gradebook_columns` table, with a default
    of false
2 - Create a new CustomGradebookColumn through the API
    and validate that it accepts and persists the
    `read_only` parameter. Example curls:

   Create the column:

   curl -H "Authorization: Bearer <token>" \
     http://localhost:3000/api/v1/courses/:id/custom_gradebook_columns \
     -X POST \
     -F "title=ReadOnly" \
     -F "read_only=true"

   Validate the columns:

   curl -H "Authorization: Bearer <token>" \
     http://localhost:3000/api/v1/courses/:id/custom_gradebook_columns/

3 - Open the gradebook for a course and validate that you cannot
    edit the `read_only` columns in both the old and new
    gradebooks. (Tabbing should still work as normal.)

4 - Go to the Individual View. Under Global Settings, check Show Notes
    in Student Info. Under Content Selection, select a student.
    Confirm that you can only edit the custom columns that were
    not created as read_only.

refs PFS-9913, PFS-9914, PFS-10003

Change-Id: I18005cc0eaf19202c00a5d79c2a04421b5d12a5c
Reviewed-on: https://gerrit.instructure.com/139625
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Tested-by: Jenkins
Product-Review: Ian Morris <ianm@instructure.com>
QA-Review: Aiona Hernandez <ahernandez@instructure.com>
2018-02-26 19:59:46 +00:00
Jeremy Stanley c78eeae6f9 don't count student-view student in course api total_students
test plan: ensure the API endpoint below does not include
 the student view student in total counts

 api/v1/courses/X?include=total_students

fixes ADMIN-800

Change-Id: I706bcdabdf2cba9031c8b5649a89370e1f0471e9
Reviewed-on: https://gerrit.instructure.com/141685
Tested-by: Jenkins
Reviewed-by: Jon Willesen <jonw+gerrit@instructure.com>
QA-Review: Jon Willesen <jonw+gerrit@instructure.com>
Product-Review: Jeremy Stanley <jeremy@instructure.com>
2018-02-23 18:28:21 +00:00
wdransfield 6b465dd804 Fix last N+1 for adding originality_data to submission_history
Closes: GRADE-861

Test Plan
- Verify there are no N+1 queries when loading speedgrader
  caused by originality reports
- Verify there are no N+1 queries when loading gradebook
  caused by originality reports
- Verify originality reports are copied to all submissions
  in a group when they are created or updated in a group
  assignment.
- Verify online upload originality reports are displayed
  correctly in speedgrader, gradebook, student grade page,
  and submission details page.
- Verify originality reports display properly in gradebook
  and speed grader when there are multiple submissions
  and each has a different originality report.
- Verify the "resubmit to plagiarism tool" button still
  appears in speedgrader.
- Verify originality reports for group assignments are displayed
  correctly.
- Verify text entry originality reports are displayed correctly.
- Verify originality report launches work correctly from speedgrader
  and gradebook.

Change-Id: I459bbf0a165bb131d58fc153feb0dce3d0bf07af
Reviewed-on: https://gerrit.instructure.com/141321
Tested-by: Jenkins
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: Weston Dransfield <wdransfield@instructure.com>
2018-02-22 17:01:41 +00:00
Augusto Callejas 4b5654711d Propagate outcome edits to unassessed rubrics
closes OUT-1566

When outcomes are imported into rubrics, then any updates
to an outcome's name, description and ratings will be
reflected in unassessed, updateable (referenced by no more
than one assignment) rubrics, specifically in the rubric
criteria containing the outcome.

test plan (unassessed/updateable):
  - create an account outcome
  - create an account rubric, using the outcome as
    a single criterion
  - edit the outcome, including name, description
    ratings and total points possible (confirm that
    a warning dialog appears before editing)
  - confirm that the changes are reflected in the
    account rubric's criterion (check criteria name,
    ratings, and total points)
  - create an assignment, and use the account rubric
    as its rubric
  - edit the outcome, including name, description
    ratings and total points possible (confirm that
    a warning dialog appears before editing)
  - confirm that the changes are reflected in the
    account rubric's criterion and the assignment's rubric
    (check criteria name, ratings, and total points)
  - create another assignment, and use the account rubric
    as its rubric
  - edit the outcome, including name, description
    ratings and total points possible (confirm that
    a warning dialog DOES NOT appear before editing)
  - confirm that the changes are NOT reflected in the
    account rubric's criterion and both the assignment
    rubrics

test plan (assessed):
  - create a new account rubric using the default criterion
  - create a new assignment and use the account rubric
    as its rubric
  - as a student, submit to the assignment
  - as a teacher, score the assignment, including the rubric
  - add the account outcome to this new account rubric
  - edit the outcome, including name, description
    ratings and total points possible (confirm that
    a warning dialog DOES NOT appear before editing)
  - confirm that the changes are NOT reflected in the
    account rubric's criterion and the assignment's rubric

Change-Id: Ie5064269689071a450fa503fb68c73f5beb16710
Reviewed-on: https://gerrit.instructure.com/127991
Reviewed-by: Michael Brewer-Davis <mbd@instructure.com>
Tested-by: Jenkins
Reviewed-by: Frank Murphy <fmurphy@instructure.com>
QA-Review: Andrew Porter <hporter-c@instructure.com>
QA-Review: Leo Abner <rabner@instructure.com>
Product-Review: Sidharth Oberoi <soberoi@instructure.com>
2018-02-21 21:59:05 +00:00
Omar Khan 353b6e90d4 Add Assignment#duplicate_of relation
This commit updates Assignment#duplicate to store a reference to the
original assignment on the duplicated assignment. Both the original
assignment and the new assignment's lti_resource_link_id are included
in the `assignment_created` live event emitted when the new assignment
is saved.

This allows LTI tools listening for Canvas live events to identify when
an assignment has been duplicated, and duplicate their own data
accordingly.

Closes QUIZ-3749

Test plan:

- Set up live events and tail the kinesis stream as per the instructions
  in doc/live_events.md
- Create an LTI assignment
- An `assignment_created` live event containing this assignment's
  lti_resource_link_id should appear in the kinesis log. Make a note of
  this lti_resource_link_id
- Duplicate this assignment by clicking the "kebab" menu and clicking
  "Duplicate"
- Check that another `assignment_created` live event appears in the
  kinesis log, containing both the original assignment's
  lti_resource_link_id and the new assignment's lti_resource_link_id

Change-Id: I64bdb9a2132e58c4e7be0ab7687c2c819a3587fd
Reviewed-on: https://gerrit.instructure.com/140877
Tested-by: Jenkins
QA-Review: Michael Hargiss <mhargiss@instructure.com>
Reviewed-by: Jeff Belser <jbelser@instructure.com>
Product-Review: Michael Hargiss <mhargiss@instructure.com>
2018-02-20 22:55:00 +00:00
Spencer Olson 2867804416 ignore soft-deleted grading periods for current_period_id
Ignores soft-deleted Grading Periods when determining the current
grading period for an enrollment.

closes GRADE-834

Test Plan:
1. At the root account grading standards page
   (accounts/:id/grading_standards), create an active Grading Period
   (a period where `start_date` > now < `end_date`).
2. In a course that is using that grading period, hit the courses
   endpoint as a student and verify the enrollments you get back have
   a not-null current_grading_period_id:

   GET /api/v1/courses/:id?include[]=total_scores&include[]=current_grading_period_scores

   => current_grading_period_id should be present

3. At the root account grading standards page, delete the Grading
   Period you created in step 1.

4. In a course that is using that grading period, hit the courses
   endpoint as a student and verify the enrollments you get back have
   a null current_grading_period_id:

   GET /api/v1/courses/:id?include[]=total_scores&include[]=current_grading_period_scores

   => current_grading_period_id should be null

Change-Id: I5aed1ba5bed47a08902d74ec3c41a4b9e2bad049
Reviewed-on: https://gerrit.instructure.com/139932
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
Reviewed-by: Josh Simpson <jsimpson@instructure.com>
Tested-by: Jenkins
Reviewed-by: Shahbaz Javeed <sjaveed@instructure.com>
QA-Review: Adrian Packel <apackel@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-02-09 15:56:11 +00:00
Adrian Packel 1c48c5e8df add unposted values to methods in API controllers
Update several API methods to return unposted scores/grades alongside
the existing fields if the requesting user has either of the
:manage_grades or :view_all_grades permissions.

The updated functions are:
submissions_api_controller.rb#for_students
users_controller.rb#grades_for_student
course_json.rb#total_scores
course_json.rb#current_grading_period_scores

closes GRADE-761

Test plan:

Initial setup and notes:
- As a teacher, set up a course with some students and at least one
  unposted assignment, and assign some grades.
- Also, set up a login for a student in the course.

For each step listed below, you should access the listed URL first
as the teacher, then log out and back in as a student, and access it
again. Check that your results are in line with what's indicated below.
To each URL, prepend your server and port (presumably localhost:3000 or
similar).

Testing submissions_api_controller:
- Access the following URL (replace "1" with your course ID):
  /api/v1/courses/1/students/submissions?student_ids=all&include=total_scores&grouped=true
- As a teacher:
  - In each individual student hash, the fields "unposted_current_score"
    and "unposted_final_score" should appear alongside the corresponding
    computed_ scores.
  - The unposted fields should reflect each student's scores with
    unposted assignments factored in.
- As a student:
  - The unposted fields should not appear.

Testing grades_for_student:
- From your course above, identify the ID for a student's enrollment,
  perhaps using the Rails console.
  (E.g.: StudentEnrollment.find_by(course_id: <course ID>).id)
- Access the following URL (replace "1" with the enrollment ID):
  /grades_for_student?enrollment_id=1
  (note that the "/api/v1/" prefix is NOT part of this one)
- As a teacher:
  - The output should include an 'unposted_grade' field reflecting the
    student's unposted (current) score.
- As a student:
  - The output should not include the new field.

Testing course_json:
- Set up a grading period that includes the current date and time,
  if one is not already active.
- Identify the ID of a student in the course.
  (E.g.: StudentEnrollment.find_by(course_id: <course ID>).user.id)
- Access the following URL (replace "1" with your course ID):
  /api/v1/users/1/courses?include[]=enrollments&include[]=total_scores&include[]=current_grading_period_scores
- As a teacher:
  - In the output, each element in the "enrollments" array should
    include the following fields (which should, as described above,
    reflect the student's scores factoring in unposted assignments):
    - unposted_current_score
    - unposted_current_grade
    - unposted_final_score
    - unposted_final_grade
    - current_period_unposted_current_score
    - current_period_unposted_current_grade
    - current_period_unposted_final_score
    - current_period_unposted_final_grade
- As a student:
  - The unposted fields listed above should *not* be included.

Change-Id: Ie2b7cbfa41446d3f9010d4f6376407b1c1edd443
Reviewed-on: https://gerrit.instructure.com/138468
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
Reviewed-by: Shahbaz Javeed <sjaveed@instructure.com>
Tested-by: Jenkins
QA-Review: Anju Reddy <areddy@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-02-07 18:34:10 +00:00
Rob Orton ae1dc5d0ee restore sis_batch errors until api is deprecated
fixes CORE-922

test plan
 - old api results should include limited errors
   and warnings

Change-Id: Ia71bca882ea234d286b43be12baa291518e69f11
Reviewed-on: https://gerrit.instructure.com/139371
Tested-by: Jenkins
Reviewed-by: Cody Cutrer <cody@instructure.com>
Product-Review: Rob Orton <rob@instructure.com>
QA-Review: Rob Orton <rob@instructure.com>
2018-02-05 18:11:44 +00:00
Rob Orton 5e735cebeb store sis_batch_errors in the db
fixes CORE-324

test plan
 - run a sis import with errors
 - the errors should be included in the api JSON

Change-Id: I97e372a82b565e7bfa01cd9ca0bb66bb67c95723
Reviewed-on: https://gerrit.instructure.com/139071
Tested-by: Jenkins
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Rob Orton <rob@instructure.com>
2018-01-26 22:08:25 +00:00
Rob Orton 68ed1c341d add sis_ids to groups and group categories APIs
fixes CORE-652

test plan
 - groups response should include sis_id
 - group category response should include sis id

Change-Id: I2e2ea884e6fed333baf4a2f5df8a8d1ad0e65f1c
Reviewed-on: https://gerrit.instructure.com/137876
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins
QA-Review: Tucker McKnight <tmcknight@instructure.com>
Product-Review: Rob Orton <rob@instructure.com>
2018-01-17 23:21:41 +00:00
James Williams 3db514f1b8 master courses: check for expired migrations in api
refs #ADMIN-675

Change-Id: Ie656b5272c63245aaa0df82d98efdd18941ea03d
Reviewed-on: https://gerrit.instructure.com/137748
Tested-by: Jenkins
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
QA-Review: James Williams  <jamesw@instructure.com>
2018-01-12 16:38:00 +00:00
Keith Garner aec7350338 add unposted scores to enrollment api for teachers/admins
This adds four additional fields (unposted_current_score,
unposted_final_score, unposted_current_grade, unposted_final_grade) to
the enrollment and users endpoints if the requesting user has either
manage_grades or view_all_grades permissions.

fixes GRADE-119

test plan:
 - Have a course with a teacher and a student.
 - Have three assignments each worth 10 points, one muted (Assignment 1)
   and two not muted (Assignment 2 and Assignment 3).
 - As the teacher, grade the student 6/10 for Assignment 1 and 10/10
   for Assignment 2. Do not grade the student for Assignment 3.
 - As the teacher, make an API call to get the grades for the student:

   GET /api/v1/courses/:course_id/users/:student_id?include[]=enrollments
   Authorization: Bearer the-teacher-api-token

   Verify the grades on the enrollments in the response include the
   unposted_current_score, unposted_final_score,
   unposted_current_grade, and unposted_final_grade keys. Verify the
   unposted_current_score is 80.00, the unposted_final_score is 53.33,
   the unposted_current_grade is null, and the unposted_final_grade is
   null.

 - As the student, make an API call to get the grades for yourself:

   GET /api/v1/courses/:course_id/users/:student_id?include[]=enrollments
   Authorization: Bearer the-student-api-token

   Verify the grades on the enrollment in the response do not include
   the unposted_current_score, unposted_final_score,
   unposted_current_grade, or unposted_final_grade keys.

Change-Id: Ibd14d0ed0a246f1cb8d16d7bc9ba0beb2680cba9
Reviewed-on: https://gerrit.instructure.com/137213
Reviewed-by: Shahbaz Javeed <sjaveed@instructure.com>
Tested-by: Jenkins
QA-Review: Indira Pai <ipai@instructure.com>
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Product-Review: Matt Goodwin <mattg@instructure.com>
2018-01-09 17:47:51 +00:00
Steven Burnett 6d26a8d4b5 add sections tool tip to index page
fixes COMMS-584

Test Plan:
- With section specific announcements turned on
- Go to the announcements index page
- If you don't have any announcements create some
  that are both section specific and some that aren't
- go back to the index page
- hover over the all sections toolip/the tool tip that
  says the count of the amount of sections
- notice it states how many users it sent to (for all sections)
  and how many it sent to for section specific

Change-Id: I74e37512f6244a32cfd2fdb90bce63c85e42be26
Reviewed-on: https://gerrit.instructure.com/136867
Reviewed-by: Venk Natarajan <vnatarajan@instructure.com>
Tested-by: Jenkins
QA-Review: Landon Gilbert-Bland <lbland@instructure.com>
Product-Review: Steven Burnett <sburnett@instructure.com>
2018-01-08 20:49:43 +00:00
Rob Orton 4c2aceed42 Revert "remove assignment stream items for students removed from assignment"
This reverts commit d64f44feeb.

Change-Id: Ibfd2d633f03fc04e9091f2241c12247fa4624b27
Reviewed-on: https://gerrit.instructure.com/137135
Reviewed-by: Steven Burnett <sburnett@instructure.com>
Reviewed-by: Tyler Pickett <tpickett@instructure.com>
Reviewed-by: Venk Natarajan <vnatarajan@instructure.com>
Product-Review: Rob Orton <rob@instructure.com>
QA-Review: Rob Orton <rob@instructure.com>
Tested-by: Rob Orton <rob@instructure.com>
2018-01-06 16:12:59 +00:00
Clay Diffrient 9f1bfa5adc Allow requests with use_verifiers=0 and jwt auth to not include verifiers
refs CORE-23

Test Plan:
  - Make a GET request to /api/v1/folders/XX/files?use_verifiers=0
    using a valid JWT
  - Verifiers should not be present in the URLs returned

Change-Id: I7111098fe1f1fd4f8d83d06bc19f0c819fb18a85
Reviewed-on: https://gerrit.instructure.com/136683
Tested-by: Jenkins
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: Tucker McKnight <tmcknight@instructure.com>
Product-Review: Clay Diffrient <cdiffrient@instructure.com>
2018-01-05 23:02:49 +00:00
Rob Orton 822d2becbc remove duplicate preload
Change-Id: If147691095e217b4a523a231a0bf9844b0eac2dc
Reviewed-on: https://gerrit.instructure.com/136905
Tested-by: Jenkins
Reviewed-by: James Williams  <jamesw@instructure.com>
Product-Review: Rob Orton <rob@instructure.com>
QA-Review: Rob Orton <rob@instructure.com>
2018-01-04 15:19:02 +00:00
Rob Orton aca718826d add sis_pseudonym_id to enrollment object
fixes CORE-667
fixes GRADE-250
fixes GRADE-251

test plan
 - have a user with multiple sis pseudonyms
 - enroll user into courses through sis import
   using both sis_ids for different enrollments
 - each enrollment should return the correct
   pseudonym in grade export, Enrollment API,
   Section API, Submission API

Change-Id: I2693851b6b65fe8266b3a4e6e8cefc30e3d6f214
Reviewed-on: https://gerrit.instructure.com/136804
Tested-by: Jenkins
QA-Review: Anju Reddy <areddy@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Product-Review: Rob Orton <rob@instructure.com>
2018-01-04 00:58:37 +00:00
Dan Minkevitch 72d695fdb7 Ignore inactive enrollments in overrides list for show page
Fixes ADMIN-311

Test Plan:
* Create an assignment that has an override
  assigned to two students
* Conclude one of the users
* Go back to the assignment page and notice it
  now only lists '1 Student'
* Go to the edit page and notice only the active
  user is listed for the override

Change-Id: I2f351afa4cf341bab1e3679d47cc032c8f729207
Reviewed-on: https://gerrit.instructure.com/131961
Tested-by: Jenkins
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
QA-Review: Deepeeca Soundarrajan <dsoundarrajan@instructure.com>
Product-Review: Dan Minkevitch <dan@instructure.com>
2017-12-28 19:31:09 +00:00
Felix Milea-Ciobanu 9e94911210 add section specific logic to announcements + discussions api
refs COMMS-587 COMMS-588

test plan:
- enable the section specific announcements feature flag
- use a course with multiple sections and students across sections
- create some section specific announcements and regular announcements
- test the following API routes as both a teacher and a student
  - use your own course id as appropriate
  - as a teacher you should see all announcements in a course
  - as a student you should only see announcements specific to the
    sections that you are enrolled in

[Announcements API]
- /api/v1/announcements?context_codes=course_2
  - note that each announcement has a "is_section_specific"
    property with the correct value
- /api/v1/announcements?context_codes=course_2&include[]=sections
  - note that section specific announcements include correct section
- /api/v1/announcements?context_codes=course_2&include[]=sections&include[]=sections_student_count
  - note that section specific announcements' include sections with
    correct "student_count" property

[Discussion Topics API]
- /api/v1/courses/2/discussion_topics/?only_announcements=true
  - note that each announcement has a "is_section_specific"
    property with the correct value
- /api/v1/courses/2/discussion_topics/?only_announcements=true&include[]=sections
  - note that section specific announcements include correct section
- /api/v1/courses/2/discussion_topics/?only_announcements=true&include[]=sections&include[]=sections_studenst_count
  - note that section specific announcements' include sections with
    correct "student_count" property

Change-Id: Idbe68e2d72a538ce5d3701daf12287f3e8bb8d94
Reviewed-on: https://gerrit.instructure.com/136266
Reviewed-by: Steven Burnett <sburnett@instructure.com>
Tested-by: Jenkins
Reviewed-by: Venk Natarajan <vnatarajan@instructure.com>
QA-Review: Landon Gilbert-Bland <lbland@instructure.com>
Product-Review: Felix Milea-Ciobanu <fmileaciobanu@instructure.com>
2017-12-22 17:59:47 +00:00
wdransfield 56ad8ef51c Fix originailty report launches for group assignments
Fixes PLAT-2967

Test Plan:
- Create an assignment that uses file upload and
  a plagiarism detection tool. The assignment
  should be a group assignment. The tool should
  support LTI launches for originality reports.
- As one of the students in the group submit
  to the assignment (there should be at least
  two students in the group).
- Create an originality report for the submission/attachment
  combo.
- Verify that all originality report LTI launches work
  for all students in the group (submission details page,
  student grade page, gradebook, speedgrader).
- Verify the normal flow for originality reports works
  for non-group assignments.

Change-Id: I2b4002c58bd6438181559f8dab66a67ee0a8f8e2
Reviewed-on: https://gerrit.instructure.com/135974
Reviewed-by: Nathan Mills <nathanm@instructure.com>
Tested-by: Jenkins
QA-Review: August Thornton <august@instructure.com>
Product-Review: Weston Dransfield <wdransfield@instructure.com>
2017-12-20 19:52:57 +00:00