$text";
}
# Add the graphic
my $title = &mt('Online Help');
- my $helpicon=&lonhttpdurl("/res/adm/pages/help.png");
+ my $helpicon=&lonhttpdurl("/adm/help/help.png");
$template .= <<"ENDTEMPLATE";
ENDTEMPLATE
- if ($text ne '') { $template.='
' };
+ if ($text ne '') { $template.='' };
return $template;
}
@@ -904,6 +957,9 @@ sub helpLatexCheatsheet {
.'
');
- foreach my $line (0..2) {
+ foreach my $line (0..($max_samples-1)) {
if (defined($samples->[$line]{$key})) {
$r->print($samples->[$line]{$key}." \n");
}
@@ -8007,8 +8637,10 @@ sub build_recipient_list {
} elsif ($origmail ne '') {
push(@recipients,$origmail);
}
- if ($defmail ne '') {
- push(@recipients,$defmail);
+ if (defined($defmail)) {
+ if ($defmail ne '') {
+ push(@recipients,$defmail);
+ }
}
if ($otheremails) {
my @others;
@@ -8044,11 +8676,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).
@@ -8091,17 +8727,26 @@ 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).
+subcats (reference to hash of arrays containing all subcategories within each
+ category, -recursive)
+
Returns: nothing
Side effects: populates trails and allitems hash references.
@@ -8109,7 +8754,7 @@ Side effects: populates trails and allit
=cut
sub extract_categories {
- my ($categories,$cats,$trails,$allitems,$idx,$jsarray) = @_;
+ my ($categories,$cats,$trails,$allitems,$idx,$jsarray,$subcats) = @_;
if (ref($categories) eq 'HASH') {
&gather_categories($categories,$cats,$idx,$jsarray);
if (ref($cats->[0]) eq 'ARRAY') {
@@ -8130,7 +8775,14 @@ sub extract_categories {
if (ref($cats->[1]{$name}) eq 'ARRAY') {
for (my $j=0; $j<@{$cats->[1]{$name}}; $j++) {
my $category = $cats->[1]{$name}[$j];
- &recurse_categories($cats,2,$category,$trails,$allitems,\@parents);
+ if (ref($subcats) eq 'HASH') {
+ push(@{$subcats->{$item}},&escape($category).':'.&escape($name).':1');
+ }
+ &recurse_categories($cats,2,$category,$trails,$allitems,\@parents,$subcats);
+ }
+ } else {
+ if (ref($subcats) eq 'HASH') {
+ $subcats->{$item} = [];
}
}
}
@@ -8146,13 +8798,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).
@@ -8160,12 +8818,10 @@ Returns: nothing
Side effects: populates trails and allitems hash references
-=back
-
=cut
sub recurse_categories {
- my ($cats,$depth,$category,$trails,$allitems,$parents) = @_;
+ my ($cats,$depth,$category,$trails,$allitems,$parents,$subcats) = @_;
my $shallower = $depth - 1;
if (ref($cats->[$depth]{$category}) eq 'ARRAY') {
for (my $k=0; $k<@{$cats->[$depth]{$category}}; $k++) {
@@ -8178,7 +8834,21 @@ sub recurse_categories {
}
my $deeper = $depth+1;
push(@{$parents},$category);
- &recurse_categories($cats,$deeper,$name,$trails,$allitems,$parents);
+ if (ref($subcats) eq 'HASH') {
+ my $subcat = &escape($name).':'.$category.':'.$depth;
+ for (my $j=@{$parents}; $j>=0; $j--) {
+ my $higher;
+ if ($j > 0) {
+ $higher = &escape($parents->[$j]).':'.
+ &escape($parents->[$j-1]).':'.$j;
+ } else {
+ $higher = &escape($parents->[$j]).'::'.$j;
+ }
+ push(@{$subcats->{$higher}},$subcat);
+ }
+ }
+ &recurse_categories($cats,$deeper,$name,$trails,$allitems,$parents,
+ $subcats);
pop(@{$parents});
}
} else {
@@ -8192,17 +8862,147 @@ 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 .= '