version 1.271, 2016/04/02 04:30:19
|
version 1.272, 2016/04/04 01:09:47
|
Line 5552 sub print_coursecategories {
|
Line 5552 sub print_coursecategories {
|
my $toggle_catscomm_dom = ' checked="checked" '; |
my $toggle_catscomm_dom = ' checked="checked" '; |
my $can_catcomm_comm = ' '; |
my $can_catcomm_comm = ' '; |
my $can_catcomm_dom = ' checked="checked" '; |
my $can_catcomm_dom = ' checked="checked" '; |
|
my $toggle_catsplace_place = ' '; |
|
my $toggle_catsplace_dom = ' checked="checked" '; |
|
my $can_catplace_place = ' '; |
|
my $can_catplace_dom = ' checked="checked" '; |
|
|
if (ref($settings) eq 'HASH') { |
if (ref($settings) eq 'HASH') { |
if ($settings->{'togglecats'} eq 'crs') { |
if ($settings->{'togglecats'} eq 'crs') { |
Line 5570 sub print_coursecategories {
|
Line 5574 sub print_coursecategories {
|
$can_catcomm_comm = $can_catcomm_dom; |
$can_catcomm_comm = $can_catcomm_dom; |
$can_catcomm_dom = ' '; |
$can_catcomm_dom = ' '; |
} |
} |
|
if ($settings->{'togglecatsplace'} eq 'place') { |
|
$toggle_catsplace_place = $toggle_catsplace_dom; |
|
$toggle_catsplace_dom = ' '; |
|
} |
|
if ($settings->{'categorizeplace'} eq 'place') { |
|
$can_catplace_place = $can_catplace_dom; |
|
$can_catplace_dom = ' '; |
|
} |
} |
} |
my %title = &Apache::lonlocal::texthash ( |
my %title = &Apache::lonlocal::texthash ( |
togglecats => 'Show/Hide a course in catalog', |
togglecats => 'Show/Hide a course in catalog', |
togglecatscomm => 'Show/Hide a community in catalog', |
togglecatscomm => 'Show/Hide a community in catalog', |
categorize => 'Assign a category to a course', |
togglecatsplace => 'Show/Hide a placement test in catalog', |
categorizecomm => 'Assign a category to a community', |
categorize => 'Assign a category to a course', |
|
categorizecomm => 'Assign a category to a community', |
|
categorizeplace => 'Assign a category to a placement test', |
); |
); |
my %level = &Apache::lonlocal::texthash ( |
my %level = &Apache::lonlocal::texthash ( |
dom => 'Set in Domain', |
dom => 'Set in Domain', |
crs => 'Set in Course', |
crs => 'Set in Course', |
comm => 'Set in Community', |
comm => 'Set in Community', |
|
place => 'Set in Placement Test', |
); |
); |
$datatable = '<tr class="LC_odd_row">'. |
$datatable = '<tr class="LC_odd_row">'. |
'<td>'.$title{'togglecats'}.'</td>'. |
'<td>'.$title{'togglecats'}.'</td>'. |
Line 5610 sub print_coursecategories {
|
Line 5625 sub print_coursecategories {
|
$can_catcomm_dom.' value="dom" />'.$level{'dom'}.'</label> '. |
$can_catcomm_dom.' value="dom" />'.$level{'dom'}.'</label> '. |
'<label><input type="radio" name="categorizecomm"'. |
'<label><input type="radio" name="categorizecomm"'. |
$can_catcomm_comm.'value="comm" />'.$level{'comm'}.'</label></span></td>'. |
$can_catcomm_comm.'value="comm" />'.$level{'comm'}.'</label></span></td>'. |
|
'</tr><tr>'. |
|
'<td>'.$title{'togglecatsplace'}.'</td>'. |
|
'<td class="LC_right_item"><span class="LC_nobreak"><label>'. |
|
'<input type="radio" name="togglecatsplace"'. |
|
$toggle_catsplace_dom.' value="dom" />'.$level{'dom'}.'</label> '. |
|
'<label><input type="radio" name="togglecatscomm"'. |
|
$toggle_catsplace_place.' value="comm" />'.$level{'place'}.'</label></span></td>'. |
|
'</tr><tr>'. |
|
'<td>'.$title{'categorizeplace'}.'</td>'. |
|
'<td class="LC_right_item"><span class="LC_nobreak">'. |
|
'<label><input type="radio" name="categorizeplace"'. |
|
$can_catplace_dom.' value="dom" />'.$level{'dom'}.'</label> '. |
|
'<label><input type="radio" name="categorizeplace"'. |
|
$can_catplace_place.'value="place" />'.$level{'place'}.'</label></span></td>'. |
'</tr>'; |
'</tr>'; |
$$rowtotal += 4; |
$$rowtotal += 6; |
} else { |
} else { |
my $css_class; |
my $css_class; |
my $itemcount = 1; |
my $itemcount = 1; |
Line 5636 sub print_coursecategories {
|
Line 5665 sub print_coursecategories {
|
my %default_names = ( |
my %default_names = ( |
instcode => &mt('Official courses'), |
instcode => &mt('Official courses'), |
communities => &mt('Communities'), |
communities => &mt('Communities'), |
|
placement => &mt('Placement Tests'), |
); |
); |
|
|
if ((!grep(/^instcode$/,@{$cats[0]})) || |
if ((!grep(/^instcode$/,@{$cats[0]})) || |
($cathash->{'instcode::0'} eq '') || |
($cathash->{'instcode::0'} eq '') || |
(!grep(/^communities$/,@{$cats[0]})) || |
(!grep(/^communities$/,@{$cats[0]})) || |
($cathash->{'communities::0'} eq '')) { |
($cathash->{'communities::0'} eq '') || |
|
(!grep(/^placement$/,@{$cats[0]})) || |
|
($cathash->{'placement::0'} eq '')) { |
$maxnum ++; |
$maxnum ++; |
} |
} |
my $lastidx; |
my $lastidx; |
Line 5662 sub print_coursecategories {
|
Line 5694 sub print_coursecategories {
|
$datatable .= '<option value="'.$k.'"'.$selstr.'>'.$vpos.'</option>'; |
$datatable .= '<option value="'.$k.'"'.$selstr.'>'.$vpos.'</option>'; |
} |
} |
$datatable .= '</select></span></td><td>'; |
$datatable .= '</select></span></td><td>'; |
if ($parent eq 'instcode' || $parent eq 'communities') { |
if ($parent eq 'instcode' || $parent eq 'communities' || $parent eq 'placement') { |
$datatable .= '<span class="LC_nobreak">' |
$datatable .= '<span class="LC_nobreak">' |
.$default_names{$parent}.'</span>'; |
.$default_names{$parent}.'</span>'; |
if ($parent eq 'instcode') { |
if ($parent eq 'instcode') { |
Line 5685 sub print_coursecategories {
|
Line 5717 sub print_coursecategories {
|
$datatable .= '<label><input type="radio" name="' |
$datatable .= '<label><input type="radio" name="' |
.$parent.'" value="0" />' |
.$parent.'" value="0" />' |
.&mt('Do not display').'</label></span>'; |
.&mt('Do not display').'</label></span>'; |
if ($parent eq 'communities') { |
if (($parent eq 'communities') || ($parent eq 'placement')) { |
$datatable .= '</td></tr></table>'; |
$datatable .= '</td></tr></table>'; |
} |
} |
$datatable .= '</td>'; |
$datatable .= '</td>'; |
Line 5717 sub print_coursecategories {
|
Line 5749 sub print_coursecategories {
|
.'<input type="text" size="20" name="addcategory_name" value="" /></td>' |
.'<input type="text" size="20" name="addcategory_name" value="" /></td>' |
.'</tr>'."\n"; |
.'</tr>'."\n"; |
$itemcount ++; |
$itemcount ++; |
foreach my $default ('instcode','communities') { |
foreach my $default ('instcode','communities','placement') { |
if ((!grep(/^\Q$default\E$/,@{$cats[0]})) || ($cathash->{$default.'::0'} eq '')) { |
if ((!grep(/^\Q$default\E$/,@{$cats[0]})) || ($cathash->{$default.'::0'} eq '')) { |
$css_class = $itemcount%2?' class="LC_odd_row"':''; |
$css_class = $itemcount%2?' class="LC_odd_row"':''; |
my $chgstr = ' onchange="javascript:reorderCats(this.form,'."'','$default"."_pos','$lastidx'".');"'; |
my $chgstr = ' onchange="javascript:reorderCats(this.form,'."'','$default"."_pos','$lastidx'".');"'; |
Line 5898 sub coursecategories_javascript {
|
Line 5930 sub coursecategories_javascript {
|
} |
} |
my $instcode_reserved = &mt('The name: [_1] is a reserved category.','"instcode"'); |
my $instcode_reserved = &mt('The name: [_1] is a reserved category.','"instcode"'); |
my $communities_reserved = &mt('The name: [_1] is a reserved category.','"communities"'); |
my $communities_reserved = &mt('The name: [_1] is a reserved category.','"communities"'); |
|
my $placement_reserved = &mt('The name: [_1] is a reserved category.','"placement"'); |
my $choose_again = "\n".&mt('Please use a different name for the new top level category.'); |
my $choose_again = "\n".&mt('Please use a different name for the new top level category.'); |
&js_escape(\$instcode_reserved); |
&js_escape(\$instcode_reserved); |
&js_escape(\$communities_reserved); |
&js_escape(\$communities_reserved); |
|
&js_escape(\$placement_reserved); |
&js_escape(\$choose_again); |
&js_escape(\$choose_again); |
$output = <<"ENDSCRIPT"; |
$output = <<"ENDSCRIPT"; |
<script type="text/javascript"> |
<script type="text/javascript"> |
Line 5970 function categoryCheck(form) {
|
Line 6004 function categoryCheck(form) {
|
alert('$communities_reserved\\n$choose_again'); |
alert('$communities_reserved\\n$choose_again'); |
return false; |
return false; |
} |
} |
|
if (form.elements['addcategory_name'].value == 'placement') { |
|
alert('$placement_reserved\\n$choose_again'); |
|
return false; |
|
} |
return true; |
return true; |
} |
} |
|
|
Line 5986 sub initialize_categories {
|
Line 6024 sub initialize_categories {
|
my %default_names = ( |
my %default_names = ( |
instcode => 'Official courses (with institutional codes)', |
instcode => 'Official courses (with institutional codes)', |
communities => 'Communities', |
communities => 'Communities', |
|
placement => 'Placement Tests', |
); |
); |
my $select0 = ' selected="selected"'; |
my $select0 = ' selected="selected"'; |
my $select1 = ''; |
my $select1 = ''; |
foreach my $default ('instcode','communities') { |
foreach my $default ('instcode','communities','placement') { |
$css_class = $itemcount%2?' class="LC_odd_row"':''; |
$css_class = $itemcount%2?' class="LC_odd_row"':''; |
$chgstr = ' onchange="javascript:reorderCats(this.form,'."'',$default"."_pos','0'".');"'; |
$chgstr = ' onchange="javascript:reorderCats(this.form,'."'',$default"."_pos','0'".');"'; |
if ($default eq 'communities') { |
if (($default eq 'communities') || ($default eq 'placement')) { |
$select1 = $select0; |
$select1 = $select0; |
$select0 = ''; |
$select0 = ''; |
} |
} |
Line 10851 sub modify_coursecategories {
|
Line 10890 sub modify_coursecategories {
|
if ($domconfig{'coursecategories'}{'categorizecomm'} ne $env{'form.categorizecomm'}) { |
if ($domconfig{'coursecategories'}{'categorizecomm'} ne $env{'form.categorizecomm'}) { |
$changes{'categorizecomm'} = 1; |
$changes{'categorizecomm'} = 1; |
$domconfig{'coursecategories'}{'categorizecomm'} = $env{'form.categorizecomm'}; |
$domconfig{'coursecategories'}{'categorizecomm'} = $env{'form.categorizecomm'}; |
|
|
|
} |
|
if ($domconfig{'coursecategories'}{'togglecatsplace'} ne $env{'form.togglecatsplace'}) { |
|
$changes{'togglecatsplace'} = 1; |
|
$domconfig{'coursecategories'}{'togglecatsplace'} = $env{'form.togglecatsplace'}; |
|
} |
|
if ($domconfig{'coursecategories'}{'categorizeplace'} ne $env{'form.categorizeplace'}) { |
|
$changes{'categorizeplace'} = 1; |
|
$domconfig{'coursecategories'}{'categorizeplace'} = $env{'form.categorizeplace'}; |
} |
} |
foreach my $item (@catitems) { |
foreach my $item (@catitems) { |
if (grep(/^\Q$env{'form.coursecat_'.$item}\E$/,@cattypes)) { |
if (grep(/^\Q$env{'form.coursecat_'.$item}\E$/,@cattypes)) { |
Line 10865 sub modify_coursecategories {
|
Line 10913 sub modify_coursecategories {
|
$changes{'categorize'} = 1; |
$changes{'categorize'} = 1; |
$changes{'togglecatscomm'} = 1; |
$changes{'togglecatscomm'} = 1; |
$changes{'categorizecomm'} = 1; |
$changes{'categorizecomm'} = 1; |
|
$changes{'togglecatsplace'} = 1; |
|
$changes{'categorizeplace'} = 1; |
$domconfig{'coursecategories'} = { |
$domconfig{'coursecategories'} = { |
togglecats => $env{'form.togglecats'}, |
togglecats => $env{'form.togglecats'}, |
categorize => $env{'form.categorize'}, |
categorize => $env{'form.categorize'}, |
togglecatscomm => $env{'form.togglecatscomm'}, |
togglecatscomm => $env{'form.togglecatscomm'}, |
categorizecomm => $env{'form.categorizecomm'}, |
categorizecomm => $env{'form.categorizecomm'}, |
|
togglecatsplace => $env{'form.togglecatsplace'}, |
|
categorizeplace => $env{'form.categorizeplace'}, |
}; |
}; |
foreach my $item (@catitems) { |
foreach my $item (@catitems) { |
if ($env{'form.coursecat_'.$item} ne 'std') { |
if ($env{'form.coursecat_'.$item} ne 'std') { |
Line 10887 sub modify_coursecategories {
|
Line 10939 sub modify_coursecategories {
|
if (($domconfig{'coursecategories'}{'cats'}{'communities::0'} ne '') && ($env{'form.communities'} == 0)) { |
if (($domconfig{'coursecategories'}{'cats'}{'communities::0'} ne '') && ($env{'form.communities'} == 0)) { |
push(@deletecategory,'communities::0'); |
push(@deletecategory,'communities::0'); |
} |
} |
|
if (($domconfig{'coursecategories'}{'cats'}{'placement::0'} ne '') && ($env{'form.placement'} == 0)) { |
|
push(@deletecategory,'placement::0'); |
|
} |
} |
} |
my (@predelcats,@predeltrails,%predelallitems,%sort_by_deltrail); |
my (@predelcats,@predeltrails,%predelallitems,%sort_by_deltrail); |
if (ref($cathash) eq 'HASH') { |
if (ref($cathash) eq 'HASH') { |
Line 10949 sub modify_coursecategories {
|
Line 11004 sub modify_coursecategories {
|
$adds{$newitem} = 1; |
$adds{$newitem} = 1; |
} |
} |
} |
} |
|
if ($env{'form.placement'} eq '1') { |
|
if (ref($cathash) eq 'HASH') { |
|
my $newitem = 'placement::0'; |
|
if ($cathash->{$newitem} eq '') { |
|
$domconfig{'coursecategories'}{'cats'}{$newitem} = $env{'form.placement_pos'}; |
|
$adds{$newitem} = 1; |
|
} |
|
} else { |
|
my $newitem = 'placement::0'; |
|
$domconfig{'coursecategories'}{'cats'}{$newitem} = $env{'form.placement_pos'}; |
|
$adds{$newitem} = 1; |
|
} |
|
} |
if ($env{'form.addcategory_name'} ne '') { |
if ($env{'form.addcategory_name'} ne '') { |
if (($env{'form.addcategory_name'} ne 'instcode') && |
if (($env{'form.addcategory_name'} ne 'instcode') && |
($env{'form.addcategory_name'} ne 'communities')) { |
($env{'form.addcategory_name'} ne 'communities') && |
|
($env{'form.addcategory_name'} ne 'placement')) { |
my $newitem = &escape($env{'form.addcategory_name'}).'::0'; |
my $newitem = &escape($env{'form.addcategory_name'}).'::0'; |
$domconfig{'coursecategories'}{'cats'}{$newitem} = $env{'form.addcategory_pos'}; |
$domconfig{'coursecategories'}{'cats'}{$newitem} = $env{'form.addcategory_pos'}; |
$adds{$newitem} = 1; |
$adds{$newitem} = 1; |