[LON-CAPA-cvs] cvs: rat /client parameter.html loncom/homework lonhomework.pm loncom/interface lonmenu.pm lonparmset.pm

raeburn raeburn at source.lon-capa.org
Fri May 13 18:48:14 EDT 2016


raeburn		Fri May 13 22:48:14 2016 EDT

  Modified files:              
    /loncom/interface	lonmenu.pm lonparmset.pm 
    /loncom/homework	lonhomework.pm 
    /rat/client	parameter.html 
  Log:
  - Bug 6763.
    - Text used for done button can be set via the "Time-Limit" (interval)
      parameter.
  
  
-------------- next part --------------
Index: loncom/interface/lonmenu.pm
diff -u loncom/interface/lonmenu.pm:1.447 loncom/interface/lonmenu.pm:1.448
--- loncom/interface/lonmenu.pm:1.447	Wed May  4 05:54:51 2016
+++ loncom/interface/lonmenu.pm	Fri May 13 22:48:05 2016
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines to control the menu
 #
-# $Id: lonmenu.pm,v 1.447 2016/05/04 05:54:51 raeburn Exp $
+# $Id: lonmenu.pm,v 1.448 2016/05/13 22:48:05 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1634,11 +1634,10 @@
 # LC_interval_done is true.
 #
 sub done_button_js {
-    my ($type,$width,$height,$proctor) = @_;
+    my ($type,$width,$height,$proctor,$donebuttontext) = @_;
     return unless (($type eq 'map') || ($type eq 'resource'));
     my %lt = &Apache::lonlocal::texthash(
                  title    => 'WARNING!',
-                 button   => 'Done',
                  preamble => 'You are trying to end this timed event early.',
                  map      => 'Confirming that you are done will cause the time to expire and prevent you from changing any answers in the current folder.',
                  resource => 'Confirming that you are done will cause the time to expire for this question, and prevent you from changing your answer(s).', 
@@ -1715,7 +1714,7 @@
 <form method="post" name="LCdoneButton" action="">
     <input type="hidden" name="LC_interval_done" value="" />
     <input type="hidden" name="LC_interval_done_proctorpass" value="" />
-    <button id="LC_done-confirm-opener" type="button">$lt{'button'}</button>
+    <button id="LC_done-confirm-opener" type="button">$donebuttontext</button>
 </form>
 
 <div id="LC_done-confirm" title="$lt{'title'}">
@@ -2501,9 +2500,17 @@
         }
         my $duedate = &Apache::lonnet::EXT("resource.0.duedate");
         my @interval=&Apache::lonnet::EXT("resource.0.interval");
-        my ($timelimit,$usesdone,$proctor,$secret);
+        my ($timelimit,$usesdone,$donebuttontext,$proctor,$secret);
         if (@interval > 1) {
-            ($timelimit,$usesdone,$proctor,$secret) = split(/_/,$interval[0]); 
+            ($timelimit,my $donesuffix) = split(/_/,$interval[0],2);
+            if ($donesuffix =~ /^done\:([^\:]+)\:(.*)$/) {
+                $usesdone = 'done';
+                $donebuttontext = $1;
+                (undef,$proctor,$secret) = split(/_/,$2);
+            } elsif ($donesuffix =~ /^done(|_.+)$/) {
+                $donebuttontext = &mt('Done');
+                ($usesdone,$proctor,$secret) = split(/_/,$donesuffix);
+            }
             my $first_access=&Apache::lonnet::get_first_access($interval[1]);
             if ($first_access > 0) {
                 if ($first_access+$timelimit > time) {
@@ -2521,7 +2528,7 @@
                 $collapse = '► ';
                 if ((@interval > 1) && ($hastimeleft)) {
                     if ($usesdone eq 'done') {
-                        $donebutton = &done_button_js($interval[1],'','',$proctor);
+                        $donebutton = &done_button_js($interval[1],'','',$proctor,$donebuttontext);
                     }
                 }
             } else {
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.558 loncom/interface/lonparmset.pm:1.559
--- loncom/interface/lonparmset.pm:1.558	Tue Mar 15 14:25:26 2016
+++ loncom/interface/lonparmset.pm	Fri May 13 22:48:05 2016
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set parameters for assessments
 #
-# $Id: lonparmset.pm,v 1.558 2016/03/15 14:25:26 raeburn Exp $
+# $Id: lonparmset.pm,v 1.559 2016/05/13 22:48:05 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -824,7 +824,16 @@
         }
     } else {
         if ($type eq 'date_interval') {
-            my ($totalsecs,$donebutton,$proctor,$secretkey) = split(/_/,$value);
+            my ($totalsecs,$donesuffix) = split(/_/,$value,2);
+            my ($usesdone,$donebuttontext,$proctor,$secretkey);
+            if ($donesuffix =~ /^done\:([^\:]+)\:(.*)$/) {
+                $donebuttontext = $1;
+                (undef,$proctor,$secretkey) = split(/_/,$2);
+                $usesdone = 'done';
+            } elsif ($donesuffix =~ /^done(|_.+)$/) {
+                $donebuttontext = &mt('Done');
+                ($usesdone,$proctor,$secretkey) = split(/_/,$donesuffix);
+            }
             my ($sec,$min,$hour,$mday,$mon,$year)=gmtime($totalsecs);
             my @timer;
             $year=$year-70;
@@ -858,12 +867,12 @@
                 push(@timer,&mt('[quant,_1,sec]',0));
             }
             $result.=join(", ", at timer);
-            if ($donebutton eq 'done') {
+            if ($usesdone eq 'done') {
                 if ($secretkey) {
-                    $result .= ' '.&mt('+ "done" with proctor key: [_1]',$secretkey);  
+                    $result .= ' '.&mt('+ "[_1]" with proctor key: [_2]',$donebuttontext,$secretkey);  
                 } else {
-                    $result .= ' '.&mt('+ "done"');
-                }  
+                    $result .= ' + "'.$donebuttontext.'"';
+                }
             }
         } elsif (&isdateparm($type)) {
             $result = &Apache::lonlocal::locallocaltime($value).
@@ -3631,8 +3640,17 @@
     }
     }
     if (($key =~ /\.interval$/) && (($env{'form.done_'.$key} eq '_done') || ($env{'form.done_'.$key} eq '_done_proctor'))) {
-        $seconds .= $env{'form.done_'.$key};
-        if ($env{'form.done_'.$key.'_proctorkey'}) {
+        if ($env{'form.done_'.$key.'_buttontext'}) {
+            $env{'form.done_'.$key.'_buttontext'} =~ s/\://g;
+            $seconds .= '_done:'.$env{'form.done_'.$key.'_buttontext'}.':';
+            if ($env{'form.done_'.$key} eq '_done_proctor') {
+                $seconds .= '_proctor';
+            }
+        } else {
+            $seconds .= $env{'form.done_'.$key}; 
+        }
+        if (($env{'form.done_'.$key} eq '_done_proctor') && 
+            ($env{'form.done_'.$key.'_proctorkey'})) {
             $seconds .= '_'.$env{'form.done_'.$key.'_proctorkey'};
         }
     }
@@ -3941,8 +3959,8 @@
 
 my %intervalmatches = (
          'date_interval'
-              => [['done','\d+_done$'],
-                  ['done_proctor','\d+_done_proctor_']],
+              => [['done','\d+_done(|\:[^\:]+\:)$'],
+                  ['done_proctor','\d+_done(|\:[^\:]+\:)_proctor_']],
     );
 
 my %intervaltypes = (
@@ -4033,8 +4051,13 @@
             my $checkedproc = '';
             my $currproctorkey = '';
             my $currprocdisplay = 'hidden';
+            my $currdonetext = &mt('Done');
             my $checkedoff = ' checked="checked"';
-            if ($currval =~ /^(\d+)_done$/) {
+            if ($currval =~ /^(?:\d+)_done$/) {
+                $checkedon = ' checked="checked"';
+                $checkedoff = '';
+            } elsif ($currval =~ /^(?:\d+)_done\:([^\:]+)\:$/) {
+                $currdonetext = $1;
                 $checkedon = ' checked="checked"';
                 $checkedoff = '';
             } elsif ($currval =~ /^(?:\d+)_done_proctor_(.+)$/) {
@@ -4042,6 +4065,12 @@
                 $checkedproc = ' checked="checked"';
                 $checkedoff = '';
                 $currprocdisplay = 'text';
+            } elsif ($currval =~ /^(?:\d+)_done\:([^\:]+)\:_proctor_(.+)$/) {
+                $currdonetext = $1;
+                $currproctorkey = $2;
+                $checkedproc = ' checked="checked"';
+                $checkedoff = '';
+                $currprocdisplay = 'text';
             }
             my $onclick = ' onclick="toggleSecret(this.form,'."'done_','$thiskey'".');"';
             $result .= '<br /><span class="LC_nobreak">'.&mt('Include "done" button').
@@ -4052,7 +4081,9 @@
                        '<label><input type="radio" value="_done_proctor" name="done_'.$thiskey.'"'.$checkedproc.$onclick.' />'.
                        &mt('Yes, with proctor key').'</label>'.
                        '<input type="'.$currprocdisplay.'" id="done_'.$thiskey.'_proctorkey" '.
-                       'name="done_'.$thiskey.'_proctorkey" value="'.$currproctorkey.'" /></span>';
+                       'name="done_'.$thiskey.'_proctorkey" value="'.&HTML::Entities::encode($currproctorkey,'"<>&').'" /></span><br />'.
+                       '<span class="LC_nobreak">'.&mt('Button text').': '.
+                       '<input type="text" name="done_'.$thiskey.'_buttontext" value="'.&HTML::Entities::encode($currdonetext,'"<>&').'" /></span>';
         }
     }
     unless ($readonly) {
Index: loncom/homework/lonhomework.pm
diff -u loncom/homework/lonhomework.pm:1.360 loncom/homework/lonhomework.pm:1.361
--- loncom/homework/lonhomework.pm:1.360	Tue Mar 15 14:25:33 2016
+++ loncom/homework/lonhomework.pm	Fri May 13 22:48:09 2016
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Homework handler
 #
-# $Id: lonhomework.pm,v 1.360 2016/03/15 14:25:33 raeburn Exp $
+# $Id: lonhomework.pm,v 1.361 2016/05/13 22:48:09 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1440,8 +1440,9 @@
             my $now = time;
             my $first_access=&Apache::lonnet::get_first_access($interval[1],$symb);
             if ($first_access > 0) {
-                my ($timelimit,$done,$proctor,$secret) = split(/_/,$interval[0]);
-                if ($done eq 'done') { 
+                my ($timelimit,$donesuffix) = split(/_/,$interval[0],2);
+                if ($donesuffix =~ /^done(?:|\:[^\:]+\:)(.*)$/) {
+                    my ($dummy,$proctor,$secret) = split(/_/,$1);
                     if (($proctor) && ($secret ne '')) {
                         my $key = $env{'form.LC_interval_done_proctorpass'};
                         $key =~ s/^\s+//;
Index: rat/client/parameter.html
diff -u rat/client/parameter.html:1.70 rat/client/parameter.html:1.71
--- rat/client/parameter.html:1.70	Tue Mar 15 14:25:41 2016
+++ rat/client/parameter.html	Fri May 13 22:48:14 2016
@@ -5,7 +5,7 @@
 The LearningOnline Network with CAPA
 Parameter Input Window
 //
-// $Id: parameter.html,v 1.70 2016/03/15 14:25:41 raeburn Exp $
+// $Id: parameter.html,v 1.71 2016/05/13 22:48:14 raeburn Exp $
 //
 // Copyright Michigan State University Board of Trustees
 //
@@ -41,6 +41,7 @@
 var pvalue='';
 var pmodval='';
 var pextraval='';
+var pextravaltwo='';
 var preturn='';
 var pcode='';
 var pscat='';
@@ -270,7 +271,7 @@
     }
     result += '</select>';
     return result;
-} 
+}
 
 function intsecond() {
     var thisseconds=csecs;
@@ -314,15 +315,19 @@
     if ((ptype=='date') && (pscat=='interval')) {
         var newpmodval = '';
         var newpextraval = '';
+        var newpextravaltwo = 'Done';
         if (sform.donebutton.length) {
             for (var i=0; i<sform.donebutton.length; i++) {
                 if (sform.donebutton[i].checked) {
                     if (sform.donebutton[i].value == '_done') {
                         newpmodval = sform.donebutton[i].value;
+                        newpextravaltwo = sform.donebutton_text.value;
                     } else {
                         if (sform.donebutton[i].value == '_done_proctor') { 
                             newpmodval = sform.donebutton[i].value;
                             newpextraval = sform.donebutton_proctorkey.value;
+                            newpextravaltwo = sform.donebutton_text.value;
+                            newpextravaltwo = newpextravaltwo.replace(/:/g,'');
                         }
                     }
                 }
@@ -330,12 +335,25 @@
         }
         pmodval = newpmodval;
         pextraval = newpextraval;
+        pextravaltwo = newpextravaltwo;
         draw();
         if (pmodval) {
-            svalue += pmodval;
-        }
-        if (pextraval != '') {
-            svalue += '_'+pextraval;
+            var doneRegExp = /^(_done)(|_proctor)$/;
+            var donevals = pmodval.match(doneRegExp);
+            if (donevals.length == 3) {
+                svalue += donevals[1];
+            }
+            if (newpextravaltwo) {
+                if (newpextravaltwo != 'Done') { 
+                    svalue += ':'+newpextravaltwo+':';
+                }
+            }
+            if (donevals[2] != '') {
+                svalue += donevals[2];
+                if (pextraval != '') {
+                    svalue += '_'+pextraval;
+                }
+            }
         }
     } else {
         draw();
@@ -347,6 +365,15 @@
     if (sform.donebutton.length) {
         for (var i=0; i<sform.donebutton.length; i++) {
             if (sform.donebutton[i].checked) {
+                if (sform.donebutton[i].value == '') {
+                    if (document.getElementById('donebuttontextdiv')) {
+                        document.getElementById('donebuttontextdiv').style.display='none';
+                    }
+                } else {
+                    if (document.getElementById('donebuttontextdiv')) {
+                        document.getElementById('donebuttontextdiv').style.display='block';
+                    }
+                }
                 if (sform.donebutton[i].value == '_done_proctor') {
                     if (document.getElementById('done_proctorkey')) {
                         document.getElementById('done_proctorkey').type='text';
@@ -551,8 +578,13 @@
       }
       if (pscat=='interval') {
          var proctorkeytype = 'hidden'; 
+         var donebuttontext = 'none';
          if (pmodval == '_done_proctor') {
              proctorkeytype = 'text';
+             donebuttontext = 'block';
+         }
+         if (pmodval == '_done') {
+             donebuttontext = 'block';
          }
          tablestart('Time interval');
          choicewrite( [
@@ -583,8 +615,14 @@
          choicewrite(' /> Yes, with proctor key</label>');
          choicewrite(' <input name="donebutton_proctorkey" value='+
                      '"'+escapeHTML(pextraval)+'" type="'+proctorkeytype+
-                     '" id="done_proctorkey"'+' size="10"'+
-                     ' onblur="parent.intcalc();" /></span>');
+                     '" id="done_proctorkey" size="10"'+
+                     ' onblur="parent.intcalc();" /></span><br />'+
+                     '<div id="donebuttontextdiv" style="display:'+donebuttontext+'">'+
+                     '<br /><span style="white-space:nowrap">'+
+                     'Button text:'+
+                     '<input name="donebutton_text" value='+
+                     '"'+escapeHTML(pextravaltwo)+'" type="text" '+
+                     'size="10" onblur="parent.intcalc();" /></span></div>');
          choicewrite('</td></tr></table>');
       } else {
          choicewrite('<tr><td colspan="3">'
@@ -937,9 +975,10 @@
 function init() {
   var i;
   var subs=new Array();
-  var doneRegExp = /_done/;
-  var doneproctorRegExp = /_done_proctor/;
+  var doneRegExp = /_done(|\:[^\:]+\:)/;
+  var doneproctorRegExp = /_done(|\:[^\:]+\:)_proctor/;
   var proctorkeyRegExp = /^(\d+)_(.+)$/;
+  var donetextRegExp = /\:([^\:]+)\:/;
   var namevalue=this.window.location.search.split('&');
   namevalue[0]=namevalue[0].substr(1,namevalue[0].length-1);
 
@@ -971,21 +1010,41 @@
 
   if (ptype=='date' && pscat == 'interval') {
       if (doneproctorRegExp.test(pvalue)) {
-          pmodval = pvalue.match(doneproctorRegExp);
+          var current = pvalue.match(doneproctorRegExp);
+          if (current.length == 2) {
+              var textstr = current[1];
+              if (textstr != '') {
+                  var textvals = textstr.match(donetextRegExp);
+                  if (textvals.length == 2) {
+                      pextravaltwo = textvals[1];
+                  }
+              }
+          }
           var intervalwithkey = pvalue.replace(doneproctorRegExp,'');
           if (proctorkeyRegExp.test(intervalwithkey)) {
               var currvals = intervalwithkey.match(proctorkeyRegExp);
               if (currvals.length == 3) {
                   pvalue = currvals[1];
                   pextraval = currvals[2];
+                  pmodval = '_done_proctor';
               } else {
                   pmodval = '';
               }
           }
       } else {
           if (doneRegExp.test(pvalue)) {
+              var current = pvalue.match(doneRegExp); 
+              if (current.length == 2) {
+                  var textstr = current[1];
+                  if (textstr != '') {
+                      var textvals = textstr.match(donetextRegExp);
+                      if (textvals.length == 2) {
+                          pextravaltwo = textvals[1];
+                      }
+                  }
+              }
               var pnumval = pvalue.replace(doneRegExp,'');
-              pmodval = pvalue.match(doneRegExp);
+              pmodval = '_done';
               pvalue = pnumval;
           }
       }


More information about the LON-CAPA-cvs mailing list