[LON-CAPA-cvs] cvs: loncom /interface coursecatalog.pm courseprefs.pm domainprefs.pm loncommon.pm lonconfigsettings.pm lonmodifycourse.pm
raeburn
raeburn@source.lon-capa.org
Mon, 23 Nov 2009 21:45:19 -0000
This is a MIME encoded message
--raeburn1259012719
Content-Type: text/plain
raeburn Mon Nov 23 21:45:19 2009 EDT
Modified files:
/loncom/interface coursecatalog.pm courseprefs.pm domainprefs.pm
loncommon.pm lonconfigsettings.pm
lonmodifycourse.pm
Log:
- Accommodate Communities
- Top Level Category: "Communities" defined in system
(Domain control to hide/unhide).
- Can only assign communities to this category (and its subcategories).
- Domain Coordinator definition of new top level categories:
instcode and communities are reserved for system use
(may not be used for names of additional top level categories).
--raeburn1259012719
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20091123214519.txt"
Index: loncom/interface/coursecatalog.pm
diff -u loncom/interface/coursecatalog.pm:1.56 loncom/interface/coursecatalog.pm:1.57
--- loncom/interface/coursecatalog.pm:1.56 Fri Oct 23 16:14:43 2009
+++ loncom/interface/coursecatalog.pm Mon Nov 23 21:45:18 2009
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler for displaying the course catalog interface
#
-# $Id: coursecatalog.pm,v 1.56 2009/10/23 16:14:43 bisitz Exp $
+# $Id: coursecatalog.pm,v 1.57 2009/11/23 21:45:18 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -149,13 +149,19 @@
for (my $i=0; $i<$deeper; $i++) {
$r->print('<input type="hidden" name="currcat_'.$i.'" value="'.$env{'form.currcat_'.$i}.'" />'."\n");
}
+ my $display_button;
+ if ($env{'form.currcat_0'} eq 'communities::0') {
+ $display_button = &mt('Display communities');
+ } else {
+ $display_button = &mt('Display courses');
+ }
$r->print('<input type="hidden" name="coursenum" value="" />'."\n".
'<input type="hidden" name="sortby" value="" />'."\n".
'<input type="hidden" name="state" value="listing" />'."\n".
'<input type="hidden" name="showdom" value="'.
$env{'form.showdom'}.'" />'.
'<input type="submit" name="catalogfilter" value="'.
- &mt('Display courses').'" /></form><br /><br />');
+ $display_button.'" /></form><br /><br />');
}
if ($env{'form.state'} eq 'listing') {
$r->print(&print_course_listing($codedom,undef,\@trails,\%allitems,$subcats));
@@ -325,7 +331,9 @@
my ($dom,@cats) = @_;
my $crumbsymbol = ' ▶ ';
my ($currdepth,$deeper) = &get_depth_values();
- my $currcat_str = '<input type="hidden" name="catalog_maxdepth" value="'.$deeper.'" /><input type="hidden" name="showdom" value="'.$dom.'" />';
+ my $currcat_str =
+ '<input type="hidden" name="catalog_maxdepth" value="'.$deeper.'" />'.
+ '<input type="hidden" name="showdom" value="'.$dom.'" />';
my $catlinks = '<td valign="top"><b>'.&mt('Catalog:').'</b></td><td><table><tr>';
my $has_subcats;
my $selitem;
@@ -355,6 +363,10 @@
$catlinks .= &mt('Official courses (with institutional codes)').
'<input type="hidden" name="currcat_0" value="instcode::0" />';
$env{'form.currcat_0'} = 'instcode::0';
+ } elsif ($cats[0][0] eq 'communities') {
+ $catlinks .= &mt('Communities').
+ '<input type="hidden" name="currcat_0" value="instcode::0" />';
+ $env{'form.currcat_0'} = 'communities::0';
} else {
my $name = $cats[0][0];
my $item = &escape($name).'::0';
@@ -377,6 +389,8 @@
$catlinks .= '<option value="'.$item.'">';
if ($name eq 'instcode') {
$catlinks .= &mt('Official courses (with institutional codes)');
+ } elsif ($name eq 'communities') {
+ $catlinks .= &mt('Communities');
} else {
$catlinks .= $name;
}
@@ -403,6 +417,8 @@
my $currcat = $cat;
if ($cat eq 'instcode') {
$currcat = &mt('Official courses (with institutional codes)');
+ } elsif ($cat eq 'communities') {
+ $currcat = &mt('Communities');
}
$catlinks .= '<td><b>'.$currcat.'</b>';
if (ref($cats[$deeper]{$cat}) eq 'ARRAY') {
@@ -475,10 +491,15 @@
if ($env{'form.showselfenroll'}) {
$show_selfenroll_status = 'checked="checked" ';
}
+ my $selfenroll_text;
+ if ($env{'form.currcat_0'} eq 'communities::0') {
+ $selfenroll_text = &mt('Only show communities which allow self-enrollment');
+ } else {
+ $selfenroll_text = &mt('Only show courses which allow self-enrollment');
+ }
$output .= '<tr><td>'.
'<label><input type="checkbox" name="showselfenroll" value="1" '.
- $show_selfenroll_status.'/>'.
- &mt('Only show courses which allow self-enrollment').
+ $show_selfenroll_status.'/>'.$selfenroll_text.
'</label></td></tr>';
if (&user_is_dc($codedom)) {
my $showdetails_status;
@@ -490,14 +511,20 @@
$showhidden_status = 'checked="checked" ';
}
my $dc_title = &Apache::lonnet::plaintext('dc');
+ my ($details_text,$hidden_text);
+ if ($env{'form.currcat_0'} eq 'communities::0') {
+ $details_text = &mt('Show full details for each community ([_1] only)',$dc_title);
+ $hidden_text = &mt('Include communities set to be hidden from catalog ([_1] only)',$dc_title);
+ } else {
+ $details_text = &mt('Show full details for each course ([_1] only)',$dc_title);
+ $hidden_text = &mt('Include courses set to be hidden from catalog ([_1] only)',$dc_title);
+ }
$output .= '<tr><td>'."\n".
'<label><input type="checkbox" name="showdetails" value="1" '.
- $showdetails_status.'/>'.
- &mt('Show full details for each course ([_1] only)',$dc_title).
+ $showdetails_status.'/>'.$details_text.
'</label>'."\n".'</td></tr><tr><td>'.
'<label><input type="checkbox" name="showhidden" value="1" '.
- $showhidden_status.'/>'.
- &mt('Include courses set to be hidden from catalog ([_1] only)',$dc_title).
+ $showhidden_status.'/>'.$hidden_text.
'</label>'."\n".'</td></tr>';
}
$output .= '</table><br />';
@@ -558,13 +585,18 @@
} else {
$filterstr = $filter;
}
- my $showhidden;
+ my ($showhidden,$typefilter);
if (&user_is_dc($domain)) {
$showhidden = $env{'form.showhidden'};
}
+ if ($env{'form.currcat_0'} eq 'communities::0') {
+ $typefilter = 'Community';
+ } else {
+ $typefilter = '.';
+ }
%courses =
&Apache::lonnet::courseiddump($domain,'.',1,'.','.','.',undef,undef,
- '.',1,$env{'form.showselfenroll'},
+ $typefilter,1,$env{'form.showselfenroll'},
$filterstr,$showhidden,'coursecatalog');
}
return %courses;
@@ -596,7 +628,11 @@
%courses = &search_courselist($domain,$subcats);
}
if (keys(%courses) == 0) {
- $output = &mt('No courses match the criteria you selected.');
+ if ($env{'form.currcat_0'} eq 'communities::0') {
+ $output = &mt('No communities match the criteria you selected.');
+ } else {
+ $output = &mt('No courses match the criteria you selected.');
+ }
return $output;
}
if (($knownuser) && (!$env{'form.showdetails'}) && (!&user_is_dc($domain))) {
Index: loncom/interface/courseprefs.pm
diff -u loncom/interface/courseprefs.pm:1.11 loncom/interface/courseprefs.pm:1.12
--- loncom/interface/courseprefs.pm:1.11 Sat Nov 21 18:07:03 2009
+++ loncom/interface/courseprefs.pm Mon Nov 23 21:45:18 2009
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set configuration settings for a course
#
-# $Id: courseprefs.pm,v 1.11 2009/11/21 18:07:03 www Exp $
+# $Id: courseprefs.pm,v 1.12 2009/11/23 21:45:18 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -332,7 +332,7 @@
\@prefs_order,\%prefs,\%values,
$cnum,undef,\@allitems);
} elsif ($phase eq 'display') {
- my $jscript = &get_jscript($cdom,$phase);
+ my $jscript = &get_jscript($cdom,$phase,$crstype);
my @allitems = &get_allitems(%prefs);
&Apache::lonconfigsettings::display_settings($r,$cdom,$phase,$context,
\@prefs_order,\%prefs,\%values,undef,$jscript,\@allitems,$crstype);
@@ -1174,8 +1174,8 @@
}
sub get_jscript {
- my ($cdom,$phase) = @_;
- my ($can_toggle_cat,$can_categorize) = &can_modify_catsettings($cdom);
+ my ($cdom,$phase,$crstype) = @_;
+ my ($can_toggle_cat,$can_categorize) = &can_modify_catsettings($cdom,$crstype);
my ($jscript,$categorize_js);
my $stubrowse_js = &Apache::loncommon::studentbrowser_javascript();
my $browse_js = &Apache::loncommon::browser_and_searcher_javascript('parmset');
@@ -1294,14 +1294,14 @@
if (ref($cathash) eq 'HASH') {
$categoriesform =
&Apache::loncommon::assign_categories_table($cathash,
- $settings->{'categories'})."\n";
+ $settings->{'categories'},$crstype)."\n";
}
}
if (!defined($categoriesform)) {
$categoriesform = &mt('No categories defined for this domain');
}
- my ($can_toggle_cat,$can_categorize) = &can_modify_catsettings($cdom);
+ my ($can_toggle_cat,$can_categorize) = &can_modify_catsettings($cdom,$crstype);
my $replace;
if ($crstype eq 'Community') {
@@ -1507,15 +1507,24 @@
}
sub can_modify_catsettings {
- my ($dom) = @_;
+ my ($dom,$crstype) = @_;
my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$dom);
my ($can_toggle_cat,$can_categorize);
if (ref($domconf{'coursecategories'}) eq 'HASH') {
- if ($domconf{'coursecategories'}{'togglecats'} eq 'crs') {
- $can_toggle_cat = 1;
- }
- if ($domconf{'coursecategories'}{'categorize'} eq 'crs') {
- $can_categorize = 1;
+ if ($crstype eq 'Community') {
+ if ($domconf{'coursecategories'}{'togglecatscomm'} eq 'comm') {
+ $can_toggle_cat = 1;
+ }
+ if ($domconf{'coursecategories'}{'categorizecomm'} eq 'comm') {
+ $can_categorize = 1;
+ }
+ } else {
+ if ($domconf{'coursecategories'}{'togglecats'} eq 'crs') {
+ $can_toggle_cat = 1;
+ }
+ if ($domconf{'coursecategories'}{'categorize'} eq 'crs') {
+ $can_categorize = 1;
+ }
}
}
return ($can_toggle_cat,$can_categorize);
@@ -1531,7 +1540,13 @@
if (ref($domconf{'coursecategories'}) eq 'HASH') {
$cathash = $domconf{'coursecategories'}{'cats'};
if (ref($cathash) eq 'HASH') {
- $hascats = 1;
+ foreach my $cat (keys(%{$cathash})) {
+ next if ($cat eq 'instcode::0');
+ unless ($crstype eq 'Community') {
+ next if ($cat eq 'communities::0');
+ }
+ $hascats ++;
+ }
}
}
my $catwin_js;
@@ -1597,15 +1612,20 @@
if ($hascats) {
my %currsettings =
&Apache::lonnet::get('environment',['hidefromcat','categories'],$cdom,$cnum);
- $categoriesform .= $assign.'<br /><br />'.
- '<form name="chgcats" action="/adm/courseprefs" method="post">'."\n".
- &Apache::loncommon::assign_categories_table($cathash,
- $currsettings{'categories'})."\n".
- '<br /><input type="button" name="changes" value="'.
- &mt('Copy to main window').'" '.
- 'onclick="javascript:updateCategories()" /></form><br />';
+ my $cattable = &Apache::loncommon::assign_categories_table($cathash,
+ $currsettings{'categories'},$crstype);
+ if ($cattable eq '') {
+ $categoriesform .= &mt('No suitable categories defined for this course type in this domain.');
+ } else {
+ $categoriesform .= $assign.'<br /><br />'.
+ '<form name="chgcats" action="/adm/courseprefs" method="post">'."\n".
+ $cattable."\n".
+ '<br /><input type="button" name="changes" value="'.
+ &mt('Copy to main window').'" '.
+ 'onclick="javascript:updateCategories()" /></form><br />';
+ }
} else {
- $categoriesform .= &mt('No categories defined for this domain');
+ $categoriesform .= &mt('No categories defined in this domain.');
}
$r->print($start_page.$categoriesform.$end_page);
return;
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.119 loncom/interface/domainprefs.pm:1.120
--- loncom/interface/domainprefs.pm:1.119 Mon Nov 16 04:03:05 2009
+++ loncom/interface/domainprefs.pm Mon Nov 23 21:45:18 2009
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.119 2009/11/16 04:03:05 raeburn Exp $
+# $Id: domainprefs.pm,v 1.120 2009/11/23 21:45:18 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -303,7 +303,7 @@
col2 => 'Value'}],
},
'coursecategories' =>
- { text => 'Cataloging of courses',
+ { text => 'Cataloging of courses/communities',
help => 'Domain_Configuration_Cataloging_Courses',
header => [{col1 => 'Category settings',
col2 => '',},
@@ -325,6 +325,12 @@
header => [{col1 => 'Setting',
col2 => 'Value',}],
},
+ 'privacy' =>
+ {text => 'User Privacy',
+ help => 'Domain_Configuration_User_Privacy',
+ header => [{col1 => 'Setting',
+ col2 => 'Value',}],
+ },
);
my %servers = &dom_servers($dom);
if (keys(%servers) > 1) {
@@ -2595,6 +2601,11 @@
my $toggle_cats_dom = ' checked="checked" ';
my $can_cat_crs = ' ';
my $can_cat_dom = ' checked="checked" ';
+ my $toggle_catscomm_comm = ' ';
+ my $toggle_catscomm_dom = ' checked="checked" ';
+ my $can_catcomm_comm = ' ';
+ my $can_catcomm_dom = ' checked="checked" ';
+
if (ref($settings) eq 'HASH') {
if ($settings->{'togglecats'} eq 'crs') {
$toggle_cats_crs = $toggle_cats_dom;
@@ -2604,14 +2615,25 @@
$can_cat_crs = $can_cat_dom;
$can_cat_dom = ' ';
}
+ if ($settings->{'togglecatscomm'} eq 'comm') {
+ $toggle_catscomm_comm = $toggle_catscomm_dom;
+ $toggle_catscomm_dom = ' ';
+ }
+ if ($settings->{'categorizecomm'} eq 'comm') {
+ $can_catcomm_comm = $can_catcomm_dom;
+ $can_catcomm_dom = ' ';
+ }
}
my %title = &Apache::lonlocal::texthash (
- togglecats => 'Show/Hide a course in the catalog',
- categorize => 'Assign a category to a course',
+ togglecats => 'Show/Hide a course in catalog',
+ togglecatscomm => 'Show/Hide a community in catalog',
+ categorize => 'Assign a category to a course',
+ categorizecomm => 'Assign a category to a community',
);
my %level = &Apache::lonlocal::texthash (
- dom => 'Set in "Modify Course" (Domain)',
- crs => 'Set in "Modify Parameters" (Course)',
+ dom => 'Set in Domain',
+ crs => 'Set in Course',
+ comm => 'Set in Community',
);
$datatable = '<tr class="LC_odd_row">'.
'<td>'.$title{'togglecats'}.'</td>'.
@@ -2627,8 +2649,22 @@
$can_cat_dom.' value="dom" />'.$level{'dom'}.'</label> '.
'<label><input type="radio" name="categorize"'.
$can_cat_crs.'value="crs" />'.$level{'crs'}.'</label></span></td>'.
+ '</tr><tr class="LC_odd_row">'.
+ '<td>'.$title{'togglecatscomm'}.'</td>'.
+ '<td class="LC_right_item"><span class="LC_nobreak"><label>'.
+ '<input type="radio" name="togglecatscomm"'.
+ $toggle_catscomm_dom.' value="dom" />'.$level{'dom'}.'</label> '.
+ '<label><input type="radio" name="togglecatscomm"'.
+ $toggle_catscomm_comm.' value="comm" />'.$level{'comm'}.'</label></span></td>'.
+ '</tr><tr>'.
+ '<td>'.$title{'categorizecomm'}.'</td>'.
+ '<td class="LC_right_item"><span class="LC_nobreak">'.
+ '<label><input type="radio" name="categorizecomm"'.
+ $can_catcomm_dom.' value="dom" />'.$level{'dom'}.'</label> '.
+ '<label><input type="radio" name="categorizecomm"'.
+ $can_catcomm_comm.'value="comm" />'.$level{'comm'}.'</label></span></td>'.
'</tr>';
- $$rowtotal += 2;
+ $$rowtotal += 4;
} else {
my $css_class;
my $itemcount = 1;
@@ -2650,7 +2686,15 @@
if (ref($cats[0]) eq 'ARRAY') {
my $numtop = @{$cats[0]};
my $maxnum = $numtop;
- if ((!grep(/^instcode$/,@{$cats[0]})) || ($cathash->{'instcode::0'} eq '')) {
+ my %default_names = (
+ instcode => &mt('Official courses'),
+ communities => &mt('Communities'),
+ );
+
+ if ((!grep(/^instcode$/,@{$cats[0]})) ||
+ ($cathash->{'instcode::0'} eq '') ||
+ (!grep(/^communities$/,@{$cats[0]})) ||
+ ($cathash->{'communities::0'} eq '')) {
$maxnum ++;
}
my $lastidx;
@@ -2671,14 +2715,33 @@
$datatable .= '<option value="'.$k.'"'.$selstr.'>'.$vpos.'</option>';
}
$datatable .= '</select></td><td>';
- if ($parent eq 'instcode') {
- $datatable .= '<span class="LC_nobreak">'.&mt('Official courses')
- .'</span><br /><span class="LC_nobreak">('
- .&mt('with institutional codes').')</span></td>'
- .'<td'.$colattrib.'><span class="LC_nobreak"><label><input type="radio" name="instcode" value="1" checked="checked" />'
- .&mt('Display').'</label> '
- .'<label><input type="radio" name="instcode" value="0" />'
- .&mt('Do not display').'</label></span></td>';
+ if ($parent eq 'instcode' || $parent eq 'communities') {
+ $datatable .= '<span class="LC_nobreak">'
+ .$default_names{$parent}.'</span>';
+ if ($parent eq 'instcode') {
+ $datatable .= '<br /><span class="LC_nobreak">('
+ .&mt('with institutional codes')
+ .')</span></td><td'.$colattrib.'>';
+ } else {
+ $datatable .= '<table><tr><td>';
+ }
+ $datatable .= '<span class="LC_nobreak">'
+ .'<label><input type="radio" name="'
+ .$parent.'" value="1" checked="checked" />'
+ .&mt('Display').'</label>';
+ if ($parent eq 'instcode') {
+ $datatable .= ' ';
+ } else {
+ $datatable .= '</span></td></tr><tr><td>'
+ .'<span class="LC_nobreak">';
+ }
+ $datatable .= '<label><input type="radio" name="'
+ .$parent.'" value="0" />'
+ .&mt('Do not display').'</label></span>';
+ if ($parent eq 'communities') {
+ $datatable .= '</td></tr></table>';
+ }
+ $datatable .= '</td>';
} else {
$datatable .= $parent
.' <label><input type="checkbox" name="deletecategory" '
@@ -2706,26 +2769,33 @@
.'<input type="text" size="20" name="addcategory_name" value="" /></td>'
.'</tr>'."\n";
$itemcount ++;
- if ((!grep(/^instcode$/,@{$cats[0]})) || ($cathash->{'instcode::0'} eq '')) {
- $css_class = $itemcount%2?' class="LC_odd_row"':'';
- my $chgstr = ' onchange="javascript:reorderCats(this.form,'."'','instcode_pos','$lastidx'".');"';
- $datatable .= '<tr><td colspan="'.$maxdepth.'" class="LC_row_separator"></td></tr><tr '.$css_class.'><td>'.
- '<span class="LC_nobreak"><select name="instcode_pos"'.$chgstr.'>';
- for (my $k=0; $k<=$maxnum; $k++) {
- my $vpos = $k+1;
- my $selstr;
- if ($k == $maxnum) {
- $selstr = ' selected="selected" ';
+ foreach my $default ('instcode','communities') {
+ if ((!grep(/^\Q$default\E$/,@{$cats[0]})) || ($cathash->{$default.'::0'} eq '')) {
+ $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ my $chgstr = ' onchange="javascript:reorderCats(this.form,'."'','$default"."_pos','$lastidx'".');"';
+ $datatable .= '<tr><td colspan="'.$maxdepth.'" class="LC_row_separator"></td></tr><tr '.$css_class.'><td>'.
+ '<span class="LC_nobreak"><select name="'.$default.'_pos"'.$chgstr.'>';
+ for (my $k=0; $k<=$maxnum; $k++) {
+ my $vpos = $k+1;
+ my $selstr;
+ if ($k == $maxnum) {
+ $selstr = ' selected="selected" ';
+ }
+ $datatable .= '<option value="'.$k.'"'.$selstr.'>'.$vpos.'</option>';
}
- $datatable .= '<option value="'.$k.'"'.$selstr.'>'.$vpos.'</option>';
+ $datatable .= '</select></span></td>'.
+ '<td><span class="LC_nobreak">'.
+ $default_names{$default}.'</span>';
+ if ($default eq 'instcode') {
+ $datatable .= '<br /><span class="LC_nobreak">('
+ .&mt('with institutional codes').')</span>';
+ }
+ $datatable .= '</td>'
+ .'<td><span class="LC_nobreak"><label><input type="radio" name="'.$default.'" value="1" />'
+ .&mt('Display').'</label> '
+ .'<label><input type="radio" name="'.$default.'" value="0" checked="checked"/>'
+ .&mt('Do not display').'</label></span></td></tr>';
}
- $datatable .= '</select></span></td><td><span class="LC_nobreak">'
- .&mt('Official courses').'</span>'.'<br /><span class="LC_nobreak">('
- .&mt('with institutional codes').')</span></td>'
- .'<td><span class="LC_nobreak"><label><input type="radio" name="instcode" value="1" />'
- .&mt('Display').'</label> '
- .'<label><input type="radio" name="instcode" value="0" checked="checked"/>'
- .&mt('Do not display').'</label></span></td></tr>';
}
}
} else {
@@ -2814,6 +2884,9 @@
$jstext = ' var categories = Array(1);'."\n".
' categories[0] = Array("instcode_pos");'."\n";
}
+ my $instcode_reserved = &mt('The name: "instcode" is a reserved category');
+ my $communities_reserved = &mt('The name: "communities" is a reserved category');
+ my $choose_again = '\\n'.&mt('Please use a different name for the new top level category');
$output = <<"ENDSCRIPT";
<script type="text/javascript">
// <![CDATA[
@@ -2873,6 +2946,19 @@
}
return;
}
+
+function categoryCheck(form) {
+ if (form.elements['addcategory_name'].value == 'instcode') {
+ alert('$instcode_reserved\\n$choose_again');
+ return false;
+ }
+ if (form.elements['addcategory_name'].value == 'communities') {
+ alert('$communities_reserved\\n$choose_again');
+ return false;
+ }
+ return true;
+}
+
// ]]>
</script>
@@ -2882,25 +2968,40 @@
sub initialize_categories {
my ($itemcount) = @_;
- my $datatable;
- my $css_class = $itemcount%2?' class="LC_odd_row"':'';
- my $chgstr = ' onchange="javascript:reorderCats(this.form,'."'','instcode_pos','0'".');"';
-
- $datatable = '<tr '.$css_class.'><td><span class="LC_nobreak">'
- .'<select name="instcode_pos"><option value="0" selected="selected">1</option>'
- .'<option value="1">2</option></select> '
- .&mt('Official courses (with institutional codes)')
- .'</span></td><td><span class="LC_nobreak">'
- .'<label><input type="radio" name="instcode" value="1" checked="checked" />'
- .&mt('Display').'</label> <label>'
- .'<input type="radio" name="instcode" value="0" />'.&mt('Do not display')
+ my ($datatable,$css_class,$chgstr);
+ my %default_names = (
+ instcode => 'Official courses (with institutional codes)',
+ communities => 'Communities',
+ );
+ my $select0 = ' selected="selected"';
+ my $select1 = '';
+ foreach my $default ('instcode','communities') {
+ $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ $chgstr = ' onchange="javascript:reorderCats(this.form,'."'',$default"."_pos','0'".');"';
+ if ($default eq 'communities') {
+ $select1 = $select0;
+ $select0 = '';
+ }
+ $datatable .= '<tr '.$css_class.'><td><span class="LC_nobreak">'
+ .'<select name="'.$default.'_pos">'
+ .'<option value="0"'.$select0.'>1</option>'
+ .'<option value="1"'.$select1.'>2</option>'
+ .'<option value="2">3</option></select> '
+ .$default_names{$default}
+ .'</span></td><td><span class="LC_nobreak">'
+ .'<label><input type="radio" name="'.$default.'" value="1" checked="checked" />'
+ .&mt('Display').'</label> <label>'
+ .'<input type="radio" name="'.$default.'" value="0" />'.&mt('Do not display')
.'</label></span></td></tr>';
- $itemcount ++;
+ $itemcount ++;
+ }
$css_class = $itemcount%2?' class="LC_odd_row"':'';
$chgstr = ' onchange="javascript:reorderCats(this.form,'."'','addcategory_pos','0'".');"';
$datatable .= '<tr '.$css_class.'><td><span class="LC_nobreak">'
- .'<select name="addcategory_pos"'.$chgstr.'><option value="0">1</option>'
- .'<option value="1" selected="selected">2</option></select> '
+ .'<select name="addcategory_pos"'.$chgstr.'>'
+ .'<option value="0">1</option>'
+ .'<option value="1">2</option>'
+ .'<option value="2" selected="selected">3</option></select> '
.&mt('Add category').'</td><td>'.&mt('Name:')
.' <input type="text" size="20" name="addcategory_name" value="" /></td></tr>';
return $datatable;
@@ -5398,6 +5499,14 @@
$changes{'categorize'} = 1;
$domconfig{'coursecategories'}{'categorize'} = $env{'form.categorize'};
}
+ if ($domconfig{'coursecategories'}{'togglecatscomm'} ne $env{'form.togglecatscomm'}) {
+ $changes{'togglecatscomm'} = 1;
+ $domconfig{'coursecategories'}{'togglecatscomm'} = $env{'form.togglecatscomm'};
+ }
+ if ($domconfig{'coursecategories'}{'categorizecomm'} ne $env{'form.categorizecomm'}) {
+ $changes{'categorizecomm'} = 1;
+ $domconfig{'coursecategories'}{'categorizecomm'} = $env{'form.categorizecomm'};
+ }
} else {
$changes{'togglecats'} = 1;
$changes{'categorize'} = 1;
@@ -5405,11 +5514,20 @@
togglecats => $env{'form.togglecats'},
categorize => $env{'form.categorize'},
};
+ $changes{'togglecatscomm'} = 1;
+ $changes{'categorizecomm'} = 1;
+ $domconfig{'coursecategories'} = {
+ togglecats => $env{'form.togglecatscomm'},
+ categorize => $env{'form.categorizecomm'},
+ };
}
if (ref($cathash) eq 'HASH') {
if (($domconfig{'coursecategories'}{'cats'}{'instcode::0'} ne '') && ($env{'form.instcode'} == 0)) {
push (@deletecategory,'instcode::0');
}
+ if (($domconfig{'coursecategories'}{'cats'}{'communities::0'} ne '') && ($env{'form.communities'} == 0)) {
+ push(@deletecategory,'communities::0');
+ }
}
my (@predelcats,@predeltrails,%predelallitems,%sort_by_deltrail);
if (ref($cathash) eq 'HASH') {
@@ -5459,10 +5577,26 @@
$adds{$newitem} = 1;
}
}
+ if ($env{'form.communities'} eq '1') {
+ if (ref($cathash) eq 'HASH') {
+ my $newitem = 'communities::0';
+ if ($cathash->{$newitem} eq '') {
+ $domconfig{'coursecategories'}{'cats'}{$newitem} = $env{'form.communities_pos'};
+ $adds{$newitem} = 1;
+ }
+ } else {
+ my $newitem = 'communities::0';
+ $domconfig{'coursecategories'}{'cats'}{$newitem} = $env{'form.communities_pos'};
+ $adds{$newitem} = 1;
+ }
+ }
if ($env{'form.addcategory_name'} ne '') {
- my $newitem = &escape($env{'form.addcategory_name'}).'::0';
- $domconfig{'coursecategories'}{'cats'}{$newitem} = $env{'form.addcategory_pos'};
- $adds{$newitem} = 1;
+ if (($env{'form.addcategory_name'} ne 'instcode') &&
+ ($env{'form.addcategory_name'} ne 'communities')) {
+ my $newitem = &escape($env{'form.addcategory_name'}).'::0';
+ $domconfig{'coursecategories'}{'cats'}{$newitem} = $env{'form.addcategory_pos'};
+ $adds{$newitem} = 1;
+ }
}
my $putresult;
if ((keys(%deletions) > 0) || (keys(%reorderings) > 0) || (keys(%adds) > 0)) {
@@ -5499,12 +5633,15 @@
$putresult = &Apache::lonnet::put_dom('configuration',\%domconfig,$dom);
if ($putresult eq 'ok') {
my %title = (
- togglecats => 'Show/Hide a course in the catalog',
- categorize => 'Category assigned to course',
+ togglecats => 'Show/Hide a course in catalog',
+ categorize => 'Assign a category to a course',
+ togglecatscomm => 'Show/Hide a community in catalog',
+ categorizecomm => 'Assign a category to a community',
);
my %level = (
- dom => 'set from "Modify Course" (Domain)',
- crs => 'set from "Parameters" (Course)',
+ dom => 'set in Domain ("Modify Course/Community")',
+ crs => 'set in Course ("Course Configuration")',
+ comm => 'set in Community ("Community Configuration")',
);
$resulttext = &mt('Changes made:').'<ul>';
if ($changes{'togglecats'}) {
@@ -5513,6 +5650,12 @@
if ($changes{'categorize'}) {
$resulttext .= '<li>'.&mt("$title{'categorize'} $level{$env{'form.categorize'}}").'</li>';
}
+ if ($changes{'togglecatscomm'}) {
+ $resulttext .= '<li>'.&mt("$title{'togglecatscomm'} $level{$env{'form.togglecatscomm'}}").'</li>';
+ }
+ if ($changes{'categorizecomm'}) {
+ $resulttext .= '<li>'.&mt("$title{'categorizecomm'} $level{$env{'form.categorizecomm'}}").'</li>';
+ }
if ((keys(%deletions) > 0) || (keys(%reorderings) > 0) || (keys(%adds) > 0)) {
my $cathash;
if (ref($domconfig{'coursecategories'}) eq 'HASH') {
@@ -5562,7 +5705,7 @@
&mt('An error occurred: [_1]',$putresult).'</span>';
}
} else {
- $resulttext = &mt('No changes made to course categories');
+ $resulttext = &mt('No changes made to course and community categories');
}
return $resulttext;
}
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.918 loncom/interface/loncommon.pm:1.919
--- loncom/interface/loncommon.pm:1.918 Mon Nov 23 14:04:36 2009
+++ loncom/interface/loncommon.pm Mon Nov 23 21:45:18 2009
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.918 2009/11/23 14:04:36 wenzelju Exp $
+# $Id: loncommon.pm,v 1.919 2009/11/23 21:45:18 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -9648,6 +9648,8 @@
my $trailstr;
if ($name eq 'instcode') {
$trailstr = &mt('Official courses (with institutional codes)');
+ } elsif ($name eq 'communities') {
+ $trailstr = &mt('Communities');
} else {
$trailstr = $name;
}
@@ -9760,12 +9762,14 @@
currcat - scalar with an & separated list of categories assigned to a course.
+type - scalar contains course type (Course or Community).
+
Returns: $output (markup to be displayed)
=cut
sub assign_categories_table {
- my ($cathash,$currcat) = @_;
+ my ($cathash,$currcat,$type) = @_;
my $output;
if (ref($cathash) eq 'HASH') {
my (@cats,@trails,%allitems,%idx,@jsarray,@path,$maxdepth);
@@ -9774,15 +9778,20 @@
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);
}
+ my $table;
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');
+ if ($type eq 'Community') {
+ next unless ($parent eq 'communities');
+ } else {
+ next if ($parent eq 'communities');
+ }
+ my $css_class = $itemcount%2?' class="LC_odd_row"':'';
my $item = &escape($parent).'::0';
my $checked = '';
if (@currcategories > 0) {
@@ -9790,18 +9799,26 @@
$checked = ' checked="checked"';
}
}
- $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 $parent_title = $parent;
+ if ($parent eq 'communities') {
+ $parent_title = &mt('Communities');
+ }
+ $table .= '<tr '.$css_class.'><td><span class="LC_nobreak">'.
+ '<input type="checkbox" name="usecategory" value="'.
+ $item.'"'.$checked.' />'.$parent_title.'</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);
+ $table .= &assign_category_rows($itemcount,\@cats,$depth,$parent,\@path,\@currcategories);
pop(@path);
- $output .= '</tr><tr><td colspan="'.$maxdepth.'" class="LC_row_separator"></td></tr>';
+ $table .= '</tr><tr><td colspan="'.$maxdepth.'" class="LC_row_separator"></td></tr>';
$itemcount ++;
}
- $output .= &Apache::loncommon::end_data_table();
+ if ($itemcount) {
+ $output = &Apache::loncommon::start_data_table().
+ $table.
+ &Apache::loncommon::end_data_table();
+ }
}
}
}
Index: loncom/interface/lonconfigsettings.pm
diff -u loncom/interface/lonconfigsettings.pm:1.7 loncom/interface/lonconfigsettings.pm:1.8
--- loncom/interface/lonconfigsettings.pm:1.7 Thu Oct 29 14:57:18 2009
+++ loncom/interface/lonconfigsettings.pm Mon Nov 23 21:45:18 2009
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: lonconfigsettings.pm,v 1.7 2009/10/29 14:57:18 raeburn Exp $
+# $Id: lonconfigsettings.pm,v 1.8 2009/11/23 21:45:18 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -38,10 +38,22 @@
sub print_header {
my ($r,$phase,$context,$jscript) = @_;
- my ($pagetitle,$brcrumtitle,$action);
+ my ($pagetitle,$brcrumtitle,$action,$call_category_check);
if ($context eq 'domain') {
($pagetitle, $brcrumtitle) = ('View/Modify Domain Settings','Domain Settings');
$action = '/adm/domainprefs';
+ if ($phase eq 'display') {
+ my @actions = &Apache::loncommon::get_env_multiple('form.actions');
+ if (grep(/^coursecategories$/,@actions)) {
+ $call_category_check = qq|
+ if (formname == document.display) {
+ if (!categoryCheck(formname)) {
+ return;
+ }
+ }
+|;
+ }
+ }
} else {
if (&Apache::loncommon::course_type() eq 'Community') {
($pagetitle,$brcrumtitle) = ('Community Configuration','Community Configuration');
@@ -77,6 +89,7 @@
return;
}
}
+ '.$call_category_check.'
formname.submit();
}'."\n";
if ($phase eq 'pickactions') {
Index: loncom/interface/lonmodifycourse.pm
diff -u loncom/interface/lonmodifycourse.pm:1.48 loncom/interface/lonmodifycourse.pm:1.49
--- loncom/interface/lonmodifycourse.pm:1.48 Mon Nov 9 03:50:27 2009
+++ loncom/interface/lonmodifycourse.pm Mon Nov 23 21:45:18 2009
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# handler for DC-only modifiable course settings
#
-# $Id: lonmodifycourse.pm,v 1.48 2009/11/09 03:50:27 raeburn Exp $
+# $Id: lonmodifycourse.pm,v 1.49 2009/11/23 21:45:18 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -55,14 +55,23 @@
}
sub catalog_settable {
- my ($confhash) = @_;
+ my ($confhash,$type) = @_;
my @settable;
if (ref($confhash) eq 'HASH') {
- if ($confhash->{'togglecats'} ne 'crs') {
- push(@settable,'togglecats');
- }
- if ($confhash->{'categorize'} ne 'crs') {
- push(@settable,'categorize');
+ if ($type eq 'Community') {
+ if ($confhash->{'togglecatscomm'} ne 'comm') {
+ push(@settable,'togglecats');
+ }
+ if ($confhash->{'categorizecomm'} ne 'comm') {
+ push(@settable,'categorize');
+ }
+ } else {
+ if ($confhash->{'togglecats'} ne 'crs') {
+ push(@settable,'togglecats');
+ }
+ if ($confhash->{'categorize'} ne 'crs') {
+ push(@settable,'categorize');
+ }
}
} else {
push(@settable,('togglecats','categorize'));
@@ -224,7 +233,7 @@
}
);
my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$dom);
- my @additional_params = &catalog_settable($domconf{'coursecategories'});
+ my @additional_params = &catalog_settable($domconf{'coursecategories'},$type);
if (@additional_params > 0) {
push (@menu, { text => $cat_text,
phase => 'catsettings',
@@ -399,12 +408,12 @@
$lt{'catset'} = &mt('Catalog Settings for Community');
$lt{'exclude'} = &mt('Exclude from course catalog');
$lt{'categ'} = &mt('Categorize Community');
- $lt{'assi'} = &mt('Assign one or more categories and/or subcategories to this community.');
+ $lt{'assi'} = &mt('Assign one or more subcategories to this community.');
}
$r->print('<form action="/adm/modifycourse" method="post" name="catsettings">'.
'<h3>'.$lt{'catset'}.' <span class="LC_nobreak">'.$cdesc.'</span></h3>');
my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);
- my @cat_params = &catalog_settable($domconf{'coursecategories'});
+ my @cat_params = &catalog_settable($domconf{'coursecategories'},$type);
if (@cat_params > 0) {
my %currsettings =
&Apache::lonnet::get('environment',['hidefromcat','categories'],$cdom,$cnum);
@@ -434,7 +443,7 @@
if (ref($cathash) eq 'HASH') {
$r->print($lt{'assi'}.'<br /><br />'.
&Apache::loncommon::assign_categories_table($cathash,
- $currsettings{'categories'}));
+ $currsettings{'categories'},$type));
} else {
$r->print(&mt('No categories defined for this domain'));
}
@@ -933,7 +942,7 @@
<form action="/adm/modifycourse" method="post" name="processcat">
<h3>'.&mt('Category settings').'</h3>');
my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);
- my @cat_params = &catalog_settable($domconf{'coursecategories'});
+ my @cat_params = &catalog_settable($domconf{'coursecategories'},$type);
if (@cat_params > 0) {
my (%cenv,@changes,@nochanges);
my %currsettings =
--raeburn1259012719--