[LON-CAPA-cvs] cvs: loncom /interface coursecatalog.pm

raeburn lon-capa-cvs@mail.lon-capa.org
Wed, 10 Jan 2007 03:57:51 -0000


raeburn		Tue Jan  9 22:57:51 2007 EDT

  Modified files:              
    /loncom/interface	coursecatalog.pm 
  Log:
  Make life easier for Domain Coordinators by allowing display of full details for several courses at once, if user has an active DC role in the domain.
  
  
Index: loncom/interface/coursecatalog.pm
diff -u loncom/interface/coursecatalog.pm:1.15 loncom/interface/coursecatalog.pm:1.16
--- loncom/interface/coursecatalog.pm:1.15	Mon Jan  8 10:54:56 2007
+++ loncom/interface/coursecatalog.pm	Tue Jan  9 22:57:51 2007
@@ -66,7 +66,7 @@
         &course_selector($r,$codedom,$formname,$domdesc);
         if ($env{'form.state'} eq 'listing') {
             $r->print('<br /><br />'.&print_course_listing($codedom).'<br />');
-        }
+        } 
     }
     $r->print(&Apache::loncommon::end_page());
     return OK;
@@ -236,6 +236,13 @@
                       '</option>'."\n".'</select>'."\n".
                  '</td>'
                 );
+            if (&user_is_dc($codedom)) {
+                my $showdetails_status;
+                if ($env{'form.showdetails'}) {
+                    $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('</tr></table>');
             if ($numtitles > 4) {
                 $r->print('<br /><br />'.$codetitles[$numtitles-1].'<br />'."\n".
@@ -252,6 +259,18 @@
     return;
 }
 
+sub user_is_dc {
+    my ($codedom) = @_;
+    if (exists($env{'user.role.dc./'.$codedom.'/'})) {
+        my $livedc = 1;
+        my $now = time;
+        my ($start,$end)=split(/\./,$env{'user.role.dc./'.$codedom.'/'});
+        if ($start && $start>$now) { $livedc = 0; }
+        if ($end   && $end  <$now) { $livedc = 0; }
+        return $livedc;
+    }
+    return;
+}
 
 sub recurse_options {
     my ($currkey,$currlist,$level,$cat,$cat_options,$data,$by_year,$by_sem,$by_dept) = @_;
@@ -366,6 +385,12 @@
     my $output;
     my %courses;
     my $knownuser = &user_is_known();
+    my $details = $env{'form.coursenum'};
+    if (&user_is_dc($domain)) {
+        if ($env{'form.showdetails'}) {
+            $details = 1;
+        }
+    }
     if ($env{'form.coursenum'} ne '') {
         %courses = &Apache::lonnet::courseiddump($domain,'.',1,'.','.',
                                                  $env{'form.coursenum'},
@@ -380,19 +405,19 @@
             $output = &mt('No courses match the criteria you selected.');
             return $output;
         }
-        if ($knownuser) {
+        if ($knownuser && !$env{'form.showdetails'}) {
             $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,$env{'form.coursenum'});
-    $output .= &Apache::lonhtmlcommon::echo_form_input(['coursenum','state','catalogfilter','sortby']);
+    $output .= &construct_data_table($knownuser,\%courses,$details);
+    $output .= &Apache::lonhtmlcommon::echo_form_input(['coursenum','state','catalogfilter','sortby','showdetails']);
     return $output;
 }
 
 sub construct_data_table {
     my ($knownuser,$courses,$details,$usersections) = @_;
     my %sortname;
-    if ($details eq '') {
+    if (($details eq '') || ($env{'form.showdetails'})) {
         $sortname{'Code'} = 'code';
         $sortname{'Title'} = 'title';
         $sortname{'Owner'} = 'owner';