');
- foreach my $line (0..2) {
+ foreach my $line (0..($max_samples-1)) {
if (defined($samples->[$line]{$key})) {
$r->print($samples->[$line]{$key}." \n");
}
@@ -8052,11 +8272,15 @@ domain - to an array. Also generates ja
generate Domain Coordinator interface for editing Course Categories.
Inputs:
+
categories (reference to hash of category definitions).
+
cats (reference to array of arrays/hashes which encapsulates hierarchy of
categories and subcategories).
+
idx (reference to hash of counters used in Domain Coordinator interface for
editing Course Categories).
+
jsarray (reference to array of categories used to create Javascript arrays for
Domain Coordinator interface for editing Course Categories).
@@ -8099,14 +8323,20 @@ sub gather_categories {
Used to generate breadcrumb trails for course categories.
Inputs:
+
categories (reference to hash of category definitions).
+
cats (reference to array of arrays/hashes which encapsulates hierarchy of
categories and subcategories).
+
trails (reference to array of breacrumb trails for each category).
+
allitems (reference to hash - key is category key
(format: escaped(name):escaped(parent category):depth in hierarchy).
+
idx (reference to hash of counters used in Domain Coordinator interface for
editing Course Categories).
+
jsarray (reference to array of categories used to create Javascript arrays for
Domain Coordinator interface for editing Course Categories).
@@ -8154,13 +8384,19 @@ sub extract_categories {
Recursively used to generate breadcrumb trails for course categories.
Inputs:
+
cats (reference to array of arrays/hashes which encapsulates hierarchy of
categories and subcategories).
+
depth (current depth in hierarchy of categories and sub-categories - 0 indexed).
-category (current course category, for which breadcrumb trail is being generated).
-trails (reference to array of breacrumb trails for each category).
+
+category (current course category, for which breadcrumb trail is being generated).
+
+trails (reference to array of breadcrumb trails for each category).
+
allitems (reference to hash - key is category key
(format: escaped(name):escaped(parent category):depth in hierarchy).
+
parents (array containing containers directories for current category,
back to top level).
@@ -8168,8 +8404,6 @@ Returns: nothing
Side effects: populates trails and allitems hash references
-=back
-
=cut
sub recurse_categories {
@@ -8200,17 +8434,144 @@ sub recurse_categories {
return;
}
+=pod
+
+=item *&assign_categories_table()
+
+Create a datatable for display of hierarchical categories in a domain,
+with checkboxes to allow a course to be categorized.
+
+Inputs:
+
+cathash - reference to hash of categories defined for the domain (from
+ configuration.db)
+
+currcat - scalar with an & separated list of categories assigned to a course.
+
+Returns: $output (markup to be displayed)
+
+=cut
+
+sub assign_categories_table {
+ my ($cathash,$currcat) = @_;
+ my $output;
+ if (ref($cathash) eq 'HASH') {
+ my (@cats,@trails,%allitems,%idx,@jsarray,@path,$maxdepth);
+ &extract_categories($cathash,\@cats,\@trails,\%allitems,\%idx,\@jsarray);
+ $maxdepth = scalar(@cats);
+ if (@cats > 0) {
+ my $itemcount = 0;
+ if (ref($cats[0]) eq 'ARRAY') {
+ $output = &Apache::loncommon::start_data_table();
+ my @currcategories;
+ if ($currcat ne '') {
+ @currcategories = split('&',$currcat);
+ }
+ for (my $i=0; $i<@{$cats[0]}; $i++) {
+ my $parent = $cats[0][$i];
+ my $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ next if ($parent eq 'instcode');
+ my $item = &escape($parent).'::0';
+ my $checked = '';
+ if (@currcategories > 0) {
+ if (grep(/^\Q$item\E$/,@currcategories)) {
+ $checked = ' checked="checked" ';
+ }
+ }
+ $output .= '
';
+ $itemcount ++;
+ }
+ $output .= &Apache::loncommon::end_data_table();
+ }
+ }
+ }
+ return $output;
+}
+
+=pod
+
+=item *&assign_category_rows()
+
+Create a datatable row for display of nested categories in a domain,
+with checkboxes to allow a course to be categorized,called recursively.
+
+Inputs:
+
+itemcount - track row number for alternating colors
+
+cats - reference to array of arrays/hashes which encapsulates hierarchy of
+ categories and subcategories.
+
+depth - current depth in hierarchy of categories and sub-categories - 0 indexed.
+
+parent - parent of current category item
+
+path - Array containing all categories back up through the hierarchy from the
+ current category to the top level.
+
+currcategories - reference to array of current categories assigned to the course
+
+Returns: $output (markup to be displayed).
+
+=cut
+
+sub assign_category_rows {
+ my ($itemcount,$cats,$depth,$parent,$path,$currcategories) = @_;
+ my ($text,$name,$item,$chgstr);
+ if (ref($cats) eq 'ARRAY') {
+ my $maxdepth = scalar(@{$cats});
+ if (ref($cats->[$depth]) eq 'HASH') {
+ if (ref($cats->[$depth]{$parent}) eq 'ARRAY') {
+ my $numchildren = @{$cats->[$depth]{$parent}};
+ my $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ $text .= '
';
+ for (my $j=0; $j<$numchildren; $j++) {
+ $name = $cats->[$depth]{$parent}[$j];
+ $item = &escape($name).':'.&escape($parent).':'.$depth;
+ my $deeper = $depth+1;
+ my $checked = '';
+ if (ref($currcategories) eq 'ARRAY') {
+ if (@{$currcategories} > 0) {
+ if (grep(/^\Q$item\E$/,@{$currcategories})) {
+ $checked = ' checked="checked" ';
+ }
+ }
+ }
+ $text .= '