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

raeburn raeburn@source.lon-capa.org
Sun, 23 Aug 2009 03:51:54 -0000


This is a MIME encoded message

--raeburn1250999514
Content-Type: text/plain

raeburn		Sun Aug 23 03:51:54 2009 EDT

  Modified files:              
    /loncom/interface	lonrequestcourse.pm 
  Log:
  - Institutional section settings and crosslistings correctly displayed in request review screen when modifying an existing request.
  - Section choices and crosslistings can also now be modified on a pending request.
  
  
--raeburn1250999514
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20090823035154.txt"

Index: loncom/interface/lonrequestcourse.pm
diff -u loncom/interface/lonrequestcourse.pm:1.23 loncom/interface/lonrequestcourse.pm:1.24
--- loncom/interface/lonrequestcourse.pm:1.23	Sat Aug 22 21:08:39 2009
+++ loncom/interface/lonrequestcourse.pm	Sun Aug 23 03:51:53 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Request a course
 #
-# $Id: lonrequestcourse.pm,v 1.23 2009/08/22 21:08:39 raeburn Exp $
+# $Id: lonrequestcourse.pm,v 1.24 2009/08/23 03:51:53 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -363,30 +363,28 @@
             for (my $i=0; $i<$env{'form.sectotal'}; $i++) {
                 $extras{'sec_'.$i} = 'checkbox',
                 $extras{'secnum_'.$i} = 'text',
-                $extras{'loncapasec_'.$i} = 'checkbox',
+                $extras{'loncapasec_'.$i} = 'text',
             }
         }
         my $crosslisttotal = $env{'form.crosslisttotal'};
         if ($env{'form.addcrosslist'}) {
             $crosslisttotal ++;
         }
-        if (!defined($crosslisttotal)) {
+        if (!$crosslisttotal) {
             $crosslisttotal = 1;
         }
-        if ($crosslisttotal > 0) {
-            for (my $i=0; $i<$env{'form.crosslisttotal'}; $i++) {
-                if ($numtitles) {
-                    $extras{'crosslist_'.$i.'_'.$lastitem} = 'text';
-                }
-                if (@codetitles > 0) {
-                    foreach my $item (@codetitles) {
-                        $extras{'crosslist_'.$i.'_'.$item} = 'selectbox';
-                    }
+        for (my $i=0; $i<$env{'form.crosslisttotal'}; $i++) {
+            if ($numtitles) {
+                $extras{'crosslist_'.$i.'_'.$lastitem} = 'text';
+            }
+            if (@codetitles > 0) {
+                foreach my $item (@codetitles) {
+                    $extras{'crosslist_'.$i.'_'.$item} = 'selectbox';
                 }
-                $extras{'crosslist_'.$i} = 'checkbox';
-                $extras{'crosslist_'.$i.'_instsec'} = 'text',
-                $extras{'crosslist_'.$i.'_lcsec'} = 'text',
             }
+            $extras{'crosslist_'.$i} = 'checkbox';
+            $extras{'crosslist_'.$i.'_instsec'} = 'text',
+            $extras{'crosslist_'.$i.'_lcsec'} = 'text',
         }
         my %mergedhash = (%{$elements{'new'}{'enrollment'}},%extras);
         %{$elements{'new'}{'enrollment'}} = %mergedhash;
@@ -856,6 +854,9 @@
         $r->print($result);
     }
     my @excluded = &get_excluded_elements($dom,$states,$action,$state);
+    if ($state eq 'personnel') {
+        push(@excluded,'persontotal');
+    }
     $r->print(&Apache::lonhtmlcommon::echo_form_input(\@excluded).'</form>');
     &display_navbuttons($r,$formname,$prev,$navtxt{'prev'},$next,$navtxt{'next'},$state);
     return;
@@ -908,7 +909,7 @@
             my ($section_form,$crosslist_form,$autoenroll_form);
             $section_form = &inst_section_selector($dom,$instcode);
             my $crosslisttotal = $env{'form.crosslisttotal'};
-            if (!defined($crosslisttotal)) {
+            if (!$crosslisttotal) {
                 $crosslisttotal = 1;
             }
             if ($env{'form.addcrosslist'}) {
@@ -974,15 +975,19 @@
                     &Apache::loncommon::start_data_table().
                     &Apache::loncommon::start_data_table_row().
                     '<th>'.&mt('Include?').'<input type="hidden" name="sectotal" '.
-                    'value="'.$sectotal.'"</th>'.
+                    'value="'.$sectotal.'"  /></th>'.
                     '<th>'.&mt('Institutional Section').'</th>'.
                     '<th>'.&mt('LON-CAPA section').'</th>'.
                     &Apache::loncommon::end_data_table_row();
         for (my $i=0; $i<@sections; $i++) {
             my $colflag = $i%2;
+            my $checked = ' checked="checked"';
+            if ($env{'form.origcnum'}) {
+                $checked='';
+            }
             $output .= &Apache::loncommon::start_data_table_row().
                        '<td><input type="checkbox" name="sec_'.$i.
-                       '" checked="checked" /></td>'.
+                       '"'.$checked.' value="1" /></td>'.
                        '<td>'.$sections[$i].
                        '<input type="hidden" name="secnum_'.$i.'" value="'.
                        $sections[$i].'" /></td>'.
@@ -1430,32 +1435,35 @@
                                &mt('Institutional course/section').'</th>'.
                                '<th>'.&mt('LON-CAPA section').'</th></tr>';
             my $xlistinfo;
-            if ($env{'form.crosslisttotal'}) {
-                for (my $i=0; $i<$env{'form.crosslisttotal'}; $i++) {
-                    if ($env{'form.crosslist_'.$i}) {
-                        $xlistinfo .= '<tr><td>';
-                        if (ref($code_order) eq 'ARRAY') {
-                            if (@{$code_order} > 0) {
-                                foreach my $item (@{$code_order}) {
-                                    $xlistinfo .= $env{'form.crosslist_'.$i.'_'.$item};
-                                }
+            my $crosslisttotal = $env{'form.crosslisttotal'};
+            if (!$crosslisttotal) {
+                $crosslisttotal = 1;
+            }
+            for (my $i=0; $i<$crosslisttotal; $i++) {
+                if ($env{'form.crosslist_'.$i}) {
+                    $xlistinfo .= '<tr><td>';
+                    if (ref($code_order) eq 'ARRAY') {
+                        if (@{$code_order} > 0) {
+                            foreach my $item (@{$code_order}) {
+                                $xlistinfo .= $env{'form.crosslist_'.$i.'_'.$item};
                             }
                         }
-                        $xlistinfo .= $env{'form.crosslist_'.$i.'_instsec'}.'</td><td>';
-                        if ($env{'form.crosslist_'.$i.'_lcsec'}) {
-                            $xlistinfo .= $env{'form.crosslist_'.$i.'_lcsec'};
-                        } else {
-                            $xlistinfo .= &mt('None');
-                        }
-                        $xlistinfo .= '</td></tr>';
                     }
+                    $xlistinfo .= $env{'form.crosslist_'.$i.'_instsec'}.'</td><td>';
+                    if ($env{'form.crosslist_'.$i.'_lcsec'}) {
+                        $xlistinfo .= $env{'form.crosslist_'.$i.'_lcsec'};
+                    } else {
+                        $xlistinfo .= &mt('None');
+                    }
+                    $xlistinfo .= '</td></tr>';
                 }
             }
             if ($xlistinfo eq '') {
                 $xlistinfo = '<tr><td colspan="2">'.&mt('None').'</td></tr>';
             }
-            $section_values .= $xlistinfo.'</table></td>';
+            $section_values .= $xlistinfo;
         }
+        $section_values .= '</table></td>';
     }
 
     my %ctxt = &clone_text();
@@ -1531,10 +1539,16 @@
                     }
                 }
             }
-            my $showsec = 'None';
+            my $showsec;
             if (@allsecs) {
                 $showsec = join(', ',@allsecs);
             }
+            if ($showsec eq '') {
+                $showsec = &mt('None');
+            }
+            if ($env{'form.person_'.$i.'_role'} eq 'cc') {
+                $showsec = &mt('None');
+            }
             $personnel_values .= 
                 '<tr><td>'.$env{'form.person_'.$i.'_firstname'}.' '.
                 $env{'form.person_'.$i.'_lastname'}.'</td>'.
@@ -1832,6 +1846,8 @@
     my ($dom,$codetitles,$code_order) = @_;
     my ($output,$cnum,$now,$req_notifylist,$crstype,$enrollstart,$enrollend,
         %sections,%crosslistings,%personnel,@baduname,@missingdom,%domconfig,);
+    my $sectotal = $env{'form.sectotal'};
+    my $crosslisttotal = 0;
     $cnum = $env{'form.cnum'};
     unless ($cnum =~ /^$match_courseid$/) {
         $output = &mt('Invalid LON-CAPA course number for the new course')."\n"; 
@@ -1874,6 +1890,9 @@
                     }
                 }
                 $crosslistings{$i}{'instcode'} = $xlistinfo;
+                if ($xlistinfo ne '') {
+                    $crosslisttotal ++;
+                }
                 $crosslistings{$i}{'instsec'} = $env{'form.crosslist_'.$i.'_instsec'}; 
                 $crosslistings{$i}{'loncapa'} = $env{'form.crosslist_'.$i.'_lcsec'};
             }
@@ -1940,17 +1959,9 @@
     if ($env{'form.autoadds'}) {
         $autodrops = $env{'form.autoadds'};
     }
-    my $sectotal = 0;
-    if ($env{'form.sectotal'}) {
-        $sectotal = $env{'form.sectotal'};
-    }
     if ($env{'form.autoadds'}) {
         $autodrops = $env{'form.autoadds'};
     }
-    my $crosslisttotal = 0;
-    if ($env{'form.crosslisttotal'}) {
-        $crosslisttotal = $env{'form.crosslisttotal'};
-    }
     my $instcode = '';
     if (exists($env{'form.instcode'})) {
         $instcode = $env{'form.instcode'};
@@ -2342,17 +2353,18 @@
                  $env{'form.autoadds'} = $reqinfo{'autoadds'};
                  $env{'form.autdrops'} = $reqinfo{'autodrops'};
                  $env{'form.instcode'} = $reqinfo{'instcode'};
-                 my %crscode = (
-                                 instcode => $reqinfo{'instcode'},
-                               );
-                 &extract_instcode($dom,'instcode',\%crscode);
+                 my $crscode = { 
+                                 $cnum => $reqinfo{'instcode'},
+                               };
+                 &extract_instcode($dom,'instcode',$crscode,$cnum);
             }
             my @currsec;
             if (ref($reqinfo{'sections'}) eq 'HASH') {
                 foreach my $i (sort(keys(%{$reqinfo{'sections'}}))) {
                     if (ref($reqinfo{'sections'}{$i}) eq 'HASH') {
-                        my $sec = $reqinfo{'sections'}{$i}{'inst'};;
+                        my $sec = $reqinfo{'sections'}{$i}{'inst'};
                         $env{'form.secnum_'.$i} = $sec;
+                        $env{'form.sec_'.$i} = '1';
                         if (!grep(/^\Q$sec\E$/,@currsec)) {
                             push(@currsec,$sec);
                         }
@@ -2360,15 +2372,19 @@
                     }
                 }
             }
-            if (ref($reqinfo{'crosslistings'}) eq 'HASH') {
-                foreach my $i (sort(keys(%{$reqinfo{'crosslistings'}}))) {
-                    if (ref($reqinfo{'crosslistings'}{$i}) eq 'HASH') {
-                        $env{'form.crosslist_'.$i.'_lcsec'} = $reqinfo{'crosslistings'}{$i}{'loncapa'};
-                        my $xlistsec = $reqinfo{'crosslistings'}{$i}{'instsec'};
-                        my %crscode = (
-                                        $i => $reqinfo{'crosslistings'}{$i}{'instcode'},
-                                      );
-                        &extract_instcode($dom,'crosslist',\%crscode,$i,$xlistsec);
+            if (ref($reqinfo{'crosslists'}) eq 'HASH') {
+                foreach my $i (sort(keys(%{$reqinfo{'crosslists'}}))) {
+                    if (ref($reqinfo{'crosslists'}{$i}) eq 'HASH') {
+                        $env{'form.crosslist_'.$i} = '1';
+                        $env{'form.crosslist_'.$i.'_instsec'} = $reqinfo{'crosslists'}{$i}{'instsec'};
+                        $env{'form.crosslist_'.$i.'_lcsec'} = $reqinfo{'crosslists'}{$i}{'loncapa'};
+                        if ($reqinfo{'crosslists'}{$i}{'instcode'} ne '') {
+                            my $key = $cnum.$i; 
+                            my $crscode = {
+                                              $key => $reqinfo{'crosslists'}{$i}{'instcode'},
+                                          };
+                            &extract_instcode($dom,'crosslist',$crscode,$key,$i);
+                        }
                     }
                 }
             }
@@ -2440,26 +2456,19 @@
 }
 
 sub extract_instcode {
-    my ($cdom,$element,$crscodehashref,$counter,$xlistsec) = @_;
+    my ($cdom,$element,$crscode,$crskey,$counter) = @_;
     my (%codes,@codetitles,%cat_titles,%cat_order);
-    if (ref($crscodehashref) eq 'HASH') {
-        if (&Apache::lonnet::auto_instcode_format('requests',$cdom,$crscodehashref,
-                       \%codes,\@codetitles,\%cat_titles,\%cat_order) eq 'ok') {
+    if (&Apache::lonnet::auto_instcode_format('requests',$cdom,$crscode,\%codes,
+                                              \@codetitles,\%cat_titles,
+                                              \%cat_order) eq 'ok') {
+        if (ref($codes{$crskey}) eq 'HASH') {
             if (@codetitles > 0) {
                 my $sel = $element;
                 if ($element eq 'crosslist') {
                     $sel .= '_'.$counter;
                 }
-                my $lastitem = pop(@codetitles);
                 foreach my $title (@codetitles) {
-                    if (ref($cat_order{$title}) eq 'ARRAY') {
-                        if (@{$cat_order{$title}} > 0) {
-                            $env{'form.'.$sel.'_'.$title} = $cat_order{$title}[0];
-                        }
-                    }
-                }
-                if ($element eq 'crosslist') { 
-                    $env{'form.'.$sel.'_'.$lastitem} = $xlistsec; 
+                    $env{'form.'.$sel.'_'.$title} = $codes{$crskey}{$title};
                 }
             }
         }

--raeburn1250999514--