version 1.100, 2019/07/21 14:26:02
|
version 1.102, 2019/07/23 13:58:53
|
Line 91 sub handler {
|
Line 91 sub handler {
|
$r->print(&Apache::loncommon::end_page()); |
$r->print(&Apache::loncommon::end_page()); |
return OK; |
return OK; |
} |
} |
my %domconfig = |
my $crscats = &Apache::lonnet::get_dom_cats($codedom); |
&Apache::lonnet::get_dom('configuration',['coursecategories'],$codedom); |
my %domdefaults = &Apache::lonnet::get_domain_defaults($codedom); |
my $knownuser = &user_is_known(); |
my $knownuser = &user_is_known(); |
my $canviewall = &canview_all($knownuser,$codedom); |
my $canviewall = &canview_all($knownuser,$codedom); |
|
|
my ($cathash,$cattype); |
my ($cathash,$cattype); |
if (ref($domconfig{'coursecategories'}) eq 'HASH') { |
if (ref($crscats) eq 'HASH') { |
$cathash = $domconfig{'coursecategories'}{'cats'}; |
%{$cathash} = %{$crscats}; |
if ($knownuser || $canviewall) { |
|
$cattype = $domconfig{'coursecategories'}{'auth'}; |
|
} else { |
|
$cattype = $domconfig{'coursecategories'}{'unauth'}; |
|
} |
|
if ($cattype eq '') { |
|
$cattype = 'std'; |
|
} |
|
} else { |
} else { |
$cathash = {}; |
$cathash = {}; |
|
} |
|
if ($knownuser || $canviewall) { |
|
$cattype = $domdefaults{'catauth'}; |
|
} else { |
|
$cattype = $domdefaults{'catunauth'}; |
|
} |
|
if ($cattype eq '') { |
$cattype = 'std'; |
$cattype = 'std'; |
} |
} |
if ($cattype eq 'none') { |
if ($cattype eq 'none') { |
Line 120 sub handler {
|
Line 119 sub handler {
|
if ($knownuser || $canviewall) { |
if ($knownuser || $canviewall) { |
$r->print('<div>'.&mt('No catalog of LON-CAPA courses/communities is provided for: [_1]',$domdesc).'</div>'); |
$r->print('<div>'.&mt('No catalog of LON-CAPA courses/communities is provided for: [_1]',$domdesc).'</div>'); |
} else { |
} else { |
if ($domconfig{'coursecategories'}{'auth'} eq 'none') { |
if ($domdefaults{'catauth'} eq 'none') { |
$r->print('<div>'.&mt('No catalog of LON-CAPA courses/communities is provided for: [_1]',$domdesc).'</div>'); |
$r->print('<div>'.&mt('No catalog of LON-CAPA courses/communities is provided for: [_1]',$domdesc).'</div>'); |
} else { |
} else { |
$r->print('<div>'.&mt('The catalog of LON-CAPA courses/communities provided for: "[_1]" is only available to users who are logged in.',$domdesc).'</div>'); |
$r->print('<div>'.&mt('The catalog of LON-CAPA courses/communities provided for: "[_1]" is only available to users who are logged in.',$domdesc).'</div>'); |
Line 130 sub handler {
|
Line 129 sub handler {
|
return OK; |
return OK; |
} |
} |
|
|
my $cnum; |
my $cnum; |
if ($cattype eq 'codesrch') { |
if ($cattype eq 'codesrch') { |
my ($uniquecode,$codemsg,$brtext); |
my ($uniquecode,$codemsg,$brtext); |
if ($env{'form.uniquecode'}) { |
if ($env{'form.uniquecode'}) { |
Line 251 sub handler {
|
Line 250 sub handler {
|
$toplevelstr =~ s/,$//; |
$toplevelstr =~ s/,$//; |
$maxdepthstr =~ s/,$//; |
$maxdepthstr =~ s/,$//; |
} |
} |
&validate_input($codedom,\@cats,\%maxd,$domconfig{'coursecategories'}); |
&validate_input($codedom,\@cats,\%maxd,$cathash); |
my ($numtitles,@codetitles); |
my ($numtitles,@codetitles); |
if (($env{'form.coursenum'} ne '') && ($knownuser)) { |
if (($env{'form.coursenum'} ne '') && ($knownuser)) { |
&course_details($r,$codedom,$formname,$domdesc,\@trails,\%allitems,\@codetitles); |
&course_details($r,$codedom,$formname,$domdesc,\@trails,\%allitems,\@codetitles); |
Line 282 function setCatDepth(depth) {
|
Line 281 function setCatDepth(depth) {
|
} |
} |
document.coursecats.catalog_maxdepth.value = depth; |
document.coursecats.catalog_maxdepth.value = depth; |
} else { |
} else { |
document.coursecats.currcat_0.value = ''; |
document.coursecats.currcat_0.value = ''; |
document.coursecats.catalog_maxdepth.value = ''; |
document.coursecats.catalog_maxdepth.value = ''; |
} |
} |
document.coursecats.submit(); |
document.coursecats.submit(); |
Line 393 ENDJS
|
Line 392 ENDJS
|
} |
} |
|
|
sub validate_input { |
sub validate_input { |
my ($codedom,$cats,$maxd,$configref) = @_; |
my ($codedom,$cats,$maxd,$crscatsref) = @_; |
my $currcat = ''; |
my $currcat = ''; |
my $depth = 0; |
my $depth = 0; |
if ($env{'form.catalog_maxdepth'} ne '') { |
if ($env{'form.catalog_maxdepth'} ne '') { |
Line 519 sub validate_input {
|
Line 518 sub validate_input {
|
if (exists($env{'form.currcat_0'})) { |
if (exists($env{'form.currcat_0'})) { |
unless ($env{'form.currcat_0'} =~ /^(instcode|communities|placement)\Q::0\E$/) { |
unless ($env{'form.currcat_0'} =~ /^(instcode|communities|placement)\Q::0\E$/) { |
if ($env{'form.currcat_0'} =~ /^.+\Q::0\E$/) { |
if ($env{'form.currcat_0'} =~ /^.+\Q::0\E$/) { |
if (ref($configref) eq 'HASH') { |
if (ref($crscatsref) eq 'HASH') { |
if (ref($configref->{'cats'}) eq 'HASH') { |
unless (exists($crscatsref->{$env{'form.currcat_0'}})) { |
unless (exists($configref->{'cats'}->{$env{'form.currcat_0'}})) { |
|
delete($env{'form.currcat_0'}); |
|
} |
|
} else { |
|
delete($env{'form.currcat_0'}); |
delete($env{'form.currcat_0'}); |
} |
} |
} else { |
} else { |
Line 625 sub validate_input {
|
Line 620 sub validate_input {
|
foreach my $key (keys(%currcats)) { |
foreach my $key (keys(%currcats)) { |
if ($env{'form.'.$key} eq '') { |
if ($env{'form.'.$key} eq '') { |
delete($env{'form.'.$key}); |
delete($env{'form.'.$key}); |
} elsif (ref($configref) eq 'HASH') { |
} elsif (ref($crscatsref) eq 'HASH') { |
if (ref($configref->{'cats'}) eq 'HASH') { |
unless (exists($crscatsref->{$env{'form.'.$key}})) { |
unless (exists($configref->{'cats'}->{$env{'form.'.$key}})) { |
|
delete($env{'form.'.$key}); |
|
} |
|
} else { |
|
delete($env{'form.'.$key}); |
delete($env{'form.'.$key}); |
} |
} |
} else { |
} else { |
Line 644 sub validate_input {
|
Line 635 sub validate_input {
|
sub get_instcode_allowable { |
sub get_instcode_allowable { |
my ($codedom,$possvalref) = @_; |
my ($codedom,$possvalref) = @_; |
return 1 unless (ref($possvalref) eq 'HASH'); |
return 1 unless (ref($possvalref) eq 'HASH'); |
my $caller = 'global'; |
my $instcats = &Apache::lonnet::get_dom_instcats($codedom); |
my %coursecodes = (); |
if (ref($instcats) eq 'HASH') { |
my %codes = (); |
if ((ref($instcats->{'codetitles'}) eq 'ARRAY') && (ref($instcats->{'codes'}) eq 'HASH')) { |
my @codetitles = (); |
my %codes = %{$instcats->{'codes'}}; |
my %cat_titles = (); |
my @codetitles = @{$instcats->{'codetitles'}}; |
my %cat_order = (); |
|
my $totcodes = &Apache::courseclassifier::retrieve_instcodes(\%coursecodes,$codedom); |
|
if ($totcodes > 0) { |
|
if (&Apache::lonnet::auto_instcode_format($caller,$codedom,\%coursecodes, |
|
\%codes,\@codetitles,\%cat_titles,\%cat_order) eq 'ok') { |
|
my @standardnames = &Apache::loncommon::get_standard_codeitems(); |
my @standardnames = &Apache::loncommon::get_standard_codeitems(); |
my %local_to_standard; |
my %local_to_standard; |
for (my $i=0; $i<@codetitles; $i++) { |
for (my $i=0; $i<@codetitles; $i++) { |
Line 778 END
|
Line 764 END
|
|
|
sub instcode_course_selector { |
sub instcode_course_selector { |
my ($r,$codedom,$formname,$domdesc,$catlinks,$catjs,$codetitles,$cattype,$canviewall) = @_; |
my ($r,$codedom,$formname,$domdesc,$catlinks,$catjs,$codetitles,$cattype,$canviewall) = @_; |
my %coursecodes = (); |
|
my %codes = (); |
|
my %cat_titles = (); |
my %cat_titles = (); |
my %cat_order = (); |
my %cat_order = (); |
my %cat_items; |
my %cat_items = (); |
my $caller = 'global'; |
|
my $format_reply; |
|
my %add_entries = (topmargin => "0", |
my %add_entries = (topmargin => "0", |
marginheight => "0",); |
marginheight => "0",); |
my ($jscript,$totcodes,$numtitles,$lasttitle) = |
my ($jscript,$totcodes,$numtitles,$lasttitle) = |