Diff for /loncom/interface/lonmenu.pm between versions 1.439 and 1.440

version 1.439, 2016/02/26 21:44:39 version 1.440, 2016/03/15 14:25:26
Line 1568  END Line 1568  END
 }  }
   
 # This creates a "done button" for timed events.  The confirmation box is a jQuery  # This creates a "done button" for timed events.  The confirmation box is a jQuery
 # dialog widget.  Clicking OK will set (LC_interval_done = 'true') which is checked in   # dialog widget. If the interval parameter requires a proctor key for the timed 
 # lonhomework.pm.  # event to be marked done, there will also be a textbox where that can be entered. 
   # Clicking OK will set the value of LC_interval_done to 'true', and, if needed will 
   # set the value of LC_interval_done_proctorpass to the text entered in that box, 
   # and submit the corresponding form.
   # 
   # The &zero_time() routine in lonhomework.pm is called when a page is rendered if
   # LC_interval_done is true.
   #
 sub done_button_js {  sub done_button_js {
     my ($type,$height) = @_;      my ($type,$width,$height,$proctor) = @_;
     if ($height !~ /^\d+$/) {  
         $height = 320;  
     }  
     my %lt = &Apache::lonlocal::texthash(      my %lt = &Apache::lonlocal::texthash(
                  title    => 'WARNING!',                   title    => 'WARNING!',
                  button   => 'Done',                   button   => 'Done',
                  preamble => 'You are trying to end this timed event early.',                   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.',                   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).',                    resource => 'Confirming that you are done will cause the time to expire for this question, and prevent you from changing your answer(s).', 
                  ok       => 'Click "OK" if you are completely finished.',                   okdone   => 'Click "OK" if you are completely finished.',
                  cancel   => 'Click "Cancel" to continue working.',                   cancel   => 'Click "Cancel" to continue working.',
                    proctor  => 'Ask a proctor to enter the key, then click "OK" if you are completely finished.',
                    ok       => 'OK',
                    exit     => 'Cancel',
                    key      => 'Key:',
                    nokey    => 'A proctor key is required', 
     );      );
     my $confirm;      my $confirm;
     if (($type eq 'map') || ($type eq 'resource')) {      if (($type eq 'map') || ($type eq 'resource')) {
         $confirm = $lt{'preamble'}.' '.$lt{$type}.' '.$lt{'ok'}.' '.$lt{'cancel'};          if ($proctor) {
     }              $confirm = $lt{'preamble'}.' '.$lt{$type};
     if ($confirm) {              if ($height !~ /^\d+$/) {
         return <<END;                  $height = 400;
               }
               if ($width !~ /^\d+$/) {
                   $width = 400;
               }
               return <<END;
   <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>
   </form>
   
   <div id="LC_done-confirm" title="$lt{'title'}">
     <p>$lt{'preamble'} $lt{$type}</p>
     <p>$lt{'proctor'}</p>
     <form>
       <label>$lt{'key'}<input type="password" name="LC_interval_done_proctorkey" value="" /></label>
       <input type="submit" tabindex="-1" style="position:absolute; top:-1000px" />
     </form>
     <p>$lt{'cancel'}</p>
   </div>
   
   <script type="text/javascript">
   // <![CDATA[
       \$( "#LC_done-confirm" ).dialog({ autoOpen: false });
       \$( "#LC_done-confirm-opener" ).on("click", function() {
           \$( "#LC_done-confirm" ).dialog("open");
           \$( "#LC_done-confirm" ).dialog({
               height: $height,
               width: $width,
               modal: true,
               resizable: false,
               buttons: [
                   {
                       text: "$lt{'ok'}",
                       click: function() {
                           var proctorkey = \$( '[name="LC_interval_done_proctorkey"]' )[0].value;
                           if ((proctorkey == '') || (proctorkey == null)) {
                               alert("$lt{'nokey'}"); 
                           } else { 
                               \$( '[name="LC_interval_done"]' )[0].value = 'true';
                               \$( '[name="LC_interval_done_proctorpass"]' )[0].value = proctorkey;
                               \$( '[name="LCdoneButton"]' )[0].submit();
                           }
                       },
                   },
                   {
                       text: "$lt{'exit'}",
                       click: function() {
                           \$("#LC_done-confirm").dialog( "close" );
                       }
                   }
               ],
               close: function() {
                   \$( '[name="LC_interval_done_proctorkey"]' )[0].value = '';
               }
           });
           \$( "#LC_done-confirm" ).find( "form" ).on( "submit", function( event ) {
               event.preventDefault();
               \$( '[name="LC_interval_done"]' )[0].value = 'true';
               \$( '[name="LC_interval_done_proctorpass"]' )[0].value = \$( '[name="LC_interval_done_proctorkey"]' )[0].value;
               \$( '[name="LCdoneButton"]' )[0].submit();
           });
   });
   
   // ]]>
   </script>
   
   END
           } else {
               if ($height !~ /^\d+$/) {
                   $height = 320;
               }
               if ($width !~ /^\d+$/) {
                   $width = 320;
               }
               return <<END;
   
 <form method="post" name="LCdoneButton" action="">  <form method="post" name="LCdoneButton" action="">
     <input type="hidden" name="LC_interval_done" value="" />      <input type="hidden" name="LC_interval_done" value="" />
Line 1597  sub done_button_js { Line 1682  sub done_button_js {
 </form>  </form>
   
 <div id="LC_done-confirm" title="$lt{'title'}">  <div id="LC_done-confirm" title="$lt{'title'}">
     <p>$confirm</p>      <p>$lt{'preamble'} $lt{$type} $lt{'okdone'} $lt{'cancel'}</p>
 </div>  </div>
   
 <script type="text/javascript">  <script type="text/javascript">
Line 1608  sub done_button_js { Line 1693  sub done_button_js {
     \$( "#LC_done-confirm" ).dialog({      \$( "#LC_done-confirm" ).dialog({
       resizable: false,        resizable: false,
       height: $height,        height: $height,
         width: $width,
       modal: true,        modal: true,
       buttons: {        buttons: [
         "OK": function() {                   {
             \$( this ).dialog( "close" );                      text: "$lt{'ok'}",
             \$( '[name="LC_interval_done"]' )[0].value = 'true';                      click: function() {
             \$( '[name="LCdoneButton"]' )[0].submit();                          \$( this ).dialog( "close" );
         },                          \$( '[name="LC_interval_done"]' )[0].value = 'true';
         Cancel: function() {                          \$( '[name="LCdoneButton"]' )[0].submit();
           \$( this ).dialog( "close" );                      },
         }                   },
       }                       {
     })                       text: "$lt{'exit'}",
                        click: function() {
                            \$( this ).dialog( "close" );
                        },
                     },
                  ],
          });
 });  });
 // ]]>  // ]]>
 </script>  </script>
   
 END  END
           }
     } else {      } else {
         return;          return;
     }      }
Line 2293  sub countdown_timer { Line 2386  sub countdown_timer {
         }          }
         my $duedate = &Apache::lonnet::EXT("resource.0.duedate");          my $duedate = &Apache::lonnet::EXT("resource.0.duedate");
         my @interval=&Apache::lonnet::EXT("resource.0.interval");          my @interval=&Apache::lonnet::EXT("resource.0.interval");
         my ($timelimit,$usesdone);          my ($timelimit,$usesdone,$proctor,$secret);
         if (@interval > 1) {          if (@interval > 1) {
             ($timelimit,$usesdone) = split(/_/,$interval[0]);               ($timelimit,$usesdone,$proctor,$secret) = split(/_/,$interval[0]); 
             my $first_access=&Apache::lonnet::get_first_access($interval[1]);              my $first_access=&Apache::lonnet::get_first_access($interval[1]);
             if ($first_access > 0) {              if ($first_access > 0) {
                 if ($first_access+$timelimit > time) {                  if ($first_access+$timelimit > time) {
Line 2313  sub countdown_timer { Line 2406  sub countdown_timer {
                 $collapse = '&#9658;&nbsp;';                  $collapse = '&#9658;&nbsp;';
                 if ((@interval > 1) && ($hastimeleft)) {                  if ((@interval > 1) && ($hastimeleft)) {
                     if ($usesdone eq 'done') {                      if ($usesdone eq 'done') {
                         $donebutton = &done_button_js($interval[1]);                          $donebutton = &done_button_js($interval[1],'','',$proctor);
                     }                      }
                 }                  }
             } else {              } else {

Removed from v.1.439  
changed lines
  Added in v.1.440


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>