--- loncom/interface/lonmenu.pm 2015/07/17 19:11:06 1.436 +++ loncom/interface/lonmenu.pm 2016/03/17 13:51:28 1.442 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.436 2015/07/17 19:11:06 raeburn Exp $ +# $Id: lonmenu.pm,v 1.442 2016/03/17 13:51:28 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -371,7 +371,8 @@ sub secondary_menu { my $canmgr = &Apache::lonnet::allowed('mgr', $crs_sec); my $author = &getauthor(); - my ($cdom,$cnum,$showsyllabus,$showfeeds,$showresv); + my ($cdom,$cnum,$showsyllabus,$showfeeds,$showresv,$grouptools); + $grouptools = 0; if ($env{'request.course.id'}) { $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; @@ -397,6 +398,17 @@ sub secondary_menu { $showresv = 1; } } + my %groups = &Apache::lonnet::get_active_groups( + $env{'user.domain'}, $env{'user.name'},$cdom,$cnum); + if (%groups) { + foreach my $group (keys(%groups)) { + my @privs = split(/:/,$env{"user.priv.$env{'request.role'}./$cdom/$cnum/$group"}); + shift(@privs); + if (@privs) { + $grouptools ++; + } + } + } } my ($canmodifycoauthor); @@ -407,12 +419,6 @@ sub secondary_menu { $canmodifycoauthor = 1; } } - - my %groups = &Apache::lonnet::get_active_groups( - $env{'user.domain'}, $env{'user.name'}, - $env{'course.' . $env{'request.course.id'} . '.domain'}, - $env{'course.' . $env{'request.course.id'} . '.num'}); - my ($roleswitcher_js,$roleswitcher_form); foreach my $menuitem (@secondary_menu) { @@ -441,7 +447,7 @@ sub secondary_menu { && !$canmodpara; next if $$menuitem[4] =~ /showgroups$/ && !$canviewgrps - && !%groups; + && !$grouptools; next if $$menuitem[4] eq 'showsyllabus' && !$showsyllabus; next if $$menuitem[4] eq 'showfeeds' @@ -847,7 +853,7 @@ if ($env{'browser.mobile'}) { $is_mobile = 1; } - unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme|viewclasslist|portfolio)(\?|$)/) { + unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme|viewclasslist|portfolio|exttools?)(\?|$)/) { if ((!$env{'request.enc'}) && ($env{'request.noversionuri'} !~ m{^/adm/wrapper/ext/}) && ($env{'request.noversionuri'} !~ m{^/uploaded/$match_domain/$match_courseid/docs/})) { $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).', - ok => 'Click "OK" if you are completely finished.', + 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 $confirm; - if (($type eq 'map') || ($type eq 'resource')) { - $confirm = $lt{'preamble'}.' '.$lt{$type}.' '.$lt{'ok'}.' '.$lt{'cancel'}; + my $navmap = Apache::lonnavmaps::navmap->new(); + my ($missing,$tried); + if (ref($navmap)) { + $missing=0; + $tried=0; + my @resources=(); + if ($type eq 'map') { + my ($mapurl,$rid,$resurl)=&Apache::lonnet::decode_symb($env{'request.symb'}); + @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 ($res->singlepart()) { + if (!$res->tries()) { + $missing++; + } else { + $tried++; + } + } else { + foreach my $part (@{$res->parts()}) { + if (!$res->tries($part)) { + $missing++; + } else { + $tried++; + } + } + } + } + } + if ($missing) { + $lt{'miss'} .= '

'; + 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.').''; + } else { + $lt{'miss'} .= ' '.&mt('If you confirm you are done you will be unable to submit an answer for it.').'

'; + } } - if ($confirm) { + if ($proctor) { + if ($height !~ /^\d+$/) { + $height = 400; + if ($missing) { + $height += 60; + } + } + if ($width !~ /^\d+$/) { + $width = 400; + if ($missing) { + $width += 60; + } + } + return < + + + + + +
+

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

+ $lt{'miss'} +

$lt{'proctor'}

+
+ + +
+

$lt{'cancel'}

+
+ + + +END + } else { + if ($height !~ /^\d+$/) { + $height = 320; + if ($missing) { + $height += 60; + } + } + if ($width !~ /^\d+$/) { + $width = 320; + if ($missing) { + $width += 60; + } + } + if ($missing) { + $lt{'miss'} = '

'.$lt{'miss'}.'

'; + } return < @@ -1590,7 +1744,7 @@ sub done_button_js {

-

$confirm

+

$lt{'preamble'} $lt{$type} $lt{'miss'} $lt{'okdone'} $lt{'cancel'}

END - } else { - return; } } @@ -2286,10 +2445,12 @@ sub countdown_timer { } my $duedate = &Apache::lonnet::EXT("resource.0.duedate"); my @interval=&Apache::lonnet::EXT("resource.0.interval"); + my ($timelimit,$usesdone,$proctor,$secret); if (@interval > 1) { + ($timelimit,$usesdone,$proctor,$secret) = split(/_/,$interval[0]); my $first_access=&Apache::lonnet::get_first_access($interval[1]); if ($first_access > 0) { - if ($first_access+$interval[0] > time) { + if ($first_access+$timelimit > time) { $hastimeleft = 1; } } @@ -2303,7 +2464,9 @@ sub countdown_timer { $currdisp = 'inline'; $collapse = '► '; if ((@interval > 1) && ($hastimeleft)) { - $donebutton = &done_button_js($interval[1]); + if ($usesdone eq 'done') { + $donebutton = &done_button_js($interval[1],'','',$proctor); + } } } else { $currdisp = 'none';