[LON-CAPA-cvs] cvs: loncom /interface loncommon.pm lonhtmlcommon.pm lonpickcourse.pm

raeburn lon-capa-cvs@mail.lon-capa.org
Tue, 15 Nov 2005 20:46:42 -0000


This is a MIME encoded message

--raeburn1132087602
Content-Type: text/plain

raeburn		Tue Nov 15 15:46:42 2005 EDT

  Modified files:              
    /loncom/interface	lonpickcourse.pm loncommon.pm lonhtmlcommon.pm 
  Log:
  Making support for multiple selects in pickcourse more general. 
  
  
--raeburn1132087602
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20051115154642.txt"

Index: loncom/interface/lonpickcourse.pm
diff -u loncom/interface/lonpickcourse.pm:1.34 loncom/interface/lonpickcourse.pm:1.35
--- loncom/interface/lonpickcourse.pm:1.34	Fri Oct 14 15:11:56 2005
+++ loncom/interface/lonpickcourse.pm	Tue Nov 15 15:46:40 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Pick a course
 #
-# $Id: lonpickcourse.pm,v 1.34 2005/10/14 19:11:56 albertel Exp $
+# $Id: lonpickcourse.pm,v 1.35 2005/11/15 20:46:40 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -55,7 +55,7 @@
 			       'sincefilter','form','cnumelement',
 			       'cdomelement','cnameelement','roleelement',
                                'pickedcourse','instcodefilter',
-                               'ownerfilter','coursefilter']);
+                               'ownerfilter','coursefilter','multiple']);
 # domain filter and selection
     my $domainfilter=$env{'form.domainfilter'};
     $domainfilter=~s/\W//g;
@@ -115,16 +115,15 @@
             $seclist = join('","',@sections);
         }
     }
-# if called from rolefilter, setup for multiple course selections.
-    my $multflag = 0;
     my $jscript;
     my $title = 'Selecting a course';
-    if ($env{'form.form'} eq 'rolefilter') {
-        $multflag = 1;
+# Setup for multiple course selections, if flag for multiples set.
+    my $multiple = $env{'form.multiple'};
+    my $multelement;
+    if ($multiple) {
         $title = 'Selecting course(s)';
-    }
-    if ($multflag) {
         $jscript = &Apache::loncommon::check_uncheck_jscript();
+        $multelement = '<input type="hidden" name="multiple" value="'.$multiple.'" />';
     }
     $r->print(&Apache::loncommon::bodytag($title,undef,$loaditem,undef,undef,undef,undef,1));
     my %lt=&Apache::lonlocal::texthash(
@@ -155,11 +154,11 @@
     }
     $r->print(<<ENDSCRIPT);
 <script>
-function gochoose(cname,cdom,cdesc,multflag,caller) {
+function gochoose(cname,cdom,cdesc,multiple,caller) {
     var openerForm = "$env{'form.form'}";
     courseCount = 0;
     var courses = '';
-    if (multflag) {
+    if (multiple) {
 	if (typeof(document.courselist.course_id.length) == 'undefined') {
 	    // only 1 course checkbox was created
 	    if (document.courselist.course_id.checked) {
@@ -198,10 +197,11 @@
     } else {
         $name_code
         opener.document.$env{'form.form'}.$env{'form.cnumelement'}.value=cname;
-        if (openerForm == 'cu') {
+        var slct=opener.document.$env{'form.form'}.$env{'form.cdomelement'};
+        if (slct.options == undefined) {
             opener.document.$env{'form.form'}.$env{'form.cdomelement'}.value=cdom;
-        } else {
-            var slct=opener.document.$env{'form.form'}.$env{'form.cdomelement'};
+        }
+        else {
             var i;
             for (i=0;i<slct.length;i++) {
                 if (slct.options[i].value==cdom) { slct.selectedIndex=i; }
@@ -252,6 +252,7 @@
 $name_input
 <input type="hidden" name="form" value="$env{'form.form'}" />
 $roleelement
+$multelement
 $lt{'cac'}: $sincefilterform
 <br />
 $lt{'cdo'}: $domainselectform
@@ -294,7 +295,7 @@
             my $description = lc($descr);
             push (@{$by_descrip{$description}}, $course);
 	}
-        if ($numcourses > 1 && $multflag) {
+        if ($numcourses > 1 && $multiple) {
             $r->print('<input type="button" value="check all"
                     onclick="javascript:checkAll(document.courselist.course_id)" />                    &nbsp;&nbsp;<input type="button" value="uncheck all"
                     onclick="javascript:uncheckAll(document.courselist.course_id)" />
@@ -306,7 +307,7 @@
 	        $cleandesc=~s/'/\\'/g;
 	        my ($cdom,$cnum)=split(/\_/,$course);
                 my ($descr,$instcode,$owner) = split/:/,$courses{$course};
-                $r->print(&course_chooser($multflag,$cdom,$cnum,$cleandesc));
+                $r->print(&course_chooser($multiple,$cdom,$cnum,$cleandesc));
 	        $r->print($description.'('.
 		      ($Apache::lonnet::domaindescription{$cdom}?
                        $Apache::lonnet::domaindescription{$cdom}:$cdom).")");
@@ -316,13 +317,13 @@
                 unless ($owner eq '') {
                     $r->print(", owner - ".&Apache::lonnet::unescape($owner));
                 }
-		if ($multflag) { $r->print("</label>\n"); }
+		if ($multiple) { $r->print("</label>\n"); }
                 $r->print("<br />\n");
             }
 	}
 	if (!%courses) { 
             $r->print(&mt('None found'));
-        } elsif ($multflag) {
+        } elsif ($multiple) {
             $r->print('<input type="button" value="Submit" onClick="gochoose('."'','','',1)".'" />');
         }
         $r->print('<input type="hidden" name="form" value="'.$env{'form.form'}.'" />'."\n".
@@ -336,9 +337,9 @@
 }
 
 sub course_chooser {
-    my ($multflag,$cdom,$cnum,$cleandesc) = @_;
+    my ($multiple,$cdom,$cnum,$cleandesc) = @_;
     my $output; 
-    if ($multflag) {
+    if ($multiple) {
         $output = '<label><input type="checkbox" name="course_id" value="'.$cdom.'_'.$cnum.'" />'."\n";
     } else {
         $output = '<input type="button" value="Select" onClick="gochoose('.
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.292 loncom/interface/loncommon.pm:1.293
--- loncom/interface/loncommon.pm:1.292	Tue Nov 15 13:07:46 2005
+++ loncom/interface/loncommon.pm	Tue Nov 15 15:46:40 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.292 2005/11/15 18:07:46 albertel Exp $
+# $Id: loncommon.pm,v 1.293 2005/11/15 20:46:40 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -380,7 +380,7 @@
    return (<<ENDSTDBRW);
 <script type="text/javascript" language="Javascript" >
     var stdeditbrowser;
-    function opencrsbrowser(formname,uname,udom,desc,extra_element) {
+    function opencrsbrowser(formname,uname,udom,desc,extra_element,multflag) {
         var url = '/adm/pickcourse?';
         var filter;
         if (filter != null) {
@@ -403,6 +403,9 @@
                 url += '&domainfilter='+extra_element;
             }
         }
+        if (multflag !=null && multflag != '') {
+            url += '&multiple='+multflag;
+        }
         var title = 'Course_Browser';
         var options = 'scrollbars=1,resizable=1,menubar=0';
         options += ',width=700,height=600';
@@ -414,9 +417,9 @@
 }
 
 sub selectcourse_link {
-   my ($form,$unameele,$udomele,$desc,$extra_element)=@_;
+   my ($form,$unameele,$udomele,$desc,$extra_element,$multflag)=@_;
     return "<a href='".'javascript:opencrsbrowser("'.$form.'","'.$unameele.
-        '","'.$udomele.'","'.$desc.'","'.$extra_element.'");'."'>".&mt('Select Course')."</a>";
+        '","'.$udomele.'","'.$desc.'","'.$extra_element.'","'.$multflag.'");'."'>".&mt('Select Course')."</a>";
 }
 
 sub check_uncheck_jscript {
Index: loncom/interface/lonhtmlcommon.pm
diff -u loncom/interface/lonhtmlcommon.pm:1.117 loncom/interface/lonhtmlcommon.pm:1.118
--- loncom/interface/lonhtmlcommon.pm:1.117	Thu Oct 27 19:18:21 2005
+++ loncom/interface/lonhtmlcommon.pm	Tue Nov 15 15:46:40 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common html routines
 #
-# $Id: lonhtmlcommon.pm,v 1.117 2005/10/27 23:18:21 raeburn Exp $
+# $Id: lonhtmlcommon.pm,v 1.118 2005/11/15 20:46:40 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1387,7 +1387,7 @@
 </script>
     |;
     my $courseform='<b>'.&Apache::loncommon::selectcourse_link
-                     ($formname,'pickcourse','pickdomain','coursedesc').'</b>';
+                     ($formname,'pickcourse','pickdomain','coursedesc','',1).'</b>';
     if ($totcodes > 0) {
         $output .= '<input type="radio" name="coursepick" value="all" onclick="coursePick(this.form)" />'.&mt('All courses');
         my $numtitles = @$codetitles;
@@ -1433,7 +1433,7 @@
             $output .= '</tr></table><br />';
         }
     }
-    $output .= '<input type="radio" name="coursepick" value="specific" onclick="coursePick(this.form);opencrsbrowser('."'".'rolefilter'."'".','."'".'dccourse'."'".','."'".'dcdomain'."'".','."'".'coursedesc'."',''".')" />'.&mt('Pick specific course(s):').' '.$courseform.'&nbsp;&nbsp;<input type="text" value="0" size="4" name="coursetotal" /><input type="hidden" name="courselist" value="" />selected.<br /></td>'."\n";
+    $output .= '<input type="radio" name="coursepick" value="specific" onclick="coursePick(this.form);opencrsbrowser('."'".$formname."'".','."'".'dccourse'."'".','."'".'dcdomain'."'".','."'".'coursedesc'."','','1'".')" />'.&mt('Pick specific course(s):').' '.$courseform.'&nbsp;&nbsp;<input type="text" value="0" size="4" name="coursetotal" /><input type="hidden" name="courselist" value="" />selected.<br /></td>'."\n";
     $output .= &row_closure();
     return $output;
 }

--raeburn1132087602--