Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix duplicate name error warning logic #821

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions editor/static/js/question/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ $(document).ready(function() {
names.sort(Numbas.util.sortBy('name'));
function handle_group(group) {
group.forEach(function(n) {
n.v.duplicateNameError(group.length > 1 ? n.name : null);
//n.v.duplicateNameError(group.length > 1 ? n.name : null);
});
}

Expand Down Expand Up @@ -1963,11 +1963,15 @@ $(document).ready(function() {

var nameError = ko.pureComputed(function() {
var duplicateNameError = v.duplicateNameError();
var nameErrDuplicates = {} // tracks duplicate names using an object
var name_errors = names().map(function(nd) {
var name = nd.name;
if(name.toLowerCase() == duplicateNameError) {
var name = nd.name.toLowerCase();
if(nameErrDuplicates[name] && name!=='') {
return 'There\'s another variable or constant with the name '+name+'.';
} else {
nameErrDuplicates[name] = true
}
console.log("NameErr Map: ",nameErrDuplicates)
if(name=='') {
return '';
}
Expand Down