--- loncom/interface/lonparmset.pm 2017/04/02 13:39:05 1.522.2.23 +++ loncom/interface/lonparmset.pm 2017/06/13 16:20:44 1.522.2.23.2.1 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set parameters for assessments # -# $Id: lonparmset.pm,v 1.522.2.23 2017/04/02 13:39:05 raeburn Exp $ +# $Id: lonparmset.pm,v 1.522.2.23.2.1 2017/06/13 16:20:44 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -752,7 +752,7 @@ sub storeparm_by_symb_inner { sub valout { - my ($value,$type,$editable)=@_; + my ($value,$type,$name,$editable)=@_; my $result = ''; # Values of zero are valid. if (! $value && $value ne '0') { @@ -766,7 +766,17 @@ sub valout { } } else { if ($type eq 'date_interval') { - my ($sec,$min,$hour,$mday,$mon,$year)=gmtime($value); + my ($totalsecs,$donesuffix) = split(/_/,$value,2); + my ($usesdone,$donebuttontext,$proctor,$secretkey); + if ($donesuffix =~ /^done\:([^\:]+)\:(.*)$/) { + $donebuttontext = $1; + (undef,$proctor,$secretkey) = split(/_/,$2); + $usesdone = 'done'; + } elsif ($donesuffix =~ /^done(|_.+)$/) { + $donebuttontext = &mt('Done'); + ($usesdone,$proctor,$secretkey) = split(/_/,$donesuffix); + } + my ($sec,$min,$hour,$mday,$mon,$year)=gmtime($totalsecs); my @timer; $year=$year-70; $mday--; @@ -799,6 +809,13 @@ sub valout { push(@timer,&mt('[quant,_1,sec]',0)); } $result.=join(", ",@timer); + if ($usesdone eq 'done') { + if ($secretkey) { + $result .= ' '.&mt('+ "[_1]" with proctor key: [_2]',$donebuttontext,$secretkey); + } else { + $result .= ' + "'.$donebuttontext.'"'; + } + } } elsif (&isdateparm($type)) { $result = &Apache::lonlocal::locallocaltime($value). &date_sanity_info($value); @@ -825,7 +842,7 @@ sub plink { my ($parmname)=((split(/\&/,$marker))[1]=~/\_([^\_]+)$/); my ($hour,$min,$sec,$val)=&preset_defaults($parmname); unless (defined($winvalue)) { $winvalue=$val; } - my $valout = &valout($value,$type,1); + my $valout = &valout($value,$type,$parmname,1); my $unencmarker = $marker; foreach my $item (\$type, \$dis, \$winvalue, \$marker, \$return, \$call, \$hour, \$min, \$sec) { @@ -905,6 +922,31 @@ function showHide_courseContent() { COURSECONTENTSCRIPT } +sub done_proctor_js { + return <<"END"; +function toggleSecret(form,radio,key) { + var radios = form[radio+key]; + if (radios.length) { + for (var i=0; iprint(''. - &valout($sessionval,$sessionvaltype).' '. + &valout($sessionval,$sessionvaltype,$$name{$which}).' '. ''); } $r->print(''); @@ -1102,7 +1144,7 @@ sub print_td { } } if ($nolink) { - $r->print(&valout($$outpar[$which],$$typeoutpar[$which])); + $r->print(&valout($$outpar[$which],$$typeoutpar[$which],$mprefix)); } else { $r->print(&plink($$typeoutpar[$which], $$display{$value},$$outpar[$which], @@ -1127,9 +1169,9 @@ sub print_usergroups { if (($coursereply) && ($cgroup ne $resultgroup)) { if ($result > 3) { $bgcolor = '#AAFFAA'; - $grp_parm = &valout($coursereply,$resulttype); + $grp_parm = &valout($coursereply,$resulttype,$what); } - $grp_parm = &valout($coursereply,$resulttype); + $grp_parm = &valout($coursereply,$resulttype,$what); $output = ''; if ($resultgroup && $resultlevel) { $output .= ''.$resultgroup.' ('.$resultlevel.'): '.$grp_parm; @@ -3159,7 +3201,7 @@ sub listdata { ); } } elsif ($thistype eq 'date_interval') { - $r->print(&date_interval_selector($thiskey, + $r->print(&date_interval_selector($thiskey,$name, $$resourcedata{$thiskey},$readonly)); } elsif ($thistype =~ m/^string/) { $r->print(&string_selector($thistype,$thiskey, @@ -3179,8 +3221,9 @@ sub listdata { sub date_interval_selector { - my ($thiskey, $showval, $readonly) = @_; - my $result; + my ($thiskey, $pname, $showval, $readonly) = @_; + my ($result,%skipval); + my $currval = $showval; foreach my $which (['days', 86400, 31], ['hours', 3600, 23], ['minutes', 60, 59], @@ -3194,6 +3237,51 @@ sub date_interval_selector { \%select,'',$readonly); $result .= ' '.&mt($name); } + if ($pname eq 'interval') { + unless ($skipval{'done'}) { + my $checkedon = ''; + my $checkedproc = ''; + my $currproctorkey = ''; + my $currprocdisplay = 'hidden'; + my $currdonetext = &mt('Done'); + my $checkedoff = ' checked="checked"'; + if ($currval =~ /^(?:\d+)_done$/) { + $checkedon = ' checked="checked"'; + $checkedoff = ''; + } elsif ($currval =~ /^(?:\d+)_done\:([^\:]+)\:$/) { + $currdonetext = $1; + $checkedon = ' checked="checked"'; + $checkedoff = ''; + } elsif ($currval =~ /^(?:\d+)_done_proctor_(.+)$/) { + $currproctorkey = $1; + $checkedproc = ' checked="checked"'; + $checkedoff = ''; + $currprocdisplay = 'text'; + } elsif ($currval =~ /^(?:\d+)_done\:([^\:]+)\:_proctor_(.+)$/) { + $currdonetext = $1; + $currproctorkey = $2; + $checkedproc = ' checked="checked"'; + $checkedoff = ''; + $currprocdisplay = 'text'; + } + my $onclick = ' onclick="toggleSecret(this.form,'."'done_','$thiskey'".');"'; + my $disabled; + if ($readonly) { + $disabled = ' disabled="disabled"'; + } + $result .= '
'.&mt('Include "done" button'). + ''.(' 'x2). + ''.(' 'x2). + ''. + '&').'"'.$disabled.' />
'. + ''.&mt('Button text').': '. + '&').'"'.$disabled.' />'; + } + } unless ($readonly) { $result .= ''; } @@ -3403,6 +3491,7 @@ sub newoverview { '. &Apache::lonhtmlcommon::resize_scrollbox_js('params')."\n". &showhide_js()."\n". + &done_proctor_js()."\n". '// ]]> '; @@ -3579,13 +3668,19 @@ sub overview { my ($r,$parm_permission) = @_; my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; + my $crstype = $env{'course.'.$env{'request.course.id'}.'.type'}; + my $js = ''."\n"; my $readonly = 1; if ($parm_permission->{'edit'}) { undef($readonly); } &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview', text=>"Overview Mode"}); - my $start_page=&Apache::loncommon::start_page('Modify Parameters'); + my $start_page=&Apache::loncommon::start_page('Modify Parameters'.$js); my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Overview'); $r->print($start_page.$breadcrumbs); $r->print('
');