--- loncom/interface/lonmenu.pm 2016/02/26 21:44:39 1.439 +++ 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.439 2016/02/26 21:44:39 raeburn Exp $ +# $Id: lonmenu.pm,v 1.442 2016/03/17 13:51:28 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1568,27 +1568,174 @@ END } # This creates a "done button" for timed events. The confirmation box is a jQuery -# dialog widget. Clicking OK will set (LC_interval_done = 'true') which is checked in -# lonhomework.pm. +# 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,$height) = @_; - if ($height !~ /^\d+$/) { - $height = 320; - } + my ($type,$width,$height,$proctor) = @_; + return unless (($type eq 'map') || ($type eq 'resource')); my %lt = &Apache::lonlocal::texthash( title => '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'}
+';
+ }
return < $confirm $lt{'preamble'} $lt{$type} $lt{'miss'} $lt{'okdone'} $lt{'cancel'}