remove checks for post_policies_enabled

closes EVAL-671
flag=post_policies_enabled

Test Plan:
- General smoke test of post policies

Change-Id: I618ade57dca203e5500d882f29a9494253839319
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/251977
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Aaron Shafovaloff <ashafovaloff@instructure.com>
Reviewed-by: Adrian Packel <apackel@instructure.com>
QA-Review: Kai Bjorkman <kbjorkman@instructure.com>
Product-Review: Syed Hussain <shussain@instructure.com>
This commit is contained in:
Spencer Olson 2020-11-05 09:44:34 -06:00
parent 5b6355785d
commit 3eb1a26604
33 changed files with 291 additions and 554 deletions

View File

@ -144,8 +144,7 @@ class GradebooksController < ApplicationController
student_outcome_gradebook_enabled: @context.feature_enabled?(:student_outcome_gradebook),
student_id: @presenter.student_id,
students: @presenter.students.as_json(include_root: false),
outcome_proficiency: outcome_proficiency,
post_policies_enabled: @context.post_policies_enabled?
outcome_proficiency: outcome_proficiency
}
# This really means "if the final grade override feature flag is enabled AND
@ -456,7 +455,6 @@ class GradebooksController < ApplicationController
post_grades_feature: post_grades_feature?,
post_grades_ltis: post_grades_ltis,
post_manually: @context.post_manually?,
post_policies_enabled: @context.post_policies_enabled?,
publish_to_sis_enabled: (
!!@context.sis_source_id && @context.allows_grade_publishing_by(@current_user) && gradebook_is_editable
@ -572,8 +570,6 @@ class GradebooksController < ApplicationController
outcome_rollups_url: api_v1_course_outcome_rollups_url(@context, per_page: 100),
post_grades_feature: post_grades_feature?,
post_manually: @context.post_manually?,
post_policies_enabled: @context.post_policies_enabled?,
publish_to_sis_enabled: (
!!@context.sis_source_id && @context.allows_grade_publishing_by(@current_user) && gradebook_is_editable
),

View File

@ -476,11 +476,7 @@ class Gradebook {
} else {
this.finalGradeOverrides = null
}
if (this.options.post_policies_enabled) {
this.postPolicies = new PostPolicies(this)
} else {
this.postPolicies = null
}
this.postPolicies = new PostPolicies(this)
$.subscribe('assignment_muting_toggled', this.handleSubmissionPostedChange)
$.subscribe('submissions_updated', this.updateSubmissionsFromExternal)
// emitted by SectionMenuView; also subscribed in OutcomeGradebookView
@ -506,7 +502,6 @@ class Gradebook {
this.headerComponentRefs = {}
this.filteredContentInfo = {
invalidAssignmentGroups: [],
mutedAssignments: [],
totalPointsPossible: 0
}
this.setAssignments({})
@ -2853,9 +2848,6 @@ class Gradebook {
return results
}.call(this)
const filteredAssignments = this.filterAssignments(unorderedAssignments)
this.filteredContentInfo.mutedAssignments = filteredAssignments.filter(assignment => {
return assignment.muted
})
this.filteredContentInfo.totalPointsPossible = _.reduce(
this.assignmentGroups,
function(sum, assignmentGroup) {
@ -2878,27 +2870,23 @@ class Gradebook {
}
listHiddenAssignments(studentId) {
if (this.options.post_policies_enabled) {
if (!(this.contentLoadStates.submissionsLoaded && this.assignmentsLoadedForCurrentView())) {
return []
}
return Object.values(this.assignments).filter(assignment => {
const submission = this.getSubmission(studentId, assignment.id)
// Ignore anonymous assignments when deciding whether to show the
// "hidden" icon, as including them could reveal which students have
// and have not been graded.
// Ignore 'not_graded' assignments as they are not counted into the
// student's grade, nor are they visible in the Gradebook.
return (
submission != null &&
isPostable(submission) &&
!assignment.anonymize_students &&
assignment.grading_type !== 'not_graded'
)
})
} else {
return this.filteredContentInfo.mutedAssignments
if (!(this.contentLoadStates.submissionsLoaded && this.assignmentsLoadedForCurrentView())) {
return []
}
return Object.values(this.assignments).filter(assignment => {
const submission = this.getSubmission(studentId, assignment.id)
// Ignore anonymous assignments when deciding whether to show the
// "hidden" icon, as including them could reveal which students have
// and have not been graded.
// Ignore 'not_graded' assignments as they are not counted into the
// student's grade, nor are they visible in the Gradebook.
return (
submission != null &&
isPostable(submission) &&
!assignment.anonymize_students &&
assignment.grading_type !== 'not_graded'
)
})
}
getTotalPointsPossible() {
@ -3285,7 +3273,6 @@ class Gradebook {
assignmentId,
userId: studentId
}),
postPoliciesEnabled: this.options.post_policies_enabled,
requireStudentGroupForSpeedGrader: this.requireStudentGroupForSpeedGrader(assignment),
selectNextAssignment: () => {
return this.loadTrayAssignment('next')

View File

@ -146,8 +146,6 @@ export default class AssignmentCellFormatter {
return gradebook.options.show_similarity_score
}
}
this.postPoliciesEnabled = gradebook.options.post_policies_enabled
}
render = (_row, _cell, submission /* value */, columnDef, student /* dataContext */) => {
@ -172,12 +170,6 @@ export default class AssignmentCellFormatter {
submissionTypes: assignment.submission_types
}
// Avoid setting muted styles in the cell when Post Policies are enabled,
// as the unposted indicator already serves the same function.
if (!this.postPoliciesEnabled) {
assignmentData.muted = assignment.muted
}
const submissionData = {
dropped: submission.drop,
excused: submission.excused,

View File

@ -38,9 +38,5 @@ export function classNamesForAssignmentCell(assignment, submissionData) {
classNames.push('ungraded')
}
if (assignment.muted) {
classNames.push('muted')
}
return classNames
}

View File

@ -54,7 +54,7 @@ function SecondaryDetailLine(props) {
</Text>
</span>
{props.postPoliciesEnabled && props.assignment.postManually && (
{props.assignment.postManually && (
<span>
&nbsp;
<Text size="x-small" transform="uppercase" weight="bold">
@ -62,15 +62,6 @@ function SecondaryDetailLine(props) {
</Text>
</span>
)}
{!props.postPoliciesEnabled && props.assignment.muted && (
<span>
&nbsp;
<Text size="x-small" transform="uppercase" weight="bold">
{I18n.t('Muted')}
</Text>
</span>
)}
</span>
)
}
@ -78,11 +69,9 @@ function SecondaryDetailLine(props) {
SecondaryDetailLine.propTypes = {
assignment: shape({
anonymizeStudents: bool.isRequired,
muted: bool.isRequired,
pointsPossible: number,
published: bool.isRequired
}).isRequired,
postPoliciesEnabled: bool.isRequired
}).isRequired
}
function labelForPostGradesAction(postGradesAction) {
@ -120,7 +109,6 @@ export default class AssignmentColumnHeader extends ColumnHeader {
courseId: string.isRequired,
htmlUrl: string.isRequired,
id: string.isRequired,
muted: bool.isRequired,
name: string.isRequired,
pointsPossible: number,
postManually: bool.isRequired,
@ -500,7 +488,6 @@ export default class AssignmentColumnHeader extends ColumnHeader {
render() {
const classes = `Gradebook__ColumnHeaderAction ${this.state.menuShown ? 'menuShown' : ''}`
const postPoliciesEnabled = this.props.postGradesAction.featureEnabled
return (
<div
@ -513,7 +500,7 @@ export default class AssignmentColumnHeader extends ColumnHeader {
<Grid.Row>
<Grid.Col textAlign="center" width="auto" vAlign="top">
<div className="Gradebook__ColumnHeaderIndicators">
{postPoliciesEnabled && this.renderUnpostedSubmissionsIcon()}
{this.renderUnpostedSubmissionsIcon()}
</div>
</Grid.Col>
@ -523,10 +510,7 @@ export default class AssignmentColumnHeader extends ColumnHeader {
{this.renderAssignmentLink()}
</span>
<SecondaryDetailLine
assignment={this.props.assignment}
postPoliciesEnabled={postPoliciesEnabled}
/>
<SecondaryDetailLine assignment={this.props.assignment} />
</span>
</Grid.Col>

View File

@ -79,7 +79,6 @@ export function createGradebook(options = {}) {
active_request_limit: 10
},
post_grades_ltis: [],
post_policies_enabled: true,
publish_to_sis_enabled: false,
sections: [],

View File

@ -34,7 +34,6 @@ export default class SubmissionStatus extends React.Component {
static propTypes = {
assignment: shape({
anonymizeStudents: bool.isRequired,
muted: bool.isRequired,
postManually: bool.isRequired,
published: bool.isRequired
}).isRequired,
@ -43,7 +42,6 @@ export default class SubmissionStatus extends React.Component {
isInNoGradingPeriod: bool.isRequired,
isInOtherGradingPeriod: bool.isRequired,
isNotCountedForScore: bool.isRequired,
postPoliciesEnabled: bool.isRequired,
submission: shape({
drop: bool,
excused: bool,
@ -55,7 +53,7 @@ export default class SubmissionStatus extends React.Component {
}
getStatusPills() {
const {assignment, postPoliciesEnabled, submission} = this.props
const {assignment, submission} = this.props
const statusPillComponents = []
if (!assignment.published) {
@ -74,23 +72,12 @@ export default class SubmissionStatus extends React.Component {
return statusPillComponents
}
if (postPoliciesEnabled) {
if (isPostable(submission)) {
statusPillComponents.push(
<Pill
key="hidden-submission"
variant="warning"
text={I18n.t('Hidden')}
margin="0 0 x-small"
/>
)
}
} else if (assignment.muted) {
if (isPostable(submission)) {
statusPillComponents.push(
<Pill
key="muted-assignment"
variant="default"
text={I18n.t('Muted')}
key="hidden-submission"
variant="warning"
text={I18n.t('Hidden')}
margin="0 0 x-small"
/>
)

View File

@ -93,7 +93,6 @@ export default class SubmissionTray extends React.Component {
grade: string,
valid: bool.isRequired
}),
postPoliciesEnabled: bool.isRequired,
requireStudentGroupForSpeedGrader: bool.isRequired,
student: shape({
id: string.isRequired,
@ -384,7 +383,6 @@ export default class SubmissionTray extends React.Component {
isInClosedGradingPeriod={this.props.isInClosedGradingPeriod}
isInNoGradingPeriod={this.props.isInNoGradingPeriod}
isNotCountedForScore={this.props.isNotCountedForScore}
postPoliciesEnabled={this.props.postPoliciesEnabled}
submission={this.props.submission}
/>

View File

@ -227,9 +227,8 @@ const GradeSummary = {
if ($assignment.data('muted')) {
title = I18n.t('Instructor is working on grades')
const className = ENV.post_policies_enabled ? 'icon-off' : 'icon-muted muted_icon'
// xsslint safeString.identifier className title
$grade.html(`<i class="${className}" aria-hidden="true" title="${title}"=></i>`)
// xsslint safeString.identifier title
$grade.html(`<i class="icon-off" aria-hidden="true" title="${title}"=></i>`)
} else {
title = I18n.t('Click to test a different score')
$grade.text(score.formattedValue)

View File

@ -536,7 +536,7 @@ class Assignment < ActiveRecord::Base
until self.observer_alerts.limit(1_000).delete_all < 1_000; end
end
before_create :set_root_account_id, :set_muted_if_post_policies_enabled
before_create :set_root_account_id, :set_muted
after_save :update_submissions_and_grades_if_details_changed,
:update_grading_period_grades,
@ -730,7 +730,6 @@ class Assignment < ActiveRecord::Base
def needs_to_recompute_grade?
!id_before_last_save.nil? && (
saved_change_to_points_possible? ||
(saved_change_to_muted? && !course.post_policies_enabled?) ||
saved_change_to_workflow_state? ||
saved_change_to_assignment_group_id? ||
saved_change_to_only_visible_to_overrides? ||
@ -3346,9 +3345,6 @@ class Assignment < ActiveRecord::Base
# Only anonymize students for moderated assignments if grades have not been published.
return !grades_published? if moderated_grading?
# If Post Policies isn't enabled, we can just check whether the assignment is muted.
return muted? unless course.post_policies_enabled?
# Otherwise, only anonymize students if there's at least one active student with
# an unposted submission.
unposted_anonymous_submissions?
@ -3421,11 +3417,7 @@ class Assignment < ActiveRecord::Base
end
def post_manually?
if course.post_policies_enabled?
!!effective_post_policy&.post_manually?
else
muted?
end
!!effective_post_policy&.post_manually?
end
def post_submissions(progress: nil, submission_ids: nil, skip_updating_timestamp: false, posting_params: nil)
@ -3458,10 +3450,8 @@ class Assignment < ActiveRecord::Base
submissions.in_workflow_state('graded').each(&:assignment_muted_changed)
show_stream_items(submissions: submissions)
if course.post_policies_enabled?
course.recompute_student_scores(submissions.pluck(:user_id))
update_muted_status!
end
course.recompute_student_scores(submissions.pluck(:user_id))
update_muted_status!
delay_if_production.recalculate_module_progressions(submission_ids)
progress.set_results(assignment_id: id, posted_at: update_time, user_ids: user_ids) if progress.present?
broadcast_submissions_posted(posting_params) if posting_params.present?
@ -3480,10 +3470,8 @@ class Assignment < ActiveRecord::Base
submissions.update_all(posted_at: nil, updated_at: Time.zone.now) unless skip_updating_timestamp
submissions.in_workflow_state('graded').each(&:assignment_muted_changed)
hide_stream_items(submissions: submissions)
if course.post_policies_enabled?
course.recompute_student_scores(submissions.pluck(:user_id))
update_muted_status!
end
course.recompute_student_scores(submissions.pluck(:user_id))
update_muted_status!
progress.set_results(assignment_id: id, posted_at: nil, user_ids: user_ids) if progress.present?
end
@ -3556,6 +3544,10 @@ class Assignment < ActiveRecord::Base
private
def set_muted
self.muted = true
end
def anonymous_grader_identities(index_by:)
return {} unless moderated_grading?
@ -3585,12 +3577,6 @@ class Assignment < ActiveRecord::Base
self.muted = true if moderated_grading?
end
def set_muted_if_post_policies_enabled
return unless course.post_policies_enabled?
self.muted = true
end
private :set_muted_if_post_policies_enabled
def ensure_manual_posting_if_anonymous
ensure_post_policy(post_manually: true) if saved_change_to_anonymous_grading?(from: false, to: true)
end

View File

@ -48,7 +48,6 @@ module BroadcastPolicies
end
def should_dispatch_submissions_posted?
return false unless assignment.context.post_policies_enabled?
context_sendable? && assignment.posting_params_for_notifications.present?
end

View File

@ -81,12 +81,7 @@ module BroadcastPolicies
end
def quiz_posted?(quiz_submission)
quiz = quiz_submission.quiz
if quiz.assignment.context.post_policies_enabled?
quiz_submission.posted?
else
!quiz.muted?
end
quiz_submission.posted?
end
end
end

View File

@ -75,9 +75,7 @@ module BroadcastPolicies
end
def should_dispatch_submission_posted?
return false unless assignment.course.post_policies_enabled? &&
submission.grade_posting_in_progress &&
context_sendable?
return false unless submission.grade_posting_in_progress && context_sendable?
submission.reload
posted_recently?

View File

@ -246,16 +246,9 @@ class ContextModuleProgression < ActiveRecord::Base
remove_incomplete_requirement(requirement[:id]) # start from a fresh slate so we don't hold onto a max score that doesn't exist anymore
return if subs.blank?
if tag.course.post_policies_enabled?
if unposted_sub = subs.detect { |sub| sub.is_a?(Submission) && !sub.posted? }
# don't mark the progress as in-progress if they haven't submitted
self.update_incomplete_requirement!(requirement, nil) unless unposted_sub.unsubmitted?
return
end
elsif tag.assignment&.muted?
if subs.any? { |sub| sub.is_a?(Submission) && !sub.unsubmitted? }
self.update_incomplete_requirement!(requirement, nil)
end
if (unposted_sub = subs.detect { |sub| sub.is_a?(Submission) && !sub.posted? })
# don't mark the progress as in-progress if they haven't submitted
self.update_incomplete_requirement!(requirement, nil) unless unposted_sub.unsubmitted?
return
end

View File

@ -2521,8 +2521,8 @@ class Submission < ActiveRecord::Base
end
def hide_grade_from_student?(for_plagiarism: false)
return muted_assignment? unless assignment.course.post_policies_enabled?
return false if for_plagiarism
if assignment.post_manually?
posted_at.blank?
else
@ -2541,14 +2541,7 @@ class Submission < ActiveRecord::Base
end
def posted?
# NOTE: This really should be a call to assignment.course.post_policies_enabled?
# but we're going to leave it the way it is for the next few months (until
# New Gradebook becomes universal) for fear of breaking even more things.
if PostPolicy.feature_enabled?
posted_at.present?
else
!assignment.muted?
end
posted_at.present?
end
def assignment_muted_changed
@ -2785,14 +2778,6 @@ class Submission < ActiveRecord::Base
end
def handle_posted_at_changed
# This method will be called if a posted_at date was changed specifically
# on this submission (e.g., if it received a grade or a comment and the
# assignment is not manually posted), as opposed to the usual situation
# where all submissions in a section are updated. In this case, we call
# [un]post_submissions to follow the normal workflow, but skip updating the
# posted_at date since that already happened.
return unless assignment.course.post_policies_enabled?
previously_posted = posted_at_before_last_save.present?
# If this submission is part of an assignment associated with a quiz, the

View File

@ -237,13 +237,10 @@ class GradeSummaryPresenter
end
def hidden_submissions?
if @context.post_policies_enabled?
submissions.any? do |sub|
return !sub.posted? if sub.assignment.post_manually?
sub.graded? && !sub.posted?
end
else
assignments.any?(&:muted?)
submissions.any? do |sub|
return !sub.posted? if sub.assignment.post_manually?
sub.graded? && !sub.posted?
end
end

View File

@ -24,7 +24,6 @@
whatif_instructions = t("You can view your grades based on What-If scores so that you know how grades will be affected by upcoming or resubmitted assignments. You can test scores for an assignment that already includes a score, or an assignment that has yet to be graded.")
hidden_text = t("Instructor is working on grades")
hidden_icon_class = @context.post_policies_enabled? ? "icon-off" : "icon-muted"
%>
<div id="grade-summary-content" style="display: none;">
<% provide :right_side do %>
@ -209,7 +208,7 @@
<% end %>
</span>
<% if assignment_presenter.hide_grade_from_student? %>
<i class="<%= hidden_icon_class %>" title="<%= hidden_text %>"></i>
<i class="icon-off" title="<%= hidden_text %>"></i>
<% else %>
<span class="screenreader-only" role="button">
<%= t(:click_to_change, "Click to test a different score") unless assignment_presenter.unchangeable? %>
@ -583,7 +582,7 @@
</table>
</div>
<% if @presenter.hidden_submissions? %>
<small><i class="<%= hidden_icon_class %>" role="presentation"></i><%= t(:student_mute_legend, "Your instructor is working on grades. While your instructor is working on grades, grade and comment information is unavailable.") %></small>
<small><i class="icon-off" role="presentation"></i><%= t(:student_mute_legend, "Your instructor is working on grades. While your instructor is working on grades, grade and comment information is unavailable.") %></small>
<% end %>
<div id="total_groups_weight" style="display: none;"><%= @presenter.total_weight %></div>
<%= render :partial => "shared/rubric_criterion_dialog" %>

View File

@ -398,10 +398,7 @@ module Api::V1::Assignment
hash['planner_override'] = planner_override_json(override, user, session)
end
if assignment.course.post_policies_enabled?
hash['post_manually'] = assignment.post_manually?
end
hash['post_manually'] = assignment.post_manually?
hash['anonymous_grading'] = value_to_boolean(assignment.anonymous_grading)
hash['anonymize_students'] = assignment.anonymize_students?

View File

@ -43,7 +43,7 @@ module Api::V1::AssignmentGroup
assignments = opts[:assignments] || group.visible_assignments(user)
# Preload assignments' post policies for Assignment#assignment_json.
if assignments.present? && assignments.first.context.post_policies_enabled?
if assignments.present?
ActiveRecord::Associations::Preloader.new.preload(assignments, :post_policy)
Assignment.preload_unposted_anonymous_submissions(assignments)
end

View File

@ -413,15 +413,11 @@ class GradebookExporter
end
def show_as_hidden?(assignment)
if @course.post_policies_enabled?
assignment.post_manually?
else
assignment.muted?
end
assignment.post_manually?
end
def hidden_assignment_text
@course.post_policies_enabled? ? "Manual Posting" : "Muted"
"Manual Posting"
end
def include_grading_period_in_headers?

View File

@ -197,12 +197,6 @@ describe GradebooksController do
expect(order).to eq :due_at
end
it "includes the post_policies_enabled in the ENV" do
user_session(@teacher)
get :grade_summary, params: { course_id: @course.id, id: @student.id }
expect(assigns[:js_env][:post_policies_enabled]).to be true
end
it "includes the current grading period id in the ENV" do
group = @course.root_account.grading_period_groups.create!
period = group.grading_periods.create!(title: "GP", start_date: 3.months.ago, end_date: 3.months.from_now)
@ -914,11 +908,6 @@ describe GradebooksController do
expect(gradebook_options).to have_key :grading_schemes
end
it "sets post_policies_enabled to true" do
get :show, params: { course_id: @course.id }
expect(gradebook_options[:post_policies_enabled]).to be(true)
end
it "sets show_similarity_score to true when the New Gradebook Plagiarism Indicator feature flag is enabled" do
@course.root_account.enable_feature!(:new_gradebook_plagiarism_indicator)
get :show, params: { course_id: @course.id }

View File

@ -2028,7 +2028,7 @@ QUnit.module('#listHiddenAssignments', hooks => {
user_id: '1101'
}
]
gradebook = createGradebook({post_policies_enabled: true})
gradebook = createGradebook()
gradebook.assignments = {
2301: gradedAssignment,
2302: notGradedAssignment
@ -6932,13 +6932,6 @@ QUnit.module('Gradebook#getSubmissionTrayProps', suiteHooks => {
notOk(props.pendingGradeInfo)
})
test('sets postPoliciesEnabled to true when post_policies_enabled is true', () => {
gradebook.options.post_policies_enabled = true
gradebook.setSubmissionTrayState(true, '1101', '2301')
const props = gradebook.getSubmissionTrayProps(gradebook.student('1101'))
strictEqual(props.postPoliciesEnabled, true)
})
QUnit.module('requireStudentGroupForSpeedGrader', requireStudentGroupHooks => {
requireStudentGroupHooks.beforeEach(() => {
const studentGroups = [

View File

@ -305,12 +305,6 @@ QUnit.module('GradebookGrid AssignmentCellFormatter', suiteHooks => {
ok(renderCell().classList.contains('ungraded'))
})
test('does not include the "muted" class when post policies are enabled', () => {
gradebook.options.post_policies_enabled = true
gradebook.getAssignment('2301').muted = true
notOk(renderCell().classList.contains('muted'))
})
test('escapes html in the grade', () => {
gradebook.getDefaultGradingScheme().data[0][0] = '<img src=null onerror=alert(1) >'
gradebook.getAssignment('2301').grading_type = 'letter_grade'

View File

@ -26,7 +26,6 @@ QUnit.module('GradebookGrid CellStyles', () => {
QUnit.module('.classNamesForAssignmentCell', hooks => {
hooks.beforeEach(() => {
assignment = {
muted: false,
submissionTypes: ['online_text_entry']
}
submissionData = {
@ -163,25 +162,11 @@ QUnit.module('GradebookGrid CellStyles', () => {
deepEqual(classNames, ['ungraded'])
})
test('includes "muted" when the assignment is muted', () => {
assignment.muted = true
const classNames = classNamesForAssignmentCell(assignment, submissionData)
deepEqual(classNames, ['muted'])
})
test('assignment classNames are not exclusive', () => {
assignment.submissionTypes = ['not_graded']
assignment.muted = true
const classNames = classNamesForAssignmentCell(assignment, submissionData)
deepEqual(classNames, ['ungraded', 'muted'])
})
test('assignment classNames are not exclusive with submission classNames', () => {
submissionData.dropped = true
assignment.submissionTypes = ['not_graded']
assignment.muted = true
const classNames = classNamesForAssignmentCell(assignment, submissionData)
deepEqual(classNames, ['dropped', 'ungraded', 'muted'])
deepEqual(classNames, ['dropped', 'ungraded'])
})
})
})

View File

@ -28,7 +28,6 @@ QUnit.module('GradebookGrid AssignmentColumnHeaderRenderer', suiteHooks => {
let assignment
let column
let component
let gradebookOptions
let renderer
let student
let submission
@ -49,10 +48,6 @@ QUnit.module('GradebookGrid AssignmentColumnHeaderRenderer', suiteHooks => {
suiteHooks.beforeEach(() => {
$container = document.createElement('div')
document.body.appendChild($container)
gradebookOptions = {
post_policies_enabled: true
}
})
suiteHooks.afterEach(() => {
@ -60,7 +55,7 @@ QUnit.module('GradebookGrid AssignmentColumnHeaderRenderer', suiteHooks => {
})
function buildGradebook() {
gradebook = createGradebook(gradebookOptions)
gradebook = createGradebook()
sinon.stub(gradebook, 'saveSettings')
assignment = {
@ -338,83 +333,80 @@ QUnit.module('GradebookGrid AssignmentColumnHeaderRenderer', suiteHooks => {
strictEqual(component.props.enterGradesAsSetting.showGradingSchemeOption, true)
})
QUnit.module('"Post grades" action', () => {
QUnit.module('when Post Policies is enabled', contextHooks => {
let onSelectCallback
QUnit.module('"Post grades" action', hooks => {
let onSelectCallback
contextHooks.beforeEach(() => {
gradebookOptions.post_policies_enabled = true
onSelectCallback = sinon.spy()
buildGradebook()
hooks.beforeEach(() => {
onSelectCallback = sinon.spy()
buildGradebook()
sinon.stub(gradebook.postPolicies, 'showPostAssignmentGradesTray')
})
sinon.stub(gradebook.postPolicies, 'showPostAssignmentGradesTray')
})
test('sets featureEnabled to true', () => {
gradebook.gotChunkOfStudents([student])
render()
strictEqual(component.props.postGradesAction.featureEnabled, true)
})
test('sets featureEnabled to true', () => {
gradebook.gotChunkOfStudents([student])
render()
strictEqual(component.props.postGradesAction.featureEnabled, true)
})
test('sets hasGradesOrPostableComments to true if at least one submission is graded', () => {
submission.workflow_state = 'graded'
submission.score = 1
gradebook.gotChunkOfStudents([student])
render()
strictEqual(component.props.postGradesAction.hasGradesOrPostableComments, true)
})
test('sets hasGradesOrPostableComments to true if at least one submission is graded', () => {
submission.workflow_state = 'graded'
submission.score = 1
gradebook.gotChunkOfStudents([student])
render()
strictEqual(component.props.postGradesAction.hasGradesOrPostableComments, true)
})
test('sets hasGradesOrPostableComments to false if no submissions are graded', () => {
gradebook.gotChunkOfStudents([student])
render()
strictEqual(component.props.postGradesAction.hasGradesOrPostableComments, false)
})
test('sets hasGradesOrPostableComments to false if no submissions are graded', () => {
gradebook.gotChunkOfStudents([student])
render()
strictEqual(component.props.postGradesAction.hasGradesOrPostableComments, false)
})
test('sets hasGradesOrCommentsToPost to true if at least one submission is graded and unposted', () => {
submission.workflow_state = 'graded'
submission.score = 1
gradebook.gotChunkOfStudents([student])
render()
strictEqual(component.props.postGradesAction.hasGradesOrCommentsToPost, true)
})
test('sets hasGradesOrCommentsToPost to true if at least one submission is graded and unposted', () => {
submission.workflow_state = 'graded'
submission.score = 1
gradebook.gotChunkOfStudents([student])
render()
strictEqual(component.props.postGradesAction.hasGradesOrCommentsToPost, true)
})
test('sets hasGradesOrCommentsToPost to true if at least one submission has a postable comment and unposted', () => {
submission.has_postable_comments = true
gradebook.gotChunkOfStudents([student])
render()
strictEqual(component.props.postGradesAction.hasGradesOrCommentsToPost, true)
})
test('sets hasGradesOrCommentsToPost to true if at least one submission has a postable comment and unposted', () => {
submission.has_postable_comments = true
gradebook.gotChunkOfStudents([student])
render()
strictEqual(component.props.postGradesAction.hasGradesOrCommentsToPost, true)
})
test('sets hasGradesOrCommentsToPost to false if all submissions have a posted_at date', () => {
submission.posted_at = new Date('Wed Oct 1 1997')
test('sets hasGradesOrCommentsToPost to false if all submissions have a posted_at date', () => {
submission.posted_at = new Date('Wed Oct 1 1997')
gradebook.gotChunkOfStudents([student])
render()
strictEqual(component.props.postGradesAction.hasGradesOrCommentsToPost, false)
})
gradebook.gotChunkOfStudents([student])
render()
strictEqual(component.props.postGradesAction.hasGradesOrCommentsToPost, false)
})
test('includes a callback to show the "Post Assignment Grades" tray', () => {
gradebook.gotChunkOfStudents([student])
render()
component.props.postGradesAction.onSelect(onSelectCallback)
strictEqual(gradebook.postPolicies.showPostAssignmentGradesTray.callCount, 1)
})
test('includes a callback to show the "Post Assignment Grades" tray', () => {
gradebook.gotChunkOfStudents([student])
render()
component.props.postGradesAction.onSelect(onSelectCallback)
strictEqual(gradebook.postPolicies.showPostAssignmentGradesTray.callCount, 1)
})
test('includes the assignment id when showing the "Post Assignment Grades" tray', () => {
gradebook.gotChunkOfStudents([student])
render()
component.props.postGradesAction.onSelect(onSelectCallback)
const [{assignmentId}] = gradebook.postPolicies.showPostAssignmentGradesTray.lastCall.args
strictEqual(assignmentId, '2301')
})
test('includes the assignment id when showing the "Post Assignment Grades" tray', () => {
gradebook.gotChunkOfStudents([student])
render()
component.props.postGradesAction.onSelect(onSelectCallback)
const [{assignmentId}] = gradebook.postPolicies.showPostAssignmentGradesTray.lastCall.args
strictEqual(assignmentId, '2301')
})
test('includes the `onSelect` callback when showing the "Post Assignment Grades" tray', () => {
gradebook.gotChunkOfStudents([student])
render()
component.props.postGradesAction.onSelect(onSelectCallback)
const [{onExited}] = gradebook.postPolicies.showPostAssignmentGradesTray.lastCall.args
strictEqual(onExited, onSelectCallback)
})
test('includes the `onSelect` callback when showing the "Post Assignment Grades" tray', () => {
gradebook.gotChunkOfStudents([student])
render()
component.props.postGradesAction.onSelect(onSelectCallback)
const [{onExited}] = gradebook.postPolicies.showPostAssignmentGradesTray.lastCall.args
strictEqual(onExited, onSelectCallback)
})
})
@ -422,7 +414,6 @@ QUnit.module('GradebookGrid AssignmentColumnHeaderRenderer', suiteHooks => {
let onSelectCallback
hooks.beforeEach(() => {
gradebookOptions.post_policies_enabled = true
onSelectCallback = sinon.spy()
buildGradebook()
submission.posted_at = new Date('Wed Oct 1 1997')
@ -492,7 +483,6 @@ QUnit.module('GradebookGrid AssignmentColumnHeaderRenderer', suiteHooks => {
let onSelectCallback
hooks.beforeEach(() => {
gradebookOptions.post_policies_enabled = true
onSelectCallback = sinon.spy()
buildGradebook()
render()

View File

@ -47,7 +47,6 @@ QUnit.module('GradebookGrid AssignmentColumnHeader', suiteHooks => {
htmlUrl: 'http://localhost/assignments/2301',
id: '2301',
invalid: false,
muted: false,
name: 'Math 1.1',
omitFromFinalGrade: false,
pointsPossible: 10,
@ -227,64 +226,55 @@ QUnit.module('GradebookGrid AssignmentColumnHeader', suiteHooks => {
})
})
QUnit.module('header indicators', () => {
QUnit.module('header indicators', hooks => {
function getColumnHeaderIcon(name = null) {
const iconSpecifier = name != null ? `svg[name="${name}"]` : 'svg'
return $container.querySelector(`.Gradebook__ColumnHeaderIndicators ${iconSpecifier}`)
}
QUnit.module('when post policies are enabled', postPoliciesEnabledHooks => {
postPoliciesEnabledHooks.beforeEach(() => {
props.postGradesAction.featureEnabled = true
})
hooks.beforeEach(() => {
props.postGradesAction.featureEnabled = true
})
QUnit.module('when the assignment is auto-posted', () => {
test('displays no icon when no submissions are graded but unposted', () => {
props.students.forEach(student => {
if (student.submission.score != null) {
student.submission.postedAt = new Date()
}
})
mountComponent()
notOk(getColumnHeaderIcon())
QUnit.module('when the assignment is auto-posted', () => {
test('displays no icon when no submissions are graded but unposted', () => {
props.students.forEach(student => {
if (student.submission.score != null) {
student.submission.postedAt = new Date()
}
})
test('displays an "off" icon when submissions are graded but unposted', () => {
mountComponent()
ok(getColumnHeaderIcon('IconOff'))
})
})
QUnit.module('when the assignment is manually-posted', manualPostingHooks => {
manualPostingHooks.beforeEach(() => {
props.assignment.postManually = true
})
test('does not display an "off" icon when no submissions are graded but unposted', () => {
props.students.forEach(student => {
if (student.submission.workflowState === 'graded') {
student.submission.postedAt = new Date()
}
})
mountComponent()
notOk(getColumnHeaderIcon('IconOff'))
})
})
test('displays no icon when submissions have not been loaded', () => {
props.submissionsLoaded = false
mountComponent()
notOk(getColumnHeaderIcon())
})
test('displays an "off" icon when submissions are graded but unposted', () => {
mountComponent()
ok(getColumnHeaderIcon('IconOff'))
})
})
QUnit.module('when post policies are not enabled', () => {
test('does not display an icon', () => {
mountComponent()
notOk(getColumnHeaderIcon())
QUnit.module('when the assignment is manually-posted', manualPostingHooks => {
manualPostingHooks.beforeEach(() => {
props.assignment.postManually = true
})
test('does not display an "off" icon when no submissions are graded but unposted', () => {
props.students.forEach(student => {
if (student.submission.workflowState === 'graded') {
student.submission.postedAt = new Date()
}
})
mountComponent()
notOk(getColumnHeaderIcon('IconOff'))
})
})
test('displays no icon when submissions have not been loaded', () => {
props.submissionsLoaded = false
mountComponent()
notOk(getColumnHeaderIcon())
})
})
@ -304,27 +294,6 @@ QUnit.module('GradebookGrid AssignmentColumnHeader', suiteHooks => {
equal(getSecondaryDetailText(), 'Out of 0')
})
QUnit.module('when the assignment is muted', () => {
test('displays a muted status when post policies are not enabled', () => {
props.assignment.muted = true
mountComponent()
ok(getSecondaryDetailText().includes('Muted'))
})
test('does not display a muted status when post policies are enabled', () => {
props.assignment.muted = true
props.postGradesAction.featureEnabled = true
mountComponent()
notOk(getSecondaryDetailText().includes('Muted'))
})
test('displays points possible', () => {
props.assignment.muted = true
mountComponent()
ok(getSecondaryDetailText().includes('Out of 10'))
})
})
test('displays an anonymous status when students are anonymized', () => {
props.assignment.anonymizeStudents = true
mountComponent()
@ -341,12 +310,6 @@ QUnit.module('GradebookGrid AssignmentColumnHeader', suiteHooks => {
equal(getSecondaryDetailText(), 'Unpublished')
})
test('displays an unpublished status when the assignment is muted', () => {
props.assignment.muted = true
mountComponent()
equal(getSecondaryDetailText(), 'Unpublished')
})
test('displays an unpublished status when students are anonymized', () => {
props.assignment.anonymizeStudents = true
mountComponent()
@ -354,32 +317,26 @@ QUnit.module('GradebookGrid AssignmentColumnHeader', suiteHooks => {
})
})
QUnit.module('when post policies are enabled', postPoliciesEnabledHooks => {
postPoliciesEnabledHooks.beforeEach(() => {
props.postGradesAction.featureEnabled = true
QUnit.module('when the assignment is manually posted', manualPostHooks => {
manualPostHooks.beforeEach(() => {
props.assignment.postManually = true
})
QUnit.module('when the assignment is manually posted', manualPostHooks => {
manualPostHooks.beforeEach(() => {
props.assignment.postManually = true
})
test('displays post policy "Manual" text', () => {
mountComponent()
ok(getSecondaryDetailText().includes('Manual'))
})
test('prioritizes "Anonymous" text when the assignment is anonymized', () => {
props.assignment.anonymizeStudents = true
mountComponent()
equal(getSecondaryDetailText(), 'Anonymous')
})
})
test('does not display "Manual" text when the assignment is auto-posted', () => {
test('displays post policy "Manual" text', () => {
mountComponent()
notOk(getSecondaryDetailText().includes('Manual'))
ok(getSecondaryDetailText().includes('Manual'))
})
test('prioritizes "Anonymous" text when the assignment is anonymized', () => {
props.assignment.anonymizeStudents = true
mountComponent()
equal(getSecondaryDetailText(), 'Anonymous')
})
})
test('does not display "Manual" text when the assignment is auto-posted', () => {
mountComponent()
notOk(getSecondaryDetailText().includes('Manual'))
})
})

View File

@ -37,9 +37,7 @@ QUnit.module('Gradebook PostPolicies', suiteHooks => {
$container = document.body.appendChild(document.createElement('div'))
setFixtureHtml($container)
gradebookOptions = {
post_policies_enabled: true
}
gradebookOptions = {}
})
suiteHooks.afterEach(() => {

View File

@ -28,7 +28,6 @@ QUnit.module('SubmissionStatus - Pills', hooks => {
props = {
assignment: {
anonymizeStudents: false,
muted: false,
postManually: false,
published: true
},
@ -37,7 +36,6 @@ QUnit.module('SubmissionStatus - Pills', hooks => {
isInClosedGradingPeriod: false,
isInNoGradingPeriod: false,
isNotCountedForScore: false,
postPoliciesEnabled: false,
submission: {
assignmentId: '1',
excused: false,
@ -55,44 +53,17 @@ QUnit.module('SubmissionStatus - Pills', hooks => {
wrapper.unmount()
})
function getHiddenPills() {
return wrapper
.find('Pill')
.getElements()
.filter(node => node.props.text === 'Hidden')
}
function mountComponent() {
return shallow(<SubmissionStatus {...props} />)
}
test('shows the "Muted" pill when the assignment is muted and not postPoliciesEnabled', () => {
props.assignment.muted = true
wrapper = mountComponent()
const mutedPills = wrapper
.find('Pill')
.getElements()
.filter(node => node.props.text === 'Muted')
strictEqual(mutedPills.length, 1)
})
test('does not show the "Muted" pill when the assignment is muted and students are anonymous', () => {
props.assignment.muted = true
props.assignment.anonymizeStudents = true
wrapper = mountComponent()
const mutedPills = wrapper
.find('Pill')
.getElements()
.filter(node => node.props.text === 'Muted')
strictEqual(mutedPills.length, 0)
})
test('does not show the "Muted" pill when the assignment is not muted', () => {
props.assignment.muted = false
wrapper = mountComponent()
const pills = wrapper
.find('Pill')
.getElements()
.map(node => node.props.text)
strictEqual(pills.length, 0)
})
test('shows the "Unpublished" pill when the assignment is unpublished', () => {
props.assignment.published = false
wrapper = mountComponent()
@ -183,71 +154,47 @@ QUnit.module('SubmissionStatus - Pills', hooks => {
strictEqual(pills.length, 0)
})
QUnit.module('Post Policies enabled', postPoliciesEnabledHooks => {
function getHiddenPills() {
return wrapper
.find('Pill')
.getElements()
.filter(node => node.props.text === 'Hidden')
}
test('shows the "Hidden" pill when the submission is graded and not posted', () => {
props.submission.score = 1
props.submission.workflowState = 'graded'
wrapper = mountComponent()
const hiddenPills = getHiddenPills()
strictEqual(hiddenPills.length, 1)
})
postPoliciesEnabledHooks.beforeEach(() => {
props.postPoliciesEnabled = true
})
test('shows the "Hidden" pill when the submission has comments and not posted', () => {
props.submission.hasPostableComments = true
wrapper = mountComponent()
const hiddenPills = getHiddenPills()
strictEqual(hiddenPills.length, 1)
})
test('does not show the "Muted" pill when the assignment is muted', () => {
props.assignment.muted = true
wrapper = mountComponent()
const mutedPills = wrapper
.find('Pill')
.getElements()
.filter(node => node.props.text === 'Muted')
test('does not show the "Hidden" pill when students are anonymized', () => {
props.submission.hasPostableComments = true
props.assignment.anonymizeStudents = true
wrapper = mountComponent()
const hiddenPills = getHiddenPills()
strictEqual(hiddenPills.length, 0)
})
strictEqual(mutedPills.length, 0)
})
test('does not show the "Hidden" pill when the submission is not graded', () => {
props.submission.workflowState = 'unsubmitted'
wrapper = mountComponent()
const hiddenPills = getHiddenPills()
strictEqual(hiddenPills.length, 0)
})
test('shows the "Hidden" pill when the submission is graded and not posted', () => {
props.submission.score = 1
props.submission.workflowState = 'graded'
wrapper = mountComponent()
const hiddenPills = getHiddenPills()
strictEqual(hiddenPills.length, 1)
})
test('does not show the "Hidden" pill when the submission is posted', () => {
props.submission.postedAt = new Date()
wrapper = mountComponent()
const hiddenPills = getHiddenPills()
strictEqual(hiddenPills.length, 0)
})
test('shows the "Hidden" pill when the submission has comments and not posted', () => {
props.submission.hasPostableComments = true
wrapper = mountComponent()
const hiddenPills = getHiddenPills()
strictEqual(hiddenPills.length, 1)
})
test('does not show the "Hidden" pill when students are anonymized', () => {
props.submission.hasPostableComments = true
props.assignment.anonymizeStudents = true
wrapper = mountComponent()
const hiddenPills = getHiddenPills()
strictEqual(hiddenPills.length, 0)
})
test('does not show the "Hidden" pill when the submission is not graded', () => {
props.submission.workflowState = 'unsubmitted'
wrapper = mountComponent()
const hiddenPills = getHiddenPills()
strictEqual(hiddenPills.length, 0)
})
test('does not show the "Hidden" pill when the submission is posted', () => {
props.submission.postedAt = new Date()
wrapper = mountComponent()
const hiddenPills = getHiddenPills()
strictEqual(hiddenPills.length, 0)
})
test('does not show the "Hidden" pill when the submission is not graded nor posted', () => {
wrapper = mountComponent()
const hiddenPills = getHiddenPills()
strictEqual(hiddenPills.length, 0)
})
test('does not show the "Hidden" pill when the submission is not graded nor posted', () => {
wrapper = mountComponent()
const hiddenPills = getHiddenPills()
strictEqual(hiddenPills.length, 0)
})
})
@ -259,7 +206,6 @@ QUnit.module('SubmissionStatus - Grading Period not in any grading period warnin
hooks.beforeEach(() => {
props = {
assignment: {
muted: false,
postManually: false,
published: true
},
@ -268,7 +214,6 @@ QUnit.module('SubmissionStatus - Grading Period not in any grading period warnin
isInClosedGradingPeriod: false,
isInNoGradingPeriod: false,
isNotCountedForScore: false,
postPoliciesEnabled: false,
submission: {
excused: false,
hasPostableComments: false,
@ -320,7 +265,6 @@ QUnit.module('SubmissionStatus - Grading Period is a closed warning', hooks => {
hooks.beforeEach(() => {
props = {
assignment: {
muted: false,
postManually: false,
published: true
},
@ -329,7 +273,6 @@ QUnit.module('SubmissionStatus - Grading Period is a closed warning', hooks => {
isInClosedGradingPeriod: false,
isInNoGradingPeriod: false,
isNotCountedForScore: false,
postPoliciesEnabled: false,
submission: {
excused: false,
hasPostableComments: false,
@ -381,7 +324,6 @@ QUnit.module('SubmissionStatus - Grading Period is in another period warning', h
hooks.beforeEach(() => {
props = {
assignment: {
muted: false,
postManually: false,
published: true
},
@ -390,7 +332,6 @@ QUnit.module('SubmissionStatus - Grading Period is in another period warning', h
isInClosedGradingPeriod: false,
isInNoGradingPeriod: false,
isNotCountedForScore: false,
postPoliciesEnabled: false,
submission: {
excused: false,
hasPostableComments: false,
@ -442,7 +383,6 @@ QUnit.module('SubmissionStatus - Concluded Enrollment Warning', hooks => {
hooks.beforeEach(() => {
props = {
assignment: {
muted: false,
postManually: false,
published: true
},
@ -451,7 +391,6 @@ QUnit.module('SubmissionStatus - Concluded Enrollment Warning', hooks => {
isInClosedGradingPeriod: false,
isInNoGradingPeriod: false,
isNotCountedForScore: false,
postPoliciesEnabled: false,
submission: {
excused: false,
hasPostableComments: false,
@ -503,7 +442,6 @@ QUnit.module('SubmissionStatus - Not calculated in final grade', hooks => {
hooks.beforeEach(() => {
props = {
assignment: {
muted: false,
postManually: false,
published: true
},
@ -512,7 +450,6 @@ QUnit.module('SubmissionStatus - Not calculated in final grade', hooks => {
isInClosedGradingPeriod: false,
isInNoGradingPeriod: false,
isNotCountedForScore: false,
postPoliciesEnabled: false,
submission: {
excused: false,
hasPostableComments: false,

View File

@ -49,7 +49,12 @@ QUnit.module('SubmissionTray', hooks => {
editSubmissionComment() {},
enterGradesAs: 'points',
gradingDisabled: false,
gradingScheme: [['A', 0.9], ['B+', 0.85], ['B', 0.8], ['B-', 0.75]],
gradingScheme: [
['A', 0.9],
['B+', 0.85],
['B', 0.8],
['B-', 0.75]
],
locale: 'en',
onAnonymousSpeedGraderClick() {},
onGradeSubmission() {},
@ -60,7 +65,6 @@ QUnit.module('SubmissionTray', hooks => {
isOpen: true,
courseId: '1',
currentUserId: '2',
postPoliciesEnabled: false,
speedGraderEnabled: true,
student: {
id: '27',
@ -297,22 +301,16 @@ QUnit.module('SubmissionTray', hooks => {
})
})
QUnit.module('when passing true for postPoliciesEnabled', contextHooks => {
contextHooks.beforeEach(() => {
defaultProps.postPoliciesEnabled = true
})
test('"Hidden" is displayed when a submission is graded and unposted', () => {
defaultProps.submission.workflowState = 'graded'
mountComponent()
ok(content.textContent.includes('Hidden'))
})
test('"Hidden" is displayed when a submission is graded and unposted', () => {
defaultProps.submission.workflowState = 'graded'
mountComponent()
ok(content.textContent.includes('Hidden'))
})
test('"Hidden" is displayed when a submission has comments and is unposted', () => {
defaultProps.submission.hasPostableComments = true
mountComponent()
ok(content.textContent.includes('Hidden'))
})
test('"Hidden" is displayed when a submission has comments and is unposted', () => {
defaultProps.submission.hasPostableComments = true
mountComponent()
ok(content.textContent.includes('Hidden'))
})
test('shows avatar if avatar is not null', () => {
@ -411,7 +409,13 @@ QUnit.module('SubmissionTray', hooks => {
})
test('receives the "gradingScheme" given to the Tray', () => {
const gradingScheme = [['A', 0.9], ['B+', 0.85], ['B', 0.8], ['B-', 0.75], ['C+', 0.7]]
const gradingScheme = [
['A', 0.9],
['B+', 0.85],
['B', 0.8],
['B-', 0.75],
['C+', 0.7]
]
mountComponent({enterGradesAs: 'gradingScheme', gradingScheme})
const $el = content.querySelector('#final-grade-value')
strictEqual($el.textContent, 'C+')
@ -669,7 +673,13 @@ QUnit.module('SubmissionTray', hooks => {
})
test('receives the "gradingScheme" given to the Tray', () => {
const gradingScheme = [['A', 0.9], ['B+', 0.85], ['B', 0.8], ['B-', 0.75], ['C+', 0.7]]
const gradingScheme = [
['A', 0.9],
['B+', 0.85],
['B', 0.8],
['B-', 0.75],
['C+', 0.7]
]
mountComponent({enterGradesAs: 'gradingScheme', gradingScheme})
equal(findGradeInput().labelText, 'Letter Grade')
})

View File

@ -32,7 +32,13 @@ let exampleGrades
function createAssignmentGroups() {
return [
{id: '301', assignments: [{id: '201', muted: false}, {id: '202', muted: true}]},
{
id: '301',
assignments: [
{id: '201', muted: false},
{id: '202', muted: true}
]
},
{id: '302', assignments: [{id: '203', muted: true}]}
]
}
@ -210,7 +216,10 @@ QUnit.module('GradeSummary.getGradingPeriodSet', {
test('normalizes the grading period set from the env', () => {
ENV.grading_period_set = {
id: '1501',
grading_periods: [{id: '701', weight: 50}, {id: '702', weight: 50}],
grading_periods: [
{id: '701', weight: 50},
{id: '702', weight: 50}
],
weighted: true
}
const gradingPeriodSet = GradeSummary.getGradingPeriodSet()
@ -388,7 +397,13 @@ QUnit.module('GradeSummary.calculateTotals', suiteHooks => {
contextHooks.beforeEach(() => {
exampleGrades = createExampleGrades()
exampleGrades.current = {score: 23, possible: 100}
ENV.grading_scheme = [['A', 0.9], ['B', 0.8], ['C', 0.7], ['D', 0.6], ['F', 0]]
ENV.grading_scheme = [
['A', 0.9],
['B', 0.8],
['C', 0.7],
['D', 0.6],
['F', 0]
]
})
test('sets the letter grade to the effective grade', () => {
@ -584,7 +599,10 @@ QUnit.module('GradeSummary.calculateGrades', {
ENV.group_weighting_scheme = 'points'
ENV.grading_period_set = {
id: '1501',
grading_periods: [{id: '701', weight: 50}, {id: '702', weight: 50}],
grading_periods: [
{id: '701', weight: 50},
{id: '702', weight: 50}
],
weighted: true
}
ENV.effective_due_dates = {201: {101: {grading_period_id: '701'}}}
@ -1188,10 +1206,10 @@ QUnit.module('GradeSummary - Revert Score', hooks => {
equal($assignment.find('.score_value').text(), '-')
})
test('sets the .grade html to the "muted assignment" indicator when the assignment is muted', () => {
test('sets the .grade html to the "icon-off" indicator when the assignment is muted', () => {
$assignment.data('muted', true)
GradeSummary.onScoreRevert($assignment)
equal($assignment.find('.grade .muted_icon').length, 1)
equal($assignment.find('.grade .icon-off').length, 1)
})
test('removes the "changed" class from the .grade element', () => {
@ -1253,17 +1271,11 @@ QUnit.module('GradeSummary - Revert Score', hooks => {
)
})
QUnit.module('when post policies are enabled', postPoliciesEnabledHooks => {
postPoliciesEnabledHooks.beforeEach(() => {
ENV.post_policies_enabled = true
})
test('sets the unposted icon to icon-off when submission is unposted', () => {
const $unpostedAssignment = $fixtures.find('#grades_summary .student_assignment').eq(1)
simulateWhatIfUse($unpostedAssignment)
GradeSummary.onScoreRevert($unpostedAssignment)
strictEqual($unpostedAssignment.find('i.icon-off').length, 1)
})
test('sets the unposted icon to icon-off when submission is unposted', () => {
const $unpostedAssignment = $fixtures.find('#grades_summary .student_assignment').eq(1)
simulateWhatIfUse($unpostedAssignment)
GradeSummary.onScoreRevert($unpostedAssignment)
strictEqual($unpostedAssignment.find('i.icon-off').length, 1)
})
})
@ -1318,7 +1330,10 @@ test('returns the score with points possible if assignment groups are not weight
test('returns an empty string if grading periods are weighted and "All Grading Periods" is selected', () => {
ENV.grading_period_set = {
id: '1501',
grading_periods: [{id: '701', weight: 50}, {id: '702', weight: 50}],
grading_periods: [
{id: '701', weight: 50},
{id: '702', weight: 50}
],
weighted: true
}
ENV.current_grading_period_id = '0'
@ -1329,7 +1344,10 @@ test('returns an empty string if grading periods are weighted and "All Grading P
test('returns the score with points possible if grading periods are weighted and a period is selected', () => {
ENV.grading_period_set = {
id: '1501',
grading_periods: [{id: '701', weight: 50}, {id: '702', weight: 50}],
grading_periods: [
{id: '701', weight: 50},
{id: '702', weight: 50}
],
weighted: true
}
ENV.current_grading_period_id = '701'
@ -1340,7 +1358,10 @@ test('returns the score with points possible if grading periods are weighted and
test('returns the score with points possible if grading periods are not weighted', () => {
ENV.grading_period_set = {
id: '1501',
grading_periods: [{id: '701', weight: 50}, {id: '702', weight: 50}],
grading_periods: [
{id: '701', weight: 50},
{id: '702', weight: 50}
],
weighted: false
}
@ -1511,7 +1532,10 @@ QUnit.module('GradeSummary', () => {
})
test('sets students to the students environment variable', () => {
ENV.students = [{id: 42, name: 'Abel'}, {id: 43, name: 'Baker'}]
ENV.students = [
{id: 42, name: 'Abel'},
{id: 43, name: 'Baker'}
]
deepEqual(GradeSummary.getSelectMenuGroupProps().students, ENV.students)
})

View File

@ -26,7 +26,6 @@ module BroadcastPolicies
ctx = double()
allow(ctx).to receive(:available?).and_return(true)
allow(ctx).to receive(:concluded?).and_return(false)
allow(ctx).to receive(:post_policies_enabled?).and_return(false)
ctx
}
let(:assignment) do
@ -121,7 +120,6 @@ module BroadcastPolicies
let(:posting_params) { { graded_only: false } }
before(:each) do
allow(context).to receive(:post_policies_enabled?).and_return true
allow(assignment).to receive(:posting_params_for_notifications).and_return posting_params
end
@ -136,7 +134,6 @@ module BroadcastPolicies
specify { wont_send_when { allow(context).to receive(:available?).and_return false } }
specify { wont_send_when { allow(context).to receive(:concluded?).and_return true } }
specify { wont_send_when { allow(context).to receive(:post_policies_enabled?).and_return false } }
specify { wont_send_when { allow(assignment).to receive(:posting_params_for_notifications).and_return nil } }
end
end

View File

@ -24,7 +24,7 @@ module BroadcastPolicies
describe QuizSubmissionPolicy do
let(:course) do
instance_double("Course", available?: true, id: 1, post_policies_enabled?: false)
instance_double("Course", available?: true, id: 1)
end
let(:assignment) do
instance_double("Assignment", context: course)
@ -81,7 +81,6 @@ module BroadcastPolicies
end
specify { wont_send_when { allow(quiz).to receive(:assignment).and_return nil } }
specify { wont_send_when { allow(quiz).to receive(:muted?).and_return true } }
specify { wont_send_when { allow(course).to receive(:available?).and_return false} }
specify { wont_send_when { allow(quiz).to receive(:deleted?).and_return true } }
specify { wont_send_when { allow(quiz_submission).to receive(:user).and_return nil } }
@ -92,14 +91,6 @@ module BroadcastPolicies
allow(quiz_submission).to receive(:changed_state_to).with(:complete).and_return false
end
end
context "with post policies" do
before { allow(course).to receive(:post_policies_enabled?).and_return true }
it 'is true when the dependent inputs are true' do
expect(policy).to be_should_dispatch_submission_graded
end
end
end
describe '#should_dispatch_submission_needs_grading?' do
@ -150,7 +141,6 @@ module BroadcastPolicies
end
specify { wont_send_when { allow(quiz).to receive(:assignment).and_return nil } }
specify { wont_send_when { allow(quiz).to receive(:muted?).and_return true } }
specify { wont_send_when { allow(course).to receive(:available?).and_return false} }
specify { wont_send_when { allow(quiz).to receive(:deleted?).and_return true } }
specify { wont_send_when { allow(submission).to receive(:graded_at).and_return nil }}
@ -165,8 +155,6 @@ module BroadcastPolicies
end
context "with post policies" do
before { allow(course).to receive(:post_policies_enabled?).and_return true }
specify { wont_send_when { allow(quiz_submission).to receive(:posted?).and_return false } }
it 'is true when the dependent inputs are true' do

View File

@ -1470,14 +1470,6 @@ describe Course do
expect(course.reload.default_post_policy).to be_post_manually
end
end
describe "#post_policies_enabled?" do
let_once(:course) { Course.create! }
it "returns true" do
expect(course).to be_post_policies_enabled
end
end
end
describe Course do