[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /homework grades.pm

raeburn raeburn at source.lon-capa.org
Thu Aug 4 14:47:54 EDT 2016


raeburn		Thu Aug  4 18:47:54 2016 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/homework	grades.pm 
  Log:
  - For 2.11
    - Backport 1.736
  
  
-------------- next part --------------
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.596.2.12.2.35 loncom/homework/grades.pm:1.596.2.12.2.36
--- loncom/homework/grades.pm:1.596.2.12.2.35	Thu Mar 19 10:31:17 2015
+++ loncom/homework/grades.pm	Thu Aug  4 18:47:52 2016
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.596.2.12.2.35 2015/03/19 10:31:17 raeburn Exp $
+# $Id: grades.pm,v 1.596.2.12.2.36 2016/08/04 18:47:52 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -914,10 +914,11 @@
 
     my ($table,undef,$hdgrade,$partlist,$handgrade) = &showResourceInfo($symb,$env{'form.probTitle'},($env{'form.showgrading'} eq 'yes'));
 
-    my %lt = &Apache::lonlocal::texthash (
+    my %js_lt = &Apache::lonlocal::texthash (
 		'multiple' => 'Please select a student or group of students before clicking on the Next button.',
 		'single'   => 'Please select the student before clicking on the Next button.',
 	     );
+    &js_escape(\%js_lt);
     $request->print(<<LISTJAVASCRIPT);
 <script type="text/javascript" language="javascript">
     function checkSelect(checkBox) {
@@ -929,12 +930,12 @@
 		    ctr++;
 		}
 	    }
-	    sense = '$lt{'multiple'}';
+	    sense = '$js_lt{'multiple'}';
 	} else {
 	    if (checkBox.checked) {
 		ctr = 1;
 	    }
-	    sense = '$lt{'single'}';
+	    sense = '$js_lt{'single'}';
 	}
 	if (ctr == 0) {
 	    alert(sense);
@@ -1253,7 +1254,8 @@
 #--- Javascript to handle the submission page functionality ---
 sub sub_page_js {
     my $request = shift;
-	    my $alertmsg = &mt('A number equal or greater than 0 is expected. Entered value = ');
+    my $alertmsg = &mt('A number equal or greater than 0 is expected. Entered value = ');
+    &js_escape(\$alertmsg); 
     $request->print(<<SUBJAVASCRIPT);
 <script type="text/javascript" language="javascript">
     function updateRadio(formname,id,weight) {
@@ -1507,10 +1509,21 @@
 
     my $docopen=&Apache::lonhtmlcommon::javascript_docopen();
     $docopen=~s/^document\.//;
-    my %lt = &Apache::lonlocal::texthash(
+    my %js_lt = &Apache::lonlocal::texthash(
                 keyw => 'Keywords list, separated by a space. Add/delete to list if desired.',
                 plse => 'Please select a word or group of words from document and then click this link.',
                 adds => 'Add selection to keyword list? Edit if desired.',
+                col1 => 'red',
+                col2 => 'green',
+                col3 => 'blue',
+                siz1 => 'normal',
+                siz2 => '+1',
+                siz3 => '+2',
+                sty1 => 'normal',
+                sty2 => 'italic',
+                sty3 => 'bold',
+             );
+    my %html_js_lt = &Apache::lonlocal::texthash(
                 comp => 'Compose Message for: ',
                 incl => 'Include',
                 type => 'Type',
@@ -1523,22 +1536,16 @@
                 txtc => 'Text Color',
                 font => 'Font Size',
                 fnst => 'Font Style',
-                col1 => 'red',
-                col2 => 'green',
-                col3 => 'blue',
-                siz1 => 'normal',
-                siz2 => '+1',
-                siz3 => '+2',
-                sty1 => 'normal',
-                sty2 => 'italic',
-                sty3 => 'bold',
              );
+    &js_escape(\%js_lt);
+    &html_escape(\%html_js_lt);
+    &js_escape(\%html_js_lt);
     $request->print(<<SUBJAVASCRIPT);
 <script type="text/javascript" language="javascript">
 
 //===================== Show list of keywords ====================
   function keywords(formname) {
-    var nret = prompt("$lt{'keyw'}",formname.keywords.value);
+    var nret = prompt("$js_lt{'keyw'}",formname.keywords.value);
     if (nret==null) return;
     formname.keywords.value = nret;
 
@@ -1565,10 +1572,10 @@
     else return;
     var cleantxt = txt.replace(new RegExp('([\\f\\n\\r\\t\\v ])+', 'g')," ");
     if (cleantxt=="") {
-	alert("$lt{'plse'}");
+	alert("$js_lt{'plse'}");
 	return;
     }
-    var nret = prompt("$lt{'adds'}",cleantxt);
+    var nret = prompt("$js_lt{'adds'}",cleantxt);
     if (nret==null) return;
     document.SCORE.keywords.value = document.SCORE.keywords.value+" "+nret;
     if (document.SCORE.keywords.value != "") {
@@ -1648,16 +1655,16 @@
 
     pDoc.write("<form action=\\"inactive\\" name=\\"msgcenter\\">");
     pDoc.write("<input value=\\""+usrctr+"\\" name=\\"usrctr\\" type=\\"hidden\\">");
-    pDoc.write("<h3><span class=\\"LC_info\\"> $lt{'comp'}\"+fullname+\"<\\/span><\\/h3><br /><br />");
+    pDoc.write("<h3><span class=\\"LC_info\\"> $html_js_lt{'comp'}\"+fullname+\"<\\/span><\\/h3><br /><br />");
 
     pDoc.write('<table border="0" width="100%"><tr><td bgcolor="#777777">');
     pDoc.write('<table border="0" width="100%"><tr bgcolor="#DDFFFF">');
-    pDoc.write("<td><b>$lt{'type'}<\\/b><\\/td><td><b>$lt{'incl'}<\\/b><\\/td><td><b>$lt{'mesa'}<\\/td><\\/tr>");
+    pDoc.write("<td><b>$html_js_lt{'type'}<\\/b><\\/td><td><b>$html_js_lt{'incl'}<\\/b><\\/td><td><b>$html_js_lt{'mesa'}<\\/td><\\/tr>");
 }
     function displaySubject(msg,shwsel) {
     pDoc = pWin.document;
     pDoc.write("<tr bgcolor=\\"#ffffdd\\">");
-    pDoc.write("<td>$lt{'subj'}<\\/td>");
+    pDoc.write("<td>$html_js_lt{'subj'}<\\/td>");
     pDoc.write("<td align=\\"center\\"><input name=\\"subchk\\" type=\\"checkbox\\"" +shwsel+"><\\/td>");
     pDoc.write("<td><input name=\\"msgsub\\" type=\\"text\\" value=\\""+msg+"\\"size=\\"60\\" maxlength=\\"80\\"><\\/td><\\/tr>");
 }
@@ -1673,7 +1680,7 @@
   function newMsg(newmsg,shwsel) {
     pDoc = pWin.document;
     pDoc.write("<tr bgcolor=\\"#ffffdd\\">");
-    pDoc.write("<td align=\\"center\\">$lt{'new'}<\\/td>");
+    pDoc.write("<td align=\\"center\\">$html_js_lt{'new'}<\\/td>");
     pDoc.write("<td align=\\"center\\"><input name=\\"newmsgchk\\" type=\\"checkbox\\"" +shwsel+"><\\/td>");
     pDoc.write("<td><textarea name=\\"newmsg\\" cols=\\"60\\" rows=\\"3\\" onchange=\\"javascript:this.form.newmsgchk.checked=true\\" >"+newmsg+"<\\/textarea><\\/td><\\/tr>");
 }
@@ -1682,8 +1689,8 @@
     pDoc = pWin.document;
     pDoc.write("<\\/table>");
     pDoc.write("<\\/td><\\/tr><\\/table> ");
-    pDoc.write("<input type=\\"button\\" value=\\"$lt{'save'}\\" onclick=\\"javascript:checkInput()\\">  ");
-    pDoc.write("<input type=\\"button\\" value=\\"$lt{'canc'}\\" onclick=\\"self.close()\\"><br /><br />");
+    pDoc.write("<input type=\\"button\\" value=\\"$html_js_lt{'save'}\\" onclick=\\"javascript:checkInput()\\">  ");
+    pDoc.write("<input type=\\"button\\" value=\\"$html_js_lt{'canc'}\\" onclick=\\"self.close()\\"><br /><br />");
     pDoc.write("<\\/form>");
     pDoc.write('$end_page_msg_central');
     pDoc.close();
@@ -1697,15 +1704,15 @@
     var redsel = "";
     var grnsel = "";
     var blusel = "";
-    var txtcol1 = "$lt{'col1'}";
-    var txtcol2 = "$lt{'col2'}";
-    var txtcol3 = "$lt{'col3'}";
-    var txtsiz1 = "$lt{'siz1'}";
-    var txtsiz2 = "$lt{'siz2'}";
-    var txtsiz3 = "$lt{'siz3'}";
-    var txtsty1 = "$lt{'sty1'}";
-    var txtsty2 = "$lt{'sty2'}";
-    var txtsty3 = "$lt{'sty3'}";
+    var txtcol1 = "$js_lt{'col1'}";
+    var txtcol2 = "$js_lt{'col2'}";
+    var txtcol3 = "$js_lt{'col3'}";
+    var txtsiz1 = "$js_lt{'siz1'}";
+    var txtsiz2 = "$js_lt{'siz2'}";
+    var txtsiz3 = "$js_lt{'siz3'}";
+    var txtsty1 = "$js_lt{'sty1'}";
+    var txtsty2 = "$js_lt{'sty2'}";
+    var txtsty3 = "$js_lt{'sty3'}";
     if (kwclr=="red")   {var redsel="checked='checked'"};
     if (kwclr=="green") {var grnsel="checked='checked'"};
     if (kwclr=="blue")  {var blusel="checked='checked'"};
@@ -1742,10 +1749,10 @@
     hDoc.$docopen;
     hDoc.write('$start_page_highlight_central');
     hDoc.write("<form action=\\"inactive\\" name=\\"hlCenter\\">");
-    hDoc.write("<h1>$lt{'kehi'}<\\/h1>");
+    hDoc.write("<h1>$html_js_lt{'kehi'}<\\/h1>");
 
     hDoc.write('<table border="0" width="100%"><tr style="background-color:#A1D676">');
-    hDoc.write("<th>$lt{'txtc'}<\\/th><th>$lt{'font'}<\\/th><th>$lt{'fnst'}<\\/th><\\/tr>");
+    hDoc.write("<th>$html_js_lt{'txtc'}<\\/th><th>$html_js_lt{'font'}<\\/th><th>$html_js_lt{'fnst'}<\\/th><\\/tr>");
   }
 
   function highlightbody(clrval,clrtxt,clrsel,szval,sztxt,szsel,syval,sytxt,sysel) { 
@@ -1763,8 +1770,8 @@
   function highlightend() { 
     var hDoc = hwdWin.document;
     hDoc.write("<\\/table><br \\/>");
-    hDoc.write("<input type=\\"button\\" value=\\"$lt{'save'}\\" onclick=\\"javascript:updateChoice(1)\\" \\/>  ");
-    hDoc.write("<input type=\\"button\\" value=\\"$lt{'canc'}\\" onclick=\\"self.close()\\" \\/><br /><br />");
+    hDoc.write("<input type=\\"button\\" value=\\"$html_js_lt{'save'}\\" onclick=\\"javascript:updateChoice(1)\\" \\/>  ");
+    hDoc.write("<input type=\\"button\\" value=\\"$html_js_lt{'canc'}\\" onclick=\\"self.close()\\" \\/><br /><br />");
     hDoc.write("<\\/form>");
     hDoc.write('$end_page_highlight_central');
     hDoc.close();
@@ -3551,6 +3558,7 @@
     my ($request) = shift;
 
     my $alertmsg = &mt('A number equal or greater than 0 is expected. Entered value = ');
+    &js_escape(\$alertmsg);
     $request->print(<<VIEWJAVASCRIPT);
 <script type="text/javascript" language="javascript">
    function writePoint(partid,weight,point) {
@@ -4207,6 +4215,8 @@
 sub csvupload_javascript_reverse_associate {
     my $error1=&mt('You need to specify the username or the student/employee ID');
     my $error2=&mt('You need to specify at least one grading field');
+  &js_escape(\$error1);
+  &js_escape(\$error2);
   return(<<ENDPICK);
   function verify(vf) {
     var foundsomething=0;
@@ -4247,6 +4257,8 @@
 sub csvupload_javascript_forward_associate {
     my $error1=&mt('You need to specify the username or the student/employee ID');
     my $error2=&mt('You need to specify at least one grading field');
+  &js_escape(\$error1);
+  &js_escape(\$error2);
   return(<<ENDPICK);
   function verify(vf) {
     var foundsomething=0;
@@ -4366,6 +4378,7 @@
 
 sub checkforfile_js {
     my $alertmsg = &mt('Please use the browse button to select a file from your local directory.');
+    &js_escape(\$alertmsg);
     my $result =<<CSVFORMJS;
 <script type="text/javascript" language="javascript">
     function checkUpload(formname) {
@@ -4662,6 +4675,7 @@
     my ($request) = shift;
 
     my $alertmsg = &mt('Please select the student you wish to grade.');
+    &js_escape(\$alertmsg);
     $request->print(<<LISTJAVASCRIPT);
 <script type="text/javascript" language="javascript">
 
@@ -5697,11 +5711,13 @@
     my $default_form_data=&defaultFormData(&get_symb($r,1));
     my $cdom= $env{'course.'.$env{'request.course.id'}.'.domain'};
     my $cnum= $env{'course.'.$env{'request.course.id'}.'.num'};
+    my $alertmsg = &mt('Please use the browse button to select a file from your local directory.');
+    &js_escape(\$alertmsg);
     $r->print('
               <script type="text/javascript" language="javascript">
     function checkUpload(formname) {
         if (formname.upfile.value == "") {
-            alert("'.&mt('Please use the browse button to select a file from your local directory.').'");
+            alert("'.$alertmsg.'");
             return false;
         }
         formname.submit();
@@ -7690,6 +7706,7 @@
     my (@ansnums) = @_;
     my $ansnumstr = join('","', at ansnums);
     my $warning = &mt("A bubble or 'No bubble' selection has not been made for one or more lines.");
+    &js_escape(\$warning);
     my $output = (<<ENDSCRIPT);
 <script type="text/javascript">
 function verify_bubble_radio(form) {
@@ -8880,7 +8897,9 @@
     my ($symb) = &get_symb($r,1);
     my $default_form_data=&defaultFormData($symb);
     my $nofile_alert = &mt('Please use the browse button to select a file from your local directory.');
+    &js_escape(\$nofile_alert); 
     my $nocourseid_alert = &mt("Please use the 'Select Course' link to open a separate window where you can search for a course to which a file can be uploaded.");
+    &js_escape(\$nocourseid_alert);
     $r->print('
 <script type="text/javascript" language="javascript">
     function checkUpload(formname) {


More information about the LON-CAPA-cvs mailing list