--- loncom/interface/lonmenu.pm 2012/08/03 17:35:32 1.369.2.17 +++ loncom/interface/lonmenu.pm 2012/09/26 00:39:32 1.369.2.24 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.369.2.17 2012/08/03 17:35:32 raeburn Exp $ +# $Id: lonmenu.pm,v 1.369.2.24 2012/09/26 00:39:32 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -443,8 +443,10 @@ sub secondary_menu { } $menu =~ s/\[uname\]/$$author{user}/g; $menu =~ s/\[udom\]/$$author{dom}/g; - - return ""; + if ($menu) { + $menu = ""; + } + return $menu; } sub create_submenu { @@ -569,46 +571,8 @@ sub innerregister { my $timesync = ( $noremote ? '' : 'swmenu.syncclock(1000*'.time.');' ); # ============================================================================= # ============================ This is for URLs that actually can be registered - unless ( ($env{'request.noversionuri'}!~m{^/(res/)*adm/}) + if ( ($env{'request.noversionuri'}!~m{^/(res/)*adm/}) || ($forcereg)) { - unless ($noremote) { -# Not registered, graphical - return (< -// - -ENDDONOTREGTHIS - - } - return ''; - } - # -- This applies to homework problems for users with grading privileges my $crs='/'.$env{'request.course.id'}; if ($env{'request.course.sec'}) { @@ -616,30 +580,38 @@ ENDDONOTREGTHIS } $crs=~s/\_/\//g; + my %swtext; + if ($noremote) { + %swtext = &get_inline_text(); + } else { + %swtext = &get_rc_text(); + } my $hwkadd=''; if ($env{'request.symb'} ne '' && $env{'request.filename'}=~/$LONCAPA::assess_re/) { if (&Apache::lonnet::allowed('mgr',$crs)) { - $hwkadd.=&switch('','',7,2,'pgrd.png','Content Grades','grades[_4]', + $hwkadd.=&switch('','',7,2,'pgrd.png',$swtext{'pgrd'},'grades[_4]', "gocmd('/adm/grades','gradingmenu')", 'Content Grades'); } elsif (&Apache::lonnet::allowed('vgr',$crs)) { - $hwkadd.=&switch('','',7,2,'subm.png','Content Submissions','missions[_1]', + $hwkadd.=&switch('','',7,2,'subm.png',$swtext{'subm'},'missions[_1]', "gocmd('/adm/grades','submission')", 'Content Submissions'); } } if ($env{'request.symb'} ne '' && &Apache::lonnet::allowed('opa',$crs)) { - $hwkadd.=&switch('','',7,3,'pparm.png','Content Settings','parms[_2]', + $hwkadd.=&switch('','',7,3,'pparm.png',$swtext{'pparm'},'parms[_2]', "gocmd('/adm/parmset','set')", 'Content Settings'); } - if ($env{'request.symb'}=~/^uploaded/ && - &Apache::lonnet::allowed('mdc',$crs)) { - $hwkadd.=&switch('','',7,4,'docs.png','Folder/Page Content','parms[_2]', - "gocmd('/adm/coursedocs','direct')", - 'Folder/Page Content'); + if ($noremote) { + if ($env{'request.symb'}=~/^uploaded/ && + &Apache::lonnet::allowed('mdc',$crs)) { + $hwkadd.=&switch('','',7,4,'docs.png',$swtext{'docs'},'parms[_2]', + "gocmd('/adm/coursedocs','direct')", + 'Folder/Page Content'); + } } # -- End Homework ### @@ -682,7 +654,7 @@ ENDDONOTREGTHIS my @ids=&Apache::lonnet::current_machine_ids(); foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } } if (!$allowed) { - $editbutton=&switch('','',6,1,$top,,$bottom,$action,$desc); + $editbutton=&switch('','',6,1,,$top,$bottom,$action,$desc); $noeditbutton = 0; } } @@ -749,7 +721,7 @@ ENDDONOTREGTHIS } } $editbutton=&switch - ('','',6,1,'pcstr.png','Edit','resource[_2]', + ('','',6,1,'pcstr.png',$swtext{'pcstr'},'resource[_2]', $bot,"Edit this resource"); $noeditbutton = 0; } @@ -765,7 +737,7 @@ ENDDONOTREGTHIS my $cfile = &edit_course_upload($file,$cnum,$cdom); if ($cfile) { $editbutton=&switch - ('','',6,1,'pcstr.png','Edit', + ('','',6,1,'pcstr.png',$swtext{'pcstr'}, 'resource[_2]',"go('".$cfile."');", 'Edit this resource'); } @@ -777,7 +749,7 @@ ENDDONOTREGTHIS if ($resurl eq "public/$cdom/$cnum/syllabus") { if ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ /\w/) { if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) { - $editbutton=&switch('','',6,1,'pcstr.png','Edit', + $editbutton=&switch('','',6,1,'pcstr.png',$swtext{'pcstr'}, 'resource[_2]', "go('/adm/courseprefs?phase=display&actions=courseinfo')", 'Edit this resource'); @@ -788,7 +760,7 @@ ENDDONOTREGTHIS ### ### # Prepare the rest of the buttons - my ($menuitems,$got_prt,$got_wishlist); + my ($menuitems,$got_prt,$got_wishlist,$cstritems); if ($const_space) { # # We are in construction space @@ -814,6 +786,10 @@ s&6&3&pub.png&Publish&resource[_3]&gocst s&7&1&del.png&Delete&resource[_2]&gocstr('/adm/cfile?action=delete','/priv/$udom/$uname/$cleandisfn')&Delete this resource s&7&2&prt.png&Print&printout[_1]&gocstr('/adm/printout','/priv/$udom/$uname/$cleandisfn')&Prepare a printable document ENDMENUITEMS + unless ($noremote) { + $cstritems = $menuitems; + undef($menuitems); + } } if (ref($bread_crumbs) eq 'ARRAY') { &Apache::lonhtmlcommon::clear_breadcrumbs(); @@ -827,14 +803,15 @@ ENDMENUITEMS # We are in a course and looking at a registered URL # Should probably be in mydesk.tab # + $menuitems=(< 0){ }else{ $menuitems.="anot.png"; } -$menuitems.="&Notes&&annotate()&"; +$menuitems.="&$swtext{'anot'}&tations[_1]&annotate()&"; $menuitems.="Make notes and annotations about this resource&&1\n"; unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme|viewclasslist|portfolio)(\?|$)/) { if ((!$env{'request.enc'}) && ($env{'request.noversionuri'} !~ m{^/adm/wrapper/ext/}) && ($env{'request.noversionuri'} !~ m{^/uploaded/$match_domain/$match_courseid/docs/})) { $menuitems.=(< + +$cstrcrumbs ENDREGTHIS } + } else { + unless ($noremote) { +# Not registered, graphical + return (< +// + +ENDDONOTREGTHIS + + } + return ''; + } +} + +sub get_inline_text { + my %text = ( + pgrd => 'Content Grades', + subm => 'Content Submissions', + pparm => 'Content Settings', + docs => 'Folder/Page Content', + pcstr => 'Edit', + prt => 'Print', + alnk => 'Stored Links', + anot => 'Notes', + catalog => 'Info', + eval => 'Evaluate', + fdbk => 'Feedback', + ); + return %text; +} - return &Apache::lonhtmlcommon::scripttag('', 'start') - . &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0) - . &Apache::lonhtmlcommon::scripttag('', 'end'); +sub get_rc_text { + my %text = ( + pgrd => 'problem[_1]', + subm => 'view sub-[_1]', + pparm => 'problem[_2]', + pcstr => 'edit[_1]', + prt => 'prepare[_1]', + back => 'backward[_1]', + forw => 'forward[_1]', + alnk => 'add to[_1]', + anot => 'anno-[_1]', + catalog => 'catalog[_2]', + eval => 'evaluate[_1]', + fdbk => 'feedback[_1]', + ); + return %text; } sub is_course_upload { @@ -1239,6 +1316,16 @@ sub switch { if ($env{'environment.remote'} eq 'on') { if (($row<1) || ($row>13)) { return ''; } + if ($env{'request.state'} eq 'construct') { + my $text = $top.' '.$bot; + $text=~s/\s*\-\s*//gs; + my $pic = ''.$text.''; + $inlineremote[$idx] = + ''. + $pic.''.$top.' '; + } # Remote $img=~s/\.png$/\.gif/; return "\n". @@ -1888,8 +1975,22 @@ sub roles_selector { } else { $ccrole = 'cc'; } - my $priv; + my ($priv,$gotsymb,$destsymb); my $destinationurl = $ENV{'REQUEST_URI'}; + if ($destinationurl =~ /\?symb=/) { + $gotsymb = 1; + } elsif ($destinationurl =~ m{^/enc/}) { + my $plainurl = &Apache::lonenc::unencrypted($destinationurl); + if ($plainurl =~ /\?symb=/) { + $gotsymb = 1; + } + } + unless ($gotsymb) { + $destsymb = &Apache::lonnet::symbread(); + if ($destsymb ne '') { + $destsymb = &Apache::lonenc::check_encrypt($destsymb); + } + } my $reqprivs = &required_privs(); if (ref($reqprivs) eq 'HASH') { my $destination = $destinationurl; @@ -1977,7 +2078,12 @@ sub roles_selector { $role_selector .= "\n".''; } } - $role_selector .= ''."\n". + $role_selector .= ''."\n"; + if ($destsymb ne '') { + $role_selector .= ''."\n"; + } + $role_selector .= ''."\n". ''."\n". @@ -2233,8 +2339,27 @@ sub required_privs { sub countdown_timer { if (($env{'request.course.id'}) && ($env{'request.symb'} ne '') && - ($env{'request.filename'}=~/$LONCAPA::assess_re/) && - ($Apache::inputtags::status[-1] eq 'CAN_ANSWER')) { + ($env{'request.filename'}=~/$LONCAPA::assess_re/)) { + my ($type,$hastimeleft,$slothastime); + my $now = time; + if ($env{'request.filename'} =~ /\.task$/) { + $type = 'Task'; + } else { + $type = 'problem'; + } + my ($status,$accessmsg,$slot_name,$slot) = + &Apache::lonhomework::check_slot_access('0',$type); + if ($slot_name ne '') { + if (ref($slot) eq 'HASH') { + if (($slot->{'starttime'} < $now) && + ($slot->{'endtime'} > $now)) { + $slothastime = 1; + } + } + } + if ($status ne 'CAN_ANSWER') { + return; + } my $duedate = &Apache::lonnet::EXT("resource.0.duedate"); my @interval=&Apache::lonnet::EXT("resource.0.interval"); my $hastimeleft; @@ -2247,9 +2372,11 @@ sub countdown_timer { } } if (($duedate && $duedate > time) || - (!$duedate && $hastimeleft)) { + (!$duedate && $hastimeleft) || + ($slot_name ne '' && $slothastime)) { my ($collapse,$expand,$alttxt,$title,$currdisp); - if (@interval > 1 && $hastimeleft) { + if ((@interval > 1 && $hastimeleft) || + ($type eq 'Task' && $slothastime)) { $currdisp = 'inline'; $collapse = '► '; } else {