--- loncom/interface/lonuserutils.pm 2010/01/20 21:49:26 1.97.2.14 +++ loncom/interface/lonuserutils.pm 2010/02/02 06:05:03 1.97.2.15 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Utility functions for managing LON-CAPA user accounts # -# $Id: lonuserutils.pm,v 1.97.2.14 2010/01/20 21:49:26 raeburn Exp $ +# $Id: lonuserutils.pm,v 1.97.2.15 2010/02/02 06:05:03 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -4835,11 +4835,14 @@ sub setsections_javascript { function setSections(formname,crstype) { var re1 = /^currsec_/; var re2 =/\\W/; + var trimleading = /^\\s+/; + var trimtrailing = /\\s+\$/; var groups = new Array($groupslist); for (var i=0;i 0) { - if (formname.elements[i+1].value != "" && formname.elements[i+1].value != null) { - sections = sections + "," + formname.elements[i+1].value; - } - } - else { - sections = formname.elements[i+1].value; - } - var newsecs = formname.elements[i+1].value; - var numsplit; + var newsecs = formname.elements[num+1].value; var validsecs = new Array(); + var validsecstr = ''; var badsecs = new Array(); if (newsecs != null && newsecs != "") { - numsplit = newsecs.split(/,/g); - numsec = numsec + numsplit.length; + var numsplit; + if (newsecs.indexOf(',') == -1) { + numsplit = new Array(newsecs); + } else { + numsplit = newsecs.split(/,/g); + } for (var i=0; i 0) { @@ -4896,7 +4908,6 @@ function setSections(formname,crstype) { } numsec = numsec + validsecs.length; } - if ((role == 'st') && (numsec > 1)) { if (crstype == 'Community') { alert("$alerts{'inea'} $alerts{'youh'} "+numsec+" $alerts{'secs'}\\n$alerts{'plmo'}"); @@ -4904,25 +4915,36 @@ function setSections(formname,crstype) { alert("$alerts{'inco'} $alerts{'youh'} "+numsec+" $alerts{'secs'}\\n$alerts{'plmo'}"); } return; - } - else { - if (numsplit != null) { - for (var j=0; j 0) { + sections = sections + "," + validsecstr; + } else { + sections = validsecstr; + } + } + formname.elements[num+2].value = sections; } } }