--- loncom/interface/lonparmset.pm 2022/01/03 20:08:24 1.603 +++ loncom/interface/lonparmset.pm 2023/12/22 13:38:02 1.621 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set parameters for assessments # -# $Id: lonparmset.pm,v 1.603 2022/01/03 20:08:24 raeburn Exp $ +# $Id: lonparmset.pm,v 1.621 2023/12/22 13:38:02 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -329,6 +329,7 @@ use Apache::lonnavmaps; use Apache::longroup; use Apache::lonrss; use HTML::Entities; +use Text::Wrap(); use LONCAPA qw(:DEFAULT :match); @@ -1252,10 +1253,14 @@ function validateParms() { var dlKeyRegExp = /^deeplink_key_/; var dlMenusRegExp = /^deeplink_menus_/; var dlCollsRegExp = /^deeplink_colls_/; + var dlTargetRegExp = /^deeplink_target_/; + var dlExitRegExp = /^deeplink_exit_/; + var dlExitTextRegExp = /^deeplink_exittext_/; var patternIP = /[\[\]\*\.a-zA-Z\d\-]+/; - if ((document.parmform.elements.length != 'undefined') && (document.parmform.elements.length) != 'null') { - if (document.parmform.elements.length) { - for (i=0; i 0) { + var linktarget = document.parmform.elements[i].options[idx].value + linktarget = linktarget.replace(/^\s+|\s+$/g,''); + if (document.parmform.elements['set_'+identifier].value) { + linktarget = ','+linktarget; + } + document.parmform.elements['set_'+identifier].value += linktarget; + } + } else if (dlExitRegExp.test(name)) { + if (document.parmform.elements[i].checked) { + var identifier = name.replace(dlExitRegExp,''); + var posslinkexit = document.parmform.elements[i].value; + posslinkexit = posslinkexit.replace(/^\s+|\s+$/g,''); + if (document.parmform.elements['set_'+identifier].value) { + posslinkexit = ','+posslinkexit; + } + document.parmform.elements['set_'+identifier].value += posslinkexit; + } + } else if (dlExitTextRegExp.test(name)) { + var identifier = name.replace(dlExitTextRegExp,''); + if ((isRadioSet('deeplink_exit_'+identifier,'yes')) || + (isRadioSet('deeplink_exit_'+identifier,'url'))) { + var posstext = document.parmform.elements[i].value; + posstext = posstext.replace(/^\s+|\s+$/g,''); + var origlength = posstext.length; + posstext = posstext.replace(/[:;'",]/g,''); + var newlength = posstext.length; + if (newlength > 0) { + var change = origlength - newlength; + if (change) { + alert(change+' disallowed character(s) removed from Exit Button text'); + } + if (posstext !== 'Exit Tool') { + posstext = ':'+posstext; + document.parmform.elements['set_'+identifier].value += posstext; + } + } else { + document.parmform.elements['set_'+identifier].value = ''; + if (newlength < origlength) { + alert("An exit link type of 'In use' was selected but the button text value was blank, after removing disallowed characters.\nDisallowed characters are ,\":;'"); + } else { + alert("An exit link type of 'In use' was selected but the button text value was blank.\nPlease enter the text to use."); + } + return false; + } + } } } } @@ -1461,6 +1515,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 +1533,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'; + } + } + } } } } @@ -1539,6 +1604,24 @@ function toggleDeepLink(form,item,key) { keybox.type = 'hidden'; } } + } else if (item == 'exit') { + if (document.getElementById('deeplinkdiv_'+item+'_'+key)) { + if (radios[i].value == 'no') { + document.getElementById('deeplinkdiv_'+item+'_'+key).style.display = 'none'; + if (document.getElementById('deeplink_exittext_'+key)) { + if (document.getElementById('deeplink_exittext_'+key).value != '') { + document.getElementById('deeplink_exittext_'+key).value = ''; + } + } + } else { + document.getElementById('deeplinkdiv_'+item+'_'+key).style.display = 'inline-block'; + if (document.getElementById('deeplink_exittext_'+key)) { + if (document.getElementById('deeplink_exittext_'+key).value == '') { + document.getElementById('deeplink_exittext_'+key).value = 'Exit Tool'; + } + } + } + } } } } @@ -1667,6 +1750,24 @@ sub print_row { if ($automatic) { $parm.='
'.&mt('Automatically sets').' '.join(', ',split(/\:/,$automatic)).'
'; } + my $advice; + if ((ref($name) eq 'HASH') && ($name->{$which} eq 'mapalias') && + (ref($symbp) eq 'HASH') && ($parmlev eq 'full')) { + if ($symbp->{$rid} =~ m{^uploaded/}) { + if ($result == 14) { + $advice = &mt('Use Course Editor to modify this.'); + } else { + $advice = &mt('Use Course Editor to set this.'); + } + } else { + if ($result == 14) { + $advice = &mt('Use Resource Assembly Tool to modify this.'); + } else { + $advice = &mt('Use Resource Assembly Tool to set this.'); + } + } + $parm .= '
'.$advice.''; + } $r->print(''.$parm.''); my $thismarker=$which; @@ -1736,13 +1837,11 @@ sub print_row { my ($domltistr,$crsltistr); my %lti = &Apache::lonnet::get_domain_lti($env{'course.'.$env{'request.course.id'}.'.domain'}, - 'provider'); + 'linkprot'); if (keys(%lti)) { foreach my $item (sort { $a <=> $b } (keys(%lti))) { - if (ref($lti{$item}) eq 'HASH') { - unless ($lti{$item}{'requser'}) { - $domltistr .= $item.':'.&escape(&escape($lti{$item}{'consumer'})).','; - } + if (($item =~ /^\d+$/) && (ref($lti{$item}) eq 'HASH')) { + $domltistr .= $item.':'.&escape(&escape($lti{$item}{'name'})).','; } } $domltistr =~ s/,$//; @@ -1750,7 +1849,7 @@ sub print_row { $extra = 'ltid_'.$domltistr; } } - my %courselti = &Apache::lonnet::get_course_lti($cnum,$cdom); + my %courselti = &Apache::lonnet::get_course_lti($cnum,$cdom,'provider'); if (keys(%courselti)) { foreach my $item (sort { $a <=> $b } keys(%courselti)) { if (($item =~ /^\d+$/) && (ref($courselti{$item}) eq 'HASH')) { @@ -2076,6 +2175,7 @@ sub parm_control_group { # @param {hash reference} $uris - hash resource/map id -> resource src # @param {hash reference} $keyorder - hash parameter key -> appearance rank for this parameter when looking through every resource and every parameter, starting at 100 (integer) # @param {hash reference} $defkeytype - hash parameter name -> parameter type +# @param {string} $pssymb - resource symb (when a single resource is selected) sub extractResourceInformation { my $ids = shift; my $typep = shift; @@ -2382,6 +2482,7 @@ sub lookUpTableParameter { 'lenient' => 'grading', 'retrypartial' => 'tries', 'discussvote' => 'misc', + 'texdisplay' => 'misc', 'examcode' => 'high_level_randomization', ); } @@ -2471,6 +2572,8 @@ sub parmboxes { &whatIsMyCategory($tempparameter, \%categoryList); } #part to print the parm-list + $Text::Wrap::columns=60; + $Text::Wrap::separator='
'; foreach my $key (sort { $category_order{$a} <=> $category_order{$b} } keys(%categoryList)) { next if (@{$categoryList{$key}} == 0); next if ($key eq ''); @@ -2484,8 +2587,9 @@ sub parmboxes { if ($$pscat[0] eq "all" || grep $_ eq $tempkey, @{$pscat}) { $r->print( ' checked="checked"'); } - $r->print(' />'.($$allparms{$tempkey}=~/\S/ ? $$allparms{$tempkey} - : $tempkey) + $r->print(' />'.($$allparms{$tempkey}=~/\S/ ? + Text::Wrap::wrap('',' 'x4,$$allparms{$tempkey}) + : $tempkey) .'
'."\n"); } $r->print(''); @@ -2744,8 +2848,9 @@ sub displaymenu { # @param {string} $pschp - selected map pc, or 'all' # @param {hash reference} $maptitles - hash map id or src -> map title # @param {hash reference} $symbp - hash map pc or resource/map id -> map src.'___(all)' or resource symb +# @param {string} $parmlev - parameter level (Resource:'full', Map:'map', Course:'general') sub mapmenu { - my ($r,$allmaps,$pschp,$maptitles,$symbp)=@_; + my ($r,$allmaps,$pschp,$maptitles,$symbp,$parmlev)=@_; my %allmaps_inverted = reverse %$allmaps; my $navmap = Apache::lonnavmaps::navmap->new(); my $tree=[]; @@ -2793,7 +2898,11 @@ sub mapmenu { } } # Show it ... - $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Enclosing Map or Folder'),'','',' id="mapmenu"')); + my $rowattr = ' id="mapmenu"'; + if ($parmlev eq 'general') { + $rowattr .= ' style="display:none"'; + } + $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Enclosing Map or Folder'),'','',$rowattr)); if ((ref($tree) eq 'ARRAY') && (ref($treeinfo) eq 'HASH')) { my $icon = ''; my $whitespace = @@ -3035,19 +3144,33 @@ sub keysindisplayorder { # # @param {Apache2::RequestRec} $r - the Apache request # @param {string} $sortorder - realmstudent|studentrealm +# @param {string} $context - newoverview|overview sub sortmenu { - my ($r,$sortorder)=@_; - $r->print('

'); } # Returns a hash parameter key -> order (integer) giving the order for some parameters. @@ -3394,6 +3517,7 @@ sub assessparms { my $chome = $env{'course.'.$env{'request.course.id'}.'.home'}; my ($got_chostname,$chostname,$cmajor,$cminor); my $totalstored = 0; + my $totalskippeduser = 0; my $now = time; for (my $i=0;$i<=$#markers;$i++) { my ($needsrelease,$needsnewer,$name,$namematch); @@ -3402,6 +3526,11 @@ sub assessparms { } if ($markers[$i] =~ /\&(8|7|6|5)$/) { next if ($noeditgrp); + } elsif ($markers[$i] =~ /\&(4|3|2|1)$/) { + if ($uname eq '') { + $totalskippeduser ++; + next; + } } if ($markers[$i] =~ /\&(17|11|7|3)$/) { $namematch = 'maplevelrecurse'; @@ -3540,9 +3669,27 @@ sub assessparms { # ---------------------------------------------------------------- Done storing if ($totalstored) { $message.='

' + .&mt('Changes for [quant,_1,parameter] saved.',$totalstored) + .'
' .&mt('Changes can take up to 10 minutes before being active for all students.') .&Apache::loncommon::help_open_topic('Caching') .'

'; + } else { + $message.='

'.&mt('No parameter changes saved.').'

'; + } + if ($totalskippeduser) { + $message .= '

'; + if ($uhome eq 'no_host') { + $message .= &mt('Changes for [quant,_1,user-specific parameter] not saved because the username or ID was invalid.', + $totalskippeduser); + } elsif ($env{'form.userroles'} eq 'any') { + $message .= &mt('Changes for [quant,_1,user-specific parameter] not saved because the user does not have a course role.', + $totalskippeduser); + } else { + $message .= &mt('Changes for [quant,_1,user-specific parameter] not saved because the user is not a student.', + $totalskippeduser); + } + $message .= '

'; } } @@ -3565,7 +3712,7 @@ sub assessparms { 'date_interval','int','float','string','string_lenient', 'string_examcode','string_deeplink','string_discussvote', 'string_useslots','string_problemstatus','string_ip', - 'string_questiontype') { + 'string_questiontype','string_tex') { $r->print(''). '" name="recent_'.$item.'" />'); @@ -3573,13 +3720,20 @@ sub assessparms { # ----- Start Parameter Selection - # Hide parm selection? + # Hide parm selection and possibly table? + my ($tablejs,$tabledivsty); + if (((($env{'form.uname'} ne '') || ($env{'form.id'} ne '')) && ($uname eq '')) && + ($env{'form.dis'}) && ($pssymb eq '')) { + $tablejs = 'document.getElementById('."'parmtable'".').style.display = "";'; + $tabledivsty = ' style="display:none"'; + } $r->print(< // @@ -3606,7 +3760,7 @@ ENDPARMSELSCRIPT $r->print(&Apache::lonhtmlcommon::start_pick_box(undef,'parmlevel')); &levelmenu($r,\%alllevs,$parmlev); $r->print(&Apache::lonhtmlcommon::row_closure()); - &mapmenu($r,\%allmaps,$pschp,\%maptitles, \%symbp); + &mapmenu($r,\%allmaps,$pschp,\%maptitles,\%symbp,$parmlev); $r->print(&Apache::lonhtmlcommon::row_closure()); $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Parts to View'))); &partmenu($r,\%allparts,\@psprt); @@ -3686,6 +3840,7 @@ ENDPARMSELSCRIPT if ($parm_permission->{'edit'}) { undef($readonly); } + $r->print('
'); if ($parmlev eq 'full') { # @@ -3902,7 +4057,7 @@ ENDTABLEHEADFOUR #-------------------------------------------- for each map, gather information my $mapid; - foreach $mapid (sort {$maplist{$a} cmp $maplist{$b}} keys(%maplist)) { + foreach $mapid (sort { $a <=> $b } keys(%maplist)) { my $maptitle = $maplist{$mapid}; #----------------------- loop through ids and get all parameter types for map @@ -4119,6 +4274,7 @@ ENDMAPONE .'' ); } # end of $parmlev eq general + $r->print('
'); } $r->print(''); if ($numreclinks) { @@ -4317,6 +4473,8 @@ sub storedata { if ($thiskey =~ /\.retrypartial$/) { $name = 'retrypartial'; } + } elsif ($typeof eq 'string_tex') { + $name = 'texdisplay'; } } elsif ($cmd eq 'datepointer') { $data=&Apache::lonhtmlcommon::get_date_from_form($env{$key}); @@ -4656,9 +4814,12 @@ sub parse_listdata_key { # @param {string} $caller - name of the calling sub (overview|newoverview) # @param {hash reference} $classlist - from loncoursedata::get_classlist # @param {boolean} $readonly - true if editing not allowed +# @param {string} $parmlev - full|map +# @param {hash reference} $hash_for_realm - keys: realm, values: numeric order +# @param {string} $pschp - selected map pc, or 'all' # @returns{integer} - number of $listdata parameters processed sub listdata { - my ($r,$resourcedata,$listdata,$sortorder,$caller,$classlist,$readonly)=@_; + my ($r,$resourcedata,$listdata,$sortorder,$caller,$classlist,$readonly,$parmlev,$hash_for_realm,$pschp)=@_; # Start list output @@ -4684,6 +4845,20 @@ sub listdata { foreach my $key (sort { my ($astudent,$ares,$apart,$aparm) = &parse_listdata_key($a,$listdata); my ($bstudent,$bres,$bpart,$bparm) = &parse_listdata_key($b,$listdata); + my ($aid,$bid); + if ($caller eq 'newoverview') { + if (ref($hash_for_realm) eq 'HASH') { + if (($parmlev eq 'map') && ($pschp eq 'all')) { + my ($aurl) = ($ares =~ /^(.+\.(?:sequence|page))___\(all\)$/); + my ($burl) = ($bres =~ /^(.+\.(?:sequence|page))___\(all\)$/); + $aid = $hash_for_realm->{$aurl}; + $bid = $hash_for_realm->{$burl}; + } elsif ($parmlev eq 'full') { + $aid = $hash_for_realm->{$ares}; + $bid = $hash_for_realm->{$bres}; + } + } + } # get the numerical order for the param $aparm=$keyorder{'parameter_0_'.$aparm}; @@ -4693,7 +4868,21 @@ sub listdata { if ($sortorder eq 'realmstudent') { if ($ares ne $bres ) { - $result = ($ares cmp $bres); + if ($caller eq 'newoverview') { + if (ref($hash_for_realm) eq 'HASH') { + if (($parmlev eq 'map') && ($pschp eq 'all')) { + $result = ($aid <=> $bid); + } elsif ($parmlev eq 'full') { + $result = ($aid <=> $bid); + } else { + $result = ($ares cmp $bres); + } + } else { + $result = ($ares cmp $bres); + } + } else { + $result = ($ares cmp $bres); + } } elsif ($astudent ne $bstudent) { $result = ($astudent cmp $bstudent); } elsif ($apart ne $bpart ) { @@ -4703,7 +4892,21 @@ sub listdata { if ($astudent ne $bstudent) { $result = ($astudent cmp $bstudent); } elsif ($ares ne $bres ) { - $result = ($ares cmp $bres); + if ($caller eq 'newoverview') { + if (ref($hash_for_realm) eq 'HASH') { + if (($parmlev eq 'map') && ($pschp eq 'all')) { + $result = ($aid <=> $bid); + } elsif ($parmlev eq 'full') { + $result = ($aid <=> $bid); + } else { + $result = ($ares cmp $bres); + } + } else { + $result = ($ares cmp $bres); + } + } else { + $result = ($ares cmp $bres); + } } elsif ($apart ne $bpart ) { $result = ($apart cmp $bpart); } @@ -4783,6 +4986,12 @@ sub listdata { } if ($is_map) { my $leveltitle = &mt('Folder/Map'); + my $title = &Apache::lonnet::gettitle($mapurl); + if (ref($hash_for_realm) eq 'HASH') { + if ($hash_for_realm->{$mapurl} eq '1') { + $title = &mt('Main Content'); + } + } unless (($name eq 'hiddenresource') || ($name eq 'encrypturl')) { if ($caller eq 'newoverview') { my $altkey = $thiskey; @@ -4799,9 +5008,10 @@ sub listdata { $is_recursive = 1; } } - $realm=''.$leveltitle.': '.&Apache::lonnet::gettitle($mapurl).'
('.$mapurl.')
'; + $realm=''.$leveltitle.': '.$title.'
('.$mapurl.')
'; } elsif ($middle) { my ($map,$id,$url)=&Apache::lonnet::decode_symb($middle); + next if (($url =~ /\.(page|sequence)$/) && ($parmlev eq 'full') && ($caller eq 'newoverview')); $realm=''.&mt('Resource'). ': '.&Apache::lonnet::gettitle($middle). '
('.$url.' in '.$map.' id: '. @@ -4839,15 +5049,26 @@ sub listdata { # Ready to print # my $parmitem = &standard_parameter_names($name); + my $advice; + if (($name eq 'mapalias') && ($middle) && (!$is_map)) { + if ($middle =~ m{^uploaded/}) { + $advice = &mt('Use Course Editor to set this.'); + } else { + $advice = &mt('Use Resource Assembly Tool to set this.'); + } + $advice = '
'.$advice.''; + } $r->print(&tablestart($readonly,$is_map). &Apache::loncommon::start_data_table_row(). ''.&mt($parmitem). - ''); + ''.$advice.''); unless ($readonly) { my $disabled; if (($name eq 'availablestudent') && (($showval eq '') || ($userscope))) { $disabled = ' disabled="disabled"'; + } elsif (($name eq 'mapalias') && ($showval eq '')) { + $disabled = ' disabled="disabled"'; } $r->print(''); @@ -4880,6 +5101,8 @@ sub listdata { } elsif ($thistype =~ m/^string/) { if ($name eq 'availablestudent') { $readonly = 1; + } elsif (($name eq 'mapalias') && ($showval eq '')) { + $readonly = 1; } $r->print(&string_selector($thistype,$thiskey, $showval,$name,$readonly)); @@ -4923,13 +5146,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$/) && @@ -4948,6 +5175,7 @@ sub get_date_interval_from_form { $seconds .= '_'.$env{'form.done_'.$key.'_proctorkey'}; } } + return if (!$numnotnull); return $seconds; } @@ -5035,9 +5263,13 @@ sub string_ip_selector { 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'); + my (@tables,%values,@current,%titles,%options,%optiontext,%defaults, + %selectnull,%domlti,%crslti,@possmenus,%components); + @tables = ('upper','lower'); + %components = ( + upper => ['state','others','listing','scope'], + lower => ['protect','menus','target','exit'], + ); %titles = &Apache::lonlocal::texthash ( state => 'Access status', others => 'Hide other resources', @@ -5045,6 +5277,8 @@ sub string_deeplink_selector { scope => 'Access scope for link', protect => 'Link protection', menus => 'Menu Items Displayed', + target => 'Embedded?', + exit => 'Exit Tool Button?', ); %options = ( state => ['only','off','both'], @@ -5053,6 +5287,8 @@ sub string_deeplink_selector { scope => ['res','map','rec'], protect => ['none','key','ltid','ltic'], menus => ['std','colls'], + target => ['_self','_top'], + exit => ['no','yes','url'], ); %optiontext = &Apache::lonlocal::texthash ( only => 'deep only', @@ -5074,6 +5310,11 @@ sub string_deeplink_selector { ltid => 'LTI access (domain)' , std => 'Standard (all menus)', colls => 'Numbered collection', + _self => 'Embedded', + _top => 'Not embedded', + no => 'Not in use', + yes => 'In use, no URL redirect', + url => 'In use, redirect to URL', ); %selectnull = &Apache::lonlocal::texthash ( ltic => 'Select Launcher', @@ -5089,6 +5330,8 @@ 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)$/); + ($values{'exit'}) = ($current[7] =~ /^((?:(?:yes|url)(?:|\:[^:;"',]+))|no)$/); } else { $defaults{'state'} = 'off', $defaults{'others'} = 'unhide', @@ -5096,6 +5339,8 @@ sub string_deeplink_selector { $defaults{'scope'} = 'res'; $defaults{'protect'} = 'none'; $defaults{'menus'} = '0'; + $defaults{'target'} = '_top'; + $defaults{'exit'} = 'yes'; } my $disabled; if ($readonly) { @@ -5103,7 +5348,8 @@ sub string_deeplink_selector { } my %courselti = &Apache::lonnet::get_course_lti($env{'course.'.$env{'request.course.id'}.'.num'}, - $env{'course.'.$env{'request.course.id'}.'.domain'}); + $env{'course.'.$env{'request.course.id'}.'.domain'}, + 'provider'); foreach my $item (keys(%courselti)) { if (ref($courselti{$item}) eq 'HASH') { $crslti{$item} = $courselti{$item}{'name'}; @@ -5111,12 +5357,10 @@ sub string_deeplink_selector { } my %lti = &Apache::lonnet::get_domain_lti($env{'course.'.$env{'request.course.id'}.'.domain'}, - 'provider'); + 'linkprot'); foreach my $item (keys(%lti)) { - if (ref($lti{$item}) eq 'HASH') { - unless ($lti{$item}{'requser'}) { - $domlti{$item} = $lti{$item}{'consumer'}; - } + if (($item =~ /^\d+$/) && (ref($lti{$item}) eq 'HASH')) { + $domlti{$item} = $lti{$item}{'name'}; } } if ($env{'course.'.$env{'request.course.id'}.'.menucollections'}) { @@ -5128,119 +5372,144 @@ sub string_deeplink_selector { } } - my $output = ''; - foreach my $item (@components) { - $output .= ''; - } - $output .= ''; - foreach my $item (@components) { - $output .= ''; } - $output .= '
'.$titles{$item}.'
'; - if (($item eq 'protect') || ($item eq 'menus')) { - my $selected = $values{$item}; - foreach my $option (@{$options{$item}}) { - if ($item eq 'protect') { - if ($option eq 'ltid') { - next unless (keys(%domlti)); - } elsif ($option eq 'ltic') { - next unless (keys(%crslti)); - } - } elsif (($item eq 'menus') && ($option eq 'colls')) { - next unless (@possmenus); - } - my $checked; - if ($item eq 'menus') { - if (($selected =~ /^\d+$/) && (@possmenus) && - (grep(/^\Q$selected\E$/,@possmenus))) { - if ($option eq 'colls') { + my $output = ''; + foreach my $table ('upper','lower') { + next unless (ref($components{$table}) eq 'ARRAY'); + $output .= ''; + foreach my $item (@{$components{$table}}) { + $output .= ''; + } + $output .= ''; + foreach my $item (@{$components{$table}}) { + $output .= ''; + } + $output .= '
'.$titles{$item}.'
'; + if (($item eq 'protect') || ($item eq 'menus') || ($item eq 'exit')) { + my $selected = $values{$item}; + foreach my $option (@{$options{$item}}) { + if ($item eq 'protect') { + if ($option eq 'ltid') { + next unless (keys(%domlti)); + } elsif ($option eq 'ltic') { + next unless (keys(%crslti)); + } + } elsif (($item eq 'menus') && ($option eq 'colls')) { + next unless (@possmenus); + } + my $checked; + if ($item eq 'menus') { + if (($selected =~ /^\d+$/) && (@possmenus) && + (grep(/^\Q$selected\E$/,@possmenus))) { + if ($option eq 'colls') { + $checked = ' checked="checked"'; + } + } elsif (($option eq 'std') && ($selected == 0) && ($selected ne '')) { $checked = ' checked="checked"'; } - } elsif (($option eq 'std') && ($selected == 0) && ($selected ne '')) { + } elsif ($selected =~ /^\Q$option\E/) { $checked = ' checked="checked"'; } - } elsif ($selected =~ /^\Q$option\E/) { - $checked = ' checked="checked"'; - } - my $onclick; - unless ($readonly) { - my $esc_key = &js_escape($thiskey); - $onclick = ' onclick="toggleDeepLink(this.form,'."'$item','$esc_key'".');"'; - } - $output .= ''; - if (($item eq 'protect') && ($option eq 'key')) { - my $visibility="hidden"; - my $currkey; - if ($checked) { - $visibility = "text"; - $currkey = (split(/\:/,$values{$item}))[1]; - } - $output .= ' '. - ''; - } elsif (($option eq 'ltic') || ($option eq 'ltid') || ($option eq 'colls')) { - my $display="none"; - my ($current,$blankcheck,@possibles); - if ($checked) { - $display = 'inline-block'; - if (($option eq 'ltic') || ($option eq 'ltid')) { - $current = (split(/\:/,$selected))[1]; + my $onclick; + unless ($readonly) { + my $esc_key = &js_escape($thiskey); + $onclick = ' onclick="toggleDeepLink(this.form,'."'$item','$esc_key'".');"'; + } + $output .= ''; + if (($item eq 'protect') && ($option eq 'key')) { + my $visibility="hidden"; + my $currkey; + if ($checked) { + $visibility = "text"; + $currkey = (split(/\:/,$values{$item}))[1]; + } + $output .= ' '. + ''; + } elsif (($option eq 'ltic') || ($option eq 'ltid') || ($option eq 'colls')) { + my $display="none"; + my ($current,$blankcheck,@possibles); + if ($checked) { + $display = 'inline-block'; + if (($option eq 'ltic') || ($option eq 'ltid')) { + $current = (split(/\:/,$selected))[1]; + } else { + $current = $selected; + } } else { - $current = $selected; + $blankcheck = ' selected="selected"'; } - } else { - $blankcheck = ' selected="selected"'; - } - if ($option eq 'ltid') { - @possibles = keys(%domlti); - } elsif ($option eq 'ltic') { - @possibles = keys(%crslti); - } else { - @possibles = @possmenus; - } - $output .= '
 '; + if (@possibles > 1) { + $output .= ''."\n"; + } + foreach my $poss (sort { $a <=> $b } @possibles) { + my $selected; + if (($poss == $current) || (scalar(@possibles) ==1)) { + $selected = ' selected="selected"'; + } + my $shown = $poss; + if ($option eq 'ltid') { + $shown = $domlti{$poss}; + } elsif ($option eq 'ltic') { + $shown = $crslti{$poss}; + } + $output .= ''; + } + $output .= '
'; + } + $output .= '
'; + } + if ($item eq 'exit') { + my $exitsty = 'none'; + my $displayval; + if ($values{$item} =~ /^(yes|url)/) { + $exitsty = 'inline-block'; + my $currval = (split(/\:/,$values{$item}))[1]; + if ($currval eq '') { + $displayval = 'Exit Tool'; + } else { + $displayval = $currval; } - $output .= ''; } - $output .= ''; - } - $output .= '
'; - } - } else { - my $selected = $values{$item}; - my $defsel; - if ($selected eq '') { - $defsel = ' selected="selected"'; - } - $output .= ''; } - $output .= '>'.$optiontext{$option}.''; - } - $output .= ''; + } else { + my $selected = $values{$item}; + my $defsel; + if ($selected eq '') { + $defsel = ' selected="selected"'; + } + $output .= ''; + } + $output .= '
'."\n"; + if ($table eq 'upper') { + $output .= '
'; } - $output .= '
'."\n"; return $output; } @@ -5279,7 +5548,10 @@ 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, embedding, and exit link']], + 'string_tex' + => [['tth', 'tth (TeX to HTML)'], + ['mathjax', 'MathJax']], ); @@ -5290,7 +5562,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),(yes|url|no)(|:[^:;\'",]+)$']], ); my %stringtypes = ( @@ -5301,6 +5573,7 @@ my %stringtypes = ( examcode => 'string_examcode', acc => 'string_ip', deeplink => 'string_deeplink', + texdisplay => 'string_tex', ); # Returns the possible values and titles for a given string type, or undef if there are none. @@ -5361,6 +5634,7 @@ sub string_selector { ($thistype eq 'string_discussvote') || ($thistype eq 'string_ip') || ($thistype eq 'string_deeplink') || + ($thistype eq 'string_tex') || ($name eq 'retrypartial')) { my ($got_chostname,$chostname,$cmajor,$cminor); foreach my $possibilities (@{ $strings{$thistype} }) { @@ -5610,6 +5884,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); @@ -5617,29 +5896,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; @@ -5656,7 +5935,8 @@ sub date_interval_selector { '&').'"'.$disabled.' />

'. ''.&mt('Button text').': '. - '&').'"'.$disabled.' />'; + '&').'"'.$disabled.' />
'; } } unless ($readonly) { @@ -5909,10 +6189,8 @@ ENDOVER $r->print('
'); $r->print(&Apache::lonhtmlcommon::start_pick_box(undef,'parmlevel')); &levelmenu($r,\%alllevs,$parmlev); - if ($parmlev ne 'general') { - $r->print(&Apache::lonhtmlcommon::row_closure()); - &mapmenu($r,\%allmaps,$pschp,\%maptitles,\%symbp); - } + $r->print(&Apache::lonhtmlcommon::row_closure()); + &mapmenu($r,\%allmaps,$pschp,\%maptitles,\%symbp,$parmlev); $r->print(&Apache::lonhtmlcommon::row_closure(1)); $r->print(&Apache::lonhtmlcommon::end_pick_box()); $r->print('
'); @@ -5950,7 +6228,7 @@ ENDOVER $r->print('
'); my $sortorder=$env{'form.sortorder'}; unless ($sortorder) { $sortorder='realmstudent'; } - &sortmenu($r,$sortorder); + &sortmenu($r,$sortorder,'newoverview'); $r->print('
'); $r->print('

'); @@ -5975,7 +6253,15 @@ ENDOVER # List data - &listdata($r,$resourcedata,$listdata,$sortorder,'newoverview',undef,$readonly); + my $hash_for_realm; + if (($parmlev eq 'map') && (keys(%allmaps))) { + %{$hash_for_realm} = reverse(%allmaps); + } elsif (($parmlev eq 'full') && (keys(%symbp))) { + for (my $i=0; $i<@ids; $i++) { + $hash_for_realm->{$symbp{$ids[$i]}} = $i; + } + } + &listdata($r,$resourcedata,$listdata,$sortorder,'newoverview',undef,$readonly,$parmlev,$hash_for_realm,$pschp); } $r->print(&tableend()); unless ($readonly) { @@ -6082,7 +6368,7 @@ sub overview { my $sortorder=$env{'form.sortorder'}; unless ($sortorder) { $sortorder='realmstudent'; } - &sortmenu($r,$sortorder); + &sortmenu($r,$sortorder,'overview'); my $submitbutton = '';