version 1.17, 2007/01/12 21:07:37
|
version 1.18, 2007/01/12 23:37:22
|
Line 67 sub handler {
|
Line 67 sub handler {
|
if ($env{'form.coursenum'} ne '' && &user_is_known()) { |
if ($env{'form.coursenum'} ne '' && &user_is_known()) { |
&course_details($r,$codedom,$formname,$domdesc); |
&course_details($r,$codedom,$formname,$domdesc); |
} else { |
} else { |
&course_selector($r,$codedom,$formname,$domdesc); |
my $numtitles = &course_selector($r,$codedom,$formname,$domdesc); |
if ($env{'form.state'} eq 'listing') { |
if ($env{'form.state'} eq 'listing') { |
$r->print('<br /><br />'.&print_course_listing($codedom).'<br />'); |
$r->print(&print_course_listing($codedom,$numtitles).'<br />'); |
} |
} |
} |
} |
$r->print(&Apache::loncommon::end_page()); |
$r->print(&Apache::loncommon::end_page()); |
return OK; |
return OK; |
Line 137 sub course_selector {
|
Line 137 sub course_selector {
|
if ($numtitles > 4) { |
if ($numtitles > 4) { |
$lasttitle = 4; |
$lasttitle = 4; |
} |
} |
my @data = ('top'); |
if ($numtitles == 0) { |
for (my $k=0; $k<$lasttitle; $k++) { |
if (!defined($env{'form.state'})) { |
my $cat = $codetitles[$k]; |
$env{'form.state'} = 'listing'; |
my $level = 1; |
} |
$level = &recurse_options($codetitles[$k],$idlist{$codetitles[$k]},$level,$cat,\%cat_items,\@data,\%by_year,\%by_sem,\%by_dept); } |
} else { |
$scripttext .= &build_javascript(\%by_year,\%by_sem,\%by_dept,\%cat_order,\@codetitles); |
my @data = ('top'); |
$jscript .= &javascript_select_filler($formname,$scripttext,\@codetitles,$longtitles_str,$allidlist); |
for (my $k=0; $k<$lasttitle; $k++) { |
} |
my $cat = $codetitles[$k]; |
if ($env{'form.state'} eq 'listing') { |
my $level = 1; |
$jscript .= ' |
$level = &recurse_options($codetitles[$k],$idlist{$codetitles[$k]},$level,$cat,\%cat_items,\@data,\%by_year,\%by_sem,\%by_dept); |
|
} |
|
$scripttext .= &build_javascript(\%by_year,\%by_sem,\%by_dept,\%cat_order,\@codetitles); |
|
$jscript .= &javascript_select_filler($formname,$scripttext,\@codetitles,$longtitles_str,$allidlist); |
|
if ($env{'form.state'} eq 'listing') { |
|
$jscript .= ' |
function setElements() { |
function setElements() { |
'; |
'; |
for (my $i=0; $i<@codetitles-1; $i++) { |
for (my $i=0; $i<@codetitles-1; $i++) { |
if ($env{'form.'.$codetitles[$i]} != -1) { |
if ($env{'form.'.$codetitles[$i]} != -1) { |
$jscript .= ' |
$jscript .= ' |
for (var j=0; j<document.'.$formname.'.'.$codetitles[$i].'.length; j++) { |
for (var j=0; j<document.'.$formname.'.'.$codetitles[$i].'.length; j++) { |
if (document.'.$formname.'.'.$codetitles[$i].'[j].value == "'.$env{'form.'.$codetitles[$i]}.'") { |
if (document.'.$formname.'.'.$codetitles[$i].'[j].value == "'.$env{'form.'.$codetitles[$i]}.'") { |
document.'.$formname.'.'.$codetitles[$i].'.selectedIndex = j; |
document.'.$formname.'.'.$codetitles[$i].'.selectedIndex = j; |
} |
} |
} |
} |
'; |
'; |
} |
} |
} |
} |
$jscript .= ' courseSet()'."\n"; |
$jscript .= ' courseSet()'."\n"; |
if ($env{'form.'.$codetitles[-1]} != -1) { |
if ($env{'form.'.$codetitles[-1]} != -1) { |
$jscript .= ' |
$jscript .= ' |
for (var j=0; j<document.'.$formname.'.'.$codetitles[-1].'.length; j++) { |
for (var j=0; j<document.'.$formname.'.'.$codetitles[-1].'.length; j++) { |
if (document.'.$formname.'.'.$codetitles[-1].'[j].value == "'.$env{'form.'.$codetitles[-1]}.'") { |
if (document.'.$formname.'.'.$codetitles[-1].'[j].value == "'.$env{'form.'.$codetitles[-1]}.'") { |
document.'.$formname.'.'.$codetitles[-1].'.selectedIndex = j; |
document.'.$formname.'.'.$codetitles[-1].'.selectedIndex = j; |
} |
} |
} |
} |
'; |
'; |
|
} |
|
$jscript .= '}'; |
|
} |
} |
} |
$jscript .= '}'; |
if ($env{'form.state'} eq 'listing') { |
$jscript .= qq| |
$jscript .= qq| |
function changeSort(caller) { |
function changeSort(caller) { |
document.$formname.sortby.value = caller; |
document.$formname.sortby.value = caller; |
document.$formname.submit(); |
document.$formname.submit(); |
Line 180 function setCourseId(caller) {
|
Line 188 function setCourseId(caller) {
|
document.$formname.coursenum.value = caller; |
document.$formname.coursenum.value = caller; |
document.$formname.submit(); |
document.$formname.submit(); |
}\n|; |
}\n|; |
|
} |
} |
} |
my $js = '<script type"text/javascript">'."\n$jscript\n". |
my $js = '<script type"text/javascript">'."\n$jscript\n". |
'</script>'; |
'</script>'; |
my %add_entries = (topmargin => "0", |
my %add_entries = (topmargin => "0", |
marginheight => "0",); |
marginheight => "0",); |
if ($env{'form.state'} eq 'listing') { |
if (($env{'form.state'} eq 'listing') && ($numtitles > 0)) { |
$add_entries{'onLoad'} = 'setElements()'; |
$add_entries{'onLoad'} = 'setElements()'; |
} |
} |
my $start_page = |
my $start_page = |
Line 207 function setCourseId(caller) {
|
Line 216 function setCourseId(caller) {
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Select courses')); |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Select courses')); |
} |
} |
$r->print('<h3>'.&mt('Display information about official [_1] classes for which LON-CAPA courses have been created:',$domdesc).'</h3>'); |
$r->print('<h3>'.&mt('Display information about official [_1] classes for which LON-CAPA courses have been created:',$domdesc).'</h3>'); |
$r->print(&mt('<b>Choose which course(s) to list.</b><br />')); |
|
$r->print('<form name="coursecatalog" method="post">'); |
$r->print('<form name="coursecatalog" method="post">'); |
if ($numtitles > 0) { |
if ($numtitles > 0) { |
|
$r->print(&mt('<b>Choose which course(s) to list.</b><br />')); |
$r->print('<table><tr>'); |
$r->print('<table><tr>'); |
for (my $k=0; $k<$lasttitle-1; $k++) { |
for (my $k=0; $k<$lasttitle-1; $k++) { |
my @unsorted = @{$cat_items{$codetitles[$k]}}; |
my @unsorted = @{$cat_items{$codetitles[$k]}}; |
Line 252 function setCourseId(caller) {
|
Line 261 function setCourseId(caller) {
|
$r->print('<br /><br />'.$codetitles[$numtitles-1].'<br />'."\n". |
$r->print('<br /><br />'.$codetitles[$numtitles-1].'<br />'."\n". |
'<input type="text" name="'.$codetitles[$numtitles-1].'" /><br />'."\n"); |
'<input type="text" name="'.$codetitles[$numtitles-1].'" /><br />'."\n"); |
} |
} |
|
$r->print('<br />'); |
|
} |
|
$r->print('<input type="hidden" name="coursenum" value="" /><input type="hidden" name="sortby" value="" /><input type="hidden" name="state" value="listing" />'); |
|
if ($numtitles > 0) { |
|
$r->print('<input type="submit" name="catalogfilter" value="'.&mt('Display courses').'" />'); |
|
} |
|
$r->print('</form>'); |
|
if (($numtitles > 0) && ($env{'form.state'} eq 'listing')) { |
|
$r->print('<br /><br />'); |
} |
} |
$r->print('<br /><input type="hidden" name="coursenum" value="" /><input type="hidden" name="state" value="listing" /><input type="hidden" name="sortby" value="" /><input type="submit" name="catalogfilter" value="'.&mt('Display courses').'" /></form>'); |
|
} else { |
} else { |
$r->print(&Apache::loncommon::start_page('Course Catalog','', |
$r->print(&Apache::loncommon::start_page('Course Catalog','', |
{ |
{ |
'no_inline_link' => 1,})); |
'no_inline_link' => 1,})); |
$r->print('<br />'.&mt('No official courses to display for [_1].',$domdesc)); |
$r->print('<br />'.&mt('No official courses to display for [_1].',$domdesc)); |
} |
} |
return; |
return $numtitles; |
} |
} |
|
|
sub user_is_dc { |
sub user_is_dc { |
Line 360 sub build_javascript {
|
Line 377 sub build_javascript {
|
} |
} |
|
|
sub search_courselist { |
sub search_courselist { |
my ($domain) = @_; |
my ($domain,$numtitles) = @_; |
my ($instcode,%codedefaults,@code_order); |
my $instcode; |
my $defaults_result = |
if (defined($numtitles) && $numtitles == 0) { |
&Apache::lonnet::auto_instcode_defaults($domain,\%codedefaults, |
$instcode = '.+'; |
\@code_order); |
} else { |
if ($defaults_result eq 'ok') { |
my (%codedefaults,@code_order); |
$instcode ='^'; |
my $defaults_result = |
foreach my $item (@code_order) { |
&Apache::lonnet::auto_instcode_defaults($domain,\%codedefaults, |
if ($env{'form.'.$item} eq '0' ) { |
\@code_order); |
$instcode .= $codedefaults{$item}; |
if ($defaults_result eq 'ok') { |
} else { |
$instcode ='^'; |
$instcode .= $env{'form.'.$item}; |
foreach my $item (@code_order) { |
|
if ($env{'form.'.$item} eq '0' ) { |
|
$instcode .= $codedefaults{$item}; |
|
} else { |
|
$instcode .= $env{'form.'.$item}; |
|
} |
} |
} |
|
$instcode .= '$'; |
|
} else { |
|
$instcode = '.'; |
} |
} |
$instcode .= '$'; |
|
} else { |
|
$instcode = '.'; |
|
} |
} |
my %courses = &Apache::lonnet::courseiddump($domain,'.',1,$instcode,'.','.', |
my %courses = &Apache::lonnet::courseiddump($domain,'.',1,$instcode,'.','.', |
undef,undef,'Course',1); |
undef,undef,'Course',1); |
Line 385 sub search_courselist {
|
Line 407 sub search_courselist {
|
|
|
|
|
sub print_course_listing { |
sub print_course_listing { |
my ($domain) = @_; |
my ($domain,$numtitles) = @_; |
my $output; |
my $output; |
my %courses; |
my %courses; |
my $knownuser = &user_is_known(); |
my $knownuser = &user_is_known(); |
Line 404 sub print_course_listing {
|
Line 426 sub print_course_listing {
|
return $output; |
return $output; |
} |
} |
} else { |
} else { |
%courses = &search_courselist($domain); |
%courses = &search_courselist($domain,$numtitles); |
if (keys(%courses) == 0) { |
if (keys(%courses) == 0) { |
$output = &mt('No courses match the criteria you selected.'); |
$output = &mt('No courses match the criteria you selected.'); |
return $output; |
return $output; |