Commit Graph

119 Commits

Author SHA1 Message Date
James Williams 5881701e8c rails 4.2: api spec fixes
refs #CNVS-26056

Change-Id: I082e29c642b9150260f6571f0aa8ef397c6e2cca
Reviewed-on: https://gerrit.instructure.com/70593
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins
Product-Review: James Williams  <jamesw@instructure.com>
QA-Review: James Williams  <jamesw@instructure.com>
2016-01-21 16:14:03 +00:00
Ryan Shaw 298e6808d5 get sub account branding and custom css/includes working
fixes: CNVS-24787
fixes: CNVS-23964
fixes: CNVS-23957 - Handle parent account custom css/js for new_styles
test plan:
* set up a root account, child account, and grandchild account
* use theme editor to set a custom css/js file for each
  (eg: for css `* {color:red}` and for js 'console.log("from grandchild")`
* make a course & a group in the grandchild account
* load a page in that course and group and make sure
  you see grandchild account's branding, and root's,
  child's, and then grandchild's css loaded on the page
  (grandchild should be loaded last so you see it's css
  effects override root or child's and you should see
  the console.log from root then child then grandchild)
* view a page in "child". it should have root and child's
  css/js but not grandchild
* as a user that only has enrollments (account associations)
  in "child", go to the dashboard. you should see
  css/js for both root and child but not grandchild

fixes: CNVS-25051 Opening Theme Editor for
sub-accounts shows incorrect theme preview
test plan:
* Go to a sub-account in theme editor and change
  settings so the Branding is different and save.
* the preview on the right should reflect your
  changes both after you "apply" and "save"
  (and not just show the preview of the root
  account's branding)

fixes: CNVS-23406 - global JS and CSS files are being
included when Global CSS/JavaScript includes is false
test plan:
* go to /accounts/self/, and go to theme editor and
  upload a css_override
* see that that css is loaded on pages
* back in root account settings disable Global
  CSS/JavaScript includes
* check that the css is no longer loaded.
* do the same thing checking a subaccount's custom css

fixes: CNVS-25558 - load whole chain of custom css/js 
in native app api requests

test plan:
* make api request for a wiki page in course in a 
  subaccount that has custom css/js within a root 
  account that also has custom css/js
* you should see both the root account's css/js and 
  the child account's returned in the response

to test grandchild js issue jeremyp found:
* go to theme editor for a grandchild account
* choose a js override file (like: `console.log('first')`)
* preview & apply
* you should see "first" in console
* go back to theme editor, pick a new file (like: `console.log('second')`)
* preview & apply
* you should only see "second" in console. not "first"

Change-Id: I8d9047948f5da94be41e0205844629a170f980af
Reviewed-on: https://gerrit.instructure.com/68249
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Tested-by: Jenkins
Product-Review: Ryan Shaw <ryan@instructure.com>
2015-12-19 02:47:39 +00:00
James Williams 940bce5785 don't show media previews for deleted attachments
test plan:
* embed a link to a previewable media file in html content
(e.g. a wiki page)
* the media preview should work on the page
* delete the file
* the media preview should not be shown anymore

closes #CNVS-25285

Change-Id: I6e8fb5ad875ce62c51ca9ce6882df9d6239b053e
Reviewed-on: https://gerrit.instructure.com/68442
Tested-by: Jenkins
QA-Review: Jahnavi Yetukuri <jyetukuri@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
2015-12-09 19:44:02 +00:00
James Williams f467e07aec fix media object names not appearing for conversation media
test plan:
* send a conversation message to another user with a media
 comment, either uploaded or recorded
* on the receiving end, the media link should have a name

closes #CNVS-20036

Change-Id: I8fbc1b377883de5d8b83f30e53990e79cfd87414
Reviewed-on: https://gerrit.instructure.com/66172
Tested-by: Jenkins
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
QA-Review: Ryan Allen <rallen@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
2015-11-02 16:55:52 +00:00
Cody Cutrer f3ae13a1d6 fix case sensitivey of sis_login_id lookups in the API
fixes CNVS-23835

test plan:
 * use any API endpoint that takes a user id (and thus sis_login_id)
 * change the case of the login id (all uppercase, etc.) in the URL
 * it should still find the user

Change-Id: I0821b5d7213142aefa7e26699c26b981845a220b
Reviewed-on: https://gerrit.instructure.com/64586
Tested-by: Jenkins
Reviewed-by: Rob Orton <rob@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2015-10-08 19:25:51 +00:00
Rob Orton d252a7f2b4 mobile css and js overrides
closes CNVS-19900

test plan:
 - create a brand_config for an account
 - apply brand_config
 - add ?mobile=1 to an api request that returns a
   body (like a wiki page);
   observe no additional stylesheets in the body
 - go to /accounts/self/, and go to brand
   config and upload a mobile_css_override
 - add ?mobile=1 and check the api result again
   your stylesheet should be there appended to the
   body of the wiki page
 - back in brand_config, remove the uploaded file
 - check your source again - there should not be
   an empty stylesheet tag

Change-Id: Ief728a397d185282a57f8cede0916c7ffe4a2584
Reviewed-on: https://gerrit.instructure.com/61885
Tested-by: Jenkins
Reviewed-by: Ryan Shaw <ryan@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: Rob Orton <rob@instructure.com>
2015-09-28 19:24:55 +00:00
James Williams 2dad511048 preload attachments in calendar events public feed
test plan:
* basic regression test the calendar events public feed api

closes #CNVS-22774

Change-Id: I0a21788d25c63b404a4c6410f5d01e785bed1ed8
Reviewed-on: https://gerrit.instructure.com/62941
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
QA-Review: Charles Kimball <ckimball@instructure.com>
Tested-by: Jenkins
Product-Review: James Williams  <jamesw@instructure.com>
2015-09-21 14:22:26 +00:00
James Williams d0689a15a2 improve performance in assignments/assignment groups api index
test plan:
* assignments and assignment groups api index should
 work as before

closes #CNVS-22864

Change-Id: I4b72f0fd5d5a8dc40a7669ee3929c60ddc401114
Reviewed-on: https://gerrit.instructure.com/62851
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
QA-Review: Charles Kimball <ckimball@instructure.com>
Tested-by: Jenkins
Product-Review: James Williams  <jamesw@instructure.com>
2015-09-21 14:22:05 +00:00
Derek Bender 7e96991dbd add provisional grades to submissions api
closes: CNVS-22394

test plan:
 0. enable moderated grading in a course
 1. create a moderated grading assignment
 2. submit the assignment as a student
 3. as a teacher, use the Grade or Comment on a Submission API endpoint
    to create a provisional grade for the submission
    by adding submission[provisional]=1 in addition to
    submission[posted_grade]
    - confirm the provisional grade is returned in the response json
      in an array under submission[provisional_grades]
 4. repeat step 3 as a TA, adding a different provisional grade
    to the same submission
    - confirm the TA's provisional grade alone is returned in the
      response json
 5. use the "list assignment submissions" endpoint but add
    include[]=provisional_grades as both the teacher and the TA
    - the teacher should receive both provisional grades in the response
    - the TA should receive only the provisional grade they assigned

Change-Id: Idbf05ee74b5ef40d952ebd98d87c715312e2a136
Reviewed-on: https://gerrit.instructure.com/61000
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Tested-by: Jenkins
QA-Review: Jahnavi Yetukuri <jyetukuri@instructure.com>
Product-Review: Jeremy Stanley <jeremy@instructure.com>
2015-09-03 17:39:02 +00:00
Cody Cutrer acab0d5568 change Api finding infrastructure to use relations instead of finder options
so that it can be converted to eager_load instead of includes

refs CNVS-21901

Change-Id: I4a2578a328265730070d55436f2ecbb5d0ac602d
Reviewed-on: https://gerrit.instructure.com/62298
Tested-by: Jenkins
Reviewed-by: Rob Orton <rob@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2015-09-03 17:08:38 +00:00
Ethan Vizitei 1004e66540 get sentry into canvas
closes CNVS-6016

No more error reports!  (soon)

this commit builds up sentry integration through the new
Canvas::Errors module, along with other things that need
to happen on every exception.  ErrorReports
should now get pushed towards just being used for representing
a complaint a user filed via the get help form.

I fixed about half the things that got linted as well
while I was in here, but because this touches to much
I fear divergence from tackling too many (I think we
can safely say it's "better than we found it")

I left a lot of the infrastructure for error reports in place
until other commits for plugins can be merged

TEST PLAN:
 1) setup your raven.yml config file with the dsn for our
  sentry install
 2) force an error to happen in a request response cycle.
 3) see the error in sentry
 4) force an error to happen in a job
 5) see the error in sentry
 6) statsd increments shoudl still fire
 7) for the moment, an error report should still get created.

Change-Id: I5a9dc7214598f8d5083451fd15f0423f8f939034
Reviewed-on: https://gerrit.instructure.com/51621
Reviewed-by: Simon Williams <simon@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
Tested-by: Jenkins
QA-Review: August Thornton <august@instructure.com>
Product-Review: Ethan Vizitei <evizitei@instructure.com>
2015-04-13 22:26:15 +00:00
James Williams 22b2c7fa7f still add verifiers to public syllabus content for authed users
test plan:
* create a course with a public syllabus and a link to an
unlocked file in the syllabus content
* should already be able to view the syllabus and download the
file when not logged-in
* should also be able to view the syllabus and download the
 files when logged-in (but not belonging to the course)

closes #CNVS-19585

Change-Id: I69adc4a8758a7deb2562229e20b057bcd0ad1971
Reviewed-on: https://gerrit.instructure.com/51353
Tested-by: Jenkins
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
QA-Review: Jahnavi Yetukuri <jyetukuri@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
2015-04-01 17:03:04 +00:00
Jeremy Stanley c5037b1f38 store placeholder for host in materialized view
and then replace it with the request host when
serving the content from the API

test plan:
 - create one or more /etc/hosts file entries to point at
   your canvas instance with different names
 - reply to a discussion and include embedded images
   and attached files in the reply
 - view the discussion as a user pointing at a different
   hostname.  confirm that the attachments and embedded
   images work.
 - use the "Get the full topic" API endpoint to retrieve
   the topic and replies via the API. do this with more than
   one hostname. confirm that the URLs for the attached file
   and embedded images match the name of the host you
   are hitting the API with

fixes CNVS-17708
fixes CNVS-19125

Change-Id: I055235b3e785946e5999bf522ea4cad592f0f7f7
Reviewed-on: https://gerrit.instructure.com/50360
Tested-by: Jenkins
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Jahnavi Yetukuri <jyetukuri@instructure.com>
Product-Review: Jon Willesen <jonw@instructure.com>
2015-03-31 16:32:08 +00:00
James Williams 1ffe3d2f1b don't show media preview thumbnails to students for locked files
test plan:
* with kaltura/notorious enabled, add a link to a media file
 (video/audio) in rich content (e.g. a wiki page)
* should show a preview thumbnail generate a preview
* lock the file
* view the page as a student
* should not show a preview thumbnail

closes #CNVS-6965

Change-Id: I3743ac7b2e54d6a3c57e9ea3338b25cce75825bb
Reviewed-on: https://gerrit.instructure.com/50927
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Tested-by: Jenkins
QA-Review: Jahnavi Yetukuri <jyetukuri@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
2015-03-26 16:33:53 +00:00
Jeremy Stanley 65565156b8 keep api_user_content processing when in_app
test plan:
 0. have an image file with id Y in course X
 1. put an img tag in a wiki page such as
    <img src="/courses/X/files/Y">
 2. save and re-edit the wiki page. the img tag should appear as
    <img src="/courses/X/files/Y/download">
 3. retrieve the page content via the API. you should see
    an img src that ends in "download?verifier=..."

fixes CNVS-18446

Change-Id: Ie04600041bd49125a24e294552f4673aa3445f2e
Reviewed-on: https://gerrit.instructure.com/48517
Tested-by: Jenkins
QA-Review: Clare Strong <clare@instructure.com>
Reviewed-by: James Williams  <jamesw@instructure.com>
Reviewed-by: Dan Minkevitch <dan@instructure.com>
Product-Review: Dan Minkevitch <dan@instructure.com>
2015-02-10 18:03:32 +00:00
James Williams fd323843db don't add verifiers for api_user_content from in_app calls
test plan:
* insert a link to a course file in rce content
 (such as a wiki page)
* confirm that from inside canvas, the links do not
 include the "verifier" parameter
* confirm that from the api using an authorization token
 (e.g. using curl) it does include the verifier token in the
 links

closes #CNVS-18399

Change-Id: Iad357f501e98fe5fa34ee7b20572d6f9d0b91744
Reviewed-on: https://gerrit.instructure.com/48382
Tested-by: Jenkins
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Product-Review: Jeremy Stanley <jeremy@instructure.com>
QA-Review: Clare Strong <clare@instructure.com>
2015-02-09 17:05:36 +00:00
James Williams 5f4c89e1b6 don't add verifiers for unpublished files in public syllabus
test plan:
* create a public published course
* add a link to an unpublished file on the syllabus
* should not be accessible publicly

closes #CNVS-18404

Change-Id: I5767cd31e614ec36f1820beef8b688e98bbca4f2
Reviewed-on: https://gerrit.instructure.com/48376
Tested-by: Jenkins
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
QA-Review: Jahnavi Yetukuri <jyetukuri@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
2015-02-06 22:25:05 +00:00
James Williams 6fe617afef add verifiers to attachments in public syllabus content
test plan:
* create a course with a public syllabus
* add embedded images to the syllabus
* view the syllabus as a public user  (not logged in)
* should still see the images

closes #CNVS-17174

Change-Id: I03ae8d2efddb7b50b7503f50e54937cf00aefe4b
Reviewed-on: https://gerrit.instructure.com/45336
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
QA-Review: Jahnavi Yetukuri <jyetukuri@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
2014-12-05 22:19:25 +00:00
Braden Anderson 2f9171080d course catalog
test plan:
  * open a course's settings page
  * enable listing the course in the public index but not
      making the course content public
  * open the course home page as an unregistered user
  * verify that only the course's title and description are accessible

  * open root account feature flags page
  * enable Course Catalog

  * open your "My Courses" page
  * verify that the right pane includes a "Browse more courses" link
  * click the link
  * verify that you can browse courses allowed in the public index

  * log out
  * verify that the homepage includes a "Browse courses" link

Change-Id: I44f96396859283d76bfe527672612ff71ca4ae67
Reviewed-on: https://gerrit.instructure.com/24682
Tested-by: Jenkins <jenkins@instructure.com>
Product-Review: Braden Anderson <braden@instructure.com>
QA-Review: Trevor deHaan <tdehaan@instructure.com>
Reviewed-by: Jon Jensen <jon@instructure.com>
2014-11-07 17:15:10 +00:00
James Williams d8a317dfdb restrict verifiers to public file links in calendar event export
test plan:
* create a calendar event for a private course with a link
to an unlocked attachment
* sync the calendar with an external source
* the exported calendar event should not add a verifier to
the link (and thus allow someone to bypass authentication)

* repeat for a public course
* should add a verifier this time

closes #CNVS-15352

Change-Id: I743e73dc852c204cdf68c0b8b9e3fc2d402ad855
Reviewed-on: https://gerrit.instructure.com/43288
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
QA-Review: Jahnavi Yetukuri <jyetukuri@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
2014-10-30 12:44:21 +00:00
Cody Cutrer 5d42d023d2 no more dynamic finders (lib)
refs CNVS-15126

Change-Id: I4087b1c2442c5b8f70ce2138bf4aeef6ef7e59cd
Reviewed-on: https://gerrit.instructure.com/41259
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2014-09-23 16:53:56 +00:00
Ethan Vizitei a4ab57e637 Refactor api html rewriting and parsing
refs #CNVS-11032

This was originally part of fixing the above bug (11032)
but we sent a different patch for hotfixing that
solved the problem in place.

This is the remainder of that patch which
refactors out the html content, media tag, and link
processing into their own more focused objects

Change-Id: If2d59c09c99117ab8de798f74b4513fb628bafd5
Reviewed-on: https://gerrit.instructure.com/40395
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
QA-Review: Steven Shepherd <sshepherd@instructure.com>
Product-Review: Ethan Vizitei <evizitei@instructure.com>
2014-09-22 19:39:12 +00:00
Ethan Vizitei 178f84a8b1 Don't strip the verifier from user-context files
fixes #CNVS-11032

If you were to use a files link that didnt start
with "/files" (like "/users/x/files/y" or a link
with a full host name), it would
still strip the verifier out, which would make the
file not appear to other users.  This fixes
the problem.

TEST PLAN:
 -login as a user
 -go to files and upload an image to *your* folder
    (rather than the folder for a course or something)
 -obtain a link to that file with it's verifier param through
    whatever means you prefer (simplest is to get the download
    link and then use the console to get the UUID from that
    Attachment record and use that as "verifer=[blah]" at
    the end of the url for the file)
 -post a discussion reply using that link to embed an image
    in the reply.
 -login as a different user and look at the discussionr reply;
  you should be able to see the image in the discussion reply.

Change-Id: I2e9123f08cda0e6949e8f9a8d12ba50b98de49e0
Reviewed-on: https://gerrit.instructure.com/40430
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Product-Review: Hilary Scharton <hilary@instructure.com>
Reviewed-by: James Williams  <jamesw@instructure.com>
QA-Review: Clare Strong <clare@instructure.com>
2014-09-03 20:06:38 +00:00
James Williams 6ff5b114de fix wiki sidebar file link translation in api content
test plan:
* add an inlineable file to a course (e.g. a '.html' file)
* create a wiki page content and add a link to the file through
 the wiki sidebar
* following the link on the saved page should take you
 to a preview page for the inlined content

fixes #CNVS-14211

Change-Id: I14d2fc6d90f893086eff5498d0c670b9251fdddd
Reviewed-on: https://gerrit.instructure.com/39191
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
QA-Review: Clare Strong <clare@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
2014-08-13 16:50:40 +00:00
Brandon Broschinsky de263055ce save context_id on lti launch
fixes: PS-1538

**test plan
configure and launch lti tool, upon lti tool launch the
lti_context_id for user should be set, and if course launch
the lti_context_id on course object, if account launch, then
lti_context_id on account.  Once these are set, api calls to the
corresponding object can be made using the syntax lti_context_id:id

Change-Id: Icdf02e4f99691be417c024adb2a2751ba2aa9335
Reviewed-on: https://gerrit.instructure.com/35380
Reviewed-by: Brad Humphrey <brad@instructure.com>
Reviewed-by: Rob Orton <rob@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Product-Review: Adam Phillipps <adam@instructure.com>
QA-Review: Adam Phillipps <adam@instructure.com>
2014-05-30 22:26:52 +00:00
Cody Cutrer 9b11443ae2 add hooks to Api to find objects from other root accounts
refs CNVS-1180

Change-Id: Ic3e023e1869eefb75efedec028fb54f6fc995918
Reviewed-on: https://gerrit.instructure.com/31948
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2014-05-06 20:19:33 +00:00
David Julia 12949cb829 Prefer mp3 for audio comments in api_user_content
When preparing user content for public consumption via the API, we were
hardcoding a media_type of mp4, which prevented clients using API
endpoints (specifically the mobile client) from playing audio comments
which only had mp3 sources.

This adds a new path through media_download that prefers mp3 for audio
media but falls back to the old mp4 behavior. We also maintain backwards
compatibility with other callers using the file_extension based
filtering.

NTRS-43

Test Plan:
 - With both a 'wav' and an 'mp3' sample file:
   - Create an announcement and upload an audio file via the RTE
   - Wait for transcoding to complete in Kaltura
   - The file should play properly in the web browser
   - Open the same announcement in the iOS mobile app
   - The audio file should play properly on the phone

Change-Id: I26735096ea4336cf1acc04eb9649d322f68fa515
Signed-off-by: Paul Hinze <paulh@instructure.com>
Reviewed-on: https://gerrit.instructure.com/33318
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Steven Shepherd <sshepherd@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
2014-04-30 20:00:13 +00:00
Rob Orton 1951acb152 only allow positive dates in ISO8601 regex
refs CNVS-10087

test plan
 - hit assignments api with valid iso8601 BC date
   example: -2014-10-01T00:00:00-06:00
 - should return 400

Change-Id: Ifc70bb3ce268f2fadc8ed4060ec7925164da5a19
Reviewed-on: https://gerrit.instructure.com/33789
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Product-Review: Rob Orton <rob@instructure.com>
2014-04-30 19:55:32 +00:00
Eric Adams 933bff25d3 Add integration Ids to API
fixes SIS-135
fixes SIS-136

Change-Id: Ide2f51765c76a50f09d54d2865357b5ff38bc360
Reviewed-on: https://gerrit.instructure.com/28587
Reviewed-by: Duane Johnson <duane@instructure.com>
Tested-by: Duane Johnson <duane@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Eric Adams <eadams@instructure.com>
2014-04-24 20:43:45 +00:00
Rob Orton 42bbe7702d check assignments API date times with api regex
refs CNVS-10087

test plan
 - specs should pass

Change-Id: Ia28a3ec65c24d2e70a5073b5da2caab8b282da9f
Reviewed-on: https://gerrit.instructure.com/33115
Reviewed-by: Anthus Williams <awilliams@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Product-Review: Rob Orton <rob@instructure.com>
QA-Review: Rob Orton <rob@instructure.com>
2014-04-10 18:44:16 +00:00
Rob Orton 052509f34e add api date time regular expressions
also add helper method to create error reports

refs CNVS-10087
refs CNVS-9618

test plan
 - specs should pass

Change-Id: I74f40dd16a85a0d95f9b152f6750ec98aade2ba5
Reviewed-on: https://gerrit.instructure.com/33114
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Anthus Williams <awilliams@instructure.com>
Product-Review: Rob Orton <rob@instructure.com>
QA-Review: Rob Orton <rob@instructure.com>
2014-04-10 18:43:53 +00:00
Rob Orton a82a8aed53 ensure assignments API uses correct date time format part1
refs CNVS-10087

test plan
 - assignments PUT and CREATE request will not
   change, but will create error_report when dates
   are not is08601 formatted dates

Change-Id: I83e3621c0604cf91e180f5e59bea2d6e6a164c61
Reviewed-on: https://gerrit.instructure.com/32328
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
Reviewed-by: Anthus Williams <awilliams@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Rob Orton <rob@instructure.com>
2014-04-02 21:51:11 +00:00
Braden Anderson 4f52a5e4c3 outcome gradebook: add export link
fixes CNVS-10638

test plan:
  * open outcome gradebook
  * select a section
  * click on "export report"
  * download and open the export
  * verify that the export format matches the Jira documentation
  * verify that the export data matches the data from your browser

Change-Id: I35bd78719880026b71b30da5794c9afe7dd31868
Reviewed-on: https://gerrit.instructure.com/31774
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Steven Shepherd <sshepherd@instructure.com>
Reviewed-by: Jon Willesen <jonw@instructure.com>
Product-Review: Braden Anderson <banderson@instructure.com>
2014-03-28 20:37:03 +00:00
Joel Hough 8e9db9d7e6 value_to_array returns empty array for nil
test plan
- run specs

Change-Id: I185717113fe0f6e49c7cae800597ea530d4f6a61
Reviewed-on: https://gerrit.instructure.com/30812
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Steven Shepherd <sshepherd@instructure.com>
Reviewed-by: Jon Willesen <jonw@instructure.com>
Product-Review: Joel Hough <joel@instructure.com>
2014-02-26 19:18:17 +00:00
Brian Palmer 4d615cb823 integrate the active_model-better_errors gem
refs CNVS-6040

This gem will help us output json error responses in the API using error
codes, since by itself ActiveRecord::Errors just deals in human-readable
i18n'd strings, and doesn't store detailed machine-readable information
on the error.

BetterErrors is mostly compatible, there's a few differences that mean I
had to change some unrelated code:

* errors[field_name] always returns an array, even if there's only one
  error on the field. This is an improvement IMO.
* errors is indexed by symbol, not by string
* iterating over the errors object now yields
  |attr, error_object| rather than |attr, string_message|

This includes a backport of the gem to rails 2.3.
On rails 3, we just use the vanilla gem.

The error codes aren't yet documented in the API docs, support for doing
that will come in a subsequent commit.

test plan: specs, plus you can hit the one api endpoint i've converted
so far -- account authorization configs. try to create an invalid
config, such as adding both cas and ldap configs to the same account,
and verify the error response formatting

Change-Id: Iaadd843ca9ff3f52c64e0256d82b64595c5559fb
Reviewed-on: https://gerrit.instructure.com/26178
Reviewed-by: Brian Palmer <brianp@instructure.com>
Product-Review: Brian Palmer <brianp@instructure.com>
QA-Review: Brian Palmer <brianp@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
2014-02-21 17:09:53 +00:00
Cody Cutrer cd3b797d58 support special api ids for terms
also, document all special ids

Change-Id: Ife484c02343f8b109eecb3e3b2b4a408f48895b3
Reviewed-on: https://gerrit.instructure.com/30008
QA-Review: August Thornton <august@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2014-02-12 22:10:03 +00:00
Raphael Weiner 91944495c2 convert sanitize field plugin into proper gem: CanvasSanitize
Change-Id: I5562a318bb3f52c1374a3a69f288bfb2381f8ee7
Reviewed-on: https://gerrit.instructure.com/29405
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Stephan Hagemann <stephan@pivotallabs.com>
Product-Review: Stephan Hagemann <stephan@pivotallabs.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
QA-Review: Brian Palmer <brianp@instructure.com>
2014-01-28 22:36:18 +00:00
Joel Hough 68ea9ce600 all outcome result api sideloads are optional
fixes CNVS-10527

the include[] parameter on the outcome result endpoint can now
include 'outcomes', 'users', and 'courses'

test plan
- fetch outcome results using the api
- verify that the 'linked' section is not present
- ensure that outcomes are included when requested
- with the aggregate parameter not set...
 - ensure that users are included when requested
 - ensure that requesting course inclusion results in an error
- with the aggregate parameter is set to 'course'...
 - ensure that courses are included when requested
 - ensure that requesting user inclusion results in an error

Change-Id: I80714c0c8c9534d5853bc1c0e9258919913afa60
Reviewed-on: https://gerrit.instructure.com/28826
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Matt Fairbourn <mfairbourn@instructure.com>
Reviewed-by: Braden Anderson <banderson@instructure.com>
Product-Review: Joel Hough <joel@instructure.com>
2014-01-28 21:53:54 +00:00
Joshua Simpson 1e81ea7caa move quiz into quizzes namespace as a precursor to enginifying
fixes CNVS-10679
this commit refactors quiz into a quizzes namespace. it contains various
shims to facilitate the data migration of polymorphic relationships
('Quiz' -> 'Quizzes::Quiz').  JIRA contains several tickets linked to
the above tickets in regards to removing these shims after the data
migration, as well as the strategies on reverting the shims once the
data migration is complete.
Change-Id: I30c566d60a87af6ee83e9d0041fdcb909ead6a89
Reviewed-on: https://gerrit.instructure.com/28573
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Derek DeVries <ddevries@instructure.com>
QA-Review: Myller de Araujo <myller@instructure.com>
Product-Review: Josh Simpson <jsimpson@instructure.com>
2014-01-24 00:08:46 +00:00
Braden Anderson 4b2c6771bb discussions: use strings for IDs in ENV and materialized view
fixes CNVS-10341

test plan:
  * before applying this commit, if possible:
    * create a discussion
    * add a reply as a student
  * after applying this commit:
    * open the discussion as the student
    * verify that you can edit the reply you added before, but not
        those from other users
    * add a new reply
    * without refreshing, verify that you can edit your new reply
    * refresh the page
    * verify that you can still edit your reply

  * test basic canvas functionality (sorry)

Change-Id: Ifa654f7d853fd167d5bfbaee6184657209d58272
Reviewed-on: https://gerrit.instructure.com/28413
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Zach Pendleton <zachp@instructure.com>
Reviewed-by: Jon Willesen <jonw@instructure.com>
QA-Review: Steven Shepherd <sshepherd@instructure.com>
Product-Review: Braden Anderson <banderson@instructure.com>
2014-01-16 17:31:32 +00:00
Cody Cutrer ddf2f3d4e3 allow api-style ids in non-APIs
Change-Id: I4701af3ad4b1998559ea6cbb6e28617bc38cbcd5
Reviewed-on: https://gerrit.instructure.com/28289
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Rob Orton <rob@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2014-01-14 16:10:53 +00:00
Nick Cloward 1b1ce45f3c add option for course grade change (log auditing)
fixes: CNVS-8996

Added a grade change audit UI for searching grade change events.  This allows the
user to search based off of the grader, student, course id, and assignment id.
In addition to each parameter a date range can be selected.

Currently assignment and course can only be searched if the ID is known.  This
is because there is no way to query for courses based on a name with the api.

Note: The submission after_save :grade_change_audit needed to be after the
simply_versioned call because the grade change audit uses that to grab the
previous grade.  This was a bug in the grade change audit log api.  This
fixes that issue also.

Test Case:
  - Create a course with an assignment and student.
  - Grade the assignment for the student.
  - Change the grade for the student a few times.
  - Open the admin tools. Select the Logging tab and then pick the grade change
    activity option in the drop down.
  - Search for the grader.  The results from the grade changes should show
    accordingly.
  - Search for the student.  The results from the grade changes should show
    accordingly.
  - Search for the course id.  The results from the grade changes should show
    accordingly.
  - Search for the assignment id.  The results from the grade changes should
    show accordingly.
  - Perform each search type again, testing the date range capabilities.
  - Make sure you cannot search with an invalid date range, grader, and student.
  - Enter an invalid course id,  no results should be returned.
  - Enter an invalid assignment id,  no results should be returned.

Change-Id: Ie5a4d34dbb60627374035071c68ec4d404e80135
Reviewed-on: https://gerrit.instructure.com/26868
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Nick Cloward <ncloward@instructure.com>
Product-Review: Nick Cloward <ncloward@instructure.com>
QA-Review: Nick Cloward <ncloward@instructure.com>
Tested-by: Nick Cloward <ncloward@instructure.com>
2014-01-09 23:50:57 +00:00
Joel Hough 8ab50e00a9 user_ids param on outcome result rollup endpoint
fixes CNVS-10040

test plan
- fetch outcome results using api, specifying some users from the
 context in the user_ids parameter
- ensure that only the specified users are returned, even if they
 don't have an outcome result
- fetch course aggregate results, specifying some users
- ensure that only the specified users' scores are used in the
 resulting average
- try to fetch outcome results using the api, specifying some users
 who are not in the context
- ensure that an error is returned
- fetch some outcomes using the api without the user_ids param
- ensure that results for all users are returned

Change-Id: I9e0e3fa37a7087a9808f3ab7c1859410620eab3d
Reviewed-on: https://gerrit.instructure.com/28149
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Matt Fairbourn <mfairbourn@instructure.com>
Reviewed-by: Zach Pendleton <zachp@instructure.com>
Product-Review: Joel Hough <joel@instructure.com>
2014-01-08 21:49:23 +00:00
Stanley Stuart 5f2089c889 import ActiveModel::Serializers port and convert quizzes api to it
test plan:
  - The quiz api should work like it normally does when you don't pass
    an 'Accept: application/vnd.api+json' header.
  - The quizzes index page and quiz edit page should work like they
    always do.
  - Testing the Quizzes API for "jsonapi" style:
    - For all requests, you MUST have the "Accept" header set to
      "application/vnd.api+json"
    - Test all the endpoints (PUT, POST, GET, INDEX, DELETE) like you
      normally would, except you'll need to format the data according to
      the next few steps:
      - For "POST" and "PUT" (create and update) requests, you should send
        the data like: { "quizzes": [ { id: 1, title: "blah" } ]
      - For all requests (except DELETE), you should get back a response
        that looks like: { "quizzes": [ { quiz you requested } ]
    - For the "delete" action, you should get a "no content" response
      and the request should be successful

Change-Id: Ie91deaeb6772cbe52a0fc46a28ab93a4e3036061
Reviewed-on: https://gerrit.instructure.com/25997
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Product-Review: Stanley Stuart <stanley@instructure.com>
2013-12-26 20:32:39 +00:00
Rob Orton db6158e473 allow passing account to api_find
refs CNVS-9084

test plan
 - specs should pass

Change-Id: I323fe3c0081f4268ad379bd2749f6cfd57ef3433
Reviewed-on: https://gerrit.instructure.com/27833
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: Rob Orton <rob@instructure.com>
Product-Review: Rob Orton <rob@instructure.com>
2013-12-23 17:02:34 +00:00
Jacob Fugal 9164e35c16 return empty array for api pagination past end
existing API users need API endpoints to return [] when given a page
past the end of the collection, rather than returning a 404. hopefully
this workaround is temporary...

test-plan:
 - request /api/v1/courses/:course_id/users
 - note the page number in the rel=last url of the Link header in the
   response
 - request /api/v1/courses/:course_id/users?page=<1 more than that>
 - should return an empty array of results
 - should not respond with a 404

Change-Id: Ic8639c7acd2bd07835e8216dd74c1cff0ed51c10
Reviewed-on: https://gerrit.instructure.com/27650
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: Jacob Fugal <jacob@instructure.com>
2013-12-20 05:53:27 +00:00
Ahmad Amireh e3778b529c Quiz Submissions API - Create & Complete
Allows users to start a "quiz-taking session" via the API by creating
a QuizSubmission and later on completing it.

Note that this patch isn't concerned with actually using the QS to
answer questions. That task will be the concern of a new API controller,
QuizSubmissionQuestions.

closes CNVS-8980

TEST PLAN
---- ----

- Create a quiz
- Keep a tab open on the Moderate Quiz (MQ from now) page

Create the quiz submission (ie, start a quiz-taking session):

- Via the API, as a student:
  - POST to /courses/:course_id/quizzes/:quiz_id/submissions
    - Verify that you receive a 200 response with the newly created
      QuizSubmission in the JSON response.
    - Copy the "validation_token" field down, you will need this later
    - Go to the MQ tab and verify that it says the student has started a
      quiz attempt

Complete the quiz submission (ie, finish a quiz-taking session):

- Via the API, as a student, prepare a request with:
  - Method: POST
  - URI: /courses/:course_id/quizzes/:quiz_id/submissions/:id/complete
  - Parameter "validation_token" to what you copied earlier
  - Parameter "attempt" to the current attempt number (starts at 1)
  - Now perform the request, and:
    - Verify that you receive a 200 response
    - Go to the MQ tab and verify that it says the submission has been
      completed (ie, Time column reads "finished in X seconds/minutes")

Other stuff to test (failure scenarios):

The first endpoint (one for starting a quiz attempt) should reject your
request in any of the following cases:

  - The quiz has been locked
  - You are not enrolled in the quiz course
  - The Quiz has an Access Code that you either didn't pass, or passed
    incorrectly
  - The Quiz has an IP filter and you're not in the address range
  - You are already taking the quiz (you've created the submission and
    did not call /complete yet)
  - You are not currently taking the quiz, but you already took it
    earlier and the Quiz does not allow for multiple attempts

The second endpoint (one for completing the quiz attempt) should reject
your request in any of the following cases:

  - You pass in an invalid "validation_token"
  - You already completed that quiz submission (e.g, you called that
    endpoint earlier)

Change-Id: Iff8a47859d7477c210de46ea034544d5e2527fb2
Reviewed-on: https://gerrit.instructure.com/27015
Reviewed-by: Derek DeVries <ddevries@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Myller de Araujo <myller@instructure.com>
Product-Review: Ahmad Amireh <ahmad@instructure.com>
2013-12-19 06:44:28 +00:00
Jon Willesen 1212fd72e8 fix url transforms in user content
The api_user_content function was returning absolute urls when
adding the verifier parameter, but HtmlRewriter only works
properly with relative urls (doing a regex gsub). This was
causing corruption of existing absolute urls (which were
probably introduced by a prior bug).

Fortunately, the api_user_content function translates relative
urls into absolute urls in a later step, so this just fixes a
bug and doesn't change the interface of api_user_content
function.

fixes CNVS-9882

test plan:
 - put a link to an image in the course's files a discussion
   topic and save.
 - inspect the image element; the src attribute should be a
   relative link
 - edit the discussion topic and click "switch views." Change
   the relative url for the src attribute to an absolute url
   and save.
 - inspect the image element again; the src attribute should be
   an absolute link.
 - edit the discussion topic. The image should display normally.  make a text edit and save.
 - the image should still display normally in the discussion
   topic.

Change-Id: Ifc056b5507d70ef63bbe07a2245e08cad7bbd605
Reviewed-on: https://gerrit.instructure.com/27472
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Braden Anderson <banderson@instructure.com>
QA-Review: Steven Shepherd <sshepherd@instructure.com>
Product-Review: Jon Willesen <jonw@instructure.com>
2013-12-16 18:07:37 +00:00
Jacob Fugal ac39cfcf22 clean up paginate calls
fixes CNVS-8791
fixes CNVS-8795

 * "without_count: true" -> "total_entries: nil"
 * move order clauses to the pagination target, rather than being in the
   pagination call
 * clean up implementation of first/last page links in Api.paginate

test-plan:
  - have an account report with at least two instances
  - fetch /api/v1/accounts/:account_id/reports/:report
  - response should have most recent report instance first

  - have two subaccounts under an account
  - fetch /api/v1/accounts/:id/sub_accounts?recursive=true&per_page=1
  - Links response header should not have a link with rel=last
  - fetch /api/v1/accounts/:id/sub_accounts?recursive=false&per_page=1
  - Links response header should have a link with rel=last embedding
    page=2

  - load /error_reports
  - should have most recent reports first

  - fetch /api/v1/conversations/batches
  - should have oldest batch first

Change-Id: Ifef79b193720a09ad7fe059ed23e930c97d10f59
Reviewed-on: https://gerrit.instructure.com/26535
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Product-Review: Jacob Fugal <jacob@instructure.com>
2013-12-07 00:04:06 +00:00
Jacob Fugal 03f150a078 cleanup lib/api.rb for folio
refs CNVS-5305

with folio pages, we can just trust and use page.first_page and
page.last_page

test-plan:
 * /api/v1/courses
   - should have "first" link regardless of page (first, last, in
     between)
   - should have "last" link regardless of page (first, last, in
     between)
 * /api/v1/search/recipients?context=course_123
   - should have "first" link regardless of page (first, last, in
     between)
   - should not have "last" link when there's a next page
   - should have "last" link on last page (no next page)
 * exercise the conversation receipient search when the search results
   have just one hit
   - should not throw an error
 * load gradebook2 when there's only one page of enrollments
   - should not throw an error

Change-Id: If6dfa972db22a91350ee820ccbfe25008f6b0e90
Reviewed-on: https://gerrit.instructure.com/26538
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: Jacob Fugal <jacob@instructure.com>
2013-11-25 16:37:31 +00:00