[LON-CAPA-cvs] cvs: loncom / lond /automation batchcreatecourse.pm /enrollment localenroll.pm /interface loncommon.pm loncoursequeueadmin.pm lonrequestcourse.pm

raeburn raeburn at source.lon-capa.org
Thu Feb 28 23:49:15 EST 2013


raeburn		Fri Mar  1 04:49:15 2013 EDT

  Modified files:              
    /loncom/interface	lonrequestcourse.pm loncoursequeueadmin.pm 
                     	loncommon.pm 
    /loncom/enrollment	localenroll.pm 
    /loncom	lond 
    /loncom/automation	batchcreatecourse.pm 
  Log:
  - Course credits for a particular institutional code can be provided as a 
    third item returned by localenroll::validate_instcode()
  - Course credits can be specified for an official course (or retrieved from
    localenroll::validate_instcode) or an unofficial course as part of a course
    request
  - Credits earned for a course can also be different for a specific student
    (e.g., retrieved from institutional classlist data), or specified when 
    CC adds a student to a course via the web GUI. 
  
  
-------------- next part --------------
Index: loncom/interface/lonrequestcourse.pm
diff -u loncom/interface/lonrequestcourse.pm:1.65 loncom/interface/lonrequestcourse.pm:1.66
--- loncom/interface/lonrequestcourse.pm:1.65	Wed Aug 15 14:37:13 2012
+++ loncom/interface/lonrequestcourse.pm	Fri Mar  1 04:48:59 2013
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Request a course
 #
-# $Id: lonrequestcourse.pm,v 1.65 2012/08/15 14:37:13 raeburn Exp $
+# $Id: lonrequestcourse.pm,v 1.66 2013/03/01 04:48:59 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -134,7 +134,11 @@
     my $action = $env{'form.action'};
     my $state = $env{'form.state'};
     my (%states,%stored);
-    my ($jscript,$uname,$udom,$result,$warning);
+    my ($jscript,$uname,$udom,$result,$warning,$showcredits,$instcredits);
+    my %domdefs = &Apache::lonnet::get_domain_defaults($dom);
+    if ($domdefs{'officialcredits'} || $domdefs{'unofficialcredits'}) {
+        $showcredits = 1;
+    }
 
     $states{'display'} = ['details'];
     $states{'view'} = ['pick_request','details','cancel','removal'];
@@ -180,7 +184,7 @@
         $trail{'enrollment'} = 'Enrollment';
     }
 
-    my ($page,$crumb,$newinstcode,$codechk,$checkedcode,$description) = 
+    my ($page,$crumb,$newinstcode,$codechk,$checkedcode,$description) =
         &get_breadcrumbs($dom,$action,\$state,\%states,\%trail);
     if ($action eq 'display') {
         if (($dom eq $env{'request.role.domain'}) && (&Apache::lonnet::allowed('ccc',$dom))) {
@@ -269,11 +273,11 @@
                 }
             }
         }
-        my %elements =  &form_elements($dom);
+        (my $elements,$instcredits) = &form_elements($dom,$showcredits);
         my $elementsref = {};
-        if (ref($elements{$action}) eq 'HASH') {
-            if (ref($elements{$action}{$state}) eq 'HASH') {
-                $elementsref = $elements{$action}{$state};
+        if ((ref($elements) eq 'HASH') && (ref($elements->{$action}) eq 'HASH')) {
+            if (ref($elements->{$action}{$state}) eq 'HASH') {
+                $elementsref = $elements->{$action}{$state};
             }
         }
         if (($state eq 'courseinfo') && ($env{'form.clonedom'} eq '')) {
@@ -307,7 +311,7 @@
                 &request_administration($r,$action,$state,$page,\%states,$dom,
                                         $jscript,$loaditems,$crumb,$newinstcode,
                                         $codechk,$checkedcode,$description,
-                                        \@invalidcrosslist);
+                                        $showcredits,$instcredits,\@invalidcrosslist);
             }
         } else {
             $r->print(&header('Course/Community Requests').$crumb.
@@ -320,7 +324,7 @@
             &print_main_menu($r,\%can_request,\%states,$dom,$jscript,$loaditems,$crumb,\%request_domains);
         } else {
             &request_administration($r,$action,$state,$page,\%states,$dom,$jscript,
-                                    $loaditems,$crumb);
+                                    $loaditems,$crumb,'','','','',$showcredits);
         }
     } elsif ($action eq 'display') {
         if ($warning ne '') {
@@ -331,7 +335,8 @@
                       &close_popup_form());
         } else {
             &request_administration($r,$action,$state,$page,\%states,$dom,$jscript,
-                                    $loaditems,$crumb,'','','','','',$uname,$udom);
+                                    $loaditems,$crumb,'','','','',$showcredits,'','',
+                                    $uname,$udom);
         }
     } elsif ($action eq 'log') {
         if ($state eq 'crstype') {
@@ -495,7 +500,8 @@
 }
 
 sub form_elements {
-    my ($dom) = @_;
+    my ($dom,$showcredits) = @_;
+    my $instcredits;
     my %elements =
     (
         new => {
@@ -603,6 +609,15 @@
                     $extras{'loncapasec_'.$i} = 'text',
                 }
             }
+            (my $outcome,my $desc,$instcredits) = 
+                &Apache::lonnet::auto_validate_instcode(undef,$dom,$instcode);
+            if ($showcredits && $instcredits eq '') {
+                $extras{'coursecredits'} = 'text';
+            }
+        } elsif ($env{'form.crstype'} eq 'unofficial') {
+            if ($showcredits) {
+                $extras{'coursecredits'} = 'text';
+            }
         }
         my $crosslisttotal = $env{'form.crosslisttotal'};
         if ($env{'form.addcrosslist'}) {
@@ -648,7 +663,7 @@
     }
     my %personnelhash = (%{$elements{'new'}{'personnel'}},%people);
     %{$elements{'new'}{'personnel'}} = %personnelhash;
-    return %elements;
+    return (\%elements,$instcredits);;
 }
 
 sub onload_action {
@@ -854,8 +869,8 @@
 
 sub request_administration {
     my ($r,$action,$state,$page,$states,$dom,$jscript,$loaditems,$crumb,
-        $newinstcode,$codechk,$checkedcode,$description,$invalidcrosslist,
-        $uname,$udom) = @_;
+        $newinstcode,$codechk,$checkedcode,$description,$showcredits,
+        $instcredits,$invalidcrosslist,$uname,$udom) = @_;
     my $js;
     if (($action eq 'new') || (($action eq 'view') && ($state eq 'pick_request'))) {
         $js =  <<END;
@@ -897,7 +912,8 @@
         }
         $r->print(&header($title,$js.$jscript,$loaditems,$jsextra).$crumb);
         &print_request_form($r,$action,$state,$page,$states,$dom,$newinstcode,
-                            $codechk,$checkedcode,$description,$invalidcrosslist);
+                            $codechk,$checkedcode,$description,$showcredits,
+                            $instcredits,$invalidcrosslist);
     } elsif ($action eq 'view') {
         my $jsextra;
         my $formname = 'requestcrs';
@@ -951,9 +967,10 @@
             }
             $r->print('<h3>'.$title.'</h3><div>'."\n".$form."\n".
                       &print_review($dom,\@codetitles,\%cat_titles,\%cat_order,
-                                    \@code_order)."\n".
+                                    \@code_order,'','','','',$instcredits)."\n".
                       '<input name="origcnum" value="'.$origcnum.'" type="hidden" />'."\n");
-            my @excluded = &get_excluded_elements($dom,$states,'new','review');
+            my @excluded = &get_excluded_elements($dom,$states,'new','review',
+                                                  $showcredits);
             push(@excluded,'origcnum');
             $r->print(&Apache::lonhtmlcommon::echo_form_input(\@excluded).'</div>');
             my $other = 'modify';
@@ -975,7 +992,8 @@
             my ($result,$output) = &print_cancel_request($dom,$env{'form.origcnum'});
             $r->print('<h3>'.$title.'</h3><div>'."\n".$form."\n".
                       $output);
-            my @excluded = &get_excluded_elements($dom,$states,'view','cancel');
+            my @excluded = &get_excluded_elements($dom,$states,'view','cancel',
+                                                  $showcredits);
             $r->print(&Apache::lonhtmlcommon::echo_form_input(\@excluded).'</div>');
             my %navtxt = &Apache::lonlocal::texthash (
                                                       prev => 'Back',
@@ -1052,7 +1070,8 @@
         $r->print(&header($title,'','','',{ 'only_body' => 1}).
                   $crumb."\n".'<h3>'.$header.'</h3>'.
                   &print_review($dom,\@codetitles,\%cat_titles,\%cat_order,
-                                \@code_order,$uname,$udom)."\n".'</div>'.
+                                \@code_order,$uname,$udom,'','',$instcredits)."\n".
+                  '</div>'.
                   &close_popup_form());
     }
     $r->print(&Apache::loncommon::end_page());
@@ -1246,7 +1265,7 @@
 
 sub print_request_form {
     my ($r,$action,$state,$page,$states,$dom,$newinstcode,$codechk,$checkedcode,
-        $description,$invalidcrosslist) = @_;
+        $description,$showcredits,$instcredits,$invalidcrosslist) = @_;
     my $formname = 'requestcrs';
     my ($next,$prev,$message,$output,$codepicker,$crstype);
     $prev = $states->{$action}[$page-1];
@@ -1319,7 +1338,7 @@
         }
         $r->print(&print_enrollment_menu($formname,$instcode,$dom,\@codetitles,
                                          \%cat_titles,\%cat_order,\@code_order,
-                                         $invalidcrosslist));
+                                         $showcredits,$instcredits,$invalidcrosslist));
     } elsif ($state eq 'personnel') {
         $r->print(&print_personnel_menu($dom,$formname,$crstype,$invalidcrosslist));
     } elsif ($state eq 'review') {
@@ -1435,7 +1454,7 @@
         } else {
             $r->print('<h3>'.&mt('Review course request details before submission').'</h3>');
         }
-        $r->print(&print_review($dom,\@codetitles,\%cat_titles,\%cat_order,\@code_order,'','',\@disallowed,\%disallowmsg).
+        $r->print(&print_review($dom,\@codetitles,\%cat_titles,\%cat_order,\@code_order,'','',\@disallowed,\%disallowmsg,$instcredits).
                   '<input type="hidden" name="cnum" value="'.$cnum.'" />');
         if ($crstype eq 'community') {
             $navtxt{'next'} = &mt('Submit community request');
@@ -1448,7 +1467,7 @@
                                                      \%cat_order,\@code_order);
         }
         my ($storeresult,$result) = &print_request_outcome($dom,\@codetitles,
-                                                           \@code_order);
+                                                           \@code_order,$instcredits);
         $r->print($result);
         if (($storeresult eq 'ok') || ($storeresult eq 'created')) {
             if ($storeresult eq 'ok') {
@@ -1518,7 +1537,7 @@
             $r->print('<p>'.$links[0].'</p>');
         }
     }
-    my @excluded = &get_excluded_elements($dom,$states,$action,$state);
+    my @excluded = &get_excluded_elements($dom,$states,$action,$state,$showcredits);
     if ($state eq 'personnel') {
         push(@excluded,'persontotal');
     }
@@ -1615,18 +1634,19 @@
 }
 
 sub get_excluded_elements {
-    my ($dom,$states,$action,$state) = @_;
+    my ($dom,$states,$action,$state,$showcredits) = @_;
     my @excluded = ('counter');
-    my %elements = &form_elements($dom);
+    my ($elements,$instcredits) = &form_elements($dom,$showcredits);
     if (ref($states) eq 'HASH') {
         if (ref($states->{$action}) eq 'ARRAY') {
             my @items = @{$states->{$action}};
             my $numitems = scalar(@items);
             if ($numitems) {
                 for (my $i=$numitems-1; $i>=0; $i--) {
-                    if (ref($elements{$action}) eq 'HASH') {
-                        if (ref($elements{$action}{$items[$i]}) eq 'HASH') {
-                            foreach my $key (keys(%{$elements{$action}{$items[$i]}})) {
+                    if ((ref($elements) eq 'HASH') && 
+                        (ref($elements->{$action}) eq 'HASH')) {
+                        if (ref($elements->{$action}{$items[$i]}) eq 'HASH') {
+                            foreach my $key (keys(%{$elements->{$action}{$items[$i]}})) {
                                 push(@excluded,$key);
                             }
                         }
@@ -1644,8 +1664,9 @@
 
 sub print_enrollment_menu {
     my ($formname,$instcode,$dom,$codetitles,$cat_titles,$cat_order,$code_order,
-        $invalidcrosslist) =@_;
-    my ($sections,$autoenroll,$access_dates,$output,$hasauto);
+        $showcredits,$instcredits,$invalidcrosslist) =@_;
+    my ($sections,$autoenroll,$access_dates,$output,$hasauto,$hascredits,
+        $creditsrow,$domdefcredits);
     my $starttime = time;
     my $endtime = time+(6*30*24*60*60); # 6 months from now, approx
 
@@ -1657,6 +1678,12 @@
                            'start' => 'Start auto-enrollment',
                            'end'   => 'End auto-enrollment',
                        );
+    if ($showcredits) {
+        unless ($env{'form.crstype'} eq 'community') {
+            my %domdefs = &Apache::lonnet::get_domain_defaults($dom);
+            $domdefcredits = $domdefs{$env{'form.crstype'}.'credits'};
+        }
+    }
     if ($env{'form.crstype'} eq 'official') {
         if (&Apache::lonnet::auto_run('',$dom)) {
             $output = &show_invalid_crosslists($invalidcrosslist);
@@ -1731,12 +1758,29 @@
                 &mt('No').'</label></span>'. 
                 &Apache::lonhtmlcommon::row_closure(1).
                 &date_setting_table($starttime,$endtime,$formname,'enroll',
-                                    $hasauto,%enrolltitles);
+                                    $hasauto,undef,%enrolltitles);
+            if ($showcredits) {
+                if ($instcredits) {
+                    $creditsrow = &mt('[quant,_1,credit]',$instcredits);
+                } else {
+                    $creditsrow = '<span class="LC_nobreak">'.
+                                  '<input type="text" size="3" name="coursecredits"'.
+                                  ' value="'.$domdefcredits.'" />';
+                }
+                $hascredits = 1;
+            }
+        }
+    } elsif ($env{'form.crstype'} eq 'unofficial') {
+        if ($showcredits) {
+            $creditsrow = '<span class="LC_nobreak">'.
+                          '<input type="text" size="3" name="coursecredits"'.
+                          ' value="'.$domdefcredits.'"/>';
+            $hascredits = 1;
         }
     }
     my $access_dates = 
         &date_setting_table($starttime,$endtime,$formname,'access',$hasauto,
-                            %accesstitles);
+                            $hascredits,%accesstitles);
     $output .= &Apache::lonhtmlcommon::start_pick_box();
     if ($sections) {
         $output .=  $sections;
@@ -1755,7 +1799,15 @@
         $output .= &Apache::lonhtmlcommon::row_headline('Access').
                    '<h3>'.$header.'</h3>'.
                    &Apache::lonhtmlcommon::row_closure(1).
-                   $access_dates
+                   $access_dates;
+    }
+    if ($creditsrow) {
+        $output .= &Apache::lonhtmlcommon::row_headline('Credits').
+                   '<h3>'.&mt('Credits earned by students').'</h3>'.
+                   &Apache::lonhtmlcommon::row_closure(1).
+                   &Apache::lonhtmlcommon::row_title(&mt('Default credits')).
+                   $creditsrow.
+                   &Apache::lonhtmlcommon::row_closure(1);
     }
     return '<div>'.&Apache::lonhtmlcommon::start_pick_box().$output.
            &Apache::lonhtmlcommon::end_pick_box().'</div>';
@@ -1820,7 +1872,7 @@
 }
 
 sub date_setting_table {
-    my ($starttime,$endtime,$formname,$prefix,$hasauto,%datetitles) = @_;
+    my ($starttime,$endtime,$formname,$prefix,$hasauto,$hascredits,%datetitles)=@_;
     my ($perpetual,$table);
     my $startform = &Apache::lonhtmlcommon::date_setter($formname,$prefix.'start',
                                                         $starttime,'','','',1,'','','',1);
@@ -1831,7 +1883,9 @@
         $perpetual = ' <span class="LC_nobreak"><label>'.
                      '<input type="checkbox" name="no_end_date" />'.
                      &mt('No end date').'</label></span>';
-        $closure = '1';
+        unless ($hascredits) {
+            $closure = '1';
+        }
     }
 
     my %help_item = (
@@ -2553,7 +2607,7 @@
 
 sub print_review {
     my ($dom,$codetitles,$cat_titles,$cat_order,$code_order,$uname,$udom,
-        $disallowed,$disallowmsg) = @_;
+        $disallowed,$disallowmsg,$instcredits) = @_;
     my ($types,$typename) = &Apache::loncommon::course_types();
     my ($owner,$ownername,$owneremail);
     if ($uname eq '' || $udom eq '') {
@@ -2601,6 +2655,12 @@
                 }
             }
         }
+        $inst_headers .= '<th>'.&mt('Credits').'</th>';
+        if ($instcredits) {
+            $inst_values .= '<td>'.$instcredits.'</td>';
+        } else {
+            $inst_values .= '<td>'.$env{'form.coursecredits'}.'</td>';
+        }
         if (&Apache::lonnet::auto_run('',$dom)) {
             $enrollrow_title = &mt('Enrollment');
             $enroll_headers = '<th>'.&mt('Automatic Adds').'</th>'.
@@ -2670,6 +2730,9 @@
             $section_values .= $xlistinfo;
         }
         $section_values .= '</table></td>';
+    } elsif ($env{'form.crstype'} eq 'unofficial') {
+        $inst_headers .= '<th>'.&mt('Credits').'</th>';
+        $inst_values .= '<td>'.$env{'form.coursecredits'}.'</td>';
     }
 
     my %ctxt = &clone_text();
@@ -3165,9 +3228,9 @@
 }
 
 sub print_request_outcome {
-    my ($dom,$codetitles,$code_order) = @_;
+    my ($dom,$codetitles,$code_order,$instcredits) = @_;
     my ($output,$cnum,$now,$req_notifylist,$crstype,$enrollstart,$enrollend,
-        %sections,%crosslistings,%personnel, at baduname, at missingdom,%domconfig,);
+        %sections,%crosslistings,%personnel, at baduname, at missingdom,%domconfig);
     my $sectotal = $env{'form.sectotal'};
     my $crosslisttotal = 0;
     $cnum = $env{'form.cnum'};
@@ -3356,6 +3419,12 @@
     if (exists($env{'form.instcode'})) {
         $instcode = $env{'form.instcode'};
     }
+    my $credits;
+    if ($instcredits) {
+        $credits = $instcredits;
+    } elsif (exists($env{'form.coursecredits'})) {
+        $credits = $env{'form.coursecredits'};
+    }
     my $clonecrs = '';
     my $clonedom = '';
     if (($env{'form.cloning'}) &&
@@ -3383,6 +3452,7 @@
                     cdescr         => $env{'form.cdescr'},
                     crstype        => $env{'form.crstype'},
                     instcode       => $instcode,
+                    defaultcredits => $credits, 
                     clonedom       => $clonedom,
                     clonecrs       => $clonecrs,
                     datemode       => $env{'form.datemode'},
@@ -3829,7 +3899,15 @@
                                     $cnum => $reqinfo{'instcode'},
                                   };
                     &extract_instcode($dom,'instcode',$crscode,$cnum);
+                    (undef,undef,my $instcredits) =
+                        &Apache::lonnet::auto_validate_instcode(undef,$dom,
+                                                                $reqinfo{'instcode'});
+                    if ($instcredits ne $reqinfo{'defaultcredits'}) {
+                        $env{'form.coursecredits'} = $reqinfo{'defaultcredits'};
+                    }
                 }
+            } elsif ($reqinfo{'crstype'} eq 'unofficial') {
+                $env{'form.coursecredits'} = $reqinfo{'defaultcredits'};
             }
             my @currsec;
             if (ref($reqinfo{'sections'}) eq 'HASH') {
Index: loncom/interface/loncoursequeueadmin.pm
diff -u loncom/interface/loncoursequeueadmin.pm:1.34 loncom/interface/loncoursequeueadmin.pm:1.35
--- loncom/interface/loncoursequeueadmin.pm:1.34	Fri Jan  4 01:56:35 2013
+++ loncom/interface/loncoursequeueadmin.pm	Fri Mar  1 04:48:59 2013
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Utilities to administer domain course requests and course self-enroll requests
 #
-# $Id: loncoursequeueadmin.pm,v 1.34 2013/01/04 01:56:35 raeburn Exp $
+# $Id: loncoursequeueadmin.pm,v 1.35 2013/03/01 04:48:59 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1352,6 +1352,9 @@
         }
         $batchhash{'title'} = $details->{'cdescr'};
         $batchhash{'coursecode'} = $details->{'instcode'};
+        if ($domdefs->{'officialcredits'} || $domdefs->{'unofficialcredits'}) {
+            $batchhash{'defaultcredits'} = $details->{'defaultcredits'};
+        }
         $batchhash{'emailenc'} = $emailenc;
         $batchhash{'adds'} = $details->{'autoadds'};
         $batchhash{'drops'} = $details->{'autodrops'};
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1115 loncom/interface/loncommon.pm:1.1116
--- loncom/interface/loncommon.pm:1.1115	Tue Feb 19 17:30:35 2013
+++ loncom/interface/loncommon.pm	Fri Mar  1 04:48:59 2013
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.1115 2013/02/19 17:30:35 raeburn Exp $
+# $Id: loncommon.pm,v 1.1116 2013/03/01 04:48:59 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -531,7 +531,8 @@
 }
 
 sub coursebrowser_javascript {
-    my ($domainfilter,$sec_element,$formname,$role_element,$crstype) = @_;
+    my ($domainfilter,$sec_element,$formname,$role_element,$crstype,
+        $credits_element) = @_;
     my $wintitle = 'Course_Browser';
     if ($crstype eq 'Community') {
         $wintitle = 'Community_Browser';
@@ -594,8 +595,9 @@
     }
 $id_functions
 ENDSTDBRW
-    if (($sec_element ne '') || ($role_element ne '')) {
-        $output .= &setsec_javascript($sec_element,$formname,$role_element);
+    if (($sec_element ne '') || ($role_element ne '') || ($credits_element ne '')) {
+        $output .= &setsec_javascript($sec_element,$formname,$role_element,
+                                      $credits_element);
     }
     $output .= '
 // ]]>
@@ -752,7 +754,7 @@
 }
 
 sub setsec_javascript {
-    my ($sec_element,$formname,$role_element) = @_;
+    my ($sec_element,$formname,$role_element,$credits_element) = @_;
     my (@courserolenames, at communityrolenames,$rolestr,$courserolestr,
         $communityrolestr);
     if ($role_element ne '') {
@@ -847,6 +849,14 @@
 }
 |;
     }
+    if ($credits_element) {
+        $setsections .= qq|
+function setCredits(defaultcredits) {
+    document.$formname.$credits_element.value = defaultcredits;
+    return;
+}
+|;
+    }
     return $setsections;
 }
 
@@ -13188,7 +13198,7 @@
 }
 
 sub commit_standardrole {
-    my ($udom,$uname,$url,$three,$start,$end,$one,$two,$sec,$context) = @_;
+    my ($udom,$uname,$url,$three,$start,$end,$one,$two,$sec,$context,$credits) = @_;
     my ($output,$logmsg,$linefeed);
     if ($context eq 'auto') {
         $linefeed = "\n";
@@ -13197,7 +13207,7 @@
     }  
     if ($three eq 'st') {
         my $result = &commit_studentrole(\$logmsg,$udom,$uname,$url,$three,$start,$end,
-                                         $one,$two,$sec,$context);
+                                         $one,$two,$sec,$context,$credits);
         if (($result =~ /^error/) || ($result eq 'not_in_class') || 
             ($result eq 'unknown_course') || ($result eq 'refused')) {
             $output = $logmsg.' '.&mt('Error: ').$result."\n"; 
@@ -13228,7 +13238,8 @@
 }
 
 sub commit_studentrole {
-    my ($logmsg,$udom,$uname,$url,$three,$start,$end,$one,$two,$sec,$context) = @_;
+    my ($logmsg,$udom,$uname,$url,$three,$start,$end,$one,$two,$sec,$context,
+        $credits) = @_;
     my ($result,$linefeed,$oldsecurl,$newsecurl);
     if ($context eq 'auto') {
         $linefeed = "\n";
@@ -13275,7 +13286,11 @@
             }
         }
         if (($expire_role_result eq 'ok') || ($secchange == 0)) {
-            $modify_section_result = &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,'','',$cid,'',$context); 
+            $modify_section_result = 
+                &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,
+                                                           undef,undef,undef,$sec,
+                                                           $end,$start,'','',$cid,
+                                                           '',$context,$credits);
             if ($modify_section_result =~ /^ok/) {
                 if ($secchange == 1) {
                     if ($sec eq '') {
@@ -13544,6 +13559,9 @@
     } else {
         $cenv{'internal.courseowner'} = $args->{'curruser'};
     }
+    if ($args->{'defaultcredits'}) {
+        $cenv{'internal.defaultcredits'} = $args->{'defaultcredits'};
+    }
     my @badclasses = (); # Used to accumulate sections/crosslistings that did not pass classlist access check for course owner.
     if ($args->{'crssections'}) {
         $cenv{'internal.sectionnums'} = '';
Index: loncom/enrollment/localenroll.pm
diff -u loncom/enrollment/localenroll.pm:1.43 loncom/enrollment/localenroll.pm:1.44
--- loncom/enrollment/localenroll.pm:1.43	Fri Oct 14 17:13:25 2011
+++ loncom/enrollment/localenroll.pm	Fri Mar  1 04:49:04 2013
@@ -1,6 +1,6 @@
 # functions to glue school database system into Lon-CAPA for 
 # automated enrollment
-# $Id: localenroll.pm,v 1.43 2011/10/14 17:13:25 raeburn Exp $
+# $Id: localenroll.pm,v 1.44 2013/03/01 04:49:04 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -123,6 +123,8 @@
   <middlename>D</middlename>
   <startdate></startdate>
   <studentID>A12345678</studentID>
+  <credits></credits>
+  <inststatus></inststatus>
  </student>
  
  with the following at the top of the file
@@ -147,6 +149,17 @@
  If dates are to included in the XML file, they should be in the format
  YYYY:MM:DD:HH:MM:SS (: separators required).
 
+ The <credits> tag need only be used if the credits earned by the students will 
+ be different from the default for the course. The course default is set when the
+ course is created and can be modifed by a Domain Coordinator via "View or
+ modify a course  or community" on the DC's Main Menu screen.
+
+ A value for <inststatus> should be the institutional status used for students,
+ and should be one of the types defined in inst_usertypes(). If no status
+ types are defined for the domain this tag can be omitted. If Autoupdate.pl
+ is enabled in your domain, updates to the institutional status set here
+ will be updated by Autoupdate.pl, should changes occur.
+
  If there were 10 students in fs03nop590001, 5 students in fs03nop59o601, 
  8 students in fs03nop590602, and 2 students in fs03ost580002,
  then $$reply{'43551dedcd43febmsul1'} = 25
@@ -301,8 +314,14 @@
  (c) an optional institutional username for the course owner.
 
 An array is returned containing (a) the result of the check for a valid 
-instcode, and (b) an (optional) course description.   
+instcode, (b) an (optional) course description, and (c) the default credits
+earned by students when completing this course. If no institutional credits
+value is available, the default credits for the course can be set via the
+course request form, or via XML in a batch file, of via the web form used
+by the Domain Coordinator to create new courses one at a time.
+
 A valid instcode is confirmed by returning 'valid'.
+
 If no course description is available, '' should be set as
 the value of the second item in the returned array.
 
@@ -312,7 +331,8 @@
     my ($dom,$instcode,$owner) = @_;
     my $outcome = '';
     my $description = '';
-    return ($outcome,$description);
+    my $credits = '';
+    return ($outcome,$description,$credits);
 }
 
 =pod
Index: loncom/lond
diff -u loncom/lond:1.497 loncom/lond:1.498
--- loncom/lond:1.497	Fri Oct  5 15:19:18 2012
+++ loncom/lond	Fri Mar  1 04:49:10 2013
@@ -2,7 +2,7 @@
 # The LearningOnline Network
 # lond "LON Daemon" Server (port "LOND" 5663)
 #
-# $Id: lond,v 1.497 2012/10/05 15:19:18 raeburn Exp $
+# $Id: lond,v 1.498 2013/03/01 04:49:10 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -61,7 +61,7 @@
 my $status='';
 my $lastlog='';
 
-my $VERSION='$Revision: 1.497 $'; #' stupid emacs
+my $VERSION='$Revision: 1.498 $'; #' stupid emacs
 my $remoteVERSION;
 my $currenthostid="default";
 my $currentdomainid;
@@ -5014,9 +5014,10 @@
     my ($dom,$instcode,$owner) = split(/:/, $tail);
     $instcode = &unescape($instcode);
     $owner = &unescape($owner);
-    my ($outcome,$description) = 
+    my ($outcome,$description,$credits) = 
         &localenroll::validate_instcode($dom,$instcode,$owner);
-    my $result = &escape($outcome).'&'.&escape($description);
+    my $result = &escape($outcome).'&'.&escape($description).'&'.
+                 &escape($credits);
     &Reply($client, \$result, $userinput);
 
     return 1;
Index: loncom/automation/batchcreatecourse.pm
diff -u loncom/automation/batchcreatecourse.pm:1.37 loncom/automation/batchcreatecourse.pm:1.38
--- loncom/automation/batchcreatecourse.pm:1.37	Mon Jul  4 09:24:46 2011
+++ loncom/automation/batchcreatecourse.pm	Fri Mar  1 04:49:15 2013
@@ -1,5 +1,5 @@
 #
-# $Id: batchcreatecourse.pm,v 1.37 2011/07/04 09:24:46 foxr Exp $
+# $Id: batchcreatecourse.pm,v 1.38 2013/03/01 04:49:15 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -56,6 +56,7 @@
 # <title>Underwater Basket Weaving</title>
 # <crstype>Course</crstype>
 # <coursecode>ss05ubw101</coursecode>
+# <defaultcredits>3</defaultcredits>
 # <coursehome>msul1</coursehome>
 # <coursedomain>msu</coursedomain>
 # <reshome>/res/msu/</reshome>
@@ -122,6 +123,7 @@
 #   <lastname>Spartan</lastname>x
 #   <middlename></middlename>
 #   <studentID></studentID>
+#   <credits></credits>
 #   <roles></roles>
 #  </user>
 #  <user>
@@ -253,7 +255,7 @@
     my $xlist = 0;
     my $userkey = '';
     my $role = '';
-    my @items = ('title','optional_id','coursecode','coursehome','reshome','nonstandard','adds','drops','topmap','firstres','clonecrs','clonedom','datemode','dateshift','showphotos','setpolicy','setcontent','setkeys','keyauth','disresdis','disablechat','openall','notify_owner','notify_dc','crstype','crsquota');
+    my @items = ('title','optional_id','coursecode','defaultcredits','coursehome','reshome','nonstandard','adds','drops','topmap','firstres','clonecrs','clonedom','datemode','dateshift','showphotos','setpolicy','setcontent','setkeys','keyauth','disresdis','disablechat','openall','notify_owner','notify_dc','crstype','crsquota');
     my @possroles = qw(st ad ep ta in cc co);
     my @dateitems = ('enrollstart','enrollend','accessstart','accessend');
     my @useritems = ('autharg','authtype','firstname','generation','lastname','middlename','studentID');
@@ -494,6 +496,7 @@
                course_home =>  $details->{'coursehome'},
                nonstandard => $details->{'nonstandard'},
                crscode => $details->{'coursecode'},
+               defaultcredits => $details->{'defaultcredits'},
                crsquota => $details->{'crsquota'},
                clonecourse => $details->{'clonecrs'},
                clonedomain => $details->{'clonedom'},
@@ -611,8 +614,14 @@
                     'cdom' => $crsudom,
                     'context' => 'createcourse',
                     'linefeed' => $linefeed,
-                    'role' => $details->{'users'}{$userkey}{'roles'}[0], 
+                    'role' => $details->{'users'}{$userkey}{'roles'}[0],
                    };
+                if ($userargs->{'role'} eq 'st') {
+                    if (exists($details->{'users'}{$userkey}{'credits'})) {  
+                        $userargs->{'credits'} = $details->{'users'}{$userkey}{'credits'};
+                        $userargs->{'credits'} =~ s/[^\d\.]//g;
+                    }
+                }
                 $outcome = &LONCAPA::Enrollment::create_newuser($userargs,$logmsg,$newusermsg,$enrollcount,$addresult,$longroles,\%courseinfo,$context);
 # now add other roles and other sections.
                 if ($outcome eq 'ok') {
@@ -643,7 +652,12 @@
                                 if ($usec ne '') {
                                     $url .= '/'.$usec;
                                 }
-                                $$output .= &Apache::loncommon::commit_studentrole(\$stulogmsg,$userdom,$username,$url,$curr_role,$start,$end,$crsudom,$crsunum,$usec,$context);
+                                my $credits;
+                                if (exists($details->{'users'}{$userkey}{'credits'})) {
+                                    $credits = $details->{'users'}{$userkey}{'credits'};
+                                    $credits =~ s/[^\d\.]//g;
+                                }
+                                $$output .= &Apache::loncommon::commit_studentrole(\$stulogmsg,$userdom,$username,$url,$curr_role,$start,$end,$crsudom,$crsunum,$usec,$context,$credits);
                             } elsif ($curr_role eq $ccrole) {
                                 $url = '/'.$crsudom.'/'.$crsunum;
                                 my $usec = '';
@@ -684,7 +698,12 @@
                         if ($usec ne '') {
                             $url .= '/'.$usec;
                         }
-                        $$output .= &Apache::loncommon::commit_studentrole(\$stulogmsg,$userdom,$username,$url,$curr_role,$start,$end,$crsudom,$crsunum,$usec,$context);
+                        my $credits;
+                        if (exists($details->{'users'}{$userkey}{'credits'})) {
+                            $credits = $details->{'users'}{$userkey}{'credits'};
+                            $credits =~ s/[^\d\.]//g;
+                        }
+                        $$output .= &Apache::loncommon::commit_studentrole(\$stulogmsg,$userdom,$username,$url,$curr_role,$start,$end,$crsudom,$crsunum,$usec,$context,$credits);
                     } elsif ((grep(/^\Q$curr_role\E$/, at courseroles)) ||
                                      ($curr_role =~ m{^cr/$match_domain/$match_username/[^/]+$})) {
                         if (@{$details->{'users'}{$userkey}{$curr_role}{'usec'}} > 0) {


More information about the LON-CAPA-cvs mailing list