[prev in list] [next in list] [prev in thread] [next in thread] 

List:       lon-capa-cvs
Subject:    [LON-CAPA-cvs] cvs: loncom / lond  /interface courseclassifier.pm lonpickcourse.pm
From:       raeburn <raeburn () source ! lon-capa ! org>
Date:       2009-07-29 22:32:44
Message-ID: cvsraeburn1248906764 () cvsserver
[Download RAW message or body]

This is a MIME encoded message


raeburn		Wed Jul 29 22:32:44 2009 EDT

  Modified files:              
    /loncom	lond 
    /loncom/interface	courseclassifier.pm lonpickcourse.pm 
  Log:
  lonpickcourse.pm
  - Wording change.  "Course Type" changed to "Type".
  - course filter form now sets a form element named "command" to 'gosearch' on \
                submit.
  - course filter form will automatically reload, but not search, 
    if either Domain or Type are changed.
  
  courseclassifier.pm
   Javascript function "setOfficial() checks if caller arg is defined
  
  lond
  &dump_course_id_handler() change.
   - change to the effect regexp_ok arg.
   - now if arg has a value of -1, a course will be excluded from the resturned list,
     if the instcode matches the RE.
     This excludes "official" courses (i.e., those with an instcode matching the \
expected pattern for the domain) from the list returned in a search for "unofficial" \
courses.   
  


["raeburn-20090729223244.txt" (text/plain)]

Index: loncom/lond
diff -u loncom/lond:1.417 loncom/lond:1.418
--- loncom/lond:1.417	Sat Jul 25 15:25:10 2009
+++ loncom/lond	Wed Jul 29 22:32:39 2009
@@ -2,7 +2,7 @@
 # The LearningOnline Network
 # lond "LON Daemon" Server (port "LOND" 5663)
 #
-# $Id: lond,v 1.417 2009/07/25 15:25:10 raeburn Exp $
+# $Id: lond,v 1.418 2009/07/29 22:32:39 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -59,7 +59,7 @@
 my $status='';
 my $lastlog='';
 
-my $VERSION='$Revision: 1.417 $'; #' stupid emacs
+my $VERSION='$Revision: 1.418 $'; #' stupid emacs
 my $remoteVERSION;
 my $currenthostid="default";
 my $currentdomainid;
@@ -3674,8 +3674,10 @@
 #                            will be returned. Pre-2.2.0 legacy entries from 
 #                            nohist_courseiddump will only contain usernames.
 #                 type     - optional parameter for selection 
-#                 regexp_ok - if true, allow the supplied institutional code
-#                            filter to behave as a regular expression.  
+#                 regexp_ok - if 1 or -1 allow the supplied institutional code
+#                            filter to behave as a regular expression:
+#	                      1 will not exclude the course if the instcode matches the RE \
 +#                            -1 will exclude the course if the instcode matches the \
RE  #                 rtn_as_hash - whether to return the information available for
 #                            each matched item as a frozen hash of all 
 #                            key, value pairs in the item's hash, or as a 
@@ -3829,10 +3831,14 @@
                 if (!$is_hash) {
                     $unesc_val{'inst_code'} = &unescape($val{'inst_code'});
                 }
-                if ($regexp_ok) {
+                if ($regexp_ok == 1) {
                     if (eval{$unesc_val{'inst_code'} !~ /$instcodefilter/}) {
                         $match = 0;
                     }
+                } elsif ($regexp_ok == -1) {
+                    if (eval{$unesc_val{'inst_code'} =~ /$instcodefilter/}) {
+                        $match = 0;
+                    }
                 } else {
                     if (eval{$unesc_val{'inst_code'} !~ /\Q$instcodefilter\E/i}) {
                         $match = 0;
Index: loncom/interface/courseclassifier.pm
diff -u loncom/interface/courseclassifier.pm:1.7 \
                loncom/interface/courseclassifier.pm:1.8
--- loncom/interface/courseclassifier.pm:1.7	Tue May  5 05:30:00 2009
+++ loncom/interface/courseclassifier.pm	Wed Jul 29 22:32:44 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Utilities for classifying courses based on institutional code
 #
-# $Id: courseclassifier.pm,v 1.7 2009/05/05 05:30:00 raeburn Exp $
+# $Id: courseclassifier.pm,v 1.8 2009/07/29 22:32:44 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -490,12 +490,14 @@
 }
 
 function setOfficial(caller) {
-    if (caller.options[caller.selectedIndex].value != 0) {
-        if (document.'.$formname.'.official.length > 0) {
-            for (var j=0; j<document.'.$formname.'.official.length; j++) {
-                if (document.'.$formname.'.official[j].value == 1) {
-                    document.'.$formname.'.official[j].checked = true;
-                }
+   if (typeof(caller) != "undefined") {
+       if (caller.options[caller.selectedIndex].value != 0) {
+           if (document.'.$formname.'.official.length > 0) {
+               for (var j=0; j<document.'.$formname.'.official.length; j++) {
+                   if (document.'.$formname.'.official[j].value == "on") {
+                       document.'.$formname.'.official[j].checked = true;
+                   }
+               }
             }
         }
     }
Index: loncom/interface/lonpickcourse.pm
diff -u loncom/interface/lonpickcourse.pm:1.83 loncom/interface/lonpickcourse.pm:1.84
--- loncom/interface/lonpickcourse.pm:1.83	Sat Jul 25 23:16:04 2009
+++ loncom/interface/lonpickcourse.pm	Wed Jul 29 22:32:44 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Pick a course
 #
-# $Id: lonpickcourse.pm,v 1.83 2009/07/25 23:16:04 raeburn Exp $
+# $Id: lonpickcourse.pm,v 1.84 2009/07/29 22:32:44 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -83,8 +83,10 @@
     }
 
     my %loaditem;
-    if ($env{'form.numtitles'}) {
-        $loaditem{'onload'} = 'setElements(); ';
+    if (($env{'form.type'} eq 'Course') && ($env{'form.numtitles'})) {
+        if (($env{'form.official'} eq 'on') && ($env{'form.state'} eq 'listing')) {
+            $loaditem{'onload'} = 'setElements(document.filterpicker); ';
+        }
     }
 
     if ((($env{'form.form'} eq 'cu') || ($env{'form.form'} eq 'studentform')) && 
@@ -112,7 +114,7 @@
     }
 
     # print javascript functions for choosing a course 
-    if ($env{'form.gosearch'} || $onlyown) {
+    if (($env{'form.command'} eq 'gosearch') || $onlyown) {
         $r->print(&gochoose_javascript($type,$multiple,$autosubmit,$lastaction));
     }
     $r->print('<script type="text/javascript" language="Javascript">'.$jscript.
@@ -149,7 +151,7 @@
     }
 
 # ---------------------------------------------------------------- Get the data
-    if ($env{'form.gosearch'} || $onlyown) {
+    if (($env{'form.command'} eq 'gosearch') || $onlyown) {
         my %courses = &search_courses($r,$type,$onlyown,$filter,$numtitles);
         if ($nohost) {
             $r->print ('<span class="LC_warning">'.
@@ -395,7 +397,7 @@
         $r->print('<input type="hidden" name="setroles" \
                value="'.$env{'form.setroles'}.'" />');
         $r->print('<input type="hidden" name="action" value="rolepicker" />');
     } elsif ($env{'form.form'} eq 'modifycourse') {
-        $r->print(&Apache::lonhtmlcommon::echo_form_input(['phase','pickedcourse','type','form','numtitles','state']));
 +        $r->print(&Apache::lonhtmlcommon::echo_form_input(['phase','pickedcourse','type','form','numtitles','state','command']));
  } else {
         $r->print('<input type="hidden" name="cnumelement" value="'.
                   $env{'form.cnumelement'}.'" />'."\n".  
@@ -431,6 +433,10 @@
     } else {
         $formname = $caller;
     }
+    my $onchange;
+    unless ($env{'form.interface'} eq 'textual') {
+        $onchange = 1;
+    }
     my ($domainselectform,$sincefilterform,$ownerdomselectform,$persondomselectform,
         $instcodeform,$typeselectform,$instcodetitle);
     foreach my $item (@{$filterlist}) {
@@ -450,7 +456,7 @@
             } elsif ($item eq 'personfilter') {
                 $filter->{$item} = &LONCAPA::clean_username($filter->{$item});
                 if ($env{'form.persondomfilter'} eq '') {
-                    unless ($env{'form.gosearch'}) {
+                    unless ($env{'form.command'} eq 'gosearch') {
                         $filter->{'persondomfilter'} = $env{'request.role.domain'};
                     }
                 } else {
@@ -486,7 +492,7 @@
                 $domainselectform =
 		    &Apache::loncommon::select_dom_form($filter->{$item},
 		    				        'domainfilter',
-						        $allow_blank);
+						        $allow_blank,'',$onchange);
                 $codedom = $filter->{'domainfilter'};
             }
         } else {
@@ -518,13 +524,17 @@
               'inc' => &mt('Institutional Categorization'),
               'cow' => &mt("$type Owner/Co-owner"),
               'cop' => &mt("$type Personnel Includes"),
-              'cog' => &mt('Course Type')
+              'cog' => &mt('Type')
              );
 
-    $typeselectform =  '<select name="type" size="1">'."\n";
+    $typeselectform =  '<select name="type" size="1"';
+    if ($onchange) {
+        $typeselectform .= 'onchange=" javascript:submit()"';
+    }
+    $typeselectform .= '>'."\n";
     my $officialjs;
     if ($type eq 'Course') {
-        if ($env{'form.fixeddom'}) {
+        if (($env{'form.fixeddom'}) || ($env{'form.form'} eq 'requestcrs')) {
             $officialjs = 1;
             ($instcodeform,$jscript,$$numtitlesref) = 
                 &instcode_selectors($codedom,'filterpicker',$officialjs);
@@ -540,18 +550,26 @@
         if ($env{'form.fixeddom'}) {
             $instcodetitle .= '<br />('.$codedom.')';
         }
-        if ($jscript ne '') {
-            $jscript = '<script type="text/javascript" \
                language="Javascript">'.$jscript.
-                       '</script>'."\n";
-        }
     }
+    $jscript .= <<"END_JS";
+
+function setCommand() {
+    document.filterpicker.command.value = 'gosearch';
+    return;
+}
+
+END_JS
+
+    $jscript = '<script type="text/javascript" language="Javascript">'.$jscript.
+               '</script>'."\n";
+
     foreach my $posstype ('Course','Community') {
         $typeselectform.='<option value="'.$posstype.'"'.
             ($posstype eq $type ? ' selected="selected" ' : ''). \
">".&mt($posstype)."</option>\n";  }
     $typeselectform.="</select>";
     my $output = qq|
-<form method="post" name="filterpicker" action="$action">
+<form method="post" name="filterpicker" action="$action" onsubmit="setCommand()">
 <input type="hidden" name="form" value="$formname" />
 |;
     if ($formname eq 'modifycourse') {
@@ -628,7 +646,8 @@
                   .&Apache::lonhtmlcommon::row_closure(1);
     }
     $output .= &Apache::lonhtmlcommon::end_pick_box();
-    $output .= '<p><input type="submit" name="gosearch" value="'. 
+    $output .= '<p><input type="hidden" name="command" value="">'."\n".
+               '<input type="submit" name="gosearch" value="'. 
                &mt('Search').'" /></p>'."\n".'</form>'."\n".'<hr />'."\n";
     return $jscript.$output;
 }
@@ -640,16 +659,16 @@
         &Apache::courseclassifier::instcode_selectors_data($codedom,$formname,
                            \
\%cat_items,\@codetitles,\%cat_titles,\%cat_order,$officialjs);  if ($numtitles > 0) \
                {
-        my $unofficial = ' checked="checked" ';
-        my $official = '';
-        if ($env{'form.official'}) {
-            $official = $unofficial;
-            $unofficial = '';
+        my $official = ' checked="checked" ';
+        my $unofficial = '';
+        if ($env{'form.official'} eq 'off') {
+            $unofficial = $official;
+            $official = '';
         }
         $output .= '<span class="LC_nobreak">'.&mt('Official \
                course:').'&nbsp;<label>'.
-                   '<input type="radio" name="official" value="1"'.$official.' />'.
+                   '<input type="radio" name="official" value="on"'.$official.' />'.
                    &mt('Yes').'</label>'.('&nbsp;'x3).'<label>'.
-                   '<input type="radio" name="official" value="0"'.$unofficial.
+                   '<input type="radio" name="official" value="off"'.$unofficial.
                    ' onclick="toggleOfficial();" />'.&mt('No').'</label></span><br \
                />'.
                    &Apache::courseclassifier::build_instcode_selectors($numtitles,
                    $lasttitle,\%cat_items,\@codetitles,\%cat_titles,\%cat_order)."\n".
 @@ -680,11 +699,15 @@
            ($filter->{'sincefilter'}==-1?1:time-$filter->{'sincefilter'});
         my ($instcodefilter,$regexpok);
         if ($numtitles) {
-            if ($env{'form.official'}) {
+            if ($env{'form.official'} eq 'on') {
                 $instcodefilter = 
-                    \
                &Apache::courseclassifier::instcode_search_str($filter->{'domainfilter'},
                
-                                                                   $numtitles);
+                    \
&Apache::courseclassifier::instcode_search_str($filter->{'domainfilter'},$numtitles); \
$regexpok = 1; +            } elsif ($env{'form.official'} eq 'off') {
+                $instcodefilter = \
&Apache::courseclassifier::instcode_search_str($filter->{'domainfilter'},$numtitles); \
+                unless ($instcodefilter eq '') { +                    $regexpok = \
-1; +                }
             }
         } else {
             $instcodefilter = $filter->{'instcodefilter'};
@@ -870,7 +893,7 @@
 Course Domain - the domain of the course
 
 =item *
-Course Type - Course or Community
+Type - Course or Community
 
 =item *
 Course Institutional Code - the institutional identifier assigned to the course
@@ -1031,6 +1054,10 @@
 
 (g) Scantron Operator uploading a scantron file to a course - course number is \
written to visible form element in opener window. Child window closes.  
+=item
+
+(h) User requesting creation of a course, and selecting a course to clone - course \
number and domain written to visible form elements in opener window. Child window \
closes. +
 =back
      
 =cut


_______________________________________________
LON-CAPA-cvs mailing list
LON-CAPA-cvs@mail.lon-capa.org
http://mail.lon-capa.org/mailman/listinfo/lon-capa-cvs

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic