Diff for /loncom/interface/lonmenu.pm between versions 1.369.2.83.4.1 and 1.369.2.84

version 1.369.2.83.4.1, 2022/03/25 21:25:37 version 1.369.2.84, 2024/07/02 18:35:28
Line 789  sub innerregister { Line 789  sub innerregister {
                     @mapcrumbs = $navmap->recursed_crumbs($mapurl,$restitle);                      @mapcrumbs = $navmap->recursed_crumbs($mapurl,$restitle);
                 }                  }
             }              }
             unless (($forcereg) &&               @crumbs = ({text  => $crstype.' Contents', 
                     ($env{'request.noversionuri'} eq '/adm/navmaps') &&                          href  => "Javascript:gopost('/adm/navmaps','')"});
                     ($mapurl eq $env{'course.'.$env{'request.course.id'}.'.url'})) {  
                 @crumbs = ({text  => $crstype.' Contents',   
                             href  => "Javascript:gopost('/adm/navmaps','')"});  
             }  
             if ($mapurl ne $env{'course.'.$env{'request.course.id'}.'.url'}) {               if ($mapurl ne $env{'course.'.$env{'request.course.id'}.'.url'}) { 
                 if (@mapcrumbs) {                  if (@mapcrumbs) {
                     push(@crumbs,@mapcrumbs);                      push(@crumbs,@mapcrumbs);
Line 989  s&6&1&list.png&Directory&dir[_1]&golist( Line 985  s&6&1&list.png&Directory&dir[_1]&golist(
 s&6&2&rtrv.png&Retrieve&version[_1]&gocstr('/adm/retrieve','/priv/$udom/$uname/$cleandisfn')&Retrieve old version  s&6&2&rtrv.png&Retrieve&version[_1]&gocstr('/adm/retrieve','/priv/$udom/$uname/$cleandisfn')&Retrieve old version
 s&6&3&pub.png&Publish&resource[_3]&gocstr('/adm/publish','/priv/$udom/$uname/$cleandisfn')&Publish this resource  s&6&3&pub.png&Publish&resource[_3]&gocstr('/adm/publish','/priv/$udom/$uname/$cleandisfn')&Publish this resource
 s&7&1&del.png&Delete&resource[_2]&gocstr('/adm/cfile?action=delete','/priv/$udom/$uname/$cleandisfn')&Delete this resource  s&7&1&del.png&Delete&resource[_2]&gocstr('/adm/cfile?action=delete','/priv/$udom/$uname/$cleandisfn')&Delete this resource
   ENDMENUITEMS
   #
   # Print only makes sense for certain mime types
   #
                   if ($thisdisfn=~/\.(xml|html|htm|xhtml|xhtm|tex)$/ || $thisdisfn=~/$LONCAPA::assess_re/) {
                       $menuitems .= (<<ENDMENUITEMS);
 s&7&2&prt.png&Print&printout[_1]&gocstr('/adm/printout','/priv/$udom/$uname/$cleandisfn')&Prepare a printable document  s&7&2&prt.png&Print&printout[_1]&gocstr('/adm/printout','/priv/$udom/$uname/$cleandisfn')&Prepare a printable document
 ENDMENUITEMS  ENDMENUITEMS
                   }
                 unless ($noremote) {                  unless ($noremote) {
                     $cstritems = $menuitems;                      $cstritems = $menuitems;
                     undef($menuitems);                      undef($menuitems);
                 }                  }
             }              }
   #
   # Editing options usually accessed via "Settings" in inline menu need to be
   # accessed in a different way, when Authoring Space is accessed in course
   # context
   #
               if ($env{'request.role'} !~/^(aa|ca|au)/) {
                   my $privfile = &Apache::loncommon::escape_single("/priv/$udom/$uname/$thisdisfn");
                   $menuitems .= (<<ENDMENUITEMS);
   s&7&5&editops.png&Options&edit[_1]&gocstr('/adm/preferences?action=authorsettings','$privfile')&Authoring Space Options
   ENDMENUITEMS
               }
             if (ref($bread_crumbs) eq 'ARRAY') {              if (ref($bread_crumbs) eq 'ARRAY') {
                 &Apache::lonhtmlcommon::clear_breadcrumbs();                  &Apache::lonhtmlcommon::clear_breadcrumbs();
                 foreach my $crumb (@{$bread_crumbs}){                  foreach my $crumb (@{$bread_crumbs}){
Line 1152  ENDMENUITEMS Line 1166  ENDMENUITEMS
                             'tools', $inlineremote[63]);                              'tools', $inlineremote[63]);
                     }                      }
                     &advtools_crumbs(@inlineremote);                      &advtools_crumbs(@inlineremote);
                       #options link/icon in constructions space viewed with course role
                       if (($env{'request.state'} eq 'construct') &&
                           ($env{'request.role'} !~/^(aa|ca|au)/)) {
                           &Apache::lonhtmlcommon::add_breadcrumb_tool(
                                    'advtools', $inlineremote[75]);
                       }
                 }                  }
             }              }
             my ($topic_help,$topic_help_text);              my ($topic_help,$topic_help_text);
Line 1498  sub get_editbutton { Line 1518  sub get_editbutton {
         if ($env{'form.folderpath'}) {          if ($env{'form.folderpath'}) {
             $suppanchor = $env{'form.anchor'};              $suppanchor = $env{'form.anchor'};
         }          }
           my $shownsymb;
           if ($env{'request.symb'}) {
               $shownsymb = &Apache::lonenc::check_encrypt($env{'request.symb'});
           }
         $jscall = &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,$switchserver,          $jscall = &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,$switchserver,
                                                 $forceedit,$forcereg,$env{'request.symb'},                                                  $forceedit,$forcereg,$env{'request.symb'},$shownsymb,
                                                 &escape($env{'form.folderpath'}),                                                  &escape($env{'form.folderpath'}),
                                                 &escape($env{'form.title'}),$hostname,                                                  &escape($env{'form.title'}),$hostname,
                                                 $env{'form.idx'},&escape($env{'form.suppurl'}),                                                  $env{'form.idx'},&escape($env{'form.suppurl'}),
Line 1630  sub prepare_functions { Line 1654  sub prepare_functions {
         } elsif (($resurl !~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) &&          } elsif (($resurl !~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) &&
                  ($resurl ne '/cgi-bin/printout.pl')) {                   ($resurl ne '/cgi-bin/printout.pl')) {
             if ($env{'request.filename'}) {              if ($env{'request.filename'}) {
                 my $file=&Apache::lonnet::declutter($env{'request.filename'});                  my $file;
                   my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
                   if ($env{'request.filename'} =~ m{^\Q$londocroot\E/priv/}) {
                       $file = $env{'request.filename'};
                       $file =~ s{^\Q$londocroot\E/}{};
                   } else {
                       $file=&Apache::lonnet::declutter($env{'request.filename'});
                   }
                 ($cfile,$home,$switchserver,$forceedit,$forceview) =                  ($cfile,$home,$switchserver,$forceedit,$forceview) =
                     &Apache::lonnet::can_edit_resource($file,$cnum,$cdom,                      &Apache::lonnet::can_edit_resource($file,$cnum,$cdom,
                         &Apache::lonnet::clutter($resurl),$env{'request.symb'},$group);                          &Apache::lonnet::clutter($resurl),$env{'request.symb'},$group);
Line 2225  function toggleCountdown() { Line 2256  function toggleCountdown() {
 END  END
 }  }
   
 # This creates a "done button" for timed events.  The confirmation box is a jQuery  
 # dialog widget. If the interval parameter requires a proctor key for the timed  
 # 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 {  
     my ($type,$width,$height,$proctor,$donebuttontext) = @_;  
     return unless (($type eq 'map') || ($type eq 'resource'));  
     my %lt = &Apache::lonlocal::texthash(  
                  title    => 'WARNING!',  
                  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).',  
                  okdone   => 'Click "OK" if you are completely finished.',  
                  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 $shownsymb = &HTML::Entities::encode(&Apache::lonenc::check_encrypt($env{'request.symb'}));  
     my $navmap = Apache::lonnavmaps::navmap->new();  
     my ($missing,$tried) = (0,0);  
     if (ref($navmap)) {  
         my @resources=();  
         if ($type eq 'map') {  
             my ($mapurl,$rid,$resurl)=&Apache::lonnet::decode_symb($env{'request.symb'});  
             if ($env{'request.symb'} =~ /\.page$/) {  
                 @resources=$navmap->retrieveResources($resurl,sub { $_[0]->is_problem() });  
             } else {  
                 @resources=$navmap->retrieveResources($mapurl,sub { $_[0]->is_problem() });  
             }  
         } else {  
             my $res = $navmap->getBySymb($env{'request.symb'});  
             if (ref($res)) {  
                 if ($res->is_problem()) {  
                     push(@resources,$res);  
                 }  
             }  
         }  
         foreach my $res (@resources) {  
             if (ref($res->parts()) eq 'ARRAY') {  
                 foreach my $part (@{$res->parts()}) {  
                     if (!$res->tries($part)) {  
                         $missing++;  
                     } else {  
                         $tried++;  
                     }  
                 }  
             }  
         }  
     }  
     if ($missing) {  
         $lt{'miss'} .= '<p class="LC_error">';  
         if ($type eq 'map') {  
             $lt{'miss'} .= &mt('Submissions are missing for [quant,_1,question part,question parts] in this folder.',$missing);  
         } else {  
             $lt{'miss'} .= &mt('Submissions are missing for [quant,_1,part] in this question.',$missing);  
         }  
         if ($missing > 1) {  
             $lt{'miss'} .= ' '.&mt('If you confirm you are done you will be unable to submit answers for them.').'</span>';  
         } else {  
             $lt{'miss'} .= ' '.&mt('If you confirm you are done you will be unable to submit an answer for it.').'</p>';  
         }  
     }  
     $donebuttontext = &HTML::Entities::encode($donebuttontext,'<>&"');  
     if ($proctor) {  
         if ($height !~ /^\d+$/) {  
             $height = 400;  
             if ($missing) {  
                 $height += 60;  
             }  
         }  
         if ($width !~ /^\d+$/) {  
             $width = 400;  
             if ($missing) {  
                 $width += 60;  
             }  
         }  
         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="" />  
     <input type="hidden" name="symb" value="$shownsymb" />  
     <button id="LC_done-confirm-opener" type="button">$donebuttontext</button>  
 </form>  
   
 <div id="LC_done-confirm" title="$lt{'title'}">  
   <p>$lt{'preamble'} $lt{$type}</p>  
   $lt{'miss'}  
   <p>$lt{'proctor'}</p>  
   <form name="LCdoneButtonProctor" action="">  
     <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 ($missing) {  
                 $height += 60;  
             }  
         }  
         if ($width !~ /^\d+$/) {  
             $width = 320;  
             if ($missing) {  
                 $width += 60;  
             }  
         }  
         if ($missing) {  
             $lt{'miss'} = '</p>'.$lt{'miss'}.'<p>';  
         }  
         return <<END;  
   
 <form method="post" name="LCdoneButton" action="">  
     <input type="hidden" name="LC_interval_done" value="" />  
     <input type="hidden" name="symb" value="$shownsymb" />  
     <button id="LC_done-confirm-opener" type="button">$donebuttontext</button>  
 </form>  
   
 <div id="LC_done-confirm" title="$lt{'title'}">  
     <p>$lt{'preamble'} $lt{$type} $lt{'miss'} $lt{'okdone'} $lt{'cancel'}</p>  
 </div>  
   
 <script type="text/javascript">  
 // <![CDATA[  
 \$( "#LC_done-confirm" ).dialog({ autoOpen: false });  
 \$( "#LC_done-confirm-opener" ).click(function() {  
     \$( "#LC_done-confirm" ).dialog( "open" );  
     \$( "#LC_done-confirm" ).dialog({  
       resizable: false,  
       height: $height,  
       width: $width,  
       modal: true,  
       buttons: [  
                  {  
                     text: "$lt{'ok'}",  
                     click: function() {  
                         \$( this ).dialog( "close" );  
                         \$( '[name="LC_interval_done"]' )[0].value = 'true';  
                         \$( '[name="LCdoneButton"]' )[0].submit();  
                     },  
                  },  
                  {  
                      text: "$lt{'exit'}",  
                      click: function() {  
                          \$( this ).dialog( "close" );  
                      },  
                   },  
                ],  
        });  
 });  
 // ]]>  
 </script>  
   
 END  
     }  
 }  
   
 sub utilityfunctions {  sub utilityfunctions {
     my ($httphost) = @_;      my ($httphost) = @_;
     my $currenturl=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));      my $currenturl=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));
Line 2567  function gocstr(url,filename) { Line 2384  function gocstr(url,filename) {
         this.document.cstrprint.submit();          this.document.cstrprint.submit();
         return;          return;
     }      }
       if (url == '/adm/preferences?action=authorsettings') {
           document.location.href=url+'&returnurl='+filename;
           return;
       }
     if (url !='') {      if (url !='') {
         this.document.constspace.filename.value = filename;          this.document.constspace.filename.value = filename;
         this.document.constspace.action = url;          this.document.constspace.action = url;
Line 3230  sub countdown_timer { Line 3051  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,$donebuttontext,$proctor,$secret);  
         if (@interval > 1) {          if (@interval > 1) {
             ($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]);              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+$interval[0] > time) {
                     $hastimeleft = 1;                      $hastimeleft = 1;
                 }                  }
             }              }
Line 3251  sub countdown_timer { Line 3062  sub countdown_timer {
         if (($duedate && $duedate > time) ||          if (($duedate && $duedate > time) ||
             (!$duedate && $hastimeleft) ||              (!$duedate && $hastimeleft) ||
             ($slot_name ne '' && $slothastime)) {              ($slot_name ne '' && $slothastime)) {
             my ($collapse,$expand,$alttxt,$title,$currdisp,$donebutton);              my ($collapse,$expand,$alttxt,$title,$currdisp);
             if ((@interval > 1 && $hastimeleft) ||              if ((@interval > 1 && $hastimeleft) ||
                 ($type eq 'Task' && $slothastime)) {                  ($type eq 'Task' && $slothastime)) {
                 $currdisp = 'inline';                  $currdisp = 'inline';
                 $collapse = '&#9658;&nbsp;';                  $collapse = '&#9658;&nbsp;';
                 if ((@interval > 1) && ($hastimeleft)) {  
                     if ($usesdone eq 'done') {  
                         $donebutton = &done_button_js($interval[1],'','',$proctor,$donebuttontext);  
                     }  
                 }  
             } else {              } else {
                 $currdisp = 'none';                  $currdisp = 'none';
                 $expand = '&#9668;&nbsp;';                  $expand = '&#9668;&nbsp;';
Line 3271  sub countdown_timer { Line 3077  sub countdown_timer {
             }              }
             my $desc = &mt('Countdown to due date/time');              my $desc = &mt('Countdown to due date/time');
             return <<END;              return <<END;
 $donebutton  
 <a href="javascript:toggleCountdown();" class="LC_menubuttons_link">  <a href="javascript:toggleCountdown();" class="LC_menubuttons_link">
 <span id="ddcountcollapse" class="LC_menubuttons_inline_text">  <span id="ddcountcollapse" class="LC_menubuttons_inline_text">
 $collapse  $collapse

Removed from v.1.369.2.83.4.1  
changed lines
  Added in v.1.369.2.84


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