Commit Graph

254 Commits

Author SHA1 Message Date
Simon Williams 72be6ba687 fix immediate migration notifications
fixes #8460
refs #8318

we already fixed course migration notifications to send immediately, but we
missed content export notifications. also, the previous fix would only work for
users who didn't already have a NotificationPolicy for the migration emails.
this fix also removes those NotificationPolicy objects for existing users.

test-plan:
- make sure you already have a non-immediate notification policy for the
  'Other Administrative Alerts' category. you can do this simply by going
  to the notifications page and hitting save.
- to to courses/:id/content_exports, and perform a course export
- you should get an email when it completes
- perform a course copy
- you should not get any migration/export related emails.

Change-Id: Ie0aaeee1d8d2be4ad30fecf552973fc49e25ee28
Reviewed-on: https://gerrit.instructure.com/10652
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Bracken Mosbacker <bracken@instructure.com>
2012-05-11 13:59:26 -06:00
Brian Palmer 0ec3ed5553 collections models and api
This lays the groundwork for the new collections feature. See the API
documentation for details. There is still some pending tasks before this
is totally ready, see the development board.

test plan: no UI yet, but you can make api calls to add/edit/delete
collections, add/edit/delete items, and upvote items.

Change-Id: I8fa019d428d1aae3ac62b1f34ebe2ac3c77310be
Reviewed-on: https://gerrit.instructure.com/10465
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
2012-05-10 13:38:58 -06:00
Brian Palmer b2befdfd2b optimize delayed job queue pops on psql
Use a db function with a SELECT .. FOR UPDATE clause to avoid lock
contention on the table. The makes popping off the queue a completely
serial process -- but that's what we want here.

note this also defines a maximum (lowest) priority on jobs of 1,000,000
which we didn't have before, any lower priority will now be ignored.
however, the lowest priority we use in the code is 20.

closes #8517

test plan: ensure delayed jobs still function as expected, including
when there are a very large number of jobs in the queue. test with at
least 100,000 jobs.

Change-Id: Ibf0b4ce1d54f9400d7e734f0736c702e67316b76
Reviewed-on: https://gerrit.instructure.com/10618
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
2012-05-10 13:26:41 -06:00
Brian Palmer 840de40085 select for update in the postgresql job delete trigger
we think this will avoid a deadlock condition where an insert takes the
ShareRowExclusiveLock at the wrong moment and deadlocks us inside the
trigger.

test plan: not consistently reproducable without major postgresql
instrumentation. ensure that jobs with a strand function as normal
(running the specs is a good sanity check)

Change-Id: Ib8c8ba972fd3c51ff116776213c936b9d7a48785
Reviewed-on: https://gerrit.instructure.com/10663
Reviewed-by: Zach Wily <zach@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
2012-05-10 12:11:53 -06:00
Jon Jensen 994bfeb6c1 fix ungraded counts, fixes #7774
fixes two issue with the ungraded count logic:

1. the submission triggers updated the count regardless of the enrollment
   status (or existence). teachers or people not even in the course could
   cause the count to change (e.g. by taking/previewing a quiz)
2. the enrollment triggers did not factor in the enrollment type. so
   teachers/tas (un)enrolling in the course would cause the count to
   change if they had any submissions (e.g. from a quiz)

test plan:
1. create a quiz with essay questions (so that submissions will need to be
   graded)
2. enroll a student in multiple sections in the course
3. take the quiz as the student
4. take the quiz as the teacher
5. take the quiz as an admin not in the course
6. confirm the ungraded count is just 1
7. unenroll the teacher
8. confirm the ungraded count is still 1
9. unenroll the student
10. confirm the ungraded count is now 0

Change-Id: I11dbf3915d79f9820267469fad8949abfa008e14
Reviewed-on: https://gerrit.instructure.com/10451
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Joe Tanner <joe@instructure.com>
2012-05-08 16:26:05 -06:00
Brian Palmer 5551afebde migration to revert DelayedJobsDeleteTriggerLockForUpdate
The "FOR UPDATE" clause we added triggers a bug in Postgresql 9.0.{0-3},
fixed in 9.0.4. We're backing out the change for now.

we deleted the original migration that added the "FOR UPDATE", this new
migration is just to revert on any environments that had already run
that migration.

Change-Id: I021f64a63d8c401945b47a18409667422b808b76
Reviewed-on: https://gerrit.instructure.com/10569
Reviewed-by: Ben Chobot <bench@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Zach Wily <zach@instructure.com>
2012-05-06 19:01:13 -06:00
Simon Williams 0a3008e9d6 force content migration emails to send immediately; fixes #8318
content migration notifications used to be in a category that forced them to be
sent immediately, but they inadvertently got moved to a category without that
enforcement. now they have their own category that forces sending again.

test plan:
- set your 'For Administrative Alerts' to something other than 'immediately'
- do a content import or export (not course copy)
- you should get an email as soon as the migration succeeds or fails (not in
  a summary at the end of the day/week).

Change-Id: Ifb0eddf586f3e0defc11f6159f48625e7493ccf8
Reviewed-on: https://gerrit.instructure.com/10385
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
2012-05-03 10:35:49 -06:00
Zach Wily 5868bd8b34 allow saml configurations to use the eppn
Schools want to be able to specify a saml attribute used for the user's login
instead of NameId. Usually that will be the EPPN (or the portion before the
@). This adds a Login Attribute settings to the SAML settings page, with
options for NameID (the default and historic behavior), the
eduPersonPrincipalName, and the eduPersonPrincipalName with the domain part
stripped.

test plan:
 * Set up Shibboleth... just kidding. Better to just look at the spec.
   Standing up your own shib instance is a ton of work.

Change-Id: I04e32022b940da4cb82ea5f9a59012eb48de2ab6
Reviewed-on: https://gerrit.instructure.com/10120
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Bracken Mosbacker <bracken@instructure.com>
Tested-by: Zach Wily <zach@instructure.com>
2012-04-30 16:26:09 -06:00
Cameron Matheson a2a6579c10 multiple contexts per appointment group
closes #7561

Test plan:
  - create some appointment groups:
    - make one with multiple courses
    - make one with a course, and then add more courses after saving
    - make one restricted to some (not all) sections in a course [1]
    - make one that has students sign up in groups [1]
  - make sure that only students that match the above criteria are able
    to see/reserve those appointment groups

  [1] you can only choose the group-signup option or restrict
      appointment groups to certain sections on creation (these options
      won't be availabe when editing later)

Change-Id: I1cff5fb4ed233882c2061f8fd8a7ba6f2d4959b0
Reviewed-on: https://gerrit.instructure.com/9407
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jon Jensen <jon@instructure.com>
2012-04-30 15:30:03 -06:00
Jon Jensen 7285a705b4 fix incorrect conversation tags, fixes #8274
this is similar to #7231, though the root cause is a little different.
users with duplicate concluded enrollments (e.g. two sections in a course)
may have had improperly tagged private conversations. this was because we
weren't uniq'ing User#conversation_context_codes, so it naively assumed
that both users were in those concluded courses in Conversation#
current_context_strings

the data migration is just like the one we ran in #7231, but a little more
broad (in this case, the Conversation#tags are correct, but the
ConversationParticipant#tags are not). refactored migration code and specs
accordingly, and made it a little nicer on the db.

test plan:

1. enroll user A in two sections of course A (may only be possible via SIS
   or console)
2. conclude course A
3. enroll user A and user B in course B
4. start a private conversation between the users (doesn't matter who
   starts it), but be sure to find the recipient by searching, NOT by
   browsing the course
5. ensure that both users only see course B as the tag on the conversation

Change-Id: I3065b827433b33dbb7ff6a4d0d2affa73cc06e37
Reviewed-on: https://gerrit.instructure.com/10340
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jacob Fugal <jacob@instructure.com>
2012-04-30 14:16:35 -06:00
Cameron Matheson 6416844817 allow assigning section-subsets to appointment group
closes #6832

Test plan:
  - in a separate branch (master), create a new appointment group and
    assign it a group category or section
  - switch to this branch and migrate; the appointment group should
    still be assigned to the group or section you chose earlier
  - create a new appointment group and assign it some course sections
  - verify that students in those sections can reserve appointments, but
    not students that do not belong to those sections

Change-Id: I1662374c5e6d2e5e9f7d6b54b0bc91420f150b7a
Reviewed-on: https://gerrit.instructure.com/8765
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jon Jensen <jon@instructure.com>
2012-04-27 16:59:40 -06:00
Bracken Mosbacker 98fe5ee5c0 enable assignment properties to be locked
this creates a "plugin" that allows an account to choose
assignment properties that can be locked when a course is
copied

Test Plan:
 * enable the plugin for an account
 * create an assignment and set it to be locked on copy
 * copy the course to another course
 * as an admin of the account you should still be able to edit the assignment
 * as a non-admin teacher of the course you should not be able to edit the frozen properties

refs #7931

Change-Id: I61d5dbfdf10f8f7519f8db06449b14ef5e7b8454
Reviewed-on: https://gerrit.instructure.com/10190
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
2012-04-27 10:41:41 -06:00
Cody Cutrer da62c35ca9 drop some more really old columns
Change-Id: Icd7c3733c7c29234bd2c8e2e61f780104c885fad
Reviewed-on: https://gerrit.instructure.com/10305
Reviewed-by: Ben Chobot <bench@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
2012-04-25 11:05:37 -06:00
Brian Palmer ea2e704904 select for update in the postgresql job delete trigger
we think this will avoid a deadlock condition where an insert takes the
ShareRowExclusiveLock at the wrong moment and deadlocks us inside the
trigger.

test plan: not consistently reproducable without major postgresql
instrumentation. ensure that jobs with a strand function as normal
(running the specs is a good sanity check)

Change-Id: I32fcac82dc5264445897a517ed582e17e896a14b
Reviewed-on: https://gerrit.instructure.com/10300
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
2012-04-25 10:33:10 -06:00
Jon Jensen 48e1129eda tag a few data migrations as postdeploy
avoid a chicken/egg scenario where the data migrations might be running
broken model code, depending on how far apart the old and new versions of
canvas are

test plan:
1. set up a canvas install on a revision prior to f8caf7d4
2. create some conversations
3. pull the latest code
4. run migrations and ensure that there are no errors

Change-Id: I7013d6ea73d5913e291c44242a6eb1415100ddc7
Reviewed-on: https://gerrit.instructure.com/10267
Reviewed-by: Brian Palmer <brianp@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
2012-04-24 13:13:19 -06:00
Jon Jensen 9d8bbb00a0 make attachment data migration faster and pgbouncer-friendly
also move logic into a separate file, and run it in a delayed job when in
production mode

test plan:
1. confirm the migration runs in postgres/sqlite/mysql
2. confirm the migration spec passes in postgres/sqlite/mysql

Change-Id: I1169e1fdf6d3d9996e7fbad0d2a4ab41662b7ae8
Reviewed-on: https://gerrit.instructure.com/9939
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Zach Pendleton <zachp@instructure.com>
2012-04-12 10:29:28 -06:00
Jon Jensen e385e1af29 make migration pgbouncer-friendly, move to delayed job
* wrap temp table population and extraction in a transaction
* rework first conversation_message update to not use the temp table
* move migration into delayed job

test plan:
* run migration on mysql/postgres/sqlite
* ensure there are no errors
* run migration spec on mysql/postgres/sqlite
* ensure there are no errors

Change-Id: Ia6e645ed08dfaf75f9f3438c0968c74222f8e017
Reviewed-on: https://gerrit.instructure.com/9912
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
2012-04-09 14:34:17 -06:00
Simon Williams 5c57e0714e allow student view student to upload files; fixes #7938
we tried to get away with the student view student not having a pseudonym, and
it worked until we got to file upload assignments. you need a pseudonym to
upload files, so we have to give the fake student one.

test-plan:
- before downloading, make sure you have a student view student created who
  does not have a pseudonym
- run migration and make sure that student now does have a pseudonym
- make sure a new student view student gets a pseudonym on creation
- submit a file upload assignment while in student view

Change-Id: I1a494c36cebf2b94a74cc9e531ac64b220fbfe36
Reviewed-on: https://gerrit.instructure.com/9785
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
2012-04-09 10:47:49 -06:00
Jon Jensen a8dc1c32da filter conversations while masquerading, fixes #7634
start tracking root_account_ids more consistently for messages, and
aggregate them on the conversation. add a scope when masquerading such
that conversations tied to other root accounts are hidden. a masquerader
must have access to all root accounts a conversation belongs to in order
to see it (unless the masquerader is a site admin)

test plan:

1. enroll a user in courses under two different root accounts (let's call
   them accounts A and B)
2. as the user, log in under the account domain for A and send some
   messages
3. log in under the account domain for B and send some messages to
   the existing conversations, as well as to some new recipients
4. set up an account admin with access only to B
5. log in as the admin, and masquerade as the user
6. ensure you can only see conversations created under B (none of the ones
   that are solely A, or both A and B)
7. log in as a site admin, and masquerade as the user
8. ensure you can see conversations from both accounts

Change-Id: I4a26b8b8914fd531103bb92c3d4442de843d9986
Reviewed-on: https://gerrit.instructure.com/9767
Reviewed-by: Jon Jensen <jon@instructure.com>
Tested-by: Jon Jensen <jon@instructure.com>
2012-04-06 13:49:47 -06:00
Jon Jensen a33bc4683e fix conversation merge issue, fixes #7801
fix an issue where private conversations were improperly merged when
merging user accounts (only a problem when it was being merged into an
existing conversation on the target user). this would cause page errors
due to orphaned conversation_participants.

includes a data migration to fix affected conversations.

test plan:
1. on the old code, create three users (A, B, C)
2. start a private conversation between A and B
3. start a private conversation between A and C
4. merge user B into user C
5. confirm that users A and C get a page error when going to conversations
6. upgrade the code and run the migration
7. confirm that conversations load and the merged conversation appears
   correctly
8. on the new code, create three more users, repeat steps 2-4, and confirm
   that conversations load and the merged conversation appears correctly

Change-Id: I50785764ae4376a38824ffa099ff678686ec5023
Reviewed-on: https://gerrit.instructure.com/9847
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
2012-04-05 11:53:50 -06:00
Cody Cutrer fad518c082 clean up temporary tables in migrations
since an external connection pool might be in use, and it would mess
up future migrations

test plan:
 * create two new shards through pgbouncer in the same database in
   quick succession

Change-Id: I2bf582a543a48f9df83888feda54818211931a34
Reviewed-on: https://gerrit.instructure.com/9842
Reviewed-by: Jon Jensen <jon@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
2012-04-05 08:54:01 -06:00
Cameron Matheson 038d6fac3c scheduler: per-appointment participant limit
closes #7769

Test plan:
  - create an appointment group
  - open the appointment groups and edit one of its appointments
  - change the number of users allowed to attend the appointment
  - make sure that no more users can reserve the appointment than
    configured

Change-Id: I4365113d81d123bd8c3cdc24af8761cc6b9027a3
Reviewed-on: https://gerrit.instructure.com/9648
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Zach Wily <zach@instructure.com>
2012-04-03 15:55:32 -06:00
Jon Jensen 2137fc8c99 fix attachment migration for mysql, make it nicer for all dbs
* changes temp table usage to be more efficient (also, mysql doesn't let
  you ref the same temp table twice in a query)
* make it non-transactional to reduce locking
* break up the big update statements into batches of 1000

test plan:
* confirm the migration runs in mysql/postgres/sqlite, and the migration
  spec passes for all three as well

Change-Id: Ib15028fa49103230e2cb4957754d2ac19853f90c
Reviewed-on: https://gerrit.instructure.com/9802
Reviewed-by: Ryan Shaw <ryan@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
2012-04-03 12:09:09 -06:00
Bracken Mosbacker a942ede9c6 convert course copy to use export/import functionality
This adds the ability for ContentMigration to copy courses
by exporting to a content package and then importing that
package. For attachments it just creates a new Attachment
object instead of exporting/importing them.

The course copy API did not change.

The endpoints used by the course copy UI did change and this
commit doesn't allow selective copying, it only has the
option to copy everything. Selective copying will come in
another commit.

There are also various bug fixes for export/import

Test Plan:
 * copy a course through the API
 * copy a course through the Content Imports path
 * copy a course through the Copy Cours button on the course settings page
 * export a course

refs #4645

Change-Id: Ie577329ab7caaea8dfb9359542224a1a2657e167
Reviewed-on: https://gerrit.instructure.com/9742
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
2012-04-02 17:29:01 -06:00
Jon Jensen 506ec04514 save attachments before message creation, fixes #7229
rather than proxy attachments through the conversations controller and
cause a long-running db transaction, we now just send them to the right
place (files controller, s3, whatever), and then create the message. we
now store the attachment in a special folder on the user so that they
can more easily be tracked in the future for quota management.

because we now just store one instance of each attachment, sending a
bulk private message w/ attachments should be a bit less painful.

known regression:
if a user deletes a conversation attachment from their files area, it
deletes if for all recipients. this is essentially the same problem as
tickets #6732 and #7481 where we don't let a "deleted" attachment to
still be viewed via associations with other objects.

test plan:
1. send an attachment on a new conversation and confirm that was sent
   correctly and can be viewed by recipients
2. send an attachment on an existing conversation and confirm that was
   sent correctly and can be viewed by recipients
3. send an attachment on a bulk private conversation and
   1. confirm that was sent correctly and can be viewed by recipients
   2. confirm that only one attachment was actually created, but each
      message in each conversation is linked to it
4. send multiple attachments and confirm that they were sent correctly
   and can be viewed by recipients
5. perform steps 1-4 for both local and s3 uploads

Change-Id: I7cb21c635f98e47163ef81f0c4050346c64faa91
Reviewed-on: https://gerrit.instructure.com/9046
Reviewed-by: Jon Jensen <jon@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
2012-04-02 16:39:27 -06:00
Zach Pendleton d536bb8c31 add public_description to course model. fixes #7761
affects: course model, api
test plan:
  * add a course with the api, included a public description;
  * verify that public description field is returned and
    exists on the course in the db.

Change-Id: If2766cf7ba946af5cb8a5cafebaa8209754ec2b3
Reviewed-on: https://gerrit.instructure.com/9723
Tested-by: Cody Cutrer <cody@instructure.com>
Tested-by: Zach Wily <zach@instructure.com>
Reviewed-by: Jon Jensen <jon@instructure.com>
2012-04-02 11:40:54 -06:00
Brian Palmer a2818dd9ea optionally include entries not in the view yet in /view response
consumers can use this to update the view client-side and ensure it's
always up-to-date even if the view is behind.

Change-Id: I1ff0cd80a758a113f8881ef74de78cc28e2fa16b
Reviewed-on: https://gerrit.instructure.com/9717
Reviewed-by: Ryan Florence <ryanf@instructure.com>
Reviewed-by: Zach Wily <zach@instructure.com>
Tested-by: Brian Palmer <brianp@instructure.com>
2012-03-30 15:33:54 -06:00
Cody Cutrer d7e3d5e842 refactor ReportSnapshot refs #7721
basically for detailed reports, have a row per account, instead of
stuffing everything into one massive hash with every account

test plan:
 * ensure that the account statistics page still works
 * ensure that the statistics update when the delayed job runs

Change-Id: I2d4c9ff5a86c8df6d82097aa4f0203a0f55ddb2d
Reviewed-on: https://gerrit.instructure.com/9565
Reviewed-by: Simon Williams <simon@instructure.com>
Tested-by: Cody Cutrer <cody@instructure.com>
2012-03-30 09:17:43 -06:00
Brian Palmer 409f78de9a return discussion_type in topics api response
We changed the threaded boolean to a discussion_type string, with
currently two types: 'side_comment' and 'threaded'

test plan: get the list of topics in the api, verify threaded is
returned appropriately.

Change-Id: Id5bfb867329d93fe8be6131e2e7c401f70ced290
Reviewed-on: https://gerrit.instructure.com/9647
Reviewed-by: Zach Wily <zach@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
2012-03-28 14:13:09 -06:00
Brian Palmer 64230d2746 fix materialzed view table definition for mysql
mysql always defines a field size limit, and has a default that is too
low for our purposes here, so we need to set an explicit limit

Change-Id: I86509dae04ca4f403dd77ccf45765798b2125ae8
Reviewed-on: https://gerrit.instructure.com/9639
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Ryan Shaw <ryan@instructure.com>
Reviewed-by: Jon Jensen <jon@instructure.com>
2012-03-28 08:53:58 -06:00
Brian Palmer 633356893e Revert "exclude deleted discussion entries from read counts; fixes #7741"
This reverts commit 76c1086dca.

Conflicts:

	lib/data_fixup/exclude_deleted_entries_from_unread_count.rb
	spec/migrations/exclude_deleted_entries_from_counts.rb

Change-Id: Ie75780d2fdfa17896e75e80dfd18749cc8eed1c8
Reviewed-on: https://gerrit.instructure.com/9486
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
Reviewed-by: Jon Jensen <jon@instructure.com>
2012-03-23 14:23:41 -06:00
Brian Palmer c9efb6cc72 materialized view of discussion topics, closes #7567
This is a cached-in-the-db view of the topic view json response, and
serialized arrays of participant ids and entry ids (for determining
unread entries). This is an optimization to make loading topics fast and
avoid a lot of db traffic.

test plan:

The UI for this new API is still under development, so this needs to
be tested via the API. With jobs turned off, hit the discussion view
endpoint and verify the 503 response. Then run the job to generate the
view, and verify the response json. Verify that any change to the
discussion that requires updating the view, properly updates the view.

Change-Id: I1eacace438a75a41b8b85ce6c42bfd042f27d1ea
Reviewed-on: https://gerrit.instructure.com/9443
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Jon Jensen <jon@instructure.com>
2012-03-23 14:23:11 -06:00
Brian Palmer eddbe97a53 flag topics as threaded, fixes #7792
If a discussion topic is threaded, it'll allow sub-entries to have other
sub-entries as parents. otherwise it'll force sub-entries to always have
a root entry as a parent (restoring the behavior pre-e9edb2a86f

test plan:

Make a side comment in reply to another side comment, reload the page,
and verify it shows your comment. Do the same via the API. There's no UI
yet for marking a discussion as threaded, but you can do it from the
console and then verify that replies to replies are now nested.

Change-Id: I6bddcfa318f36bcbc6ddb03c152ff1fa8fa550b8
Reviewed-on: https://gerrit.instructure.com/9506
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
2012-03-20 16:07:43 -06:00
Simon Williams 76c1086dca exclude deleted discussion entries from read counts; fixes #7741
we were including deleted discussion entries in our default unread counts, but
there was no way to mark these as read from the UI so it looked like the counts
were just off.

test-plan:
- run the migration and make sure existing unread counts look good
- create a discussion, make some entries, and delete some
- as a different user, view that discussion and make sure counts look right

Change-Id: I601fc7e0726a7982a2843b5a8a71cf782e5092eb
Reviewed-on: https://gerrit.instructure.com/9468
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Zach Wily <zach@instructure.com>
2012-03-17 13:40:09 -06:00
Simon Williams 561a3c2058 move ungraded count migration to dj
Change-Id: I8f901d1618686ec98341a594cabf6b71183a89fb
test-plan: n/a
Reviewed-on: https://gerrit.instructure.com/9372
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
2012-03-16 13:03:41 -06:00
Brian Palmer 0b570f89f9 remove dead code around page views
Removes unused methods and associations from models, and removes the
PageViewRange model completely, which is no longer used.

test plan:
  * run the specs
  * verify that no active page-view-related functionality was inadvertently removed

Change-Id: I8522d151555db64a0ad2548334ae642f9fefd54e
Reviewed-on: https://gerrit.instructure.com/9324
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
2012-03-15 08:46:51 -06:00
Cody Cutrer 3928851d58 clean up and stop creating duplication notification policies
fixes #5196

test plan:
 * perform an action that causes lots more than
   User.max_messages_per_day notifications to be sent out
 * in the db, there should only be one entry with notification_id
   is null for that communication channel

Change-Id: Ibd1c5f5273b171bd4ebb6252e942e23dac4aa7e3
Reviewed-on: https://gerrit.instructure.com/9260
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
2012-03-13 16:22:46 -06:00
Brian Palmer e9edb2a86f model and api work for threaded discussions, refs #7567
Adds support for threaded discussions. The existing API has been updated
to allow posting replies to replies, and returns the whole thread of
sub-replies rather than just first-level side comments. For backwards
compatbility, the sub-replies are returned in a flattened newest-first,
consumers can look at the parent id of each entry to re-build the
nested, threaded structure.

Another commit will add a new API endpoint for retriving the threaded
structure of the conversation in a more efficient and natural format.

test plan: there's no UI for threaded discussions yet, but you can use
the API to post replies to replies, and retrieve threads and verify the
parent_id information.

Change-Id: I7d541d093fbbdb6fc8a18d079b4337515c02a8a4
Reviewed-on: https://gerrit.instructure.com/9121
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
2012-03-09 15:10:05 -07:00
Brian Palmer 518553a628 remove some database columns from long ago
Change-Id: I8340310cb5a4ede0097e92bd1d3691644c3d460c
Reviewed-on: https://gerrit.instructure.com/9196
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
2012-03-06 10:07:57 -07:00
Brian Palmer 1692aca64d run UseAssetUserAccessLastAccess as a delayed job
this table, it is large

test plan: run the migration, verify a job is just created. run the job,
verify it updates null last_access rows as expected.

Change-Id: Id134d6795c8eef76181c20f5e3c0920dd51dda21
Reviewed-on: https://gerrit.instructure.com/9192
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
2012-03-06 09:39:09 -07:00
Bracken Mosbacker fb68a31dd1 correctly update quiz submisison when changing grade in gradebook
Before only the Submission was being updated and not the
QuizSubmission. Now the fudge points on the current QS are
updated to reflect the score set in the gradebook.

This prevented modules from progressing if the value was
changed in the gradebook.

Because the score set there should be the absolute score,
if the quiz is set to take the highest a flag is set to
prevent a previously-higher score from being the kept_score

Test Plan:
 * Create a quiz with a question with 5 points and publish it
 * Create a module item to to that quiz that needs 10 points to complete
 * Take the quiz as a student, the module should not unlock
 * As the teacher set the grade to 11 in the gradebook
 * The module item should be unlocked for the student

closes #7331 #4174

Change-Id: I30d92bfe865584b5b526cda36ef336348a647de4
Reviewed-on: https://gerrit.instructure.com/9091
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
2012-03-05 11:48:32 -07:00
Brian Palmer 30de1a294e protect against timing out ldap servers, fixes #7461
If an LDAP server times out, log the time of failure to the
AccountAuthorizationConfig, and don't try to connect again until some
time passes.

test plan:
  * set up an account that uses LDAP, point it to localhost port 6767
  * run `nc -l 6767` or some other command to listen on that port, but
    not ever respond
  * attempt to log in on that account, the first log in should hang for
    5 seconds. subsequent logins should skip even trying to talk to
    ldap, until 1 minute passes.
  * change the account authorization config, verify that it tries the
    LDAP server again immediately

Change-Id: Iea5d7c27f72341d16ae370a0f6ad4ec90fb96b74
Reviewed-on: https://gerrit.instructure.com/9116
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Zach Wily <zach@instructure.com>
2012-03-02 14:14:10 -07:00
Simon Williams 69c113d1f0 add pending_review submissions to todo list for grading
quiz submissions that have essay questions are marked as pending_review, but
they have a grade, so the previous trigger was ignoring them when incrementing
the needs_grading counts. this changes increments the counter for
pending_review even if there is already a grade.

test-plan:
- create a quiz with an essay question
- as a student, submit the quiz
- as a teacher, your to do list should indicate that you have a quiz that needs
  grading.

fixes #5326
fixes #7466

Change-Id: I7cf2293bb43df882000902109124810e896e66ad
Reviewed-on: https://gerrit.instructure.com/9095
Reviewed-by: Jon Jensen <jon@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
2012-03-02 13:10:22 -07:00
Zach Wily accee8cc6b make zip file processing asynchronous
also fix/enable zip file uploads in group and user contexts -- they were
partially enabled, but broken. This required generalizing
UnzipAttachment to work for any context, not just courses, though that
was mostly just a matter of renaming things.

The zip file uploads in accounts are still not enabled, as the accounts
file section is not implemented yet, though it's referenced in the
routes file.

fixes #5913
fixes #5728
fixes #5463
fixes #5012

test plan:
  * upload a zip file to a course, to a group, and to a user's files. in
    each case, try uploading the zip both through the button in the file
    browser, and by dragging a zip file into the file browser (in a
    capable web browser)

Change-Id: I6c648ef677d2bd61ae41a2b8fe0f89be43d63375
Reviewed-on: https://gerrit.instructure.com/7402
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Zach Wily <zach@instructure.com>
2012-02-29 14:04:53 -07:00
Cody Cutrer 0ce24b5887 remove unused notification categories fixes #7394
also move notifications in "new email messages" to "administrative alerts",
because that's a much better description of them

test plan:
 * go to communication preferences
 * the last one should be "administrative alerts"
 * "Files", "Private message from student", "New email messages",
   and "Context Message" should be nowhere to be found

Change-Id: I8b30d53b8137ab4b17cb436920d87331327e01f9
Reviewed-on: https://gerrit.instructure.com/8996
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
2012-02-27 13:24:50 -07:00
Simon Williams 258e6b36f3 read/unread state + counts for discussions; closes #7173
the backend for tracking read/unread state of discussion entries/topics and
unread counts for discussion topics. the strategy is to assume that an entry is
unread unless there is an an entry in the join table indicating otherwise.

interface:
- DiscussionEntry has #read_state, #read?, and #unread?. You can use these
  either by passing in a user directly, or by setting the current_user
  attribute on the object before calling the method (useful for json). This
  should already be handled for existing controllers.
- DiscussionTopic read_state functionality as above, plus #unread_count. Same
  general idea with current_user as above.
- routes are setup through the api, use PUT to mark read, DELETE to mark
  unread, or rails helpers like course_discussion_topic_mark_read_path

test plan:
- click through discussion pages, and make sure they all still work (no visible
  changes though, this is backend only)
- manually call some of the above methods from the console
- make sure sql for updates is reasonable

Change-Id: I655ab6a69a8cbdf1c7c99a5548b8ed0d7eadba02
Reviewed-on: https://gerrit.instructure.com/8671
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Jon Jensen <jon@instructure.com>
2012-02-24 13:34:54 -07:00
Jon Jensen 57d3a8238f fix migration error
test plan:
* run migration, it should pass
* run migration spec, it should pass

Change-Id: I024c7b07671212eb42943273d5c361cce516e015
Reviewed-on: https://gerrit.instructure.com/8961
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Zach Pendleton <zachp@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Zach Wily <zach@instructure.com>
2012-02-24 10:55:24 -07:00
Cody Cutrer 7489de2d5c improve UTF-8 detection migration refs #6035
* use a single DJ instead of a DJ per applicable attachment
 * don't hold a transaction for any length of time
 * do direct updates, instead of through AR, to avoid 7 extra
   queries per update from before_save callbacks

test plan:
 * run the migration; it should run relatively quickly, and not
   have any errors

Change-Id: I6af6f0ddbcedbb69ad6afb3688d94feb32d0f201
Reviewed-on: https://gerrit.instructure.com/8905
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Zach Wily <zach@instructure.com>
2012-02-23 12:35:49 -07:00
Jon Jensen 7dad73d873 correctly merge conversations when merging users, fixes #7246
previously, merging user accounts would result in conversations with
duplicate participants if both users were involved. additionally,
moved private conversations did not get their private hashes updated,
and private conversations between the merged users would lead to page
errors.

this fixes the behavior going forward (merging conversations if
needed) and adds a migration to fix broken conversations.

test plan:
1. create user A, user B and user C
2. create a private conversation between user A and user B
3. create a private conversation between user A and user C
4. create a private conversation between user B and user C
5. create a monologue for user A
6. create a monologue for user B
7. create a group conversation between all three users
8. merge user A into user B
9. confirm that user B now has three conversations:
 1. a monologue containing the messages from 2, 5, and 6
 2. a private conversation with C containing the messages from 3 and 4
 3. a group conversation with just user C
10. confirm that all messages formerly by A now have B as the author
11. confirm that unread counts and message counts are correct

Change-Id: I1afd824ff8ce74430f247d5b4c728937786fa37f
Reviewed-on: https://gerrit.instructure.com/8738
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Zach Pendleton <zachp@instructure.com>
2012-02-23 11:00:43 -07:00
Zach Wily ae67b679e6 don't bypass filename escaping in FileInContext; fixes #6912
FileInContext (used by the zip importer) was bypassing the filename= setter
for Attachment, so when using attachment_fu, sanitize_filename was not getting
called on the filename. This resulted in us generating S3 urls with characters
in them like filename[0].txt. That normally worked fine. However, Firefox
would escape those characters when redirected to a URL like that, which would
cause a signature mismatch with S3.

This commit stops bypassing the filename= setter so files uploaded as zip
files and in migrations have escaped filenames. Because of difficulties
testing S3 attachments, the included spec is weak.

This also includes a migration that will rename attachments with []" in their
filenames, and make a copy of the S3 object to match.

There is also an unrelated spec refactor around faking out a portion of the
code about S3.

test plan:
 * Enable S3
 * Create a ZIP file with a file in it with a name like test[0].bin
 * Upload that ZIP file to your files are, choosing to unpack the ZIP contents
 * Verify that you can download the extracted file using firefox
 * Also verify that the attachment's filename is escaped in the db

Change-Id: I54fc0682b64a9e0021b4b41236f8cab168a0e56e
Reviewed-on: https://gerrit.instructure.com/8875
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Bracken Mosbacker <bracken@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
2012-02-22 21:46:00 -07:00