--- loncom/interface/loncourserespicker.pm 2013/01/14 18:47:14 1.4 +++ loncom/interface/loncourserespicker.pm 2013/11/13 01:40:07 1.8 @@ -1,6 +1,6 @@ # The LearningOnline Network # -# $Id: loncourserespicker.pm,v 1.4 2013/01/14 18:47:14 bisitz Exp $ +# $Id: loncourserespicker.pm,v 1.8 2013/11/13 01:40:07 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -37,7 +37,8 @@ loncourserespicker provides an interface resources are to be either: (a) exported to an IMS Content Package -(b) subject to access blocking for the duriation of an exam/quiz. +(b) subject to access blocking for the duriation of an exam/quiz. +(c) dumped to an Authoring Space =head1 DESCRIPTION @@ -50,8 +51,8 @@ window used to display the Course Conten =head1 OVERVIEW The main subroutine: &create_picker() will display the hierarchy of folders, -sub-folders, and resources in the Main Course Documents area. Items can be -selected using checkboxes, and/or a "Check All" button. Selection of a folder +sub-folders, and resources in the Main Content area. Items can be selected +using checkboxes, and/or a "Check All" button. Selection of a folder causes the contents of the folder to also be selected automatically. The propagation of check status is recursive into sub-folders. Likewise, if an item deep in a nested set of folders and sub-folders is unchecked, the @@ -59,11 +60,11 @@ uncheck will propagate up through the hi a higher level to become unchecked. There is a submit button, which will be named differently according to the -content in which resource/folder selection is being made. +context in which resource/folder selection is being made. -The two contexts currently supported are: IMS export and selection of +The three contexts currently supported are: IMS export, selection of content to be subject to access restructions for the duration of an -exam. +exam, and selection of items for dumping to an Authoring Space. =head1 INTERNAL SUBROUTINES @@ -74,7 +75,7 @@ select items. Checking a folder causes within the folder. Unchecking a resource causing unchecking of folders containing the item back up to the top level. -Inputs: 7. +Inputs: 9. - $navmap -- Reference to LON-CAPA navmap object (encapsulates information about resources in the course). @@ -95,6 +96,17 @@ Inputs: 7. - $block -- An internal ID (integer) used to track which exam block currently being configured. + - $preamble -- HTML form elements used to select Authoring Space + if more than one available, and also set name of 'Folder + in Authoring Space' where content will be dumped, when + context is 'dumpdocs'. + + - $numhome -- number of possible Authoring Spaces where content could + be dumped when context is 'dumpdocs'. + + - $uploadedfiles -- Reference to hash: keys are paths to files in + /home/httpd/lonUsers/$cdom/$1/$2/$3/$cnum/userfiles. + Output: $output is the HTML mark-up for display/selection of content items in the pop-up window. @@ -111,7 +123,7 @@ Inputs: 7. - $numcount -- Total numer of folders and resources in course. - $context -- Context in which resources are being displayed - (imsexport or examblock). + (imsexport, examblock or dumpdocs). - $formname -- Name of form. @@ -121,7 +133,7 @@ Inputs: 7. - $checked_maps -- Reference to array of folders currently checked. -Output: 1. Javascript (witthin tags. +Output: 1. Javascript (within tags. =item &get_navmap_object() @@ -132,7 +144,48 @@ no object instantiated. Inputs: 2. - $crstype -- Container type: Course or Community - - $context -- Context: imsexport or examblock + - $context -- Context: imsexport, examblock or dumpdocs + + +=item &clean() + +Takes incoming title and replaces non-alphanumeric characters with underscore, +so title can be used as suggested file name (with appended extension) for file +copied from course to Authoring space. + + +=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 +(a) storage of lists of maps or resources to be blocked during an exam, +(b) processing selected form element during dumping of selected course + content to Authoring space. + +Inputs: 7 + + $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 + + $title_ref - reference to hash containing titles for items in + course + + $context - examblock or dumpdocs + + $cdom - course's domain + + $cnum - courseID + +Outputs: None + +Side Effects: $map_url and $resource_symb hashrefs are populated. + =over @@ -153,15 +206,17 @@ use Apache::lonlocal; use LONCAPA qw(:DEFAULT :match); sub create_picker { - my ($navmap,$context,$formname,$crstype,$blockedmaps,$blockedresources,$block) = @_; + my ($navmap,$context,$formname,$crstype,$blockedmaps,$blockedresources,$block,$preamble,$numhome,$uploadedfiles) = @_; return unless (ref($navmap)); - my ($it,$output,$numdisc,%maps,%resources,%discussiontime,%currmaps,%currresources); + my ($it,$output,$numdisc,%maps,%resources,%discussiontime,%currmaps,%currresources,%files); $it = $navmap->getIterator(undef,undef,undef,1,undef,undef); if (ref($blockedmaps) eq 'HASH') { %currmaps = %{$blockedmaps}; } if (ref($blockedresources) eq 'HASH') { %currresources = %{$blockedresources}; + } elsif (ref($uploadedfiles) eq 'HASH') { + %files = %{$uploadedfiles}; } my @checked_maps; my $curRes; @@ -174,42 +229,43 @@ sub create_picker { my %children = (); my %hierarchy = (); my $location=&Apache::loncommon::lonhttpdurl("/adm/lonIcons"); - my $whitespace = + my $whitespace = ''; - my $onsubmit; + my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + my $crsprefix = &propath($cdom,$cnum).'/userfiles/'; + + my ($info,$display,$onsubmit,$togglebuttons); if ($context eq 'examblock') { my $maps_elem = 'docs_maps_'.$block; my $res_elem = 'docs_resources_'.$block; $onsubmit = ' onsubmit="return writeToOpener('."'$maps_elem','$res_elem'".');"'; + $info = &mt('Items in '.lc($crstype).' for which access will be blocked.'); } - my $display = - '
'; - my $numcount = $count + $boards + $startcount; + $display .= ''; my $scripttag = &respicker_javascript($startcount,$numcount,$context,$formname,\%children, \%hierarchy,\@checked_maps); + if ($context eq 'dumpdocs') { + return $scripttag.$display; + } my ($title,$crumbs,$args); - if ($context eq 'imsexport') { + if ($context eq 'imsexport') { $title = 'Export '.$crstype.' to IMS Package'; } elsif ($context eq 'examblock') { $title = 'Resources with Access blocked'; @@ -361,6 +483,9 @@ sub create_picker { if ($context eq 'imsexport') { $output .= &Apache::lonhtmlcommon::breadcrumbs('IMS Export'). &Apache::londocs::startContentScreen('tools'); + } elsif ($context eq 'dumpdocs') { + $output .= &Apache::lonhtmlcommon::breadcrumbs('Copying to Authoring Space'). + &Apache::londocs::startContentScreen('tools'); } $output .= $display; if ($context eq 'examblock') { @@ -376,6 +501,15 @@ sub respicker_javascript { $checked_maps) = @_; return unless ((ref($children) eq 'HASH') && (ref($hierarchy) eq 'HASH') && (ref($checked_maps) eq 'ARRAY')); + my ($elem,$nested,$nameforelem); + if ($context eq 'dumpdocs') { + $elem='((parseInt(item)-'.$startcount.')*2)+'.$startcount; + $nested='((parseInt(nesting[item][i])-'.$startcount.')*2)+'.$startcount; + $nameforelem=$elem+1; + } else { + $elem='parseInt(item)'; + $nested='parseInt(nesting[item][i])'; + } my $scripttag = <<"START";