--- loncom/interface/lonmenu.pm 2012/08/03 22:38:35 1.369.2.18 +++ 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.18 2012/08/03 22:38:35 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 { @@ -578,29 +580,35 @@ sub innerregister { } $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 ($noremote) { if ($env{'request.symb'}=~/^uploaded/ && &Apache::lonnet::allowed('mdc',$crs)) { - $hwkadd.=&switch('','',7,4,'docs.png','Folder/Page Content','parms[_2]', + $hwkadd.=&switch('','',7,4,'docs.png',$swtext{'docs'},'parms[_2]', "gocmd('/adm/coursedocs','direct')", 'Folder/Page Content'); } @@ -646,7 +654,7 @@ sub innerregister { 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; } } @@ -713,7 +721,7 @@ sub innerregister { } } $editbutton=&switch - ('','',6,1,'pcstr.png','Edit','resource[_2]', + ('','',6,1,'pcstr.png',$swtext{'pcstr'},'resource[_2]', $bot,"Edit this resource"); $noeditbutton = 0; } @@ -729,7 +737,7 @@ sub innerregister { 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'); } @@ -741,7 +749,7 @@ sub innerregister { 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'); @@ -752,7 +760,7 @@ sub innerregister { ### ### # 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 @@ -778,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(); @@ -791,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 { @@ -985,6 +1024,7 @@ var swmenu=null; swmenu.clearbut(8,1); swmenu.clearbut(8,2); swmenu.clearbut(8,3); + swmenu.clearbut(9,1); if (swmenu.currentURL) { swmenu.switchbutton (3,1,'reload.gif','return','location','go(currentURL)'); @@ -1006,6 +1046,41 @@ ENDDONOTREGTHIS } } +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; +} + +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 { my ($file,$cnum,$cdom) = @_; my $uploadpath = &LONCAPA::propath($cdom,$cnum); @@ -1241,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". @@ -1890,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; @@ -1979,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". @@ -2235,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; @@ -2249,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 {