Diff for /loncom/interface/coursecatalog.pm between versions 1.26 and 1.27

version 1.26, 2008/02/15 02:30:14 version 1.27, 2008/03/08 04:00:53
Line 261  function setCourseId(caller) { Line 261  function setCourseId(caller) {
                       '</option>'."\n".'</select>'."\n".                        '</option>'."\n".'</select>'."\n".
                  '</td>'                   '</td>'
                 );                  );
               my $show_selfenroll_status;
               if ($env{'form.showselfenroll'}) {
                   $show_selfenroll_status = 'checked="checked" ';
               }
             if (&user_is_dc($codedom)) {              if (&user_is_dc($codedom)) {
                 my $showdetails_status;                  my $showdetails_status;
                 if ($env{'form.showdetails'}) {                  if ($env{'form.showdetails'}) {
                     $showdetails_status = 'checked="checked" ';                      $showdetails_status = 'checked="checked" ';
                 }                   }
                 $r->print('<td></td><td><input type="checkbox" name="showdetails" value="1" '.$showdetails_status.'/>'.&mt('Show full details for each course (DC only)').'</td>');                  $r->print('<td></td><td><label><input type="checkbox" name="showdetails" value="1" '.$showdetails_status.'/>'.&mt('Show full details for each course (DC only)').'</label><br /><label><input type="checkbox" name="showselfenroll" value="1" '.$show_selfenroll_status.'/>'.&mt('Only show courses which allow self-enrollment').'</label></td>');
               } else {
                   $r->print('<td></td><td><br /><label><input type="checkbox" name="showselfenroll" value="1" '.$show_selfenroll_status.'/>'.&mt('Only show courses which allow self-enrollment').'</label></td>');
             }              }
             $r->print('</tr></table>');              $r->print('</tr></table>');
             if ($numtitles > 4) {              if ($numtitles > 4) {
Line 414  sub search_courselist { Line 420  sub search_courselist {
         }          }
     }      }
     my %courses = &Apache::lonnet::courseiddump($domain,'.',1,$instcode,'.','.',      my %courses = &Apache::lonnet::courseiddump($domain,'.',1,$instcode,'.','.',
                                                 undef,undef,'Course',1);                                                  undef,undef,'Course',1,
                                                   $env{'form.showselfenroll'});
     return %courses;      return %courses;
 }  }
   
Line 448  sub print_course_listing { Line 455  sub print_course_listing {
             $output = &mt('<b>Note for students:</b> If you are officially enrolled in a course but the course is not listed in your LON-CAPA courses, click the "Show more details" link for the specific course and check the default access dates and/or automated enrollment settings.<br /><br />');              $output = &mt('<b>Note for students:</b> If you are officially enrolled in a course but the course is not listed in your LON-CAPA courses, click the "Show more details" link for the specific course and check the default access dates and/or automated enrollment settings.<br /><br />');
         }          }
     }      }
     $output .= &construct_data_table($knownuser,\%courses,$details);      my $now = time;
       my %domconfig =
           &Apache::lonnet::get_dom('configuration',['usercreation'],$domain);
       $output .= &construct_data_table($knownuser,\%courses,$details,undef,$now,\%domconfig);
     $output .= &Apache::lonhtmlcommon::echo_form_input(['coursenum','state','catalogfilter','sortby','showdetails']);      $output .= &Apache::lonhtmlcommon::echo_form_input(['coursenum','state','catalogfilter','sortby','showdetails']);
     return $output;      return $output;
 }  }
   
 sub construct_data_table {  sub construct_data_table {
     my ($knownuser,$courses,$details,$usersections) = @_;      my ($knownuser,$courses,$details,$usersections,$now,$domconfig) = @_;
     my %sortname;      my %sortname;
     if (($details eq '') || ($env{'form.showdetails'})) {      if (($details eq '') || ($env{'form.showdetails'})) {
         $sortname{'Code'} = 'code';          $sortname{'Code'} = 'code';
Line 485  sub construct_data_table { Line 495  sub construct_data_table {
               '<th>'.&mt('Student Counts').'</th>'.                '<th>'.&mt('Student Counts').'</th>'.
               '<th>'.&mt('Auto-enrollment of <br />registered students').'</th>';                '<th>'.&mt('Auto-enrollment of <br />registered students').'</th>';
         } else {          } else {
             $output .= '<th>&nbsp;</th>';              $output .= '<th>'.&mt('Details').'</th>';
         }          }
     }      }
       $output .= '<th>'.&mt('Self-enroll (if permitted)').'</th>';
     &Apache::loncommon::end_data_table_header_row();      &Apache::loncommon::end_data_table_header_row();
     my %courseinfo = &build_courseinfo_hash($courses,$knownuser,$details,      my %courseinfo = &build_courseinfo_hash($courses,$knownuser,$details,
                                             $usersections);                                              $usersections);
Line 516  sub construct_data_table { Line 527  sub construct_data_table {
     foreach my $item (@sorted_courses) {      foreach my $item (@sorted_courses) {
         foreach my $course (@{$Sortby{$item}}) {          foreach my $course (@{$Sortby{$item}}) {
             $output.=&Apache::loncommon::start_data_table_row();               $output.=&Apache::loncommon::start_data_table_row(); 
             $output.=&courseinfo_row($courseinfo{$course},$knownuser,$details,\$count);              $output.=&courseinfo_row($courseinfo{$course},$knownuser,
                                        $details,\$count,$now,$course);
             $output.=&Apache::loncommon::end_data_table_row();              $output.=&Apache::loncommon::end_data_table_row();
         }          }
     }      }
Line 537  sub build_courseinfo_hash { Line 549  sub build_courseinfo_hash {
         $cleandesc=~s/'/\\'/g;          $cleandesc=~s/'/\\'/g;
         $cleandesc =~ s/^\s+//;          $cleandesc =~ s/^\s+//;
         my ($cdom,$cnum)=split(/\_/,$course);          my ($cdom,$cnum)=split(/\_/,$course);
         my ($descr,$instcode,$singleowner,$ttype,@owners,%ownernames);          my ($descr,$instcode,$singleowner,$ttype,$selfenroll_types,
               $selfenroll_start,$selfenroll_end,@owners,%ownernames);
         if (ref($courses->{$course}) eq 'HASH') {          if (ref($courses->{$course}) eq 'HASH') {
             $descr = $courses->{$course}{'description'};              $descr = $courses->{$course}{'description'};
             $instcode =  $courses->{$course}{'inst_code'};              $instcode =  $courses->{$course}{'inst_code'};
             $singleowner = $courses->{$course}{'owner'};              $singleowner = $courses->{$course}{'owner'};
             $ttype =  $courses->{$course}{'type'};              $ttype =  $courses->{$course}{'type'};
               $selfenroll_types = $courses->{$course}{'selfenroll_types'};
               $selfenroll_start = $courses->{$course}{'selfenroll_start_date'};
               $selfenroll_end = $courses->{$course}{'selfenroll_end_date'};
             push(@owners,$singleowner);              push(@owners,$singleowner);
             if (ref($courses->{$course}{'co-owners'}) eq 'ARRAY') {              if (ref($courses->{$course}{'co-owners'}) eq 'ARRAY') {
                 foreach my $item (@{$courses->{$course}{'co-owners'}}) {                  foreach my $item (@{$courses->{$course}{'co-owners'}}) {
Line 577  sub build_courseinfo_hash { Line 593  sub build_courseinfo_hash {
         $courseinfo{$course}{'ownerlastnames'} = join(', ',sort(@lastnames));          $courseinfo{$course}{'ownerlastnames'} = join(', ',sort(@lastnames));
         $courseinfo{$course}{'title'} = $cleandesc;          $courseinfo{$course}{'title'} = $cleandesc;
         $courseinfo{$course}{'owner'} = $singleowner;          $courseinfo{$course}{'owner'} = $singleowner;
           $courseinfo{$course}{'selfenroll_types'} = $selfenroll_types;
           $courseinfo{$course}{'selfenroll_start'} = $selfenroll_start;
           $courseinfo{$course}{'selfenroll_end'} = $selfenroll_end;
   
         my %coursehash = &Apache::lonnet::dump('environment',$cdom,$cnum);          my %coursehash = &Apache::lonnet::dump('environment',$cdom,$cnum);
         my @classids;          my @classids;
Line 660  sub count_students { Line 679  sub count_students {
 }  }
   
 sub courseinfo_row {  sub courseinfo_row {
     my ($info,$knownuser,$details,$countref) = @_;      my ($info,$knownuser,$details,$countref,$now,$course) = @_;
     my ($cdom,$cnum,$title,$ownerlast,$code,$owner,$seclist,$xlist_items,      my ($cdom,$cnum,$title,$ownerlast,$code,$owner,$seclist,$xlist_items,
         $accessdates,$showsyllabus,$counts,$autoenrollment,$output);          $accessdates,$showsyllabus,$counts,$autoenrollment,$output);
     if (ref($info) eq 'HASH') {      if (ref($info) eq 'HASH') {
Line 703  sub courseinfo_row { Line 722  sub courseinfo_row {
             $output .= "<td><a href=\"javascript:setCourseId('$cnum')\">".&mt('Show more details').'</a></td>';              $output .= "<td><a href=\"javascript:setCourseId('$cnum')\">".&mt('Show more details').'</a></td>';
         }          }
     }      }
       my $selfenroll;
       if ($info->{'selfenroll_types'}) {
           my $showstart = &Apache::lonlocal::locallocaltime($info->{'selfenroll_start'});
           my $showend = &Apache::lonlocal::locallocaltime($info->{'selfenroll_end'});
           if (($info->{'selfenroll_end'} > 0) && ($info->{'selfenroll_end'} > $now)) {
               if (($info->{'selfenroll_start'} > 0) && ($info->{'selfenroll_start'} > $now)) {
                   $output .= '<td>'.&mt('Starts: [_1]','<span class="LC_cusr_emph">'.$showstart.'</span>').'<br />'.&mt('Ends: [_1]','<span class="LC_cusr_emph">'.$showend.'</span>').'</td>';
               } else { 
                   $output .= '<td><a href="/adm/selfenroll?cid='.$course.'">'.&mt('Enroll in course').'</a></td>';
               }
               $selfenroll = 1;
           }
       }
       if (!$selfenroll) {
           $output .= '<td>&nbsp;</td>';
       }
     $$countref ++;      $$countref ++;
     return $output;      return $output;
 }  }

Removed from v.1.26  
changed lines
  Added in v.1.27


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>