[LON-CAPA-cvs] cvs: loncom /interface domainprefs.pm loncommon.pm loncoursequeueadmin.pm lonrequestcourse.pm /misc refresh_courseids_db.pl

raeburn raeburn at source.lon-capa.org
Wed Dec 25 15:43:51 EST 2013


raeburn		Wed Dec 25 20:43:51 2013 EDT

  Modified files:              
    /loncom/interface	domainprefs.pm loncommon.pm 
                     	loncoursequeueadmin.pm lonrequestcourse.pm 
    /loncom/misc	refresh_courseids_db.pl 
  Log:
  - Domain configuration used to set generation of unique six character code 
    as course identifier when processing course requests, can be set 
    separately for different request types - official, unofficial, community
    or textbook.
  - Where a unique code is set for a course store in nohist_courseids.db on
    domain's library server(s).
  
  
-------------- next part --------------
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.217 loncom/interface/domainprefs.pm:1.218
--- loncom/interface/domainprefs.pm:1.217	Tue Dec 24 21:59:36 2013
+++ loncom/interface/domainprefs.pm	Wed Dec 25 20:43:46 2013
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set domain-wide configuration settings
 #
-# $Id: domainprefs.pm,v 1.217 2013/12/24 21:59:36 raeburn Exp $
+# $Id: domainprefs.pm,v 1.218 2013/12/25 20:43:46 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2022,14 +2022,28 @@
 sub print_studentcode {
     my ($settings,$rowtotal) = @_;
     my $rownum = 0; 
-    my %choices;
-    $choices{'uniquecode'} = &mt('Generate unique six character code as course identifier?');
-    my @toggles = ('uniquecode');
-    my %defaultchecked = ('uniquecode'  => 'off');
-    (my $reports,$rownum) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked,
-                                               \%choices,$rownum);
-    $$rowtotal += $rownum;
-    return $reports;
+    my ($output,%current);
+    my @crstypes = ('official','unofficial','community','textbook');
+    if (ref($settings->{'uniquecode'}) eq 'HASH') {
+        foreach my $type (@crstypes) {
+            $current{$type} = $settings->{'uniquecode'}{$type};
+        }
+    }
+    $output .= '<tr>'.
+               '<td class="LC_left_item">'.&mt('Generate unique six character code as course identifier?').'</td>'.
+               '<td class="LC_left_item">';
+    foreach my $type (@crstypes) {
+        my $check = ' ';
+        if ($current{$type}) {
+            $check = ' checked="checked" ';
+        }
+        $output .= '<span class="LC_nobreak"><label>'.
+                   '<input type="checkbox" name="uniquecode" value="'.$type.'"'.$check.'/>'.
+                   &mt($type).'</label></span>'.(' 'x2).' ';
+    }
+    $output .= '</td></tr>';
+    $$rowtotal ++;
+    return $output;
 }
 
 sub print_textbookcourses {
@@ -6109,10 +6123,12 @@
         my @approvalnotify = &Apache::loncommon::get_env_multiple('form.reqapprovalnotify');
         @approvalnotify = sort(@approvalnotify);
         $confhash{'notify'}{'approval'} = join(',', at approvalnotify);
-        if ($env{'form.uniquecode'}) {
-            $confhash{'uniquecode'} = 1;
-        } else {
-            $confhash{'uniquecode'} = '';
+        my @crstypes = ('official','unofficial','community','textbook');
+        my @hasuniquecode = &Apache::loncommon::get_env_multiple('form.uniquecode');
+        foreach my $type (@hasuniquecode) {
+            if (grep(/^\Q$type\E$/, at crstypes)) {
+                $confhash{'uniquecode'}{$type} = 1;
+            }
         }
         my ($newbook, at allpos);
         if ($context eq 'requestcourses') {
@@ -6147,14 +6163,25 @@
                     $changes{'notify'}{'approval'} = 1;
                 }
             }
-            if ($domconfig{$action}{'uniquecode'}) {
-                unless ($confhash{'uniquecode'}) {
-                    $changes{'uniquecode'} = 1;
-                }
-            } else {
-                if ($confhash{'uniquecode'}) {
-                    $changes{'uniquecode'} = 1;
-                }
+            if (ref($domconfig{$action}{'uniquecode'}) eq 'HASH') {
+                if (ref($confhash{'uniquecode'}) eq 'HASH') {
+                    foreach my $crstype (keys(%{$domconfig{$action}{'uniquecode'}})) {
+                        unless ($confhash{'uniquecode'}{$crstype}) {
+                            $changes{'uniquecode'} = 1;
+                        }
+                    }
+                    unless ($changes{'uniquecode'}) {
+                        foreach my $crstype (keys(%{$confhash{'uniquecode'}})) {
+                            unless ($domconfig{$action}{'uniquecode'}{$crstype}) {
+                                $changes{'uniquecode'} = 1;
+                            }
+                        }
+                    }
+               } else {
+                   $changes{'uniquecode'} = 1;
+               }
+            } elsif (ref($confhash{'uniquecode'}) eq 'HASH') {
+                $changes{'uniquecode'} = 1;
             }
             if ($context eq 'requestcourses') {
                 if (ref($domconfig{$action}{'textbooks'}) eq 'HASH') {
@@ -6216,7 +6243,7 @@
             if ($confhash{'notify'}{'approval'}) {
                 $changes{'notify'}{'approval'} = 1;
             }
-            if ($confhash{'uniquecode'}) {
+            if (ref($confhash{'uniquecode'} eq 'HASH')) {
                 $changes{'uniquecode'} = 1;
             }
         }
@@ -6544,10 +6571,15 @@
             if ($action eq 'requestcourses') {
                 my @offon = ('off','on');
                 if ($changes{'uniquecode'}) {
-                    $resulttext .= '<li>'.
-                                   &mt('Generation of six character code as course identifier for distribution to students set to '.
-                                       $offon[$env{'form.uniquecode'}]).
-                                   '</li>';
+                    if (ref($confhash{'uniquecode'}) eq 'HASH') {
+                        my $codestr = join(' ',map{ &mt($_); } sort(keys(%{$confhash{'uniquecode'}})));
+                        $resulttext .= '<li>'.
+                                       &mt('Generation of six character code as course identifier for distribution to students set to on for: [_1].','<b>'.$codestr.'</b>').
+                                       '</li>';
+                    } else {
+                        $resulttext .= '<li>'.&mt('Generation of six character code as course identifier for distribution to students set to off.').
+                                       '</li>';
+                    }
                 }
                 if (ref($changes{'textbooks'}) eq 'HASH') {
                     $resulttext .= '<li>'.&mt('Available textbooks updated').'<ul>';
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1166 loncom/interface/loncommon.pm:1.1167
--- loncom/interface/loncommon.pm:1.1166	Wed Dec 25 09:52:42 2013
+++ loncom/interface/loncommon.pm	Wed Dec 25 20:43:46 2013
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.1166 2013/12/25 09:52:42 raeburn Exp $
+# $Id: loncommon.pm,v 1.1167 2013/12/25 20:43:46 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -14168,12 +14168,18 @@
     }
 
 #
-# course should have uniquecode (available to course requester).
+#  generate and store uniquecode (available to course requester), if course should have one.
 #
     if ($args->{'uniquecode'}) {
         my ($code,$error) = &make_unique_code($$crsudom,$$crsunum);
         if ($code) {
             $cenv{'internal.uniquecode'} = $code;
+            my %crsinfo =
+                &Apache::lonnet::courseiddump($$crsudom,'.',1,'.','.',$$crsunum,undef,undef,'.');
+            if (ref($crsinfo{$$crsudom.'_'.$$crsunum}) eq 'HASH') {
+                $crsinfo{$$crsudom.'_'.$$crsunum}{'uniquecode'} = $code;
+                my $putres = &Apache::lonnet::courseidput($$crsudom,\%crsinfo,$crsuhome,'notime');
+            } 
             if (ref($coderef)) {
                 $$coderef = $code;
             }
Index: loncom/interface/loncoursequeueadmin.pm
diff -u loncom/interface/loncoursequeueadmin.pm:1.39 loncom/interface/loncoursequeueadmin.pm:1.40
--- loncom/interface/loncoursequeueadmin.pm:1.39	Wed Dec 25 09:52:42 2013
+++ loncom/interface/loncoursequeueadmin.pm	Wed Dec 25 20:43:46 2013
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Utilities to administer domain course requests and course self-enroll requests
 #
-# $Id: loncoursequeueadmin.pm,v 1.39 2013/12/25 09:52:42 raeburn Exp $
+# $Id: loncoursequeueadmin.pm,v 1.40 2013/12/25 20:43:46 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -614,9 +614,6 @@
             if (ref($domconfig{'requestcourses'}{'notify'}) eq 'HASH') { 
                 $notifylist = $domconfig{'requestcourses'}{'notify'}{'approval'};
             }
-            if ($domconfig{'requestcourses'}{'uniquecode'}) {
-                $uniquecode = 1;
-            }
         }
         $approvalmsg{'course'} = 
                         [{
@@ -1064,7 +1061,7 @@
                         }
                         my $syllabuslink =
                             &Apache::loncommon::syllabuswrapper($showcourse,$cnum,$cdom);
-                        if ($uniquecode && $codes{$cnum}) {
+                        if ($codes{$cnum}) {
                             $syllabuslink .= &mt('Unique code: [_1]',$codes{$cnum});
                         }
                         $output .= '<li>'.$syllabuslink.'</li>';
@@ -1335,6 +1332,14 @@
     }
     my ($result,$ownername,$ownerdom);
     my $crstype = $details->{'crstype'};
+    my %domconfig = &Apache::lonnet::get_dom('configuration',['requestauthor'],$dom);
+    if (ref($domconfig{'requestcourses'}) eq 'HASH') {
+        if (ref($domconfig{'requestcourses'}{'uniquecode'}) eq 'HASH') {
+            if ($domconfig{'requestcourses'}{'uniquecode'}{$crstype}) {
+                $details->{'uniquecode'} = 1;
+            }
+        }
+    }
     if ($context eq 'domain') {
         $ownername = $details->{'owner'};
         $ownerdom  = $details->{'domain'};
Index: loncom/interface/lonrequestcourse.pm
diff -u loncom/interface/lonrequestcourse.pm:1.70 loncom/interface/lonrequestcourse.pm:1.71
--- loncom/interface/lonrequestcourse.pm:1.70	Wed Dec 25 09:52:42 2013
+++ loncom/interface/lonrequestcourse.pm	Wed Dec 25 20:43:46 2013
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Request a course
 #
-# $Id: lonrequestcourse.pm,v 1.70 2013/12/25 09:52:42 raeburn Exp $
+# $Id: lonrequestcourse.pm,v 1.71 2013/12/25 20:43:46 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -3843,13 +3843,14 @@
                          mt   => 'Students can automatically select your course by entering this code: [_1]',
                          args => [$code],
                      }];
-        $output .= '<br />'.
+        $output .= '<p>'.
                    &mt('Students can automatically select your course by entering this code: [_1].','<b>'.$code.'</b>').
                    '<br />'.
-                   &mt('A message has been sent to your LON-CAPA account with this information').'</br />';
+                   &mt('A message has been sent to your LON-CAPA account with this information.');
         if ($address ne '') {
-            $output.= &mt('And an e-mail has also been sent to: [_1] with this code.',$address).'<br />';
+            $output.= '<br />'.&mt('And an e-mail has also been sent to: [_1] with this code.',$address);
         }
+        $output .= '</p>';
         my $sender = $env{'user.name'}.':'.$env{'user.domain'};
         if ($code) {
             &Apache::loncoursequeueadmin::send_selfserve_notification($req_notifylist,$codemsg,$cnum,$env{'form.cdescr'},
Index: loncom/misc/refresh_courseids_db.pl
diff -u loncom/misc/refresh_courseids_db.pl:1.16 loncom/misc/refresh_courseids_db.pl:1.17
--- loncom/misc/refresh_courseids_db.pl:1.16	Wed Jun 26 21:22:42 2013
+++ loncom/misc/refresh_courseids_db.pl	Wed Dec 25 20:43:51 2013
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 # The LearningOnline Network
 #
-# $Id: refresh_courseids_db.pl,v 1.16 2013/06/26 21:22:42 raeburn Exp $
+# $Id: refresh_courseids_db.pl,v 1.17 2013/12/25 20:43:51 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -184,8 +184,10 @@
                 my $creationcontext = $courseinfo{'internal.creationcontext'};
                 my $inst_code = $courseinfo{'internal.coursecode'};
                 my $releaserequired = $courseinfo{'internal.releaserequired'};
+                my $uniquecode = $courseinfo{'internal.uniquecode'};
                 $inst_code = '' if (!defined($inst_code));
                 $owner = '' if (!defined($owner));
+                $uniquecode = '' if (!defined($uniquecode));
                 if ($created eq '') {
                     if (ref($currhash->{$cid}) eq 'HASH') {
                         $created = $currhash->{$cid}{'created'};
@@ -326,7 +328,7 @@
                             $courseshash->{$chome}{$cid}{$item} = $courseinfo{$item}; 
                         }
                     }
-                    foreach my $item ('selfenroll_types','selfenroll_start_date','selfenroll_end_date') {
+                    foreach my $item ('selfenroll_types','selfenroll_start_date','selfenroll_end_date','uniquecode') {
                         if ($courseinfo{'internal.'.$item} ne '') {
                             $courseshash->{$chome}{$cid}{$item} =
                                 $courseinfo{'internal.'.$item};


More information about the LON-CAPA-cvs mailing list