--- loncom/interface/lonblockingmenu.pm 2012/04/04 21:04:56 1.5 +++ loncom/interface/lonblockingmenu.pm 2014/02/28 19:20:05 1.11 @@ -2,7 +2,7 @@ # Routines for configuring blocking of access to collaborative functions, # and specific resources during an exam # -# $Id: lonblockingmenu.pm,v 1.5 2012/04/04 21:04:56 raeburn Exp $ +# $Id: lonblockingmenu.pm,v 1.11 2014/02/28 19:20:05 bisitz Exp $ # # Copyright Michigan State University Board of Trustees # @@ -87,7 +87,7 @@ it is important to use reasonable time w the case of blocks triggered by clicking a button to start a timed quiz, quiz durations that are of limited duration. This is especially important when blocking prtfolio access, as other courses may require students to use -the portfolio as a mechanism for submitting assigments. +the portfolio as a mechanism for submitting assignments. Information about blocks in a course will be cached for 10 minutes, so, as with parameters set for resources, it can take up to 10 minutes for @@ -135,27 +135,6 @@ Outputs: 2 $output - Information about changes made. -=item &enumerate_course_contents() - -Create hashes of maps (for folders/pages) and symbs (for resources) in -a course, where keys are numbers (starting with 1) and values are -map url, or symb, for an iteration through the course, as seen by -a Course Coordinator. Used to generate numerical IDs to facilitate -storage of lists of maps or resources to be blocked during an exam. - -Inputs: 3 - $navmap - navmaps object - - $map_url - reference to hash to contain URLs of maps in course - - $resource_symb - reference to hash to contain symbs for - resources in course - -Outputs: None - -Side Effects: $map_url and $resource_symb hashrefs are populated. - - =item &get_dates_from_form() Extract start and end dates from web form input for blocks with @@ -238,23 +217,6 @@ Output: None Side Effects: prints web form elements (in a table) for current blocks. -=item &path_to_trigger() - -Provides hierarchy of names of folders/sub-folders containing the current -item identified as an item with an interval timer set, to be used as a -trigger. - -Inputs: 3 - - $navmap - navmaps object - - - $map - url for map (either the trigger itself, or map containing - the resource, which is the trigger). - - - $type - type of trigger: map or resource. - -Outputs: 1 @pathitems - array of folder/subfolder names. - - =item &convlim() Convert a time interval used for a timed quiz (in seconds) to @@ -405,6 +367,7 @@ use Apache::Constants qw(:common :http); use Apache::loncommon(); use Apache::lonhtmlcommon(); use Apache::lonparmset(); +use Apache::loncourserespicker(); use HTML::Entities(); use Apache::lonlocal; use lib '/home/httpd/lib/perl/'; @@ -506,7 +469,7 @@ sub handler { } &Apache::lonhtmlcommon::add_breadcrumb ({href=>'/adm/setblock', - text=>'Blocking communication/resource access'}); + text=>'Blocking communication/content access'}); my $js = &blockingmenu_javascript($blockcount); @@ -515,7 +478,6 @@ sub handler { &Apache::lonhtmlcommon::breadcrumbs('Blocking communication/content access')); my $usertype; - my $crstype = &Apache::loncommon::course_type(); if ($crstype eq 'Community') { $usertype = 'members'; } else { @@ -526,7 +488,7 @@ sub handler { 'cbds' => 'Blocking communication and/or content access during exams', 'prev' => "For the duration of an exam, or a timed quiz, students in this course can be prevented from:", 'blca' => "Blocks can potentially interrupt legitimate communication between $usertype who are also both enrolled in a different LON-CAPA $lctype.", - 'pobl' => "Portfolio blocking can impact a student's ability to complete assigments in courses besides your own. Please use this feature wisely.", + 'pobl' => "Portfolio blocking can impact a student's ability to complete assignments in courses besides your own. Please use this feature wisely.", 'actt' => "Action to take:", 'addn' => 'Add new blocking event', 'mexb' => 'Modify existing blocking event(s)', @@ -565,6 +527,7 @@ sub handler { '
  • '.&mt("displaying LON-CAPA messages sent by other $usertype in the $lctype").'
  • '."\n". '
  • '.&mt("displaying or posting to LON-CAPA discussion boards or live chat in the $lctype").'
  • '."\n". '
  • '.&mt('accessing content in LON-CAPA portfolios or blogs').'
  • '."\n". + '
  • '.&mt("generating printouts of $lctype content").'
  • '. '
  • '.&mt("accessing $lctype content in specified folders or resources").'
  • '. ''. '

    '.$lt{'blca'}.'
    '.$lt{'pobl'}.'

    ' @@ -681,7 +644,7 @@ sub blockstore { my $changestotal = 0; my $addtimer = 0; my %blocking = (); - my (%map_url,%resource_symb,$output); + my (%map_url,%resource_symb,%titles,$output); $output = '

    '.$lt{'head'}.'

    '; if ($env{'form.blockaction'} eq 'modify') { foreach my $envkey (keys(%env)) { @@ -707,7 +670,7 @@ sub blockstore { $output = $lt{'unna'}.' '.$lt{'ncwm'}.'
    '; return ($changestotal,$output); } - &enumerate_course_contents($navmap,\%map_url,\%resource_symb); + &Apache::loncourserespicker::enumerate_course_contents($navmap,\%map_url,\%resource_symb,\%titles,'examblock'); foreach my $key (keys(%removals)) { my $hashkey = $env{'form.key_'.$key}; &Apache::lonnet::del('comm_block',["$hashkey"], @@ -817,34 +780,6 @@ sub blockstore { return ($changestotal,$output); } -sub enumerate_course_contents { - my ($navmap,$map_url,$resource_symb) = @_; - if ((ref($navmap)) && (ref($map_url) eq 'HASH') && - (ref($resource_symb) eq 'HASH')) { - my $it = $navmap->getIterator(undef,undef,undef,1,undef,undef); - my $count = 0; - while (my $curRes = $it->next()) { - if (ref($curRes)) { - $count ++; - my $symb = $curRes->symb(); - my $ressymb = $symb; - if ($ressymb =~ m|adm/($match_domain)/($match_username)/(\d+)/bulletinboard$|) { - unless ($ressymb =~ m|adm/wrapper/adm|) { - $ressymb = 'bulletin___'.$3.'___adm/wrapper/adm/'.$1.'/'.$2.'/'.$3. - '/bulletinboard'; - } - } - if (($curRes->is_sequence()) || ($curRes->is_page())) { - $map_url->{$count} = (&Apache::lonnet::decode_symb($symb))[2]; - } else { - $resource_symb->{$count} = $ressymb; - } - } - } - } - return; -} - sub get_dates_from_form { my $item = shift; my $startdate = &Apache::lonhtmlcommon::get_date_from_form('startdate_'.$item); @@ -933,8 +868,8 @@ sub check_release_required { sub display_blocker_status { my ($r,$records,$ltext,$intervals,$navmap,$errormsg,$blockcount) = @_; my $parmcount = 0; - my (%map_url,%resource_symb,%lookups); - &enumerate_course_contents($navmap,\%map_url,\%resource_symb); + my (%map_url,%resource_symb,%titles,%lookups); + &Apache::loncourserespicker::enumerate_course_contents($navmap,\%map_url,\%resource_symb,\%titles,'examblock'); %{$lookups{'maps'}} = reverse(%map_url); %{$lookups{'resources'}} = reverse(%resource_symb); my %lt = &Apache::lonlocal::texthash( @@ -1128,49 +1063,8 @@ END return; } -sub path_to_trigger { - my ($navmap,$map,$type) = @_; - my @pathitems; - if (ref($navmap)) { - my $mapres = $navmap->getResourceByUrl($map); - if (ref($mapres)) { - my $pcslist = $mapres->map_hierarchy(); - if ($pcslist ne '') { - my @pcs = split(/,/,$pcslist); - foreach my $pc (@pcs) { - if ($pc == 1) { - push(@pathitems,&mt('Main Course Documents')); - } else { - my $res = $navmap->getByMapPc($pc); - if (ref($res)) { - my $title = $res->compTitle(); - $title =~ s/\W+/_/g; - if ($title ne '') { - push(@pathitems,$title); - } - } - } - } - } - } - if ($type eq 'resource') { - if ($mapres->{ID} eq '0.0') { - push(@pathitems,&mt('Main Course Documents')); - } else { - my $maptitle = $mapres->compTitle(); - $maptitle =~ s/\W+/_/g; - if ($maptitle ne '') { - push(@pathitems,$maptitle); - } - } - } - } - return @pathitems; -} - sub convlim { my ($timelimit) = @_; - my $output; my @order = ('days','hours','minutes','seconds'); my %catlimits = ( days => 86400, @@ -1180,13 +1074,15 @@ sub convlim { my @toshow; foreach my $cat (@order) { if ($cat eq 'seconds') { - last if ($timelimit <= 0); + if ($timelimit > 0) { + push(@toshow,&mt("[_1] $cat",$timelimit)); + } } elsif ($timelimit >= $catlimits{$cat}) { my $val = int($timelimit/$catlimits{$cat}); if ($val > 0) { push(@toshow,&mt("[_1] $cat",$val)); } - $timelimit =- $val*$catlimits{$cat}; + $timelimit -= $val*$catlimits{$cat}; } } my $output = join(', ',@toshow); @@ -1457,10 +1353,12 @@ sub show_timer_path { return unless(ref($navmap)); my @pathitems; if ($type eq 'map') { - @pathitems = &path_to_trigger($navmap,$item,$type); + @pathitems = + &Apache::loncommon::get_folder_hierarchy($navmap,$item); } elsif ($type eq 'resource') { my ($map,$id,$resource) = &Apache::lonnet::decode_symb($item); - @pathitems = &path_to_trigger($navmap,$map,$type); + @pathitems = + &Apache::loncommon::get_folder_hierarchy($navmap,$map,1); } if (@pathitems) { return join(' » ',@pathitems);