Skip to content

Commit

Permalink
srgb global options: hide student names
Browse files Browse the repository at this point in the history
fixes CNVS-10021

test plan:
  - in screenreader gradebook
  - click the 'Hide Student Names' checkbox
  - the students drop down should
    say 'Student 1', 'Student 2', etc.
  - click the checkbox again
  - the students drop down should list the student names

Change-Id: I566113a413c9aed294e1238c3a4dcd6be799fbc3
Reviewed-on: https://gerrit.instructure.com/28007
Tested-by: Jenkins <[email protected]>
Reviewed-by: Simon Williams <[email protected]>
QA-Review: Caleb Guanzon <[email protected]>
Reviewed-by: Matthew Irish <[email protected]>
Reviewed-by: Aaron Cannon <[email protected]>
Product-Review: Simon Williams <[email protected]>
  • Loading branch information
cameronsutter authored and simonista committed Jan 16, 2014
1 parent 531df26 commit 1d11fee
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ define [
set this, 'value', currentValue
).observes('selected')

updateOptions: (->
@arrayWillChange(@items, 0, get(@items, 'length'), 0)
@arrayDidChange(@items, 0, 0, get(@items, 'length'))
).observes('labelPath')

arrayDidChange: (items, start, removeCount, addCount) ->
select = get(this, 'element')
hasDefault = get(this, 'hasDefaultOption')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,17 @@ define [
# http://emberjs.com/api/classes/Ember.ArrayController.html
# http://emberjs.com/api/classes/Ember.ObjectController.html


studentsUniqByEnrollments = (args...)->
hiddenNameCounter = 1
options =
initialize: (array, changeMeta, instanceMeta) ->
instanceMeta.students = {}
addedItem: (array, enrollment, changeMeta, iMeta) ->
student = iMeta.students[enrollment.user_id] or enrollment.user
if !student.hiddenName?
student.hiddenName = I18n.t("student_hidden_name", "Student %{position}", {position: hiddenNameCounter})
hiddenNameCounter += 1
student.sections ||= []
student.sections.push(enrollment.course_section_id)
return array if iMeta.students[student.id]
Expand All @@ -41,8 +46,8 @@ define [
ScreenreaderGradebookController = Ember.ObjectController.extend

downloadUrl: "#{get(window, 'ENV.GRADEBOOK_OPTIONS.context_url')}/gradebook.csv"

gradingHistoryUrl: "#{get(window, 'ENV.GRADEBOOK_OPTIONS.context_url')}/history"
hideStudentNames: false

actions:
selectItem: (property, goTo) ->
Expand Down Expand Up @@ -278,3 +283,10 @@ define [
ariaDisabledNextStudent: (->
new Boolean(@get('disableNextStudentButton'))?.toString()
).property('disableNextStudentButton')

displayName: (->
if @get('hideStudentNames')
"hiddenName"
else
"name"
).property('hideStudentNames')
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<!-- -------- -->

<h2>Global Settings</h2>

<!-- filter by section -->
<div>
<label for="section_select">Select a section</label>
Expand Down Expand Up @@ -41,6 +42,20 @@

<!-- show/hide student names -->

<div>
<label>
{{
input
type="checkbox"
id="hide_names_checkbox"
name="hide_names_checkbox"
checked=hideStudentNames
}}
{{#t "hide_student_names_label"}}Hide Student Names{{/t}}
</label>
</div>


<!-- not sure this makes sense in this interface -->

<!-- arrange columns by due date -->
Expand Down Expand Up @@ -92,7 +107,7 @@
class="student_select"
items=studentsInSelectedSection
valuePath="id"
labelPath="name"
labelPath=displayName
labelDefault=studentSelectDefaultLabel
selected=selectedStudent
}}
Expand Down Expand Up @@ -201,14 +216,29 @@

<h2>Student Information</h2>

<div>Selected Student: {{selectedStudent.name}}</div>
<div>Selected Student:
{{#if hideStudentNames}}
{{selectedStudent.hiddenName}}
{{else}}
{{selectedStudent.name}}
{{/if}}
</div>

<!-- what section they are in -->

<div>Section: Section 3</div>
<!-- secondary id -->
{{#if selectedStudent.isLoaded}}
<div>Secondary ID: {{selectedStudent.login_id}}</div>

<div>Secondary ID: <span id="secondary_id">
{{#if hideStudentNames}}
<em>hidden</em>
{{else}}
{{selectedStudent.login_id}}
{{/if}}
</span>
</div>


<!-- final score/grade -->

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ define [
@srgb.get('students').forEach (s) ->
equal Ember.get(s, 'isLoaded'), true

test 'displayName is hiddenName when hideStudentNames is true', ->
@srgb.set('hideStudentNames', true)
equal @srgb.get('displayName'), "hiddenName"
@srgb.set('hideStudentNames', false)
equal @srgb.get('displayName'), "name"

test 'updateSubmission attaches the submission to the student', ->
student = clone fixtures.students[0].user
submission = clone fixtures.submissions[student.id].submissions[0]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
define [
'../start_app'
'ember'
'../shared_ajax_fixtures'
'jquery'
'vendor/jquery.ba-tinypubsub'
], (startApp, Ember, fixtures, $) ->

App = null

fixtures.create()

module 'hide student names',
setup: ->
App = startApp()
visit('/').then =>
@controller = App.__container__.lookup('controller:screenreader_gradebook')
teardown: ->
Ember.run App, 'destroy'

test 'student names are hidden', ->
selection = '#student_select option[value=1]'
equal $(selection).text(), "Bob"
click("#hide_names_checkbox").then =>
equal $(selection).text(), "Student 1"
click("#hide_names_checkbox").then =>
equal $(selection).text(), "Bob"

test 'secondary id says hidden', ->
Ember.run =>
@controller.set('selectedStudent', @controller.get('students').objectAt(0))

reg = /^\s*$/ #all whitespace
ok reg.test $("#secondary_id").text()
click("#hide_names_checkbox").then =>
reg = /hidden/
ok reg.test $("#secondary_id").text()

0 comments on commit 1d11fee

Please sign in to comment.