--- loncom/interface/lonblockingmenu.pm 2016/10/22 01:49:10 1.20 +++ loncom/interface/lonblockingmenu.pm 2016/10/22 02:03:31 1.21 @@ -2,7 +2,7 @@ # Routines for configuring blocking of access to collaborative functions, # and specific resources during an exam # -# $Id: lonblockingmenu.pm,v 1.20 2016/10/22 01:49:10 raeburn Exp $ +# $Id: lonblockingmenu.pm,v 1.21 2016/10/22 02:03:31 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -318,13 +318,16 @@ Creates web form elements used to select items in the course for use in an exam block of type: "Triggered by Activating Timer". -Inputs: 7 (three required, last four optional) +Inputs: 8 (four required, last four optional) - $intervals - Reference to hash of parameters for timed intervals - $parmcount - numeric ID of current block - $navmap - navmaps object + - $context - this will be "accesstimes" if called by lonaccesstimes.pm, + or "blocking" if called internally by lonblockingmenu.pm + - $currkey - current interval (where this is a block already using an interval-based trigger). @@ -339,6 +342,9 @@ Inputs: 7 (three required, last four opt Outputs: 1 - $intervalform - web form elements used to select a time interval +=item &interval_details() + + =item &trigger_details_toggle() Creates link used to expand item showing information about timer for current @@ -348,6 +354,7 @@ Inputs: 1 - $parmcount - numericID of ex Outputs: 1 - returns HTML for link to display contents of information item + =item &show_timer_path() Display hierarchy of names of folders/sub-folders containing the current @@ -392,11 +399,20 @@ Output: 1 - Javascript (with tags) for functions used to: + toggle visibility of unordered list for display of detailed + information about intervals. + =back =cut @@ -520,7 +536,8 @@ sub handler { ({href=>'/adm/setblock', text=>'Blocking communication/content access'}); - my $js = &blockingmenu_javascript($blockcount); + my $js = &blockingmenu_javascript($blockcount). + &details_javascript(); $r->print( &Apache::loncommon::start_page('Blocking communication/content access',$js). @@ -1094,7 +1111,6 @@ ACT $ltext->{'endd'}.':  '.$endform.''); } elsif ($record =~ /^firstaccess____(.+)$/) { my $item = $1; - my ($itemname,$iteminfo,$skipdetails); my $type = 'map'; my $url; if ($item eq 'course') { @@ -1106,118 +1122,8 @@ ACT $url = $item; } $r->print('
'.$ltext->{'trig'}.''); - if ($type eq 'course') { - $itemname = &mt('Timer for all items in course.'); - } else { - if (&Apache::lonnet::is_on_map($url)) { - if ($type eq 'map') { - if (ref($navmap)) { - my $title; - my $resobj = $navmap->getResourceByUrl($item); - if (ref($resobj)) { - $title = $resobj->compTitle(); - } else { - $title = &Apache::lonnet::gettitle($item); - } - $itemname = &mt('Timer for all items in folder: [_1]', - ''. - $title.''); - } - } else { - if (ref($navmap)) { - my $title; - my $resobj = $navmap->getBySymb($item); - if (ref($resobj)) { - $title = $resobj->compTitle(); - } else { - $title = &Apache::lonnet::gettitle($item); - } - $itemname = &mt('Timer for resource: [_1]', - ''. - $title.''); - } - } - if (ref($navmap)) { - my $path = &show_timer_path($type,$item); - if ($path) { - $iteminfo = ' '. - &mt('(in: [_1])',$path). - ''; - } - } - } else { - $skipdetails = 1; - $itemname = ''. - &mt('Timer folder/resource not in course'). - ''; - } - } - if ((!$skipdetails) && (ref($intervals) eq 'HASH')) { - if (ref($intervals->{$type}) eq 'HASH') { - $iteminfo .= &trigger_details_toggle($parmcount). - ''; - } - } - $r->print(&create_interval_form($intervals,$parmcount,$navmap,$item,$jschg, + my ($itemname,$iteminfo) = &interval_details($item,$type,$url,$navmap,$intervals,$parmcount); + $r->print(&create_interval_form($intervals,$parmcount,$navmap,'blocking',$item,$jschg, $itemname,$iteminfo,$disabled).'
'); } $r->print(<<"END"); @@ -1281,7 +1187,7 @@ sub display_addblocker_table { my %lt = &Apache::lonlocal::texthash( 'exam' => 'e.g., Exam 1', ); - my $intervalform = &create_interval_form($intervals,$parmcount,$navmap); + my $intervalform = &create_interval_form($intervals,$parmcount,$navmap,'blocking'); if ($intervalform ne '') { $intervalform = '
'. ''.$ltext->{'chtr'}.''. @@ -1405,9 +1311,10 @@ sub blocker_checkboxes { } sub create_interval_form { - my ($intervals,$parmcount,$navmap,$currkey,$jschg,$itemname,$iteminfo,$disabled) = @_; + my ($intervals,$parmcount,$navmap,$context,$currkey,$jschg,$itemname,$iteminfo,$disabled) = @_; return unless ((ref($intervals) eq 'HASH') && (ref($navmap))); my $intervalform; + my $counter = 0; if (keys(%{$intervals}) > 0) { foreach my $type (sort(keys(%{$intervals}))) { if ($type eq 'course') { @@ -1427,8 +1334,14 @@ sub create_interval_form { $intervalform .= ''; if ($currkey eq 'course') { $intervalform .= $iteminfo; + } elsif ($context eq 'accesstimes') { + (undef,$iteminfo) = &interval_details('course',$type,'',$navmap,$intervals,$counter); + if ($iteminfo) { + $intervalform .= ' '.$iteminfo; + } } $intervalform .= '
'; + $counter ++; } elsif ($type eq 'map') { if (ref($intervals->{$type}) eq 'HASH') { if (ref($navmap)) { @@ -1463,8 +1376,15 @@ sub create_interval_form { $intervalform .= &mt('Timer for all items in folder: [_1]', ''.$title.''). ''.$path; + if ($context eq 'accesstimes') { + (undef,$iteminfo) = &interval_details($map,$type,$map,$navmap,$intervals,$counter); + if ($iteminfo) { + $intervalform .= ' '.$iteminfo; + } + } } $intervalform .= '
'; + $counter ++; } } } @@ -1491,7 +1411,8 @@ sub create_interval_form { my ($title,$path,$hierarchy); if (ref($resobj)) { $title = $resobj->compTitle(); - } else { + } + if ($title eq '') { $title = &Apache::lonnet::gettitle($resource); } $hierarchy = &show_timer_path($type,$resource,$navmap); @@ -1503,8 +1424,19 @@ sub create_interval_form { $intervalform .= &mt('Timer for resource: [_1]',''.$title.''). ''. $path; + if ($context eq 'accesstimes') { + if (ref($resobj)) { + my $url = $resobj->src(); + if ($url eq '') { + (my $map, my $resid, $url) = &Apache::lonnet::decode_symb($resource); + } + ($itemname,$iteminfo) = &interval_details($resource,$type,$url,$navmap,$intervals,$counter); + $intervalform .= ' '.$iteminfo; + } + } } $intervalform .= '
'; + $counter ++; } } } @@ -1532,6 +1464,121 @@ sub trigger_details_toggle { 'style="text-decoration: none;">'.&mt('(More ...)').''; } +sub interval_details { + my ($item,$type,$url,$navmap,$intervals,$parmcount) = @_; + my ($itemname,$iteminfo,$skipdetails); + if ($type eq 'course') { + $itemname = &mt('Timer for all items in course.'); + } else { + if (&Apache::lonnet::is_on_map($url)) { + if ($type eq 'map') { + if (ref($navmap)) { + my $title; + my $resobj = $navmap->getResourceByUrl($item); + if (ref($resobj)) { + $title = $resobj->compTitle(); + } else { + $title = &Apache::lonnet::gettitle($item); + } + $itemname = &mt('Timer for all items in folder: [_1]', + ''. + $title.''); + } + } else { + if (ref($navmap)) { + my $title; + my $resobj = $navmap->getBySymb($item); + if (ref($resobj)) { + $title = $resobj->compTitle(); + } else { + $title = &Apache::lonnet::gettitle($item); + } + $itemname = &mt('Timer for resource: [_1]', + ''. + $title.''); + } + } + if (ref($navmap)) { + my $path = &show_timer_path($type,$item); + if ($path) { + $iteminfo = ' '. + &mt('(in: [_1])',$path). + ''; + } + } + } else { + $skipdetails = 1; + $itemname = ''. + &mt('Timer folder/resource not in course'). + ''; + } + } + if ((!$skipdetails) && (ref($intervals) eq 'HASH') && (ref($intervals->{$type}) eq 'HASH')) { + $iteminfo = &trigger_details_toggle($parmcount). + ''; + } + return ($itemname,$iteminfo); +} + sub show_timer_path { my ($type,$item,$navmap) = @_; return unless(ref($navmap)); @@ -1568,10 +1615,6 @@ sub blocktype_text { sub blockingmenu_javascript { my ($blockcount) = @_; - my %lt = &Apache::lonlocal::texthash ( - more => 'More ...', - less => 'Less ...', - ); return < // + +ENDSCRIPT + +} + +sub details_javascript { + my %lt = &Apache::lonlocal::texthash ( + more => 'More ...', + less => 'Less ...', + ); + return < +//