Skip to content

Commit

Permalink
remove tooltips from Gradezilla grid cells
Browse files Browse the repository at this point in the history
closes CNVS-37633

test plan:
* Create a course with at least two grading periods and enroll at
  least two students in it
* Create a differentiated assignment in the closed grading period
  which is due for one student in an open grading period
* Create an assignment in the open grading period
* Create an unpublished assignment in the open grading period

* Go to Gradezilla and ensure you can see all assignments
  including those in all grading periods and unpublished
  assignments
* Edit a grid cell and navigate from cell to cell
* Verify no tooltips are shown on any submission cells
* Verify you still see tooltips on cells in columns that display
  totals (overall or assignment group)

Change-Id: I5329739e1629ed3257cdaf0f54e24c545106afae
Reviewed-on: https://gerrit.instructure.com/116169
Reviewed-by: Keith T. Garner <[email protected]>
Reviewed-by: Derek Bender <[email protected]>
Tested-by: Jenkins
QA-Review: KC Naegle <[email protected]>
Product-Review: Keith T. Garner <[email protected]>
  • Loading branch information
sjaveed committed Jun 21, 2017
1 parent b82e2db commit 4bc1a1b
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 453 deletions.
62 changes: 3 additions & 59 deletions app/coffeescripts/gradezilla/Gradebook.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -869,13 +869,12 @@ define [
else
cellAttributes = @submissionStateMap.getSubmissionState(submission)
if cellAttributes.hideGrade
@lockedAndHiddenGradeCellFormatter(row, col, cellAttributes.tooltip)
@lockedAndHiddenGradeCellFormatter(row, col)
else
assignment = @assignments[submission.assignment_id]
student = @students[submission.user_id]
formatterOpts =
isLocked: cellAttributes.locked
tooltip: cellAttributes.tooltip

if !assignment?
@staticCellFormatter(row, col, '')
Expand All @@ -889,17 +888,8 @@ define [
staticCellFormatter: (row, col, val) ->
"<div class='cell-content gradebook-cell'>#{htmlEscape(val)}</div>"

lockedAndHiddenGradeCellFormatter: (row, col, tooltipKey) ->
if tooltipKey
tooltip = GRADEBOOK_TRANSLATIONS["submission_tooltip_#{tooltipKey}"]
"""
<div class='gradebook-tooltip'>
#{htmlEscape(tooltip)}
</div>
<div class='cell-content gradebook-cell grayed-out cannot_edit'></div>
"""
else
"<div class='cell-content gradebook-cell grayed-out cannot_edit'></div>"
lockedAndHiddenGradeCellFormatter: (row, col) ->
"<div class='cell-content gradebook-cell grayed-out cannot_edit'></div>"

groupTotalFormatter: (row, col, val, columnDef, student) =>
return '' unless val?
Expand Down Expand Up @@ -1003,46 +993,6 @@ define [
@assignmentsToHide = $.grep @assignmentsToHide, (el) -> el != columnDef.id
UserSettings.contextSet('hidden_columns', _.uniq(@assignmentsToHide))

hoverMinimizedCell: (event) =>
$hoveredCell = $(event.currentTarget)
# get rid of hover class so that no other tooltips show up
.removeClass('hover')
cell = @grid.getCellFromEvent(event)
# cell will be null when hovering a header cell
return unless cell
columnDef = @grid.getColumns()[cell.cell]
assignment = columnDef.object
offset = $hoveredCell.offset()
htmlLines = [assignment.name]
if $hoveredCell.hasClass('slick-cell')
submission = @rows[cell.row][columnDef.id]
if assignment.points_possible?
htmlLines.push "#{submission.score ? '--'} / #{assignment.points_possible}"
else if submission.score?
htmlLines.push submission.score
# add lines for dropped, late, resubmitted
Array::push.apply htmlLines, $.map(SubmissionCell.classesBasedOnSubmission(submission, assignment), (c)-> GRADEBOOK_TRANSLATIONS["#submission_tooltip_#{c}"])
else if assignment.points_possible?
htmlLines.push htmlEscape(I18n.t('points_out_of', "out of %{points_possible}", points_possible: assignment.points_possible))

$hoveredCell.data 'tooltip', $("<span />",
class: 'gradebook-tooltip'
css:
left: offset.left - 15
top: offset.top
zIndex: 10000
display: 'block'
html: $.raw(htmlLines.join('<br />'))
).appendTo('body')
.css('top', (i, top) -> parseInt(top) - $(this).outerHeight())

unhoverMinimizedCell: (event) ->
if $tooltip = $(this).data('tooltip')
if event.toElement == $tooltip[0]
$tooltip.mouseleave -> $tooltip.remove()
else
$tooltip.remove()

# this is because of a limitation with SlickGrid,
# when it makes the header row it does this:
# $("<div class='slick-header-columns' style='width:10000px; left:-1000px' />")
Expand Down Expand Up @@ -1101,15 +1051,9 @@ define [
'mouseleave.gradebook' : @unhighlightColumns
'mouseenter' : (event) ->
grid.find('.hover, .focus').removeClass('hover focus')
if $(this).parent().css('top') == '0px'
$(this).find('div.gradebook-tooltip').addClass('first-row')
$(this).addClass (if event.type == 'mouseenter' then 'hover' else 'focus')
'mouseleave' : (event) ->
$(this).removeClass('hover focus')
$(this).find('div.gradebook-tooltip').removeClass('first-row')
.delegate '.minimized',
'mouseenter' : @hoverMinimizedCell,
'mouseleave' : @unhoverMinimizedCell

@$grid.addClass('editable') if @options.gradebook_is_editable

Expand Down
16 changes: 0 additions & 16 deletions app/coffeescripts/gradezilla/SubmissionCell.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ define [
opts.editable = false if opts.student.isConcluded
submission_type = opts.submission.submission_type if opts.submission?.submission_type || null
styles = SubmissionCell.styles(opts.submission, opts.assignment)
tooltips = SubmissionCell.tooltips(opts.submission, opts.assignment)

styles.push("grayed-out") if opts.student.isInactive || opts.student.isConcluded || opts.isLocked
styles.push("cannot_edit") if opts.student.isConcluded || opts.isLocked
Expand All @@ -149,10 +148,7 @@ define [
styles.push('turnitin')
innerContents += "<span class='gradebook-cell-turnitin #{htmlEscape turnitin.state}-score' />"

tooltipText = $.map(tooltips, (t)-> GRADEBOOK_TRANSLATIONS["submission_tooltip_#{t}"]).join(', ')

"""
#{$.raw if tooltipText then '<div class="gradebook-tooltip">'+ htmlEscape(tooltipText) + '</div>' else ''}
<div class="gradebook-cell #{htmlEscape if opts.editable then 'gradebook-cell-editable focus' else ''} #{htmlEscape opts.classes} #{htmlEscape styles.join(' ')}">
#{$.raw innerContents}
</div>
Expand All @@ -165,18 +161,6 @@ define [
else
""

@tooltips: (submission = {}, assignment = {}) ->
classes = []
classes.push('dropped') if submission.drop
classes.push('excused') if submission.excused
classes.push('resubmitted') if submission.grade_matches_current_submission == false
classes.push('missing') if submission.missing
classes.push('late') if submission.late
classes.push('ungraded') if ''+assignment.submission_types is "not_graded"
classes.push('muted') if assignment.muted
classes.push(submission.submission_type) if submission.submission_type
classes

@styles: (submission = {}, assignment = {}) ->
classes = []

Expand Down
22 changes: 7 additions & 15 deletions app/jsx/gradezilla/SubmissionStateMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@
import _ from 'underscore';
import GradingPeriodsHelper from 'jsx/grading/helpers/GradingPeriodsHelper';

const TOOLTIP_KEYS = {
UNPUBLISHED_ASSIGNMENT: 'unpublished_assignment',
NOT_IN_ANY_GP: 'not_in_any_grading_period',
IN_ANOTHER_GP: 'in_another_grading_period',
IN_CLOSED_GP: 'in_closed_grading_period',
NONE: null
};

function submissionGradingPeriodInformation (assignment, student) {
const submissionInfo = assignment.effectiveDueDates[student.id] || {};
return {
Expand All @@ -45,26 +37,26 @@ function cellMappingsForMultipleGradingPeriods (assignment, student, selectedGra
const { gradingPeriodID, inClosedGradingPeriod } = submissionGradingPeriodInformation(assignment, student);

if (specificPeriodSelected && !gradingPeriodID) {
return { locked: true, hideGrade: true, tooltip: TOOLTIP_KEYS.NOT_IN_ANY_GP };
return { locked: true, hideGrade: true };
} else if (specificPeriodSelected && selectedGradingPeriodID !== gradingPeriodID) {
return { locked: true, hideGrade: true, tooltip: TOOLTIP_KEYS.IN_ANOTHER_GP };
return { locked: true, hideGrade: true };
} else if (!isAdmin && inClosedGradingPeriod) {
return { locked: true, hideGrade: false, tooltip: TOOLTIP_KEYS.IN_CLOSED_GP };
return { locked: true, hideGrade: false };
} else {
return { locked: false, hideGrade: false, tooltip: TOOLTIP_KEYS.NONE };
return { locked: false, hideGrade: false };
}
}


function cellMapForSubmission (assignment, student, hasGradingPeriods, selectedGradingPeriodID, isAdmin) {
if (!assignment.published) {
return { locked: true, hideGrade: true, tooltip: TOOLTIP_KEYS.UNPUBLISHED_ASSIGNMENT };
return { locked: true, hideGrade: true };
} else if (!visibleToStudent(assignment, student)) {
return { locked: true, hideGrade: true, tooltip: TOOLTIP_KEYS.NONE };
return { locked: true, hideGrade: true };
} else if (hasGradingPeriods) {
return cellMappingsForMultipleGradingPeriods(assignment, student, selectedGradingPeriodID, isAdmin);
} else {
return { locked: false, hideGrade: false, tooltip: TOOLTIP_KEYS.NONE };
return { locked: false, hideGrade: false };
}
}

Expand Down
75 changes: 0 additions & 75 deletions spec/coffeescripts/gradezilla/SubmissionCellSpec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,6 @@ define [
submissionCellResponse = SubmissionCell.formatter(0, 0, { grade: 73 }, {}, {}, { isLocked: false })
equal submissionCellResponse.indexOf("cannot_edit"), -1

test "#class.formatter, tooltip adds your text to the special classes", ->
submissionCellResponse = SubmissionCell.formatter(0, 0, { grade: 73 }, {}, {}, { tooltip: "dora_the_explorer" })
ok submissionCellResponse.indexOf("dora_the_explorer") > -1

test "#class.formatter, isInactive: false doesn't add grayed-out", ->
student = { isInactive: false }
submissionCellResponse = SubmissionCell.formatter(0, 0, { grade: 10 }, { }, student)
Expand Down Expand Up @@ -160,10 +156,6 @@ define [
submissionCellResponse = SubmissionCell.letter_grade.formatter(0, 0, { grade: "A" }, {}, {}, { isLocked: false })
equal submissionCellResponse.indexOf("cannot_edit"), -1

test "#letter_grade.formatter, tooltip adds your text to the special classes", ->
submissionCellResponse = SubmissionCell.letter_grade.formatter(0, 0, { grade: "A" }, {}, {}, { tooltip: "dora_the_explorer" })
ok submissionCellResponse.indexOf("dora_the_explorer") > -1

test "#gpa_scale.formatter, isLocked: true adds grayed-out", ->
submissionCellResponse = SubmissionCell.gpa_scale.formatter(0, 0, { grade: 3.2 }, {}, {}, { isLocked: true })
ok submissionCellResponse.indexOf("grayed-out") > -1
Expand All @@ -180,10 +172,6 @@ define [
submissionCellResponse = SubmissionCell.gpa_scale.formatter(0, 0, { grade: 3.2 }, {}, {}, { isLocked: false })
equal submissionCellResponse.indexOf("cannot_edit"), -1

test "#gpa_scale.formatter, tooltip adds your text to the special classes", ->
submissionCellResponse = SubmissionCell.gpa_scale.formatter(0, 0, { grade: 3.2 }, {}, {}, { tooltip: "dora_the_explorer" })
ok submissionCellResponse.indexOf("dora_the_explorer") > -1

test "#pass_fail.formatter, isLocked: true adds grayed-out", ->
submissionCellResponse = SubmissionCell.pass_fail.formatter(0, 0, { grade: "complete" }, {}, {}, { isLocked: true })
ok submissionCellResponse.indexOf("grayed-out") > -1
Expand All @@ -200,10 +188,6 @@ define [
submissionCellResponse = SubmissionCell.pass_fail.formatter(0, 0, { grade: "complete" }, {}, {}, { isLocked: false })
equal submissionCellResponse.indexOf("cannot_edit"), -1

test "#pass_fail.formatter, tooltip adds your text to the special classes", ->
submissionCellResponse = SubmissionCell.pass_fail.formatter(0, 0, { grade: "complete" }, {}, {}, { tooltip: "dora_the_explorer" })
ok submissionCellResponse.indexOf("dora_the_explorer") > -1

QUnit.module "Pass/Fail SubmissionCell",
setup: ->
opts =
Expand Down Expand Up @@ -354,54 +338,6 @@ define [
"online_text_entry"
]

QUnit.module ".tooltips"

test "given nothing, it returns nothing", ->
deepEqual SubmissionCell.tooltips(), []

test "given all criteria, everything is present", ->
submission =
drop: true
excused: true
grade_matches_current_submission: false
missing: true
late: true
submission_type: "online_url"
assignment =
submission_types: ["not_graded"]
muted: true
deepEqual SubmissionCell.tooltips(submission, assignment), [
"dropped",
"excused",
"resubmitted",
"missing",
"late",
"ungraded"
"muted",
"online_url"
]

test "given a dropped submission, it returns dropped", ->
deepEqual SubmissionCell.tooltips({ drop: true }), ["dropped"]

test "given an excused submission, it returns excused", ->
deepEqual SubmissionCell.tooltips({ excused: true }), ["excused"]

test "given a resubmitted submission, it returns resubmitted", ->
deepEqual SubmissionCell.tooltips({ grade_matches_current_submission: false }), ["resubmitted"]

test "given a missing submission, it returns missing", ->
deepEqual SubmissionCell.tooltips({ missing: true }), ["missing"]

test "given a late submission, it returns late", ->
deepEqual SubmissionCell.tooltips({ late: true }), ["late"]

test "given an ungraded assignment, it returns ungraded", ->
deepEqual SubmissionCell.tooltips({}, { submission_types: ["not_graded"] }), ["ungraded"]

test "given a muted assignment, it returns muted", ->
deepEqual SubmissionCell.tooltips({}, { muted: true }), ["muted"]

QUnit.module "#cellWrapper",
setup: ->
@fixtures = document.querySelector('#fixtures')
Expand Down Expand Up @@ -452,17 +388,6 @@ define [
@fixtures.innerHTML = (new SubmissionCell(@params())).cellWrapper('', { isLocked: true })
strictEqual @fixtures.querySelectorAll('div.cannot_edit').length, 1

test "if it has tooltip key, styles include that value", ->
@fixtures.innerHTML = (new SubmissionCell(@params())).cellWrapper('', { tooltip: 'fake-tooltip' })
strictEqual @fixtures.querySelectorAll('div.fake-tooltip').length, 1

test "if it has tooltip key, tooltips includes that value", ->
key = 'in_closed_grading_period'
@fixtures.innerHTML = (new SubmissionCell(@params())).cellWrapper('', { tooltip: key })
ok @fixtures.querySelector('.gradebook-tooltip').innerText.includes(
GRADEBOOK_TRANSLATIONS["submission_tooltip_#{key}"]
)

test "if it has turnitin data, styles includes 'turnitin'", ->
params = @params()
params.item.whatever.turnitin_data = { submission_1: 'none' }
Expand Down
Loading

0 comments on commit 4bc1a1b

Please sign in to comment.