--- loncom/interface/lonmenu.pm 2016/04/15 14:14:09 1.446 +++ loncom/interface/lonmenu.pm 2016/10/16 21:49:51 1.455 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.446 2016/04/15 14:14:09 raeburn Exp $ +# $Id: lonmenu.pm,v 1.455 2016/10/16 21:49:51 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -124,9 +124,13 @@ dropdown list when mouse hovers over top (no hover psuedo class) via LC_hoverable class for
  • tag for top- level item, which employs jQuery to handle behavior on mouseover. -Inputs: 4 - (a) link and (b) target for anchor href in top level item, - (c) title for text wrapped by anchor tag in top level item. - (d) reference to array of arrays of sub-menu items. +Inputs: 6 - (a) link and (b) target for anchor href in top level item, + (c) title for text wrapped by anchor tag in top level item, + (d) reference to array of arrays of sub-menu items, + (e) boolean to indicate whether to call &mt() to translate + name of menu item, + (f) optional class for
  • element in primary menu, for which + sub menu is being generated. The underlying datastructure used in (d) contains data from mydesk.tab. It consists of an array which has an array for each item appearing in @@ -382,8 +386,10 @@ sub secondary_menu { undef($canviewroster); } my $canviewgrps = &Apache::lonnet::allowed('vcg', $crs_sec); - my $canmodifyuser = &Apache::lonnet::allowed('cst', $crs_sec); + my $canmodifyuser = &Apache::lonnet::allowed('cst', $crs_sec); + my $canviewusers = &Apache::lonnet::allowed('vcl', $crs_sec); my $canviewwnew = &Apache::lonnet::allowed('whn', $crs_sec); + my $canviewpara = &Apache::lonnet::allowed('vpa', $crs_sec); my $canmodpara = &Apache::lonnet::allowed('opa', $crs_sec); my $canvgr = &Apache::lonnet::allowed('vgr', $crs_sec); my $canmgr = &Apache::lonnet::allowed('mgr', $crs_sec); @@ -453,17 +459,17 @@ sub secondary_menu { next if $$menuitem[4] eq 'vgr' && !$canvgr; next if $$menuitem[4] eq 'cst' - && !$canmodifyuser; + && !$canmodifyuser && !$canviewusers; next if $$menuitem[4] eq 'ncst' - && ($canmodifyuser || !$canviewroster); + && ($canmodifyuser || $canviewusers || !$canviewroster); next if $$menuitem[4] eq 'mgr' && !$canmgr; next if $$menuitem[4] eq 'showresv' && !$showresv; next if $$menuitem[4] eq 'whn' && !$canviewwnew; - next if $$menuitem[4] eq 'opa' - && !$canmodpara; + next if $$menuitem[4] eq 'params' + && (!$canmodpara && !$canviewpara); next if $$menuitem[4] =~ /showgroups$/ && !$canviewgrps && !$grouptools; @@ -534,13 +540,13 @@ sub secondary_menu { } sub create_submenu { - my ($link,$target,$title,$submenu,$translate) = @_; + my ($link,$target,$title,$submenu,$translate,$addclass) = @_; return unless (ref($submenu) eq 'ARRAY'); my $disptarget; if ($target ne '') { $disptarget = ' target="'.$target.'"'; } - my $menu = '
  • '. + my $menu = '
  • '. ''. ''.$title. ''. @@ -745,7 +751,7 @@ sub innerregister { if ($env{'request.filename'}=~/$LONCAPA::assess_re/) { push(@privs,('mgr','vgr')); } - push(@privs,'opa'); + push(@privs,('opa','vpa')); } foreach my $priv (@privs) { $perms{$priv} = &Apache::lonnet::allowed($priv,$env{'request.course.id'}); @@ -769,7 +775,7 @@ sub innerregister { 'Content Submissions'); } } - if (($env{'request.symb'} ne '') && ($perms{'opa'})) { + if (($env{'request.symb'} ne '') && (($perms{'opa'}) || ($perms{'vpa'}))) { &switch('','',7,3,'pparm.png','Content Settings','parms[_2]', "gocmd('/adm/parmset','set')", 'Content Settings'); @@ -808,7 +814,11 @@ sub innerregister { if ($currdir =~ m-/$-) { $is_const_dir = 1; if ($thisdisfn eq '') { - $is_const_dir = 2; + unless (($env{'request.course.id'}) && + ($env{'course.'.$env{'request.course.id'}.'.num'} eq $uname) && + ($env{'course.'.$env{'request.course.id'}.'.domain'} eq $udom)) { + $is_const_dir = 2; + } } } else { $currdir =~ s|[^/]+$||; @@ -869,12 +879,15 @@ ENDMENUITEMS $got_prt = 1; if (($env{'user.adv'}) && ($env{'request.uri'} =~ /^\/res/) && (!$env{'request.enc'})) { - # wishlist is only available for users with access to resource-pool - # and links can only be set for resources within the resource-pool - $menuitems .= (< '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).', @@ -1647,10 +1659,8 @@ sub done_button_js { nokey => 'A proctor key is required', ); my $navmap = Apache::lonnavmaps::navmap->new(); - my ($missing,$tried); + my ($missing,$tried) = (0,0); if (ref($navmap)) { - $missing=0; - $tried=0; my @resources=(); if ($type eq 'map') { my ($mapurl,$rid,$resurl)=&Apache::lonnet::decode_symb($env{'request.symb'}); @@ -1664,13 +1674,7 @@ sub done_button_js { } } foreach my $res (@resources) { - if ($res->singlepart()) { - if (!$res->tries()) { - $missing++; - } else { - $tried++; - } - } else { + if (ref($res->parts()) eq 'ARRAY') { foreach my $part (@{$res->parts()}) { if (!$res->tries($part)) { $missing++; @@ -1694,6 +1698,7 @@ sub done_button_js { $lt{'miss'} .= ' '.&mt('If you confirm you are done you will be unable to submit an answer for it.').'

    '; } } + $donebuttontext = &HTML::Entities::encode($donebuttontext,'<>&"'); if ($proctor) { if ($height !~ /^\d+$/) { $height = 400; @@ -1711,14 +1716,14 @@ sub done_button_js {
    - +

    $lt{'preamble'} $lt{$type}

    $lt{'miss'}

    $lt{'proctor'}

    -
    +
    @@ -1792,7 +1797,7 @@ END
    - +
    @@ -2497,9 +2502,17 @@ sub countdown_timer { } 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) { @@ -2517,7 +2530,7 @@ sub countdown_timer { $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 {