Commit Graph

2321 Commits

Author SHA1 Message Date
Jeremy Stanley 5773e05c3c avoid excessive update-cached-due-date callbacks
deleting a user could cause thousands of update-cached-due-dates
jobs to be enqueued (one per assignment per enrollment; in the
referenced ticket, the test student had 13 enrollments and there
were 88 assignments, yielding 1,144 jobs, causing the request
to time out).

fix this by
 (1) using a batch job to update all assignments in the course,
     instead of a job per assignment
 (2) when deleting a user with multiple enrollments in a course,
     only run the update cached due date job once per course

test plan:
 0. run in "production" configuration (i.e., in QA portal)
 1. have a course with 10 sections and 100 assignments.
    I suggest creating these in the console, e.g.

    course = course.create! name: "CNVS-8068"
    10.times { |x| course.course_sections.create! name: "section #{x}" }
    100.times { |x| course.assignments.create! name: "assignment #{x}" }

 2. enter student view mode in this course
 3. reset the student view student
 4. verify 1000 jobs were not created (and the request doesn't time out)

fixes CNVS-8068

Change-Id: If00dd3197b70df42b0f9ec18303b02594861f69f
Reviewed-on: https://gerrit.instructure.com/25160
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Matt Fairbourn <mfairbourn@instructure.com>
Product-Review: Bracken Mosbacker <bracken@instructure.com>
2013-10-16 21:04:03 +00:00
Cody Cutrer 4300e1bf48 Revert "Revert "use the cached plugin settings to determine if enabled""
This reverts commit 3f056ea589.

Change-Id: Ic9fd2c48ae26e26e72cca3a6563e6ee794ecccb5
Reviewed-on: https://gerrit.instructure.com/25241
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2013-10-16 19:54:11 +00:00
Stanley Stuart c4a80d6dcb prevent teachers from unpublishing assignments with submissions
test plan:
  - As a teacher, make a quiz and an assignment.
  - You should be able to unpublish and publish the quiz and assignment
    and will.
  - Publish the quiz and assignment
  - As the student, turn in a submission for the assignment and quiz.
  - As the teacher, you should not be able to unpublish the quiz and
    assignment.

fixes CNVS-7193

Change-Id: Id56ba2ec87275fcfd6d76397f2e41b32abc88833
Reviewed-on: https://gerrit.instructure.com/24103
Reviewed-by: Simon Williams <simon@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Myller de Araujo <myller@instructure.com>
Product-Review: Stanley Stuart <stanley@instructure.com>
2013-10-16 19:33:47 +00:00
Cody Cutrer 7436a7011f don't create module progressions for users that aren't even in a course
Change-Id: I1ab5201c91bac51cea142f202c7e1fb62fdc7ffe
Reviewed-on: https://gerrit.instructure.com/24987
Reviewed-by: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
2013-10-16 00:17:16 +00:00
Cody Cutrer 8cb9d0404b UI and API for publish final grade upon module completion
test plan:
 * configure grade passback to an endpoint on localhost
 * use nc to listen on that endpoint
 * add a module to a course, configure it to publish grades
   when it is completed
 * complete the module, as a student
 * your nc should have got a grade publishing notification
 * validate that you can edit grade publishing settings for
   existing modules
 * validate that updating and viewing grade publishing settings
   for modules via the API

Change-Id: I100cff54e1b5e83b56d93d35bf950f589357b88b
Reviewed-on: https://gerrit.instructure.com/24983
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2013-10-15 21:59:37 +00:00
Cody Cutrer 957d50a8e5 add framework for events to be triggered when a module is completed
use it to trigger a singular grade publish for a user

Change-Id: If28044b9bef6c71d2061adb2ac423b836f4c8634
Reviewed-on: https://gerrit.instructure.com/24977
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2013-10-15 21:59:07 +00:00
Cody Cutrer 6470c0f326 detect failed SIS jobs
fixes CNVS-7801

test plan:
 * upload a large sis import (one that will take long enough for you
   kill it) via UI
 * start jobs
 * make sure you see progress in the UI
 * kill -9 the DJ worker processing the batch
 * the UI should immediately update that it failed

Change-Id: Ifa86892326eda4f59deac659421ac8b7ce32b3bc
Reviewed-on: https://gerrit.instructure.com/23836
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2013-10-15 21:57:56 +00:00
Jacob Fugal 2bcb852a18 convert app/models/mailer.rb for rails3
fixes CNVS-8732

makes Mailer#message act in the rails3 style, but then provides
scaffolding so that it produces the necessary rails2 behavior when
running under rails2

test-plan:
 * email delivery needs to be configured
 * set up an email communication channel for a student
 * configure to receive conversation alerts at that channel
 * have a teacher send a conversation message to that student
 * confirm receipt of the email at the student's address

Change-Id: I7f027a0a9a9dfd0231847017c888f1003b38d948
Reviewed-on: https://gerrit.instructure.com/25035
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Jacob Fugal <jacob@instructure.com>
2013-10-15 21:17:42 +00:00
Derek DeVries 9660d1fdd6 fix relative margin of error for negative answer values
fixes CNVS-8836

test plan:
- create a formula question
- add a question where the answer will be negative
- add a percentage margin of error
- make sure adding an answer above/below that margin of error works correctly

Change-Id: I80ed024d0a83109f006563145bc2f363bb25418f
Reviewed-on: https://gerrit.instructure.com/25304
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Myller de Araujo <myller@instructure.com>
Reviewed-by: Josh Simpson <jsimpson@instructure.com>
Product-Review: Derek DeVries <ddevries@instructure.com>
2013-10-15 19:48:53 +00:00
Jeremy Stanley 4d38ec5ea2 allow teachers to access future courses
test plan:
 1. create an enrollment term that begins in the future
 2. create a course and put it in that term
 3. invite a teacher to the course
 4. log in as the teacher
 5. you should not be locked out of the course as soon as
    you accept the invitation

fixes CNVS-8712

Change-Id: Iae60fbeba8e7e00d434fb1f984b3a0c26f1396c3
Reviewed-on: https://gerrit.instructure.com/25289
Reviewed-by: Bracken Mosbacker <bracken@instructure.com>
Product-Review: Bracken Mosbacker <bracken@instructure.com>
QA-Review: Matt Fairbourn <mfairbourn@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
2013-10-15 19:17:26 +00:00
Jeremy Stanley 5c7c0078f6 make course end_at override enrollment_term end_at
test plan:
1. have an enrollment term that has ended
2. have a course in that term whose end date is in the future
3. check that you can still add users to the course
   (the add-users button shouldn't have mouseover text that
   says you can't add users because the course is concluded)

fixes CNVS-2702

Change-Id: I52e0ca83f488f737c95e7f58d2e59be1187970f1
Reviewed-on: https://gerrit.instructure.com/25210
Reviewed-by: Bracken Mosbacker <bracken@instructure.com>
Product-Review: Bracken Mosbacker <bracken@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Matt Fairbourn <mfairbourn@instructure.com>
2013-10-15 17:06:09 +00:00
Jon Jensen e8416649dc avoid infinte recursion when self-enrolling in another shard
fixes CNVS-8780

test plan:
1. create a user in one shard
2. try to self enroll in a course in another shard
3. it should work, and you should not get a page error

Change-Id: Id856686546499f90c4a77cd64d008b621cdc4158
Reviewed-on: https://gerrit.instructure.com/25257
Reviewed-by: Landon Wilkins <lwilkins@instructure.com>
Product-Review: Marc LeGendre <marc@instructure.com>
QA-Review: Marc LeGendre <marc@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
2013-10-14 19:55:06 +00:00
Jacob Fugal 9b3bfbfeef avoid :conditions argument to find, count, etc.
use arel's where() instead. use of :conditions in has_many/has_one
remains, and a small handful of cases where rails2 sharding needs the
conditions in the find.

also, cleanup distinct_on() to only allow the :select/:option values it
works with directly; other finder options should be scoped in before the
distinct_on call.

fixes CNVS-8754

test-plan:
 [1] communication messages API
 - fetch /api/v1/comm_messages?user_id=self as a non-siteadmin; should
   not error, should include the expected messages

 [2] course roster
 - load /courses/<id>/users
 - invite a new student to the course; do not have that student accept
   the invitation
 - reload and open the web console; ENV.courses.pendingInvitationCount
   should be 1

 [4] list enrollments API endpoint
 - full regression

 [5] list conversations API endpoint
 - fetch /api/v1/conversations; should not error, should include the
   expected messages

 [6] rubrics
 - create a rubric with title "Example Rubric"
 - create a second rubric with the same title; title should be changed
   on save to "Example Rubric (1)"
 - repeat to get "Example Rubric (2)"

Change-Id: I411676285348653044696d850efacf2e1a9e6585
Reviewed-on: https://gerrit.instructure.com/24996
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Product-Review: Jacob Fugal <jacob@instructure.com>
2013-10-14 19:29:27 +00:00
Jacob Fugal 4520f0043e use rails3 style validate/before_validation
rather than rails2.3 style validate_on_* and before_validation_on_*

fixes CNVS-8752

test-plan: (in script/console)
 - initialize a discussion entry (not yet saved)
 - set entry.depth to DiscussionEntry.max_depth + 1
 - try to save it; should raise an error about the maximum depth
 - set entry.depth to nil
 - save it; should not encounter an error
 - check entry.depth; should be 1
 [this next part seems weird to me, but follows the letter of the code]
 - with the same, no-longer-new entry, set entry.depth to nil
 - try to save it; should not encounter an error
 - check entry.depth; should still be nil

Change-Id: Ia56a7ab17d36698e59fda4b520b07352d61ce02e
Reviewed-on: https://gerrit.instructure.com/24997
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Reviewed-by: Nick Cloward <ncloward@instructure.com>
Product-Review: Jacob Fugal <jacob@instructure.com>
2013-10-14 19:28:28 +00:00
Nick Cloward 4fd6169cdd Fixed postgres build error without MRA
Change-Id: I8d5ab52470b212777757d5e3310acb168a07189b
Reviewed-on: https://gerrit.instructure.com/25198
Reviewed-by: Jacob Fugal <jacob@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Product-Review: Nick Cloward <ncloward@instructure.com>
2013-10-14 13:23:12 +00:00
Simon Williams b59fae9897 make submission version datafixup ignore yaml errors
fixes CNVS-8241

test plan:
- is possible, have a submission version with invalid yaml
- make sure the PopulateSubmissionVersions job runs successfully
- make sure the GradingHistory api endpoint returns all submission
  versions

Change-Id: I00039df95cd3725d32c5478b27f10b9557cb9172
Reviewed-on: https://gerrit.instructure.com/24646
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jacob Fugal <jacob@instructure.com>
QA-Review: Amber Taniuchi <amber@instructure.com>
Product-Review: Simon Williams <simon@instructure.com>
2013-10-11 19:51:29 +00:00
Jon Willesen 136649ce17 add Auto-Submitted header to outgoing mail
this is a standard header that indicates to other programs that
notifications and bounce messages are computer generated and
should not be responded to. This could prevent potential
message loops.

fixes CNVS-8718

test plan:
 - configure canvas to send outgoing mail.
 - generate a notification that doesn't accept replies (such as
   a new assignment) and recieve the notification email.
 - examine the headers (in gmail: "show original") and see
   "Auto-Submitted: auto-generated".
 - reply to the notification, which should bounce.
 - examine the bounce email headers and see
   "Auto-Submitted: auto-replied".

Change-Id: I2dee55628fd43b7aa61cd3167a71ed536562328d
Reviewed-on: https://gerrit.instructure.com/25132
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Amber Taniuchi <amber@instructure.com>
Reviewed-by: Jon Willesen <jonw@instructure.com>
Product-Review: Jon Willesen <jonw@instructure.com>
2013-10-11 19:37:21 +00:00
Paul Hinze 3f056ea589 Revert "use the cached plugin settings to determine if enabled"
This reverts commit 536f4d5038.

PluginSettings hold an instance of Plugin, which have a `@meta` instance
variable that contains Procs for i18n. Marshaling this entire tree into
the cache blows up with "no _dump_data is defined for class Proc".

Reverting to fix master since Cody is the only one with knowledge of why
this was done and he's out.

Change-Id: I4340e977ecfbaf6c598bdc05ce61e0d0bdce9a35
Reviewed-on: https://gerrit.instructure.com/25211
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Product-Review: Paul Hinze <paulh@instructure.com>
QA-Review: Paul Hinze <paulh@instructure.com>
2013-10-11 17:12:39 +00:00
Jacob Fugal dfab0425e3 use CANVAS_RAILS2 for conditionals
rather than CANVAS_RAILS3 or Rails.version

this is to be consistent, and to reinforce that any "special" branches
are for rails 2.3 backwards compatibility while trying to target rails
3, rather than rails 3 "forwards compatibility".

Change-Id: I4494b65e3f71108a43d09032c1569c478646a828
Reviewed-on: https://gerrit.instructure.com/24998
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
Product-Review: Jacob Fugal <jacob@instructure.com>
QA-Review: Jacob Fugal <jacob@instructure.com>
2013-10-10 15:58:43 +00:00
Cody Cutrer 536f4d5038 use the cached plugin settings to determine if enabled
Change-Id: Idae91f14090fba31391ef10b8472114b606a0322
Reviewed-on: https://gerrit.instructure.com/25023
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>
2013-10-10 15:55:22 +00:00
Nick Cloward 68d4bee5d9 favorites does not work for cross-shard users
fixes: CNVS-2197

Favorite courses between shards are broken due to the query performing an
EXISTS on the favorites table.  This change fixes the query in that it gets
the favorite course ids from the users shard and converts them to a relative id
for the each shard the queyr runs on.

Test Case:
  Setup:
    - Create two courses, each on different shards.
      (Course 1 on shard 1, Course2 on shard 2)
    - Schedule a student from either shard 1 or shard 2 to both of
      the created courses.

    Note: A teacher should also be sufficient as long as they are associated to
    both courses.

  1. Log in as the student / teacher
  2. Both courses should show under the
  Courses menu.

  3. Click the customize button in the courses menu.
  4. Uncheck one of the courses.
  5. Refresh the page and the courses menu should not show the course
  that was unchecked.

  6. Click the customize button in the courses menu.
  7. Uncheck the other course so none of them are checked.
  8. Refresh the page and the courses menu should
  be reset back to normal. (Both courses showing and checked in customize) -
  When all the courses are unchecked it should reset back to the default view.

  9. Go through steps 3-5 again but with the opposite course.

  10. Click the customize button in the courses menu.
  11. Click the reset button.
  12. Refresh the page and the courses menu should be reset back to
  normal. (Both courses showing and checked in customize)

  13. Add x number of courses and perform various customizations and the menu
  should correctly reflect it even when courses span shards.

I also fixed a bug with the favorites.  The favorites reset each time all the favorites
were unchecked.  So unchecking all the favorites and then checking another one
reset the favorites to all of them.  Here are steps to test that change:

  1.  Reset favorites
  2.  Uncheck all favorites
  3.  Check one favorite
  4. Refresh the page and the only course visible should be the favorite that was
  added in the previous step.

Change-Id: I8776696976b0974af42b7273333b39b88f388eb7
Reviewed-on: https://gerrit.instructure.com/24979
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Nick Cloward <ncloward@instructure.com>
2013-10-10 15:20:38 +00:00
Cody Cutrer d935ab98b1 deprecate Setting.get_cached
now that we have SIGHUP, we were changing everything to it anyway,
so just let caching in-proc be the default

Change-Id: Id1b44722522ac9693b17695da7107c99a359d5ac
Reviewed-on: https://gerrit.instructure.com/25020
Reviewed-by: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
2013-10-10 00:42:52 +00:00
Cody Cutrer aec69f3743 drop unused context_modules.downstream_modules
Change-Id: Icf24669d94da42e8a9e4f8e09af2cd561ab85af7
Reviewed-on: https://gerrit.instructure.com/24973
Reviewed-by: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
2013-10-10 00:42:45 +00:00
Cody Cutrer dc5bea3ca2 add stubs and use weak associated shards
refs CNVS-2203

also transfer weak associations on user merge

Change-Id: If7b9f6d2036864a96911b2ac81dfe80c4e9775c4
Reviewed-on: https://gerrit.instructure.com/24466
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2013-10-09 23:57:53 +00:00
Cody Cutrer 0c82bd3f3b remove some cache expirations for things that are properly invalidated
Change-Id: Ie9d903b791a96f24faabeccf399c59c26338a893
Reviewed-on: https://gerrit.instructure.com/25022
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2013-10-09 23:38:49 +00:00
Cody Cutrer 3bb5d7aa9d enable support for publishing grades for a limited list of users
test plan:
 * specs

Change-Id: I5335726eaae8abb245e13aaed04cf6947153b5c0
Reviewed-on: https://gerrit.instructure.com/24970
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2013-10-09 23:37:42 +00:00
Liz Abinante d97fb1611a validates length of allowed_extensions
fixes CNVS-6066

test plan
* using API:
 - make an update call to an existing assignment
 - set assignment[allowed_extenstions] to be a string > 255 chars
 - verify error message is "internal_server_error"
 - API call should not return anything from the database
 - make another update call to an existing assignment
 - set assignment[allowed_extensions] to be a string <= 255 chars
 - verify that the change was saved

* from assignment edit page:
 - check 'Allow file uploads'
 - check 'Restrict upload file types'
 - add some file types in the box and save (<= 255 chars)
 - verify that it saved the file types
 - edit the assignment again
 - verify that you cannot exceed 255 chars in the 'file types' field

Change-Id: Ibf8ce3c77282951d6180894415d23470d4402f63
Reviewed-on: https://gerrit.instructure.com/25082
Reviewed-by: Simon Williams <simon@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Amber Taniuchi <amber@instructure.com>
Product-Review: Simon Williams <simon@instructure.com>
2013-10-09 12:19:50 +00:00
James Williams f360597426 remove unnecessary clone_for methods
Change-Id: I8d80d36bde5dfdcff3de2f86aa3223e6c03a23aa
Reviewed-on: https://gerrit.instructure.com/24771
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Bracken Mosbacker <bracken@instructure.com>
Product-Review: Bracken Mosbacker <bracken@instructure.com>
QA-Review: Bracken Mosbacker <bracken@instructure.com>
2013-10-09 12:13:18 +00:00
Jeremy Stanley f6d1d8f524 add published parameter to wiki pages api index
test plan:
 1. with draft state disabled,
  - create a normal page (A)
  - create a hidden-from-students page (B)
  - create another hidden-from-students page (E), and
    delete it (make sure it isn't returned later)
 3. with draft state enabled, in the same course
  - create a published page (C)
  - create an unpublished page (D)
 4. use the wiki pages index api as a teacher, with no params
  - the four non-deleted pages (A-D) should be returned
 5. use the wiki pages index api as a teacher, with
    published = true
    - only the non-hidden page (A) and the published page (C)
      should be returned
 6. use the wiki pages index api as a teacher, with
    published = false
    - only the hidden page (B) and the unpublished page (D)
      should be returned
 7. use the wiki pages index api as a student, with no params
    - only the non-hidden page (A) and the published page (C)
      should be returned
 8. use the wiki pages index api as a student, with
    published = true
    - only the non-hidden page (A) and the published page (C)
      should be returned
 9. use the wiki pages index api as a student, with
    published = false
    - no pages should be returned

fixes CNVS-8681

Change-Id: I55c003764e34244d0a970e8ed606d38f0112a435
Reviewed-on: https://gerrit.instructure.com/25095
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Mark Severson <markse@instructure.com>
Product-Review: Bracken Mosbacker <bracken@instructure.com>
QA-Review: Hannah Bottalla <hannah@instructure.com>
2013-10-08 22:30:13 +00:00
Zach Pendleton 86f371f9d8 add agenda view setting to root accounts
fixes CNVS-8676

test plan:
  * from the console, enable the "agenda_view" setting
    on your root account;
  * verify that it works.

Change-Id: I5b20773ce8fc9496a5c5cd07c628ce2638b29d89
Reviewed-on: https://gerrit.instructure.com/25071
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jon Willesen <jonw@instructure.com>
Product-Review: Zach Pendleton <zachp@instructure.com>
QA-Review: Zach Pendleton <zachp@instructure.com>
2013-10-07 23:00:27 +00:00
Zach Pendleton edd5f5d82d remove dimdim plugin
dimdim no longer exists; no need to keep this code
around.

Change-Id: I3b1b360b71eccd7b10fd36c577bdac7b6f81976a
Reviewed-on: https://gerrit.instructure.com/24512
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Cam Theriault <cam@instructure.com>
Reviewed-by: Zach Pendleton <zachp@instructure.com>
Product-Review: Zach Pendleton <zachp@instructure.com>
2013-10-07 21:56:10 +00:00
Brian Palmer e1b650f53f log the remote_ip in page views
refs CNVS-8392

also update the page view API documentation

test plan:
* with this commit applied, page views will now log the remote
  ip of requests, and return that ip in the api and csv downloads
* regenerate api docs with rake doc:api, and verify that the user
  section now has expanded information on the api response

Change-Id: If463e211515881db6ce1f75c9bbca8c7fbcf7589
Reviewed-on: https://gerrit.instructure.com/24880
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: Brian Palmer <brianp@instructure.com>
2013-10-07 15:04:50 +00:00
Simon Williams d71df3d60f fix speedgrader regression with quiz lateness
fixes CNVS-8649

test plan:
- create a quiz with a due date in the future and a timelimit
- take the quiz as a student
- go to speedgrader
- it should not be marked as late
- now change the due date to be in the past
- go back to speedgrader
- it should be marked as late

Change-Id: I853e7eb9ecbb6f4ffae20dac3e69c64dc30829f2
Reviewed-on: https://gerrit.instructure.com/25048
Reviewed-by: Stanley Stuart <stanley@instructure.com>
Reviewed-by: Rob Orton <rob@instructure.com>
QA-Review: Bryan Madsen <bryan@instructure.com>
Tested-by: Bryan Madsen <bryan@instructure.com>
Product-Review: Brian Palmer <brianp@instructure.com>
2013-10-05 18:56:32 +00:00
Mark Severson 074151402d allow PUT requests to create wiki pages implicitly
testing note:
  this change affects all wiki page endpoints: api, draft state,
  and non-draft state. basic functionality for all of these
  pages should be verified, specifically when dealing with
  non-existent or deleted pages.

test plan:
 * PUT to /api/v1/courses/:course_id/front_page
   - variations:
     * wiki_page[title] - provided/not provided
     * wiki_page[published] - true/false/not provided
     * wiki_page[hide_from_students] - true/false/not provided
     (hiding/unpublishing the front page is not allowed)
 * PUT to /api/v1/courses/:course_id/pages/non-existent-page
   - same variations as front_page (above)
 * navigating to a non-existent/deleted page (draft state/non-draft state)
   - should redirect teachers to the edit page
   - should redirect students to the index page
     (with an alert message indicating why)
 * navigating to the 'Pages' tab (non-draft state)
   - if the 'Front Page' exists
     - shows the page
   - if the 'Front Page' has been deleted (with draft state enabled)
     - shows the edit page
   - if the 'Front Page' has never existed
     - shows the edit page

 * all other pages functionality should remain unchanged
   - non-draft state UI
     - show page
     - edit page
   - draft state UI
     - index page
     - show page
     - edit page
   - api
     - .../pages
       - GET (index)
       - POST (create page)
     - .../front_page
       - GET (show front page)
       - PUT (create/update front page)
     - .../pages/page-url
       - GET (show page)
       - PUT (create/update page)
       - DELETE (destroy page)

fixes CNVS-8488

Change-Id: I563e6944e1602e0b21ab69c6fe2dcd643c06611d
Reviewed-on: https://gerrit.instructure.com/23590
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Matt Fairbourn <mfairbourn@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Product-Review: Bracken Mosbacker <bracken@instructure.com>
2013-10-04 21:44:29 +00:00
James Williams 212bab7ebc fix quiz importing, re-importing, and overwriting
test plan:

1)
* create a course with a quiz assignment and
 a quiz module item
* copy into a new course

* in the original course, edit the quiz title
* copy the original into the new course again

* note that a new quiz, assignment, or module item
 has *not* been created, but rather their titles
have been updated

* confirm that the same happens when a course is
exported and re-imported

2)
* create a qti export from the original course
* import it as a QTI file into a new course

* edit the title of the quiz in the new course

* re-import the file, checking the "overwrite assessment
content" checkbox
* should revert the title to the original

* re=import the file, without checking the box
* should create a new quiz

fixes #CNVS-8097 #CNVS-8308 #CNVS-8443

Change-Id: I8b03ca9c9f5f1f3dada4d19369002f20b925d77e
Reviewed-on: https://gerrit.instructure.com/24710
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Bracken Mosbacker <bracken@instructure.com>
2013-10-04 16:52:35 +00:00
Brian Palmer c17f3570bd use the now-standard timeout_protection for ldap binding
The previous code was a one-off written before timeout_protection
existed. This means that we'll now allow N timeouts (3 by default) in
the given period, rather than refusing to connect to the LDAP server
after just one timeout.

closes CNVS-8371

test plan:

* Configure an account to use ldap. Rather than setting up a real ldap
  server, it's sufficient for this testing to just use nc or another
  application to listen on the port you specify in the account config.
* Attempt to login to the account, and see canvas in your nc output.
  Allow it to timeout. Attempt again, and canvas will hit your "ldap
  server" again. After 3 timed out attempts, canvas will blacklist your
  server for 1 minute.
* Also verify that logging in with ldap still works against a real ldap.

Change-Id: I60293d01690be3cc24f57b8bcd5c6c52e23fc2a9
Reviewed-on: https://gerrit.instructure.com/24657
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: Brian Palmer <brianp@instructure.com>
2013-10-03 22:18:16 +00:00
Jeremy Stanley 5f5166d37d fix up module positions after import
test plan:
  CNVS-4067
   - create a course (A) with three modules
   - use the modules API to retrieve positions, and verify
     they're unique (1, 2, 3)
   - export course A
   - create a second course (B) with three modules having
     different names from course A
   - import course A into course B
   - use the modules API to retrieve positions in course B,
     and verify that the imported modules' positions from A
     do not overlap course B's module positions
     (e.g., they should be 4, 5, 6)
   - also test positions of imported assignment groups
  CNVS-8256
   - import the course attached to the ticket
   - use the modules API to list the modules in the course
   - the positions should be unique: (1, 2, 3), not (1, 1, 1)

fixes CNVS-4067
fixes CNVS-8256

Change-Id: Ib81a238e073e46eb01d72565a569ab24762d37bf
Reviewed-on: https://gerrit.instructure.com/24525
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Bracken Mosbacker <bracken@instructure.com>
Product-Review: Bracken Mosbacker <bracken@instructure.com>
QA-Review: Matt Fairbourn <mfairbourn@instructure.com>
2013-10-03 20:54:54 +00:00
Cody Cutrer 1561f83a64 add helper for NULLS FIRST/LAST
generates sane SQL for postgresql, which natively supports that,
and the correct workaround for others.

cause I can never remember the workaround in the first place, and
it's very confusing to read existing instances

Change-Id: I75dda687c057888a02a8d99a9b26c4674383006f
Reviewed-on: https://gerrit.instructure.com/24870
Reviewed-by: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
2013-10-02 21:38:12 +00:00
Cody Cutrer 419877ff9d clean up sorting all over
* use sort_by instead of sort where possible to avoid repeating yourself
 * use new SortFirst/SortLast sentinels to avoid strange magical constants
 * fix a few places of complicated logic for tiered sorting to just use
   an array

Change-Id: I184ef0b4e31fa18294c9beb32770101d383bbea1
Reviewed-on: https://gerrit.instructure.com/24867
Reviewed-by: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
2013-10-02 21:38:08 +00:00
Cody Cutrer 266a89e7db use unicode sorting for ruby and db stuff
fixes CNVS-7199, CNVS-4414

abstract some ICU stuff out to Canvas::ICU, and add some missing
functionality in FFI-ICU

test plan:
 * create a bunch of groups in the same category, named 1-10.
   10 should sort after 9, not 1
 * repeat for creating and publishing quizzes *with the same due date*.
   go to the quiz index, and 10 should sort after 9, not 1

Change-Id: I323eb12dfb5bd23dbcbb3b543fa1b90a72f4341b
Reviewed-on: https://gerrit.instructure.com/24732
Reviewed-by: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
2013-10-02 21:38:03 +00:00
Jacob Fugal 162f5d1e84 inline (and optimize) User.file_structure_for
refs CNVS-7597

this was the only call site, and the implementation did a lot in ruby
that is better done in the database

test-plan:
  - regression testing on /api/v1/courses/123/files

Change-Id: I120438c58f1c8de34503a0d14fc51d3853eb9385
Reviewed-on: https://gerrit.instructure.com/23943
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Product-Review: Jacob Fugal <jacob@instructure.com>
QA-Review: Jacob Fugal <jacob@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
2013-10-02 16:15:31 +00:00
Cody Cutrer 83de92811d clear plugin settings cache after transaction commit
Change-Id: I0f6a72d7e8562618dbd98ad128b55a970c532c82
Reviewed-on: https://gerrit.instructure.com/24640
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2013-10-01 23:51:18 +00:00
Braden Anderson 79bb5e1c14 conversations: constrain subject length
test plan:
  * verify that the API docs for "Create a conversation" document that
      the maximum subject length is 255 characters
  * post a conversation to the API with a subject longer than 255 chars
  * verify that you get a model validation error
  * open new conversations
  * compose a message
  * try to enter more than 255 characters in the subject field
  * verify that your input is constrained

Change-Id: Ibf569c8b7aa17677a5968859b57b0e0c3c373603
Reviewed-on: https://gerrit.instructure.com/23521
QA-Review: Cam Theriault <cam@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Zach Pendleton <zachp@instructure.com>
Product-Review: Braden Anderson <banderson@instructure.com>
2013-09-30 20:52:47 +00:00
Derek DeVries bc043d8e3c add relative margin of error in formula questions
closes CNVS-7197

test plan:
- add a formula question type in a quiz
- create your variable definitions and formula definitions

  scenario 1:
- generate possible solutions, and add a margin of +/- a percentage value (5%)
- make sure that when a student answers a quiz question that it allows the
  percentage margin of error entered

  scenario 2:
- generate possible solutions, and add a margin of +/- a point value (2.0)
- make sure that when a student answers a quiz question that it allows the
  margin of error entered (as it worked previously)

Change-Id: Ib819cdd2b3412dfb080e44cacf6516ceb8fa4944
Reviewed-on: https://gerrit.instructure.com/24539
Reviewed-by: Josh Simpson <jsimpson@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Myller de Araujo <myller@instructure.com>
Product-Review: Derek DeVries <ddevries@instructure.com>
2013-09-30 20:08:21 +00:00
Nick Cloward 14b5840ae3 Add a permission option in the api to return if the user can create topics.
closes CNVS-6824

This adds a permissions attribute to the returned json for discussion topic
contexts (Course, Group).

The permissions attribute contains an optional permission of
"create_discission_topic" which returns true or false depending on whether the
current user can create discussion topics for the course or group.  For
performance reasons this is only added to a single course/group json and not in
lists so the only call that will return it is /api/v1/<context>/<context_id>
where context is a course or group.  Since we did not want to include this on
every response its a custom permissions attribute for course and groups in the
course_json or group_json serialization methods.

Using the includes parameter for the API supplying a value of "permissions"
will include the permissions with "create_discussion_topic" for a group and
course.  When the object is serialized to json it checked to see if the model
implements a serialize_permissions method and calls that to render or override
permissions generated from the policies.

- Create a test Course. Make sure the course allows members to post topics.
- Add a student to the course.
- Make a call to /api/v1/courses/<id> where "<id>" is the id of the created
  course.
- The response should include a permissions attribute with a boolean value for
  "create_discission_topic" see the example below.

- Make a call to /api/v1/courses to return a list of course objects.
- The permissions attribute should not be included in the response.

- Create a test Group tied to the course created in the first step.
- Add a mamber to the group.
- Make a call to /api/v1/groups/<id> where "<id>" is the id of the created
  group.
- The response should include a permissions attribute with a boolean value for
  "create_discission_topic" see the example below.

- Make a call to /api/v1/groups to return a list of group objects.
- The permissions attribute should not be included in the response.

Example Response:
{
	id: 42,
	...
	permissions: {
		create_discission_topic: true
	}
}

Change-Id: Ia02d5aa67e345740a93dd0f63e357e7cb5e1efd6
Reviewed-on: https://gerrit.instructure.com/24478
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: Nick Cloward <ncloward@instructure.com>
2013-09-30 14:32:48 +00:00
Zach Pendleton 27104bbeb6 properly serialize empty recordings from BBB
fixes CNVS-8461

test plan:
  * create a big blue button conference with recording
    enabled;
  * start and end the conference;
  * reload the conferences page and verify that it loads
    as expected.

Change-Id: I159765d894f37261d650ee633023b6415f19f6f4
Reviewed-on: https://gerrit.instructure.com/24766
Reviewed-by: Jon Willesen <jonw@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Cam Theriault <cam@instructure.com>
Product-Review: Zach Pendleton <zachp@instructure.com>
2013-09-27 18:15:35 +00:00
James Williams 9ef3adb6b0 preserve course links in group html content
test plan:
* create a course with a group
* create a wiki page for the group
* inside the group, add a link to content for the course
(e.g. "/courses/:course_id/files")
* it should not translate the link to point to "/groups/:group_id"

fixes #CNVS-8313

Change-Id: Icd64cf11668481cee34d4bcddd1332431826959f
Reviewed-on: https://gerrit.instructure.com/24606
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
QA-Review: Hannah Bottalla <hannah@instructure.com>
Product-Review: Bracken Mosbacker <bracken@instructure.com>
2013-09-25 13:31:22 +00:00
James Williams 2326917a0a fix course copy and content migration date adjustment processing
test plan:
* import a content migration package through
"/courses/:course_id/content_migrations",
checking the field to "adjust events and due dates"
* manually type in dates of various formats
(e.g. "MM/DD/YYYY")
* should adjust the dates accordingly

* copy a course through the "copy this course" link
shown in "/courses/:course_id/settings"
* should adjust the dates here as well

fixes #CNVS-5771

Change-Id: Ib3c74f57ce3e351f6d3df88883b055bb8aa77101
Reviewed-on: https://gerrit.instructure.com/24246
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
QA-Review: Hannah Bottalla <hannah@instructure.com>
Product-Review: Bracken Mosbacker <bracken@instructure.com>
2013-09-25 13:31:19 +00:00
James Williams 9d4660b641 fix respondus question bank and quiz importing
test plan:
* publishing through respondus should work for question banks
and for quizzes when settings are applied

fixes #CNVS-8276 #CNVS-4297

Change-Id: I3b254c6375aa5524f6ecf78c31e64d34a13ba4a7
Reviewed-on: https://gerrit.instructure.com/24566
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Product-Review: Jeremy Stanley <jeremy@instructure.com>
QA-Review: Hannah Bottalla <hannah@instructure.com>
2013-09-24 19:39:51 +00:00
Zach Pendleton 59f55aec30 allow bulk messaging in new conversations
fixes CNVS-8045

test plan:
  * as a teacher with new conversations, navigate to new
    conversations and click the compose button;
  * verify that the "Bulk message" checkbox appears
    below the subject line;
  * attempt to send two messages to an entire class: one
    with the bcc checkbox selected, and another with it
    unchecked;
  * as a student in the class using old conversations,
    navigate to conversations and verify that you have two
    messages: one group conversation with the entire class,
    and one group conversation between you and the
    instructor.

Change-Id: Ic3bab8ce406c565a50ca50ad19d74b949f1caad1
Reviewed-on: https://gerrit.instructure.com/24515
Reviewed-by: Braden Anderson <banderson@instructure.com>
Product-Review: Bryan Madsen <bryan@instructure.com>
QA-Review: Bryan Madsen <bryan@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
2013-09-24 00:29:53 +00:00