backwards compatability with old hide student names value

Just checking for true/false means people who have it saved as "false"
will get it suddenly turned on.

refs #8794

test plan: in a browser that previously used the hide student names
feature but then switched it off, verify that it's still switched off.

you can emulate this situation with this javascript console command:

localStorage.setItem("__eg_hide_student_names", "\"false\"")

Change-Id: I53242101853224685ef31d547aacd4b752baeb5e
Reviewed-on: https://gerrit.instructure.com/11071
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Zach Wily <zach@instructure.com>
This commit is contained in:
Brian Palmer 2012-05-27 09:07:08 -06:00
parent 87aed048fd
commit 101a76f1c8
1 changed files with 8 additions and 5 deletions

View File

@ -134,6 +134,12 @@ define([
match = (window.location.pathname.match(pathRegex) || window.location.search.match(searchRegex));
if (!match) return false;
return match[1];
},
shouldHideStudentNames: function() {
// this is for backwards compatability, we used to store the value as
// strings "true" or "false", but now we store boolean true/false values.
var settingVal = userSettings.get("eg_hide_student_names");
return settingVal === true || settingVal === "true";
}
};
@ -171,10 +177,7 @@ define([
//by defaut the list is sorted alphbetically by student last name so we dont have to do any more work here,
// if the cookie to sort it by submitted_at is set we need to sort by submitted_at.
var hideStudentNames;
if (userSettings.get("eg_hide_student_names")) {
hideStudentNames = true;
}
var hideStudentNames = utils.shouldHideStudentNames();
if(hideStudentNames) {
jsonData.studentsWithSubmissions.sort(function(a,b){
return ((a && a.submission && a.submission.id) || Number.MAX_VALUE) -
@ -226,7 +229,7 @@ define([
function initDropdown(){
var hideStudentNames;
if (userSettings.get("eg_hide_student_names") || window.anonymousAssignment) {
if (utils.shouldHideStudentNames() || window.anonymousAssignment) {
hideStudentNames = true;
}
$("#hide_student_names").attr('checked', hideStudentNames);