[LON-CAPA-cvs] cvs: loncom /interface loncommon.pm lonparmset.pm
raeburn
lon-capa-cvs-allow@mail.lon-capa.org
Thu, 28 Aug 2008 03:04:42 -0000
raeburn Wed Aug 27 23:04:42 2008 EDT
Modified files:
/loncom/interface lonparmset.pm loncommon.pm
Log:
- Hide escaped course categories from display in "Set Course Environment".
- Add hidden tags in pop-up window which contain unescaped category names.
- When choices are saved to main window, set the contents of the "readonly"
textbox to the concatenation of the selected category names
- The complete string of (escaped) full category IDs is saved to a hidden form
element.
- When echoing the saved categories to the user, show only the unescaped names
joined with ' & '.
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.405 loncom/interface/lonparmset.pm:1.406
--- loncom/interface/lonparmset.pm:1.405 Tue Jul 15 16:00:58 2008
+++ loncom/interface/lonparmset.pm Wed Aug 27 23:04:41 2008
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set parameters for assessments
#
-# $Id: lonparmset.pm,v 1.405 2008/07/15 20:00:58 raeburn Exp $
+# $Id: lonparmset.pm,v 1.406 2008/08/28 03:04:41 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -2126,6 +2126,8 @@
$setoutput.=&mt('Set').' <b>'.$name.'</b> '.&mt('to').' <b>';
if ($name =~ /^default_enrollment_(start|end)_date$/) {
$setoutput .= &Apache::lonlocal::locallocaltime($value);
+ } elsif ($name eq 'categories') {
+ $setoutput .= $env{'form.categories_display'};
} else {
$setoutput .= $value;
}
@@ -2431,6 +2433,21 @@
&Apache::loncommon::select_timezone($parameter.'_value',
$timezone,
$onchange,$includeempty).'</td>';
+ } elsif ($parameter eq 'categories') {
+ my $catdisplay;
+ if ($values{'categories'} ne '') {
+ my @curritems = split(/\&/,$values{'categories'});
+ foreach my $item (@curritems) {
+ my ($name,$parent,$pos) = split(/:/,$item);
+ $catdisplay .= &unescape($name).'&';
+ }
+ $catdisplay =~ s/\&$//;
+ }
+ $output .= '<td>'.
+ '<input type="hidden" name="categories_value" value="'.
+ $values{'categories'}.'" />'.
+ '<input type="textbox" name="categories_display" value="'.
+ $catdisplay.'" readonly="readonly" size="40" /></td>';
} else {
$output .= '<td>'.
&Apache::lonhtmlcommon::textbox($parameter.'_value',
@@ -2541,21 +2558,29 @@
function updateCategories() {
var newcategories = '';
+ var unescapedcats = '';
if (document.chgcats.usecategory.length) {
for (var i=0; i<document.chgcats.usecategory.length; i++) {
if (document.chgcats.usecategory[i].checked == true) {
newcategories = newcategories + document.chgcats.usecategory[i].value + '&';
+ alert("i is "+i+" and catname is "+document.chgcats.catname[i].value);
+ unescapedcats = unescapedcats + document.chgcats.catname[i].value + ' & ';
}
}
if (newcategories.length > 0) {
newcategories = newcategories.slice(0,-1);
}
+ if (unescapedcats.length > 0) {
+ usescapedcats = unescapedcats.slice(0,-3);
+ }
} else {
if (document.chgcats.usecategory.checked == true) {
newcategories = document.chgcats.usecategory.value;
+ unescapedcats = document.chgcats.catname.value;
}
}
opener.document.envform.categories_value.value = newcategories;
+ opener.document.envform.categories_display.value = unescapedcats;
opener.document.envform.categories_setparmval.checked = true;
alert("$alert");
self.close();
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.674 loncom/interface/loncommon.pm:1.675
--- loncom/interface/loncommon.pm:1.674 Wed Aug 13 04:17:58 2008
+++ loncom/interface/loncommon.pm Wed Aug 27 23:04:41 2008
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.674 2008/08/13 08:17:58 bisitz Exp $
+# $Id: loncommon.pm,v 1.675 2008/08/28 03:04:41 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -8511,9 +8511,10 @@
$checked = ' checked="checked" ';
}
}
- $output .= '<tr '.$css_class.'><td><span class="LC_nobreak">'
- .'<input type="checkbox" name="usecategory" value="'.
- $item.'"'.$checked.' />'.$parent.'</span></td>';
+ $output .= '<tr '.$css_class.'><td><span class="LC_nobreak">'.
+ '<input type="checkbox" name="usecategory" value="'.
+ $item.'"'.$checked.' />'.$parent.'</span>'.
+ '<input type="hidden" name="catname" value="'.$parent.'" /></td>';
my $depth = 1;
push(@path,$parent);
$output .= &assign_category_rows($itemcount,\@cats,$depth,$parent,\@path,\@currcategories);
@@ -8579,7 +8580,9 @@
}
$text .= '<tr><td><span class="LC_nobreak"><label>'.
'<input type="checkbox" name="usecategory" value="'.
- $item.'"'.$checked.' />'.$name.'</label></span></td><td>';
+ $item.'"'.$checked.' />'.$name.'</label></span>'.
+ '<input type="hidden" name="catname" value="'.$name.'" />'.
+ '</td><td>';
if (ref($path) eq 'ARRAY') {
push(@{$path},$name);
$text .= &assign_category_rows($itemcount,$cats,$deeper,$name,$path,$currcategories);