--- loncom/interface/lonblockingmenu.pm 2019/02/06 15:40:22 1.14.2.3.2.1 +++ loncom/interface/lonblockingmenu.pm 2016/10/16 21:49:51 1.19 @@ -2,7 +2,7 @@ # Routines for configuring blocking of access to collaborative functions, # and specific resources during an exam # -# $Id: lonblockingmenu.pm,v 1.14.2.3.2.1 2019/02/06 15:40:22 raeburn Exp $ +# $Id: lonblockingmenu.pm,v 1.19 2016/10/16 21:49:51 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -116,7 +116,7 @@ Outputs: 2 $readonly - true if modification of blocking events is prohibited. $allowed - true if blocking events information can be shown. - + =item &get_timed_items() @@ -252,7 +252,7 @@ Inputs: 8 - $blockcount - number of existing blocking events in course - $readonly - if true, modification not allowed. - + Output: None @@ -318,16 +318,13 @@ Creates web form elements used to select items in the course for use in an exam block of type: "Triggered by Activating Timer". -Inputs: 8 (four required, last four optional) +Inputs: 7 (three 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). @@ -342,34 +339,6 @@ Inputs: 8 (four required, last four opti Outputs: 1 - $intervalform - web form elements used to select a time interval -=item &interval_details() - -Creates name/scope of current interval and expandable/collapsible -showing which interval parameters apply to the current folder/resource - -Inputs: 6 - - - $item - course, map url, or resource symb - - - $type - course, map, or resource - - - $url - url of item (null if item is course). - - - $navmap - navmaps object - - - $intervals - Reference to hash of parameters for timed intervals - - - $parmcount - unique ID for current element. - - -Outputs: 2 - - - $itemname - name/scope of interval (timer) parameter - - - $iteminfo - Expandable/collapsible block showing which interval - (timer) parameters affect the current folder or resource. - - =item &trigger_details_toggle() Creates link used to expand item showing information about timer for current @@ -379,7 +348,6 @@ 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 @@ -424,21 +392,12 @@ Output: 1 - Javascript (with tags) for functions used to: - toggle visibility of unordered list for display of detailed - information about intervals. -=back +=back =cut @@ -527,7 +486,7 @@ sub handler { $r->print(&Apache::loncourserespicker::create_picker($navmap, 'examblock','resourceblocks',$crstype, \%blockedmaps,\%blockedresources, - $env{'form.block'},'','',undef,undef,$readonly)); + $env{'form.block'},'','',undef,$readonly)); } else { $r->print($errormsg); } @@ -561,8 +520,7 @@ sub handler { ({href=>'/adm/setblock', text=>'Blocking communication/content access'}); - my $js = &blockingmenu_javascript($blockcount). - &details_javascript(); + my $js = &blockingmenu_javascript($blockcount); $r->print( &Apache::loncommon::start_page('Blocking communication/content access',$js). @@ -628,8 +586,8 @@ sub handler { # ------------------------ Choose between modifying existing block or adding new $r->print('
'); - - unless ($readonly) { + + unless ($readonly) { if ($blockcount > 0) { $r->print(<<"END");
@@ -658,19 +616,20 @@ END &Apache::loncourserespicker::get_navmap_object($crstype,'examblock'); # --------------------------------------------- Interface for adding a new block - unless ($readonly) { + if ($readonly) { + if (!$blockcount) { + $r->print($lt{'ncbc'}.'
'); + } + } else { &display_addblocker_table($r,$blockcount,\%ltext,\%intervals, $navmap,$errormsg); if ($blockcount > 0) { $r->print('
'); } } + # ------------------------------------------------ Interface for existing blocks - if (!$blockcount) { - if ($readonly) { - $r->print($lt{'ncbc'}.'
'); - } - } else { + if ($blockcount > 0) { &display_blocker_status($r,\%records,\%ltext,\%intervals, $navmap,$errormsg,$blockcount,$readonly); } @@ -719,7 +678,7 @@ sub get_timed_items { my $resourcedata=&Apache::lonparmset::readdata($cnum,$cdom); if (ref($resourcedata) eq 'HASH') { foreach my $key (keys(%{$resourcedata})) { - if ($key =~ /^\Q$cid\E(.*)\.0\.interval$/) { + if ($key =~ /^\Q$cid\E(.+)\.0\.interval$/) { my $middle = $1; if ($middle eq '') { $intervals{'course'}{'all'} = $resourcedata->{$key}; @@ -1135,6 +1094,7 @@ ACT $ltext->{'endd'}.':  '.$endform.''); } elsif ($record =~ /^firstaccess____(.+)$/) { my $item = $1; + my ($itemname,$iteminfo,$skipdetails); my $type = 'map'; my $url; if ($item eq 'course') { @@ -1146,8 +1106,118 @@ ACT $url = $item; } $r->print('
'.$ltext->{'trig'}.''); - my ($itemname,$iteminfo) = &interval_details($item,$type,$url,$navmap,$intervals,$parmcount); - $r->print(&create_interval_form($intervals,$parmcount,$navmap,'blocking',$item,$jschg, + 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, $itemname,$iteminfo,$disabled).'
'); } $r->print(<<"END"); @@ -1211,7 +1281,7 @@ sub display_addblocker_table { my %lt = &Apache::lonlocal::texthash( 'exam' => 'e.g., Exam 1', ); - my $intervalform = &create_interval_form($intervals,$parmcount,$navmap,'blocking'); + my $intervalform = &create_interval_form($intervals,$parmcount,$navmap); if ($intervalform ne '') { $intervalform = '
'. ''.$ltext->{'chtr'}.''. @@ -1335,10 +1405,9 @@ sub blocker_checkboxes { } sub create_interval_form { - my ($intervals,$parmcount,$navmap,$context,$currkey,$jschg,$itemname,$iteminfo,$disabled) = @_; + my ($intervals,$parmcount,$navmap,$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') { @@ -1358,14 +1427,8 @@ 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)) { @@ -1400,15 +1463,8 @@ 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 ++; } } } @@ -1435,8 +1491,7 @@ sub create_interval_form { my ($title,$path,$hierarchy); if (ref($resobj)) { $title = $resobj->compTitle(); - } - if ($title eq '') { + } else { $title = &Apache::lonnet::gettitle($resource); } $hierarchy = &show_timer_path($type,$resource,$navmap); @@ -1448,19 +1503,8 @@ 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 ++; } } } @@ -1488,121 +1532,6 @@ 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)); @@ -1639,6 +1568,10 @@ 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 < -//