--- loncom/interface/lonparmset.pm 2022/04/30 19:29:43 1.610 +++ loncom/interface/lonparmset.pm 2022/05/24 16:23:03 1.613 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set parameters for assessments # -# $Id: lonparmset.pm,v 1.610 2022/04/30 19:29:43 raeburn Exp $ +# $Id: lonparmset.pm,v 1.613 2022/05/24 16:23:03 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1252,6 +1252,7 @@ function validateParms() { var dlKeyRegExp = /^deeplink_key_/; var dlMenusRegExp = /^deeplink_menus_/; var dlCollsRegExp = /^deeplink_colls_/; + var dlTargetRegExp = /^deeplink_target_/; var patternIP = /[\[\]\*\.a-zA-Z\d\-]+/; if ((document.parmform.elements.length != 'undefined') && (document.parmform.elements.length) != 'null') { if (document.parmform.elements.length) { @@ -1406,6 +1407,17 @@ function validateParms() { } document.parmform.elements['set_'+identifier].value += posslinkmenu; } + } else if (dlTargetRegExp.text(name)) { + var identifier = name.replace(dlTargetExp,''); + var idx = document.parmform.elements[i].selectedIndex; + if (idx > 0) { + var possdeeplink = document.parmform.elements[i].options[idx].value + possdeeplink = possdeeplink.replace(/^\s+|\s+$/g,''); + if (document.parmform.elements['set_'+identifier].value) { + possdeeplink = ','+possdeeplink; + } + document.parmform.elements['set_'+identifier].value += possdeeplink; + } } } } @@ -1461,6 +1473,8 @@ END # Javascript function toggleSecret, for overview mode. sub done_proctor_js { + my $defaultdone = &mt('Done'); + &js_escape(\$defaultdone); return <<"END"; function toggleSecret(form,radio,key) { var radios = form[radio+key]; @@ -1477,6 +1491,15 @@ function toggleSecret(form,radio,key) { document.getElementById('done_'+key+'_proctorkey').value=''; } } + if (document.getElementById('done_'+key+'_buttontext')) { + if (radios[i].value == '') { + document.getElementById('done_'+key+'_buttontext').value = ''; + } else { + if (document.getElementById('done_'+key+'_buttontext').value == '') { + document.getElementById('done_'+key+'_buttontext').value = '$defaultdone'; + } + } + } } } } @@ -5026,13 +5049,17 @@ sub listdata { sub get_date_interval_from_form { my ($key) = @_; my $seconds = 0; + my $numnotnull = 0; foreach my $which (['days', 86400], ['hours', 3600], ['minutes', 60], ['seconds', 1]) { my ($name, $factor) = @{ $which }; if (defined($env{'form.'.$name.'_'.$key})) { - $seconds += $env{'form.'.$name.'_'.$key} * $factor; + unless ($env{'form.'.$name.'_'.$key} eq '') { + $numnotnull ++; + $seconds += $env{'form.'.$name.'_'.$key} * $factor; + } } } if (($key =~ /\.interval$/) && @@ -5051,6 +5078,7 @@ sub get_date_interval_from_form { $seconds .= '_'.$env{'form.done_'.$key.'_proctorkey'}; } } + return if (!$numnotnull); return $seconds; } @@ -5140,7 +5168,7 @@ sub string_deeplink_selector { my ($thiskey, $showval, $readonly) = @_; my (@components,%values,@current,%titles,%options,%optiontext,%defaults, %selectnull,%domlti,%crslti,@possmenus); - @components = ('state','others','listing','scope','protect','menus'); + @components = ('state','others','listing','scope','protect','menus','target'); %titles = &Apache::lonlocal::texthash ( state => 'Access status', others => 'Hide other resources', @@ -5148,6 +5176,7 @@ sub string_deeplink_selector { scope => 'Access scope for link', protect => 'Link protection', menus => 'Menu Items Displayed', + target => 'Embedded?', ); %options = ( state => ['only','off','both'], @@ -5156,6 +5185,7 @@ sub string_deeplink_selector { scope => ['res','map','rec'], protect => ['none','key','ltid','ltic'], menus => ['std','colls'], + target => ['_self','_top'], ); %optiontext = &Apache::lonlocal::texthash ( only => 'deep only', @@ -5177,6 +5207,8 @@ sub string_deeplink_selector { ltid => 'LTI access (domain)' , std => 'Standard (all menus)', colls => 'Numbered collection', + _self => 'Embedded', + _top => 'Not embedded', ); %selectnull = &Apache::lonlocal::texthash ( ltic => 'Select Launcher', @@ -5192,6 +5224,7 @@ sub string_deeplink_selector { ($values{'scope'}) = ($current[3] =~ /^(res|map|rec)$/); ($values{'protect'}) = ($current[4] =~ /^(key:[a-zA-Z\d_.!\@#\$%^&*()+=-]+|ltic:\d+|ltid:\d+)$/); ($values{'menus'}) = ($current[5] =~ /^(\d+)$/); + ($values{'target'}) = ($current[6] =~ /^(_self|_top)$/); } else { $defaults{'state'} = 'off', $defaults{'others'} = 'unhide', @@ -5199,6 +5232,7 @@ sub string_deeplink_selector { $defaults{'scope'} = 'res'; $defaults{'protect'} = 'none'; $defaults{'menus'} = '0'; + $defaults{'target'} = '_top'; } my $disabled; if ($readonly) { @@ -5380,7 +5414,7 @@ my %strings = => [['_allowfrom_','Hostname(s), or IP(s) from which access is allowed'], ['_denyfrom_','Hostname(s) or IP(s) from which access is disallowed']], 'string_deeplink' - => [['on','Set choices for link protection, resource listing, access scope, and shown menu items']], + => [['on','Set choices for link protection, resource listing, access scope, shown menu items, and embedding']], ); @@ -5391,7 +5425,7 @@ my %stringmatches = ( => [['_allowfrom_','[^\!]+'], ['_denyfrom_','\!']], 'string_deeplink' - => [['on','^(only|off|both)\,(hide|unhide)\,(full|absent|grades|details|datestatus)\,(res|map|rec)\,(none|key\:\w+|ltic\:\d+|ltid\:\d+)\,(\d+|)$']], + => [['on','^(only|off|both)\,(hide|unhide)\,(full|absent|grades|details|datestatus)\,(res|map|rec)\,(none|key\:\w+|ltic\:\d+|ltid\:\d+)\,(\d+|)\,_(self|top)$']], ); my %stringtypes = ( @@ -5711,6 +5745,11 @@ sub date_interval_selector { $showval %= $factor; my %select = ((map {$_ => $_} (0..$max)), 'select_form_order' => [0..$max]); + if ($currval eq '') { + unshift(@{$select{'select_form_order'}},''); + $select{''} = ''; + $amount = ''; + } $result .= &Apache::loncommon::select_form($amount,$name.'_'.$thiskey, \%select,'',$readonly); $result .= ' '.&mt($name); @@ -5718,29 +5757,29 @@ sub date_interval_selector { if ($name eq 'interval') { unless ($skipval{'done'}) { my $checkedon = ''; + my $checkedoff = ''; 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'; + } elsif ($currval ne '') { + $checkedoff = ' checked="checked"'; + } else { + $currdonetext = ''; } my $onclick = ' onclick="toggleSecret(this.form,'."'done_','$thiskey'".');"'; my $disabled; @@ -5757,7 +5796,8 @@ sub date_interval_selector { '&').'"'.$disabled.' />
'. ''.&mt('Button text').': '. - '&').'"'.$disabled.' />'; + '&').'"'.$disabled.' />'; } } unless ($readonly) { @@ -6049,7 +6089,7 @@ ENDOVER $r->print('
'); my $sortorder=$env{'form.sortorder'}; unless ($sortorder) { $sortorder='realmstudent'; } - &sortmenu($r,$sortorder,'newoverview')); + &sortmenu($r,$sortorder,'newoverview'); $r->print('
'); $r->print('

');