Commit Graph

17 Commits

Author SHA1 Message Date
Neil Gupta 7b4a5a048a Limit EffectiveDueDates query to subset of users
Fixes CNVS-37088

Test plan:
* Create a course
* Enroll 2 students
* Create an assignment with a due date
* Grade student 1
* From rails console, run grade calculator for a single student
  GradeCalculator.new(user1_id, course)
* From console, run effective due dates for a single student
  EffectiveDueDates.for_course(course, assignment).filter_students_to(user1_id).to_hash

It should return a hash with only user 1's due date

Change-Id: Ibd509153558b2674775566b1f8ccd444a4aed1ce
Reviewed-on: https://gerrit.instructure.com/112839
Tested-by: Jenkins
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
Reviewed-by: Spencer Olson <solson@instructure.com>
QA-Review: Matt Taylor <mtaylor@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-05-26 16:40:26 +00:00
Cody Cutrer 53faedf159 use a heredoc for effective due dates query
eliminates leading blank line, so our db tools can actually show
something for this query, instead of a blank. And naming the heredoc
as SQL allows some IDEs to syntax highlight appropriately, which is
useful for this beast

Change-Id: Ic59139b9206bbf4ca72e39a8410ccfb175db39df
Reviewed-on: https://gerrit.instructure.com/112120
Reviewed-by: Rob Orton <rob@instructure.com>
Tested-by: Jenkins
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2017-05-17 19:20:58 +00:00
Neil Gupta 1e052eae19 Update DueDateCacher to use EffectiveDueDates
fixes CNVS-33651

Test plan:
* Create a course
* Enroll 3 students
* Create 2 assignments with different due dates
* In rails console:
	* Submission.pluck(:assignment_id, :cached_due_date) should return
	  an array of 6 tuples of (assignment id, its due date)
* Create an override for one student on one assignment
* In rails console:
  * Submission.where(
  		assignment_id: <assignment picked above>,
  		user_id: <user picked above>
  	).cached_due_date should equal the override date
* Smoke test grading and viewing students in different places to make
  sure the new dummy submissions aren't breaking anything

Change-Id: Idc2721fd3f05214555db780b452ddf53e67ff404
Reviewed-on: https://gerrit.instructure.com/109027
Tested-by: Jenkins
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
QA-Review: Anju Reddy <areddy@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-05-11 20:54:44 +00:00
Landon Wilkins 79215618d4 da licença part 29
add consistent license headers to all source files
(ruby, coffeescript, javascript)

except for vendor files

Change-Id: I49a8930917a609d3f118da1b20b51dedfd5d5903
Reviewed-on: https://gerrit.instructure.com/110053
Tested-by: Jenkins
Reviewed-by: Jon Jensen <jon@instructure.com>
Product-Review: Jon Jensen <jon@instructure.com>
QA-Review: Jon Jensen <jon@instructure.com>
2017-04-27 21:59:53 +00:00
Spencer Olson b5759303b5 use effective_due_dates in grade calculator
closes CNVS-36422

Change-Id: I57c120abfb309d510195926c8cf0f859798e9303
Reviewed-on: https://gerrit.instructure.com/109030
Tested-by: Jenkins
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
QA-Review: KC Naegle <knaegle@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-04-20 17:54:01 +00:00
Spencer Olson e5354a580c truncate seconds before comparing grading periods
closes CNVS-35768

test plan:

1. Create a course with grading periods.
2. Create an assignment from the assignment group using the "+" button.
3. Make the due date for the assignment end on a grading period end
   date (it is important to not copy and paste the due date in but type
   it in manually).
5. Go to the gradebook and select the grading period whose end date
   matches the assignment's due date.
6. Verify the assignment is visible.

Change-Id: Iddbcd4c790223e66f17db9f8676733c4306723d4
Reviewed-on: https://gerrit.instructure.com/106314
Tested-by: Jenkins
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Neil Gupta <ngupta@instructure.com>
QA-Review: KC Naegle <knaegle@instructure.com>
QA-Review: Spencer Olson <solson@instructure.com>
Product-Review: Christi Wruck
2017-03-31 21:22:22 +00:00
Neil Gupta 3c95f9fd9e Don't blow up if checking effective due dates for a non-assigned user
Fixes CNVS-35631

Test plan:
* Create a course with an assignment and a student
* Create another course with another student
* In rails console:
  edd = EffectiveDueDates.for_course(course1)
  edd.in_closed_grading_period?(assignment, student_in_other_course)

This should return false, rather than crash.

Change-Id: I6facdf0643b2eabc557ff2fc651534d5572bfc0b
Reviewed-on: https://gerrit.instructure.com/104965
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
Tested-by: Jenkins
Reviewed-by: Derek Bender <djbender@instructure.com>
QA-Review: Spencer Olson <solson@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-03-15 19:35:52 +00:00
Keith Garner 9f06f54427 switch to using effective_due_dates in gradebook_importer
This switches the gradebook import process to using EffectiveDueDates
to find student specific due dates.  This avoids the N+1's that
calling Submission#cache_due_date can create.

closes CNVS-35366

test plan:
 - Smoketest that gradebook importer still works, especially with a
   few assignments overrides
 - Speed test the gradebook on a large course

Change-Id: Ib669fbede2c50e78a53420868492342109df5b13
Reviewed-on: https://gerrit.instructure.com/103937
Tested-by: Jenkins
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Derek Bender <djbender@instructure.com>
QA-Review: KC Naegle <knaegle@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-03-06 19:53:36 +00:00
Neil Gupta e34d0de6a6 Merge branch 'master' into dev/weighted-grading
Fixes CNVS-35198
Fixes CNVS-34498

Change-Id: I7841fa62de2747654c3f4ad13c1124aeb10f6663
2017-02-28 16:36:42 -06:00
Cody Cutrer 6bcc5ddbbd rails 5: more various fixes
refs CNVS-34862

Change-Id: Ic49eae5da1e5e5f1425cb5ca8655b2cd8e29ae66
Reviewed-on: https://gerrit.instructure.com/102607
Tested-by: Jenkins
Reviewed-by: Simon Williams <simon@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2017-02-17 21:02:40 +00:00
Spencer Olson 8c1992716c include deactivated and concluded enrollments in due dates query
closes CNVS-34543
closes CNVS-34552
closes CNVS-34587

test plan:

CNVS-34543 Test Plan:
1. Create a grading period set with a closed and ended grading period.
2. Create a course with a teacher and 2 students.
3. Create an assignment in a closed grading period and one in an ended,
   not closed grading period.
4. Deactivate one student.
5. On the course user page click the menu cog for the student. Select
   'Deactivate'.
6. Navigate to the gradebook.
7. With 'All Grading Periods' selected try to grade the closed and
   ended assignment for the inactive student.
8. With the individual grading periods selected try to grade the closed
   and ended assignment for the inactive student.
9. Verify:
   a. As an admin both assignments are gradable.
   b. As a teacher the assignment in the ended, not closed grading
      period is gradable.
   c. As a teacher the assignment in the closed grading period is not
      gradeable.

CNVS-34552 Test Plan:
* Do the following in a course tied to a term with at least one active
  grading period. Enroll at least two students in the course.
1. Create an assignment with a due date in the active grading period.
2. Grade the Assignment for both students in the course (with or
   without a submission).
3. Conclude the course enrollment for one of the students.
4. Activate the "Show Concluded Enrollments" setting in the gradebook
   and click to view the current grading period. Verify the score for
   the concluded student appears.
5. Click to view "All Grading Periods". Verify you can see the score
   for the concluded student.

CNVS-34587 Test Plan:
* Do the following in a course with multiple grading periods and with
  at least two students in the course.
1. Create an assignment in the course.
2. Conclude one student's enrollment for the course.
3. As a teacher, go to the gradebook, click the gear and select "Show
   Concluded Enrollments".
4. Click the name of the concluded student.
5. Click the name of the assignment (which doesn't have a grade). Verify
   there is no page error.

Change-Id: Iebb7c363f37993b018925cd4f65fe8e86c351812
Reviewed-on: https://gerrit.instructure.com/100784
Reviewed-by: Neil Gupta <ngupta@instructure.com>
Tested-by: Jenkins
Reviewed-by: Jeremy Neander <jneander@instructure.com>
QA-Review: Anju Reddy <areddy@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-02-02 18:57:58 +00:00
Neil Gupta 7298b8749f Get rid of multiple_grading_periods feature flag
Fixes CNVS-27109

Test plan:
Regression test everything related to multiple grading periods.

In particular, make sure:
* there is no mention of the multiple grading periods feature flag on
  the account or course features pages
* make sure grading periods UI always shows up on the account grading
  standards page
* make sure the grading periods UI only shows on the course grading
  standards page if legacy course grading periods exist for that course
  (see below)
* grading period dropdowns only show up everywhere else if there are
  grading periods to show. Otherwise, it should behave as if MGP is
  "disabled"
* Grade calculation should work as expected with and without grading
  periods

To create legacy course grading periods, you have to use rails console:
1. Find your course:
      course = Course.find(<id>)
2. Create a grading period group:
      group = course.grading_period_groups.create!(title: "2017")
2. Create a grading period:
      group.grading_periods.create!(
        weight: 1,
        title: 'Fall',
        start_date: 5.days.ago,
        end_date: 10.days.from_now
      )

Here's the list of known places grading periods can be seen in the UI:

Instructor Assignments page
  (https://community.canvaslms.com/docs/DOC-2615)
Student Assignments page
  (https://community.canvaslms.com/docs/DOC-3123)
Gradebook (https://community.canvaslms.com/docs/DOC-2785)
Gradebook Individual View
  (https://community.canvaslms.com/docs/DOC-2788)
Course Settings grading schemes page
  (https://community.canvaslms.com/docs/DOC-4042)
Student Grades page (https://community.canvaslms.com/docs/DOC-1291)
Dashboard global Grades page
  (https://community.canvaslms.com/docs/DOC-5464)

Change-Id: Iefac4b08120bd1699d4ed98bcb418089eec9b3b8
Reviewed-on: https://gerrit.instructure.com/99744
Reviewed-by: Spencer Olson <solson@instructure.com>
Tested-by: Jenkins
QA-Review: KC Naegle <knaegle@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-01-25 20:35:18 +00:00
Spencer Olson 37fa769aef update grading period scores when student is graded
When a student is graded, the score for their grading period will now
be updated in addition to their total course score. Previously, when a
student was graded, their grading period score was not updated.

closes CNVS-26709

test plan:
1) In a course with multiple grading periods enabled and grading
   periods set up, grade students for assignments that fall in grading
   periods and make sure the scores get updated for the grading period
   and for the course total.

   * To make sure the scores get updated for the grading period, open a
     rails console and find the grading period scores (we'll assume the
     student's enrollment ID is 5, and the ID of the grading period
     that the assignment falls in is 8).

       $ Enrollment.find(5).scores.where(grading_period_id: 8)

     Then, give a different grade to the student for the assignment
     that falls in the grading period and run the command above again.
     You should see that the current_score and final_score have
     changed.

    * To make sure the scores get updated for the course total, open a
      rails console and find the course total scores (we'll assume the
      student's enrollment ID is 5).

        $ Enrollment.find(5).scores.where(grading_period_id: nil)

      Then, give a different grade to the student for the assignment
      that falls in the grading period and run the command above again.
      You should see that the current_score and final_score have
      changed.

Edge case: make sure that grading period scores continue to get updated
even if MGP is turned off. To verify this, turn off MGP in a course
that originally had MGP turned on. Then, grade students in assignments
that fell in a grading period when MGP was enabled. After grading, the
grading period scores should be updated.

Change-Id: I29e4e22a0b73d1062a93c6ad420d876c2f5d040a
Reviewed-on: https://gerrit.instructure.com/98603
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Derek Bender <djbender@instructure.com>
Tested-by: Jenkins
QA-Review: Anju Reddy <areddy@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-01-06 16:35:23 +00:00
Derek Bender b619833d12 flip bucketting rules for grading periods
closes: CNVS-33153

this changes the boundaries for how dates are bucketed
into grading periods.

Previously:
  period_start_date <= date &&
    date < period_end_date

Now behavior:
  period_start_date < date &&
    date <= period_end_date

Test Plan:
 - Given a course with multiple grading periods enabled
 - Given a grading period set with grading periods (note the time
   and date of one of the grading period's end date)
 - Given an assignment due at the same time and date as the grading
   period's end date
 - When navigating to the gradebook and selecting the grading period
 - Then the assignment id visible for the grading period

Change-Id: Iaf4a278ec670eb8575336c57be0354be9aad2441
Reviewed-on: https://gerrit.instructure.com/97018
Reviewed-by: Shahbaz Javeed <sjaveed@instructure.com>
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Tested-by: Jenkins
QA-Review: Anju Reddy <areddy@instructure.com>
Product-Review: Christi Wruck
2016-12-15 18:58:01 +00:00
Shahbaz Javeed 95283746ea prevent grading if submission is due in closed grading period
closes CNVS-32229
closes CNVS-32232

test plan:
* Create a course with MGP enabled and two grading periods in
  the default term
* Create two assignments for this course, one in a closed GP and
  one in an open GP
* To test overrides, create the following as well:
  * For one of the students, make the open assignment due in the
    closed grading period
  * For another student, make the closed assignment due in the
    open grading period

* Ensure the following steps work for all assignment/student
  combos due in a closed grading period.

** CNVS-32229 **
* Login as a teacher
* Go to speedgrader for the assignment in the closed GP
* Notice that the grade input is locked down
* Right click on the locked-down input and select 'Inspect'
* Remove the 'ui-state-disabled' class and remove
  readonly="readonly" from the input field's HTML
* Notice the input is no longer grayed out and you can enter
  a grade
* Enter a grade and tab out of the input
* You should see an error message that says something went wrong
  and notice in the Network tab of your dev tools that the AJAX
  post failed, meaning the submission was not gradeable
* Refresh the page and notice the grade is not there.
* Verify it isn't there in Gradebook either

* Login as an admin
* Go to speedgrader for the assignment in the closed GP
* Notice that the grade input is *not* locked down
* Enter a grade and tab out of the input
* You should *not* see an error message that says something went
  wrong meaning the submission was graded successfully
* Refresh the page and notice the grade is there.
* Verify it is also present in Gradebook

** CNVS-32232 **
* Login as a teacher
* Go into a gradebook that has an assignment that is
  locked down because it is in a closed grading period
* Notice that the grade cells for the assignment are locked
  down (because the submissions fall in a closed grading period)
* Right-click on one of the locked-down cells and select 'Inspect'
* Remove the 'grayed-out' and 'cannot_edit_in_closed_grading_period'
  classes
* Notice the cell is no longer grayed out and you can enter a grade.
* Enter a grade
* Click on another cell.
* You should see an error message that says something went wrong
  and in the Network tab of your dev tools verify the AJAX post
  failed, meaning the submission was not gradeable
* Refresh the page and notice the grade is not there

* Login as an admin
* Login as a teacher
* Go into a gradebook that has an assignment that is
  in a closed grading period
* Enter a grade in a cell that should be due in a closed grading
  period
* Click on another cell
* You should *not* see an error message that says something went
  wrong meaning the submission was graded successfully
* Refresh the page and notice the grade is there.
* Verify it is also present in Gradebook

Change-Id: Ia80e4de626616309c5e9dffb78ed0f9671ad1076
Reviewed-on: https://gerrit.instructure.com/95687
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Spencer Olson <solson@instructure.com>
Tested-by: Jenkins
QA-Review: Anju Reddy <areddy@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2016-12-08 21:01:07 +00:00
Spencer Olson 5569ce0e28 don't load overrides in gradebook
in gradebook (grid view and individual view),
overrides are no longer loaded. this should
decrease page load times for courses that
have differentiated assignments.

closes CNVS-33411

test plan:
 1) create a course with
  * 300 students
  * 75 assignments
  * one override per student per assignment
 2) benchmark how long it takes to load the
    gradebook
 3) switch to master. benchmark how long it takes
    to load the gradebook
 4) gradebook should load significantly faster with
    this commit than it does on master
 5) verify you can sort by due date in gradebook
 6) verify gradebook individual view loads

Change-Id: Id89cea8acadf7617bc8035789fb787a2bf68660a
Reviewed-on: https://gerrit.instructure.com/95897
Reviewed-by: Neil Gupta <ngupta@instructure.com>
Tested-by: Jenkins
QA-Review: KC Naegle <knaegle@instructure.com>
Product-Review: Spencer Olson <solson@instructure.com>
2016-12-02 23:38:12 +00:00
Spencer Olson f7814b9c53 Improve calculation of effective due dates for students
closes CNVS-33110
closes CNVS-32641

Test plan:
* regression test changing group weighting schemes
* regression test moving assignments with any due date in
  a closed grading period (this could be from an override or
  the "Everyone Else" due date) into another assignment group
    * An assignment that is "locked" (that is, one with a due date
      that falls in a closed grading period) should not be movable.

Change-Id: I9bb87dcd7c0b83535a31d079c669b86c5eee55b0
Reviewed-on: https://gerrit.instructure.com/94939
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
Tested-by: Jenkins
QA-Review: KC Naegle <knaegle@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2016-11-29 22:29:38 +00:00