load notes data when 'Show Notes' clicked
previously, when the notes column was hidden and a user clicked 'Show Notes', the notes data would not load. this commit fixes that. closes CNVS-29016 test plan: 1. log in as a teacher in a course with students and assignments 2. click |Grades| 3. click gear and select |Show Notes Column| 4. enter some notes for a few students 5. click gear and select |Hide Notes Column| 6. Refresh page 7. click gear and select |Show Notes Column| 8. verify the notes data loads Change-Id: Ifa720c0c3145bb7371ac6becadda6f663f75a972 Reviewed-on: https://gerrit.instructure.com/82804 Tested-by: Jenkins Reviewed-by: Cameron Matheson <cameron@instructure.com> QA-Review: Amber Taniuchi <amber@instructure.com> Product-Review: Keith T. Garner <kgarner@instructure.com>
This commit is contained in:
parent
cda7b85024
commit
b464261e49
|
@ -50,7 +50,7 @@ define [
|
|||
'jqueryui/sortable'
|
||||
'compiled/jquery.kylemenu'
|
||||
'compiled/jquery/fixDialogButtons'
|
||||
], (loadGradebookData, React, LongTextEditor, KeyboardNavDialog, keyboardNavTemplate, Slick, TotalColumnHeaderView, round, InputFilterView, I18n, GRADEBOOK_TRANSLATIONS,
|
||||
], (DataLoader, React, LongTextEditor, KeyboardNavDialog, keyboardNavTemplate, Slick, TotalColumnHeaderView, round, InputFilterView, I18n, GRADEBOOK_TRANSLATIONS,
|
||||
$, _, Backbone, tz, GradeCalculator, userSettings, Spinner, SubmissionDetailsDialog, AssignmentGroupWeightsDialog, GradeDisplayWarningDialog, PostGradesFrameDialog,
|
||||
SubmissionCell, GradebookHeaderMenu, numberCompare, htmlEscape, PostGradesStore, PostGradesApp, columnHeaderTemplate,
|
||||
groupTotalCellTemplate, rowStudentNameTemplate, SectionMenuView, GradingPeriodMenuView, GradebookKeyboardNav, ColumnArranger) ->
|
||||
|
@ -96,6 +96,7 @@ define [
|
|||
@gradingPeriodToShow = @getGradingPeriodToShow()
|
||||
@gradebookColumnSizeSettings = @options.gradebook_column_size_settings
|
||||
@gradebookColumnOrderSettings = @options.gradebook_column_order_settings
|
||||
@teacherNotesNotYetLoaded = !@options.teacher_notes? || @options.teacher_notes.hidden
|
||||
|
||||
$.subscribe 'assignment_group_weights_changed', @handleAssignmentGroupWeightChange
|
||||
$.subscribe 'assignment_muting_toggled', @handleAssignmentMutingChange
|
||||
|
@ -118,7 +119,7 @@ define [
|
|||
response_fields: ['id', 'user_id', 'url', 'score', 'grade', 'submission_type', 'submitted_at', 'assignment_id', 'grade_matches_current_submission', 'attachments', 'late', 'workflow_state', 'excused']
|
||||
exclude_response_fields: ['preview_url']
|
||||
submissionParams['grading_period_id'] = @gradingPeriodToShow if @mgpEnabled && @gradingPeriodToShow && @gradingPeriodToShow != '0' && @gradingPeriodToShow != ''
|
||||
dataLoader = loadGradebookData(
|
||||
dataLoader = DataLoader.loadGradebookData(
|
||||
assignmentGroupsURL: @options.assignment_groups_url
|
||||
assignmentGroupsParams: assignmentGroupsParams
|
||||
|
||||
|
@ -1646,24 +1647,9 @@ define [
|
|||
handleClick = (e, method, params) ->
|
||||
$.ajaxJSON(e.target.href, method, params)
|
||||
|
||||
toggleNotesColumn = (f) =>
|
||||
columnsToReplace = @numberOfFrozenCols
|
||||
f()
|
||||
cols = @grid.getColumns()
|
||||
cols.splice 0, columnsToReplace,
|
||||
@parentColumns..., @customColumnDefinitions()...
|
||||
@grid.setColumns(cols)
|
||||
@grid.invalidate()
|
||||
|
||||
teacherNotesDataLoaded = false
|
||||
showNotesColumn = =>
|
||||
toggleNotesColumn =>
|
||||
@customColumns.splice 0, 0, @options.teacher_notes
|
||||
@grid.setNumberOfColumnsToFreeze ++@numberOfFrozenCols
|
||||
linkContainer.html(hideLink())
|
||||
|
||||
hideNotesColumn = =>
|
||||
toggleNotesColumn =>
|
||||
@toggleNotesColumn =>
|
||||
for c, i in @customColumns
|
||||
if c.teacher_notes
|
||||
@customColumns.splice i, 1
|
||||
|
@ -1678,7 +1664,8 @@ define [
|
|||
if $target.hasClass("show")
|
||||
handleClick(e, "PUT", "column[hidden]": false)
|
||||
.then =>
|
||||
showNotesColumn()
|
||||
@showNotesColumn()
|
||||
linkContainer.html(hideLink())
|
||||
@reorderCustomColumns(@customColumns.map (c) -> c.id)
|
||||
if $target.hasClass("hide")
|
||||
handleClick(e, "PUT", "column[hidden]": true)
|
||||
|
@ -1690,7 +1677,8 @@ define [
|
|||
"column[teacher_notes]": true)
|
||||
.then (data) =>
|
||||
@options.teacher_notes = data
|
||||
showNotesColumn()
|
||||
@showNotesColumn()
|
||||
linkContainer.html(hideLink())
|
||||
|
||||
notes = @options.teacher_notes
|
||||
if !notes
|
||||
|
@ -1700,6 +1688,24 @@ define [
|
|||
else
|
||||
linkContainer.html(hideLink())
|
||||
|
||||
toggleNotesColumn: (callback) =>
|
||||
columnsToReplace = @numberOfFrozenCols
|
||||
callback()
|
||||
cols = @grid.getColumns()
|
||||
cols.splice 0, columnsToReplace,
|
||||
@parentColumns..., @customColumnDefinitions()...
|
||||
@grid.setColumns(cols)
|
||||
@grid.invalidate()
|
||||
|
||||
showNotesColumn: =>
|
||||
if @teacherNotesNotYetLoaded
|
||||
@teacherNotesNotYetLoaded = false
|
||||
DataLoader.getDataForColumn(@options.teacher_notes, @options.custom_column_data_url, {}, @gotCustomColumnDataChunk)
|
||||
|
||||
@toggleNotesColumn =>
|
||||
@customColumns.splice 0, 0, @options.teacher_notes
|
||||
@grid.setNumberOfColumnsToFreeze ++@numberOfFrozenCols
|
||||
|
||||
isAllGradingPeriods: (currentPeriodId) ->
|
||||
currentPeriodId == "0"
|
||||
|
||||
|
|
|
@ -118,5 +118,5 @@ define(['jquery', 'jsx/gradebook2/CheatDepaginator', 'underscore'], ($, cheaterD
|
|||
};
|
||||
};
|
||||
|
||||
return loadGradebookData;
|
||||
return { loadGradebookData: loadGradebookData, getDataForColumn: getDataForColumn };
|
||||
});
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
define [
|
||||
'compiled/gradebook2/Gradebook'
|
||||
'jsx/gradebook2/DataLoader'
|
||||
'underscore'
|
||||
'timezone'
|
||||
], (Gradebook, _, tz) ->
|
||||
], (Gradebook, DataLoader, _, tz) ->
|
||||
|
||||
module "Gradebook2#gradeSort"
|
||||
|
||||
|
@ -668,3 +669,24 @@ define [
|
|||
test 'when show concluded and hide inactive are true, enrollmentUrl returns "students_with_concluded_and_inactive_enrollments_url"', ->
|
||||
self = @setupThis(showConcludedEnrollments: true, showInactiveEnrollments: true)
|
||||
equal @studentsUrl.call(self), 'students_with_concluded_and_inactive_enrollments_url'
|
||||
|
||||
module 'Gradebook#showNotesColumn',
|
||||
setup: ->
|
||||
@loadNotes = @stub(DataLoader, "getDataForColumn")
|
||||
|
||||
setupShowNotesColumn: (opts) ->
|
||||
defaultOptions =
|
||||
options: {}
|
||||
toggleNotesColumn: ->
|
||||
self = _.defaults(opts || {}, defaultOptions)
|
||||
@showNotesColumn = Gradebook.prototype.showNotesColumn.bind(self)
|
||||
|
||||
test 'loads the notes if they have not yet been loaded', ->
|
||||
@setupShowNotesColumn(teacherNotesNotYetLoaded: true)
|
||||
@showNotesColumn()
|
||||
ok @loadNotes.calledOnce
|
||||
|
||||
test 'does not load the notes if they are already loaded', ->
|
||||
@setupShowNotesColumn(teacherNotesNotYetLoaded: false)
|
||||
@showNotesColumn()
|
||||
ok @loadNotes.notCalled
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
define(['jsx/gradebook2/DataLoader', 'underscore'], (loadGradebookData, _) => {
|
||||
define(['jsx/gradebook2/DataLoader', 'underscore'], (DataLoader, _) => {
|
||||
module("Gradebook Data Loader", (hooks) => {
|
||||
let savedTrackEvent;
|
||||
let fakeXhr;
|
||||
|
@ -55,7 +55,7 @@ define(['jsx/gradebook2/DataLoader', 'underscore'], (loadGradebookData, _) => {
|
|||
customColumnDataPageCb: () => { console.log("custom column data!") },
|
||||
}
|
||||
|
||||
return loadGradebookData({...defaults, ...opts});
|
||||
return DataLoader.loadGradebookData({...defaults, ...opts});
|
||||
}
|
||||
|
||||
const respondToXhr = (url, status, headers, response) => {
|
||||
|
|
Loading…
Reference in New Issue