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

raeburn lon-capa-cvs-allow@mail.lon-capa.org
Thu, 17 Jul 2008 12:00:28 -0000


raeburn		Thu Jul 17 08:00:28 2008 EDT

  Modified files:              
    /loncom/interface	coursecatalog.pm 
  Log:
  - Change link to "Enroll in course" to javascript:ToSelfenroll() which submits linklaunch form.
  - Filters used in coursecatalog display passed to selfenroll to allow breadcrumbs there.
  - syllabuslaunch form renamed linklaunch form (no longer used for just syllabus).
  - &syllabus_javascript() renamed courselink_javascript() - broader use.
  - 'courseid' added as another element to exclude from echo of form input to avoid duplicate
     when coming from breadcrumb trail link in self-enroll.
  
  
Index: loncom/interface/coursecatalog.pm
diff -u loncom/interface/coursecatalog.pm:1.40 loncom/interface/coursecatalog.pm:1.41
--- loncom/interface/coursecatalog.pm:1.40	Tue Jul 15 15:43:15 2008
+++ loncom/interface/coursecatalog.pm	Thu Jul 17 08:00:28 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler for displaying the course catalog interface
 #
-# $Id: coursecatalog.pm,v 1.40 2008/07/15 19:43:15 raeburn Exp $
+# $Id: coursecatalog.pm,v 1.41 2008/07/17 12:00:28 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -113,7 +113,7 @@
 }
 
 ENDSCRIPT
-        $catjs .= &syllabus_javascript(); 
+        $catjs .= &courselink_javascript(); 
         my $numtitles;
         if ($env{'form.currcat_0'} eq 'instcode::0') {
             $numtitles = &instcode_course_selector($r,$codedom,$formname,$domdesc,
@@ -158,7 +158,7 @@
     my %add_entries = (topmargin    => "0",
                        marginheight => "0",);
     my $js = '<script type="text/javascript">'."\n".
-             &syllabus_javascript().'</script>'."\n";
+             &courselink_javascript().'</script>'."\n";
     my $start_page =
         &Apache::loncommon::start_page('Course Catalog',$js,
                                            {
@@ -181,11 +181,12 @@
     $r->print('<form name="'.$formname.'" method="post" action="/adm/coursecatalog">'.
               '<a href = "javascript:document.coursecatalog.submit()">'.
               &mt('Back to course listing').'</a>'.
-              &Apache::lonhtmlcommon::echo_form_input(['coursenum','catalogfilter','showdetails']).'</form>');
+              &Apache::lonhtmlcommon::echo_form_input(['coursenum','catalogfilter',
+                                                       'showdetails','courseid']).'</form>');
     return;
 }
 
-sub syllabus_javascript {
+sub courselink_javascript {
     return <<"END";
 
 function ToSyllabus(cdom,cnum) {
@@ -195,8 +196,17 @@
     if (cnum == '' || cnum == null) {
         return;
     }
-    document.syllabuslaunch.action = "/public/"+cdom+"/"+cnum+"/syllabus";
-    document.syllabuslaunch.submit();
+    document.linklaunch.action = "/public/"+cdom+"/"+cnum+"/syllabus";
+    document.linklaunch.submit();
+}
+
+function ToSelfenroll(courseid) {
+    if (courseid == '') {
+        return;
+    }
+    document.linklaunch.action = "/adm/selfenroll";
+    document.linklaunch.courseid.value = courseid;
+    document.linklaunch.submit();
 }
 
 END
@@ -755,9 +765,10 @@
     my %domconfig =
         &Apache::lonnet::get_dom('configuration',['usercreation'],$domain);
     $output .= &construct_data_table($knownuser,\%courses,$details,undef,$now,\%domconfig,$trails,$allitems);
-    $output .= "\n".'<form name="syllabuslaunch" method="post" action="">'.
+    $output .= "\n".'<form name="linklaunch" method="post" action="">'.
                '<input type="hidden" name="backto" value="coursecatalog" />'.
-               &Apache::lonhtmlcommon::echo_form_input(['catalogfilter']).'</form>';
+               '<input type="hidden" name="courseid" value="" />'.
+               &Apache::lonhtmlcommon::echo_form_input(['catalogfilter','courseid']).'</form>';
     return $output;
 }
 
@@ -1084,7 +1095,7 @@
             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>';
+                $output .= '<td><a href="javascript:ToSelfenroll('."'$course'".')">'.&mt('Enroll in course').'</a></td>';
             }
             $selfenroll = 1;
         }