only send scheduler notifications to available courses; fixes #7267

test-plan:
- in an unpublished course (with students) create an appointment group
- notifications should not be send to those students

Change-Id: Ia194da05d7b4581f826a3690fe4a95bc249597c3
Reviewed-on: https://gerrit.instructure.com/9370
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Jon Jensen <jon@instructure.com>
separate require_pseudonym from require_user; closes #7718

previously, require_user actually required both a user and a pseudonym. this
change pulls them apart into separate require calls, creating the ability to
require at finer granularity.

test-plan: run specs

Change-Id: I0124d4685bd521c16ed47c7e2e35e960adc6598b
Reviewed-on: https://gerrit.instructure.com/9381
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
support for deferred delayed job creation, refs #7277

adds Delayed::Batch.serial_batch which, when given a block, will delay
the creation of (most) new jobs triggered within that block. a single
job will be created (per priority and queue) containing all the info for
those jobs. when it runs, it will create those jobs and run them
synchronously. if any of those jobs fail, they will be handled (and
possibly retried) according to the default logic.

note that jobs with a strand or a run at will not be deferred and will
be created as usual.

this is particularly helpful for places like conversations, where a
bulk private message can trigger thousands of jobs (2 per private
conversation). even though the jobs are not run synchronously with the
request, their mere creation is a significant performance bottleneck.

test plan:
1. do some stuff that creates jobs
2. ensure the jobs are created normally
3. do some stuff that creates jobs in a Delayed::Batch.serial_batch
   block
4. ensure a batch job is created for each unique priority+queue
5. ensure no jobs with a strand or run_at get put in batches
4. ensure that invoking each batch job creates all its component
   deferred jobs and runs them synchronously

Change-Id: I36a56fa0c7ee2ffcd19e82dd5733496d4872f51a
Reviewed-on: https://gerrit.instructure.com/9169
Reviewed-by: Jon Jensen <jon@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
auto-unarchive when sending direct messages, fixes #5366

when sending a message to an archived conversation (private or group),
we should auto-unarchive it for the sender. if it's a bulk private
message, we should leave it alone

test plan:
1. archive a private conversation
2. send a message to it
3. ensure it gets unarchived
4. archive a private conversation
5. send a bulk private message w/ the user from 4. as one of the
   recipients
6. ensure it does not get unarchived

Change-Id: I5c32fb41a295f8042204d723aef41a1961e6869f
Reviewed-on: https://gerrit.instructure.com/9421
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Zach Pendleton <zachp@instructure.com>
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>
don't assume topic poster is in course/group; fixes #7483

we just added some extra logic to make sure all the entry posters in
a discussion were in the course/group for notifications, but we also need to
include the topic poster in that filtering.

test-plan:
- create a topic (or copy a course with a topic)
- remove the topic poster from the course
- add an entry
- make sure topic poster is not notified

Change-Id: Id27fe84b420fae0911a31d7ca28cf8f8c91713d5
Reviewed-on: https://gerrit.instructure.com/9490
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Cameron Matheson <cameron@instructure.com>
create messages with the user/cc, not the default shard

refs #6886

test plan:
 * generate a notification on a non-default shard
 * verify the Message is created on that shard

Change-Id: I5b159f1c41f0a235994e4b2a25ebd65135fe8b32
Reviewed-on: https://gerrit.instructure.com/9340
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
added backbone.js

- un-hacked underscore.js for AMD
- added use.js
- updated scripts that required underscore

Change-Id: Ie64facf82e8d0dceedb1a1cf0f77f696d48bf7eb
Reviewed-on: https://gerrit.instructure.com/9273
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Zach Pendleton <zachp@instructure.com>
spec: fix selenium grades_spec intermittent failure

Change-Id: Id0f59222eb68cbdb898c53ad9bd4366a6d6c9dd1
Reviewed-on: https://gerrit.instructure.com/9494
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Bryan Madsen <bryan@instructure.com>
don't resubmit discussion assignments marked as graded

fixes #7790
fixes #6273

we weren't properly checking the workflow state when deciding whether or not
to create a new submission for discussion assignment posts. also, we were
ensuring that a submission exists for the entry every time the topic was
updated, which is more often than necessary.

test-plan:
- create a discussion assignment
- as a user, post an entry
- as a teacher, grade the assignment
- do something that would update the topic
- make sure a new submission isn't created and that the status is speedgrader
  is still graded.

Change-Id: Ic2d0fc5d809695cf856b2902bd8b478fe3bf6934
Reviewed-on: https://gerrit.instructure.com/9543
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Zach Wily <zach@instructure.com>
discussion topics materialized view api, refs #7567

This is a specialized, optimized view of the entire discussion,
including a nested view on all the entries and participants, and the
current user's unread entry list.

An upcoming commit will cache these views to the database, and generate
them asynchronously, rather than in-request.

test plan: No UI yet. GET /api/v1/courses/X/discussion_topics/Y/view ,
and verify the formatting of the response, including the nesting of
arbitrarily nested discussion entires (also only creatable via the api,
right now). verify that deleted entries are returned, but without a
user_id or summary and with a deleted flag.

Change-Id: Ib7332743f92cca40cc2a861973bf492b1f294a02
Reviewed-on: https://gerrit.instructure.com/9305
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
discussion entry_list api, refs #7567

allows retrieving a set of discussion entries with their full bodies.
deleted entries are returned with only skeleton information.

test plan: no UI. make a request to the endpoint, verify you can request
multiple entries, and that they are paginated.

Change-Id: Ifc677da538825d6eacca922cbecf5267881063b7
Reviewed-on: https://gerrit.instructure.com/9314
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
fix self signup help dialog account level fixes #7778

test plan:

  1. navigate to account level as admin
  2. click users on left side nav
  3. click view student groups
  4. edit group
  5. click blue ? button

Change-Id: I4920ddc6b3bc9fb9d007d8bb61d4cc4a3a5fbd23
Reviewed-on: https://gerrit.instructure.com/9503
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Rob Orton <rob@instructure.com>
update/delete discussion entry apis, refs #7567

test plan: no UI yet. update an entry, verify it gets the new message
(and updated at time). delete an entry, verify it's deleted. attempt
both as a user without permission on that entry, verify you get a 401
and the content doesn't change. also update/delete a student's entry as
a teacher.

Change-Id: I8433aa78e70b3c0597e76de1b8e1634c9f0dd27b
Reviewed-on: https://gerrit.instructure.com/9366
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
get rid of barista since we do our on cs generation

you have to do rake js:generate or run guard anyway
for handlebars (which also does CS),
so no sense in slowing dev environment by also doing 
cs with barista

Change-Id: Ieca9f6808ae042b325f253e3c10334fc1839d282
Reviewed-on: https://gerrit.instructure.com/9512
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
simple ui for site admins to debug message sending

test plan:
 * log in as site admin
 * go to /users/<id>/messages

Change-Id: I87dec0526bab52ccc45b722e705e4fc6178a8aaa
Reviewed-on: https://gerrit.instructure.com/9546
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
use global ids for message reply to addresses fixes #7723

test plan:
 * send someone a message on another shard
 * reply to that message
 * it should be added to the conversation

Change-Id: Id4439bd63f8805660d302a04e54bd47f304e29b2
Reviewed-on: https://gerrit.instructure.com/9545
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
include previous complete submissions in quiz statistics csv

fixes #7497

test plan:
 * take a quiz as a student
 * retake the quiz, but don't submit it
 * the previous submission should be in the csv if Count All Attempts
   is clicked

Change-Id: I7b529f3d54c0dda5fa78b2d7128d63ecd8fea1ad
Reviewed-on: https://gerrit.instructure.com/9186
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Jacob Fugal <jacob@instructure.com>
allow for specifying a build pattern when executing parallel specs

Change-Id: Ia855d75d03f8c34b4e0968b519a8d66eaf184b92
Reviewed-on: https://gerrit.instructure.com/9569
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Jake Sorce <jake@instructure.com>
spec: use fj for find_with_jquery in selenium tests

Change-Id: I0c05958a048ab89be87cb3a8a847b21dc602fcb4
Reviewed-on: https://gerrit.instructure.com/9530
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Jake Sorce <jake@instructure.com>