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

raeburn lon-capa-cvs@mail.lon-capa.org
Thu, 04 Nov 2004 00:57:26 -0000


This is a MIME encoded message

--raeburn1099529846
Content-Type: text/plain

raeburn		Wed Nov  3 19:57:26 2004 EDT

  Modified files:              
    /loncom/interface	lonsupportreq.pm 
  Log:
  Add select boxes for choice of institutional code, when 'Ask Helpdesk' form is called when the use has not selected a role (e.g., from the log-in page, prior to log-in).
  
  
--raeburn1099529846
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20041103195726.txt"

Index: loncom/interface/lonsupportreq.pm
diff -u loncom/interface/lonsupportreq.pm:1.9 loncom/interface/lonsupportreq.pm:1.10
--- loncom/interface/lonsupportreq.pm:1.9	Mon Sep 13 09:31:52 2004
+++ loncom/interface/lonsupportreq.pm	Wed Nov  3 19:57:25 2004
@@ -38,6 +38,7 @@
     if (($tablecolor eq '') || ($tablecolor eq '#FFFFFF')) {
         $tablecolor = '#CCCCFF';
     }
+    $ccode = '';
     $os = $ENV{'browser.os'};
     $browser = $ENV{'browser.type'};
     $bversion = $ENV{'browser.version'};
@@ -313,20 +314,66 @@
               <tr>
                <td>
 END
-    if ($coursecodes{$cnum}) {
-        foreach (@codetitles) {
-            $r->print('<i>'.$_.'</i>:&nbsp;'.$codes{$cnum}{$_}.';&nbsp;');
+    if ($cnum) { 
+        if ($coursecodes{$cnum}) {
+            foreach (@codetitles) {
+                $r->print('<i>'.$_.'</i>:&nbsp;'.$codes{$cnum}{$_}.';&nbsp;');
+            }
+            $r->print('&nbsp;<input type="hidden" name="coursecode" value="'.$coursecodes{$cnum}.'" />');
+        } else {
+            $r->print('Enter institutional course code:&nbsp;
+                  <input type="text" name="coursecode" size="15" value="" />');
         }
-        $r->print('&nbsp;<input type="hidden" name="coursecode" value="'.$coursecodes{$cnum}.'" />');
     } else {
-        $r->print('Enter institutional course code:&nbsp;
+        if ($totcodes > 0) {
+            my $numtitles = @codetitles;
+            if ($numtitles == 0) {
+                $r->print('Enter institutional course code:&nbsp;
                   <input type="text" name="coursecode" size="15" value="" />');
+            } else {
+                my $lasttitle = $numtitles;
+                if ($numtitles > 4) {
+                    $lasttitle = 4;
+                } 
+                $r->print('<table><tr><td>'.$codetitles[0].'<br />'."\n".
+                      '<select name="'.$codetitles[0].'" onChange="courseSet('."'$codetitles[0]'".')">'."\n".
+                      ' <option value="-1" />Select'."\n");
+                my @items = ();
+                if ($idlist{$codetitles[0]} =~ /","/) {
+                    @items = split/","/,$idlist{$codetitles[0]};
+                } else {
+                    $items[0] = $idlist{$codetitles[0]};
+                }
+                foreach (@items) {
+                    $r->print(' <option value="'.$_.'" />'.$_);
+                }
+                $r->print('</select></td>');
+                for (my $i=1; $i<$numtitles; $i++) {
+                    $r->print('<td>'.$codetitles[$i].'<br />'."\n".
+                     '<select name="'.$codetitles[$i].'" onChange="courseSet('."'$codetitles[$i]'".')">'."\n".
+                     '<option value="-1">&lt;-Pick '.$codetitles[$i-1].'</option>'."\n".
+                     '</select>'."\n".
+                     '</td>'
+                    );
+                }
+                $r->print('</tr></table>');
+                if ($numtitles > 4) {
+                    $r->print('<br /><br />'.$codetitles[$numtitles].'<br />'."\n".
+                          '<select name="'.$codetitles[$numtitles].'" onChange="courseSet('."'$codetitles[$numtitles]'".')">'."\n".
+                          '<option value="-1">&lt;-Pick '.$codetitles[$numtitles-1].'</option>'."\n".
+                          '</select>'."\n");
+                }
+            }
+        } else {
+            $r->print('Enter institutional course code:&nbsp;
+                  <input type="text" name="coursecode" size="15" value="" />');
+        }
     }
     if ($ctitle) {
         $r->print('<br /><i>Title</i>:&nbsp;'.$ctitle.'<input type="hidden" name="title" value="'.$ctitle.'" />');
     } else {
         $r->print('<br />Enter course title:&nbsp;
-                 <input type="text" name="title" size="15" value="" />');
+                 <input type="text" name="title" size="25" value="" />');
     }
     $r->print(<<END);
                </td>
@@ -923,18 +970,25 @@
 
 sub javascript_code_selections {
     my ($numcats,$script_tag,$idlist,$idnums,$idlist_titles,$codetitles) = @_;
+    my $numtitles = @{$codetitles};
+    my @seltitles = (); 
+    for (my $j=0; $j<$numtitles; $j++) {
+        $seltitles[$j] = 'id'.$$codetitles[$j];
+    }
+    my $seltitle_str = join('","',@seltitles);
     $$script_tag .= <<END;
 function courseSet(caller) {
-    var idyr = document.forms.logproblem.idyear.selectedIndex
-    var idsem  = document.forms.logproblem.idsem.selectedIndex
-    var iddept = document.forms.logproblem.iddept.selectedIndex
-    var idclass = document.forms.logproblem.idclass.selectedIndex
+    var ids = new Array ("$seltitle_str");
+    var formitems = new Array ($numtitles);
+    var idyr = document.forms.logproblem.Year.selectedIndex
+    var idsem  = document.forms.logproblem.Semester.selectedIndex
+    var iddept = document.forms.logproblem.Department.selectedIndex
+    var idclass = document.forms.logproblem.Number.selectedIndex
     var idyears = new Array("$$idlist{$$codetitles[0]}");
     var idsems = new Array ($$idnums{$$codetitles[0]});
     var idsemlongs = new Array ($$idnums{$$codetitles[0]});
     var idcodes = new Array ($$idnums{$$codetitles[0]});
     var idcourses = new Array ($$idnums{$$codetitles[0]});
-    var idsections = new Array ($$idnums{$$codetitles[0]})
 END
     my @sort_a = split/","/,$$idlist{$$codetitles[0]}; 
     for (my $j=0; $j<@sort_a; $j++) {
@@ -942,79 +996,65 @@
         $$script_tag .= qq| idsemlongs[$j] = new Array("$$idlist_titles{$$codetitles[1]}{$sort_a[$j]}")\n|;
         $$script_tag .= qq| idcodes[$j] = new Array($$idnums{$$codetitles[1]}{$sort_a[$j]})\n|;
         $$script_tag .= qq| idcourses[$j] = new Array($$idnums{$$codetitles[1]}{$sort_a[$j]})\n|;
-        $$script_tag .= qq| idsections[$j] = new Array($$idnums{$$codetitles[1]}{$sort_a[$j]})\n|;
         my @sort_b = split/","/,$$idlist{$$codetitles[1]}{$sort_a[$j]};
         for (my $k=0; $k<@sort_b; $k++) {
             my $idcode_entry = $$idlist{$$codetitles[2]}{$sort_a[$j]}{$sort_b[$k]};
             $$script_tag .= qq| idcodes[$j][$k] = new Array("$idcode_entry")\n|;
             $$script_tag .= qq| idcourses[$j][$k] = new Array($$idnums{$$codetitles[2]}{$sort_a[$j]}{$sort_b[$k]})\n|;
-            $$script_tag .= qq| idsections[$j][$k] = new Array($$idnums{$$codetitles[2]}{$sort_a[$j]}{$sort_b[$k]})\n|;
             my @sort_c = split/","/,$$idlist{$$codetitles[2]}{$sort_a[$j]}{$sort_b[$k]};
             for (my $l=0; $l<@sort_c; $l++) {
                 my $idcourse_entry = $$idlist{$$codetitles[3]}{$sort_a[$j]}{$sort_b[$k]}{$sort_c[$l]};
                 $$script_tag .= qq| idcourses[$j][$k][$l] = new Array("$idcourse_entry")\n|;
-                $$script_tag .= qq| idsections[$j][$k][$l] = new Array($$idnums{$$codetitles[3]}{$sort_a[$j]}{$sort_b[$k]}{$sort_c[$l]})\n|;
-                my @sort_d = split/","/,$$idlist{$$codetitles[3]}{$sort_a[$j]}{$sort_b[$k]}{$sort_c[$l]};
-                for (my $m=0; $m<@sort_d; $m++) {
-                    my $idsecentry = $$idlist{$$codetitles[4]}{$sort_a[$j]}{$sort_b[$k]}{$sort_c[$l]}{$sort_d[$m]};
-                    $$script_tag .= qq| idsections[$j][$k][$l][$m] = new Array("$idsecentry")\n|;
-                }
             }
         }
     }
     $$script_tag .= (<<END_OF_BLOCK);
- if (caller == "semester") {
-   document.forms.logproblem.iddept.length = 0
-   document.forms.logproblem.idclass.length = 0
-   document.forms.logproblem.idsec.length = 0
-   document.forms.logproblem.iddept.options[0] = new Option("<-Pick sem.","-1",true,true)
-   document.forms.logproblem.idclass.options[0] = new Option("<-Pick dept.","-1",true,true)
-   document.forms.logproblem.idsec.options[0] = new Option("Pick course first (above)","-1",true,true)
+ if (caller == "Year") {
+   document.forms.logproblem.Department.length = 0
+   document.forms.logproblem.Number.length = 0
+   document.forms.logproblem.Department.options[0] = new Option("<-Pick Semester.","-1",true,true)
+   document.forms.logproblem.Number.options[0] = new Option("<-Pick Department","-1",true,true)
    if (idyr == 0) {
-    document.forms.logproblem.idsem.length = 0
-    document.forms.logproblem.idsem.options[0] = new Option("<-Pick year","-1",true,true)
+    document.forms.logproblem.Semester.length = 0
+    document.forms.logproblem.Semester.options[0] = new Option("<-Pick Year","-1",true,true)
    }
    else {
-    document.forms.logproblem.idsem.length = 0
-    document.forms.logproblem.idsem.options[0] = new Option("Select","-1",true,true)
+    document.forms.logproblem.Semester.length = 0
+    document.forms.logproblem.Semester.options[0] = new Option("Select","-1",true,true)
     for (var i=0; i<idsems[idyr-1].length; i++) {
-      document.forms.logproblem.idsem.options[i+1] = new Option(idsemlongs[idyr-1][i],idsems[idyr-1][i],false,false)
+      document.forms.logproblem.Semester.options[i+1] = new Option(idsemlongs[idyr-1][i],idsems[idyr-1][i],false,false)
     }
    }
-   document.forms.logproblem.idsem.selectedIndex = 0;
+   document.forms.logproblem.Semester.selectedIndex = 0;
  }
- if (caller == "dept") {
-   document.forms.logproblem.iddept.length = 0
-   document.forms.logproblem.idclass.length = 0
-   document.forms.logproblem.idsec.length = 0
-   document.forms.logproblem.idclass.options[0] = new Option("<-Pick dept.","-1",true,true)
-   document.forms.logproblem.idsec.options[0] = new Option("Pick course first (above)","-1",true,true)
+ if (caller == "Semester") {
+   document.forms.logproblem.Department.length = 0
+   document.forms.logproblem.Number.length = 0
+   document.forms.logproblem.Number.options[0] = new Option("<-Pick Department.","-1",true,true)
    if (idsem == 0) {
-     document.forms.logproblem.iddept.options[0] = new Option("<-Pick sem.","-1",true,true)
-     document.forms.logproblem.iddept.options[0] = new Option("<-Pick sem.","-1",true,true)
+     document.forms.logproblem.Department.options[0] = new Option("<-Pick Semester.","-1",true,true)
+     document.forms.logproblem.Department.options[0] = new Option("<-Pick Semester","-1",true,true)
    }
    else {
-    document.forms.logproblem.iddept.options[0] = new Option("Select","-1",true,true)    
+    document.forms.logproblem.Department.options[0] = new Option("Select","-1",true,true)    
     for (var i=0; i<idcodes[idyr-1][idsem-1].length; i++) {
-      document.forms.logproblem.iddept.options[i+1] = new Option(idcodes[idyr-1][idsem-1][i],idcodes[idyr-1][idsem-1][i],false,false)
+      document.forms.logproblem.Department.options[i+1] = new Option(idcodes[idyr-1][idsem-1][i],idcodes[idyr-1][idsem-1][i],false,false)
     }
    }
-   document.forms.logproblem.iddept.selectedIndex = 0
+   document.forms.logproblem.Department.selectedIndex = 0
  }
- if (caller == "course") {
-   document.forms.logproblem.idclass.length = 0
-   document.forms.logproblem.idsec.length = 0
-   document.forms.logproblem.idsec.options[0] = new Option("Pick course first (above)","-1",true,true)
+ if (caller == "Department") {
+   document.forms.logproblem.Number.length = 0
    if (iddept == 0) {
-     document.forms.logproblem.idclass.options[0] = new Option("<-Pick dept.","-1",true,true)
+     document.forms.logproblem.Number.options[0] = new Option("<-Pick Department.","-1",true,true)
    }
    else {
-    document.forms.logproblem.idclass.options[0] = new Option("Select","-1",true,true)
+    document.forms.logproblem.Number.options[0] = new Option("Select","-1",true,true)
     for (var i=0; i<idcourses[idyr-1][idsem-1][iddept-1].length; i++) {
-      document.forms.logproblem.idclass.options[i+1] = new Option(idcourses[idyr-1][idsem-1][iddept-1][i],idcourses[idyr-1][idsem-1][iddept-1][i],false,false)
+      document.forms.logproblem.Number.options[i+1] = new Option(idcourses[idyr-1][idsem-1][iddept-1][i],idcourses[idyr-1][idsem-1][iddept-1][i],false,false)
     }
    }
-   document.forms.logproblem.idclass.selectedIndex = 0
+   document.forms.logproblem.Number.selectedIndex = 0
  }
 }
 END_OF_BLOCK

--raeburn1099529846--