fix datafixup to correctly count number of read entries for each user

We were not scoping a query correctly, which was resulting in some unread
counts to go < 0.

test plan:
 * The spec modification should adequately cover the data fixup change

Change-Id: I333d011e8656584fa261845805b87c6b4b1d53b3
Reviewed-on: https://gerrit.instructure.com/9473
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
fix saving questions in question banks; fixes #7754

test plan:
 * Create a new question bank
 * Create a question in the bank
 * Try to save the question. It should work.

Change-Id: I83213c32654e1bf0ce3e4349ae5c0b68355d5d0c
Reviewed-on: https://gerrit.instructure.com/9474
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Zach Wily <zach@instructure.com>
use flickr over ssl

test plan:
 * in a RTE, search for a flickr image, and add it
 * page should stay fully secure
 * after saving, clicking the link of the picture should go to ssl
   flickr
 * switching view of the RTE should show https urls only

Change-Id: Ia836bf127a14a50b30e7bc9e8b183e39dcb26f68
Reviewed-on: https://gerrit.instructure.com/9284
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Benji Edmund <benji@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
add spec for scribd in multiple shards refs #7695

test plan: n/a

Change-Id: I4632d236db0c3d55e7569e7f6f58687b09670796
Reviewed-on: https://gerrit.instructure.com/9368
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
error if the sis import is batch mode and no valid term is given

refs #7512

test plan:
  * post to the sis imports api, with batch_mode=1 but an invalid or
    missing batch_mode_term_id, verify the 400 error and response message
  * post with a valid term id, verify the successful creation
  * post in non-batch mode and verify things are coo

Change-Id: I804687e38f41bf9fb73b3a248907b9a27590ce52
Reviewed-on: https://gerrit.instructure.com/9460
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
add api for enrollments by section; fixes #7647

add the ability to query enrollments for a given section with the api, and use
that api URL to load the section lists for courses/x/sections/y.

test-plan:
- in a course users split between sections
- go to /courses/x/sections/y
- make sure appropriate people are there
- no gui the creates enrollments for the section, so try posting to
  /api/v1/sections/x/enrollments to create an enrollment for that section.

Change-Id: I434b10dc20e36f43e48bbad5caa8886796211b82
Reviewed-on: https://gerrit.instructure.com/9364
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
fix typo in course wizard fixes #7712

Change-Id: If6a04ca1978dd8d600bfc911a4f9cadbfc5a7811
Reviewed-on: https://gerrit.instructure.com/9480
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Rob Orton <rob@instructure.com>
indicate which appointment groups aren't published

fixes #7429

Test plan:
 - make an appointment group (save it, but do not publish)
 - verify that you can tell the difference between a published and
   un-published appointment group

Change-Id: Id7e004ac19d56e1418d57907a2a9526f5f7b5463
Reviewed-on: https://gerrit.instructure.com/9352
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Jon Jensen <jon@instructure.com>
return attach permission on discussion topics, closes #7376

This way api users can know whether the current user can post
attachments to the discussion or not.

test plan: hit the discussions api as a teacher in the course, verify
that attach is always true. hit it as a student, verify attach is only
true if the course settings allow student attachments.

Change-Id: I508e6b8f329f8472e0a2899676871a1b5318f585
Reviewed-on: https://gerrit.instructure.com/9384
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Stephen Lottermoser <stephen@instructure.com>
Reviewed-by: Zach Pendleton <zachp@instructure.com>
show archived conversations under the sent filter, fixes #7627

test plan:

* send a message
* archive the conversation
* go to your sent filter
* ensure the conversation shows up

Change-Id: I87086de2bcc33f1e2885e460117838ac3d66f364
Reviewed-on: https://gerrit.instructure.com/9420
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Zach Pendleton <zachp@instructure.com>
browsable conversations filter, fixes #7566

add browse button and corresponding functionality to conversations filter
(similar, but not identical, to recipient finder). subtle differences:

 * you can only pick one thing
 * there are no checkboxes or "Select All" options
 * you can't select sections (though you can browse them), since we don't
   tag by section, only course/group/user
 * to select a group/course, you have to drill into it and then pick the
   first option (named the same as the course/group, w/ an explanation)

test plan:

 * create conversations under various courses/groups/users
 * filter conversations by searching for courses/groups/users
 * filter conversations by browsing and selecing courses/groups/users
 * filter conversations by browsing a course and searching for users/
   groups

Change-Id: Icca7be0048b88ddb0eb638b28634f435cdcf1d76
Reviewed-on: https://gerrit.instructure.com/9417
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Zach Pendleton <zachp@instructure.com>
don't show concluded students under course in finder, fixes #7583

hide concluded student enrollments when browsing courses/sections in the
conversations recipient finder. when browsing a group or just doing a
context-less search, those users will still show up (assuming the course
is active or recently concluded, etc.)

test plan:
1. conlude a student's enrollment
2. confirm that you cannot find/message the user under the course
3. confirm that you can find/message the user under a group or via search
4. conclude a teacher's enrollment (or just conclude the course)
5. confirm that you can find/message the teacher under the course or via
   search

Change-Id: I5886d8c0805b9af617622132e7b24a9249d2a715
Reviewed-on: https://gerrit.instructure.com/9437
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Zach Pendleton <zachp@instructure.com>
update course section enrollment display to be less confusing

fixes #7600

test plan:

  1. add active enrollment
  2. add pending enrollment
  3. complete enrollment
  4. view section that enrollments
     are in and verify that the
     enrollment count display
     is less confusing

Change-Id: I72d1637665359aa75aa7a87bc399aa2d62258636
Reviewed-on: https://gerrit.instructure.com/9432
Reviewed-by: Jon Jensen <jon@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
let students join inactive long-running conferences, fixes #7454

added a :resume permission so participants can join long-running
conferences even if they go inactive

test plan:
1. set up wimba (or bbb)
2. create a conference with a duration
3. confirm that students can't join unless it's active (in the case of
   wimba, that means an admin needs to be in the conference. for bbb,
   an admin needs to have been present in the last hour)
4. create a long running conference (no duration)
5. confirm that students can join any time after it was started,
   regardless of whether the admin is still participating

Change-Id: Ie81ea7309b6334d88269af098f3b0da6fb04a177
Reviewed-on: https://gerrit.instructure.com/9433
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Zach Pendleton <zachp@instructure.com>
Canvas.revision

and display the revision on /plugins

test plan: without a VERSION file, visit /plugins and see the "Unknown"
displayed. With a VERSION file, visit /plugins and see the first line of
that file displayed.

Change-Id: I0bcb3c855c70ba444158e17302eadab317dffb02
Reviewed-on: https://gerrit.instructure.com/9197
Reviewed-by: Brian Palmer <brianp@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Hudson <hudson@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 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>
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>
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>
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>