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

raeburn lon-capa-cvs-allow@mail.lon-capa.org
Wed, 16 Jul 2008 12:06:32 -0000


This is a MIME encoded message

--raeburn1216209992
Content-Type: text/plain

raeburn		Wed Jul 16 08:06:32 2008 EDT

  Modified files:              
    /loncom/interface	loncreateuser.pm 
  Log:
  - &visible_in_cat() added to determine whether a course is currently visible in the Course Catalog, and if not, to provide advice on how to change this.
  - Messages about visibility in catalog are displayed on the Self-enrollment configuration screen, and also after making modifications to self-enrollment config.
  - Some wording changes in row titles for self-enrollment configuration data table.
    - Course Coordinators should understand that changes to access dates apply to future users self-enrolling, not retroactively to users who previously self-erolled.
  
  
--raeburn1216209992
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20080716080632.txt"

Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.255 loncom/interface/loncreateuser.pm:1.256
--- loncom/interface/loncreateuser.pm:1.255	Mon Jul 14 06:35:00 2008
+++ loncom/interface/loncreateuser.pm	Wed Jul 16 08:06:28 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Create a user
 #
-# $Id: loncreateuser.pm,v 1.255 2008/07/14 10:35:00 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.256 2008/07/16 12:06:28 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -3400,14 +3400,32 @@
     return -1;
 }
 ENDSCRIPT
+    my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+    my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+
     my $output = '<script type="text/javascript">'."\n".
                  $setsec_js."\n".$selfenroll_js."\n".
                  '</script>'."\n".
-                 '<h3>'.$lt->{'selfenroll'}.'</h3>'."\n".
-                 '<form name="'.$formname.'" method="post" action="/adm/createuser">'."\n".
-                 &Apache::lonhtmlcommon::start_pick_box();
-    my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
-    my $cnum = $env{'course.'.$env{'request.course.id'},'.num'};
+                 '<h3>'.$lt->{'selfenroll'}.'</h3>'."\n";
+    my ($visible,$cansetvis,$vismsgs,$visactions) = &visible_in_cat($cdom,$cnum);
+    if (ref($visactions) eq 'HASH') {
+        if ($visible) {
+            $output .= '<p>'.$visactions->{'vis'}.'</p>';
+        } else {
+            $output .= $visactions->{'miss'}.'<br />'.$visactions->{'yous'}.
+                       '<p>'.$visactions->{'gen'}.'<br />'.$visactions->{'coca'};
+            if (ref($vismsgs) eq 'ARRAY') {
+                $output .= '<br />'.$visactions->{'make'}.'<ul>';
+                foreach my $item (@{$vismsgs}) {
+                    $output .= '<li>'.$visactions->{$item}.'</li>';
+                }
+                $output .= '</ul>';
+            }
+            $output .= '</p>';
+        }
+    }
+    $output .= '<form name="'.$formname.'" method="post" action="/adm/createuser">'."\n".
+               &Apache::lonhtmlcommon::start_pick_box();
     if (ref($row) eq 'ARRAY') {
         foreach my $item (@{$row}) {
             my $title = $item; 
@@ -3559,6 +3577,128 @@
     return;
 }
 
+sub visible_in_cat {
+    my ($cdom,$cnum) = @_;
+    my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);
+    my ($cathash,%settable,@vismsgs,$cansetvis);
+    my %visactions = &Apache::lonlocal::texthash(
+                   vis => 'Your course currently appears in the Course Catalog for this domain.',
+                   gen => 'Courses can be both self-cataloging, based on an institutional code (e.g., fs08phy231), or can be assigned categories from a hierarchy defined for the domain.',
+                   miss => 'Your course does not currently appear in the Course Catalog for this domain.',
+                   yous => 'You should remedy this if you plan to allow self-enrollment, otherwise students will have difficulty finding your course.',
+                   coca => 'Courses can be absent from the Catalog, because they do not have an institutional code, have no assigned category, or have been specifically excluded.',
+                   make => 'Make any changes to self-enrollment settings below, click "Save changes", then take action to include the course in the Catalog:',
+                   take => 'Take the following action to ensure the course appears in the Catalog:',
+                   dc_unhide  => 'Ask a domain coordinator to change the "Exclude from course catalog" setting.',
+                   dc_addinst => 'Ask a domain coordinator to enable display the catalog of "Official courses (with institutional codes)".',
+                   dc_instcode => 'Ask a domain coordinator to assign an institutional code (if this is an official course).',
+                   dc_catalog  => 'Ask a domain coordinator to enable or create at least one course category in the domain.',
+                   dc_categories => 'Ask a domain coordinator to create a hierarchy of categories and sub categories for courses in the domain.',
+                   dc_chgcat => 'Ask a domain coordinator to change the category assigned to the course, as the one currently assigned is no longer used in the domain',
+                   dc_addcat => 'Ask a domain coordinator to assign a category to the course.',
+    );
+    $visactions{'unhide'} = &mt('Use [_1]Set course environment[_2] to change the "Exclude from course catalog" setting.','<a href="/adm/parmset?action=crsenv">','</a>');
+    $visactions{'chgcat'} = &mt('Use [_1]Set course environment[_2] to change the category assigned to the course, as the one currently assigned is no longer used in the domain.','<a href="/adm/parmset?action=crsenv">','</a>');
+    $visactions{'addcat'} = &mt('Use [_1]Set course environment[_2] to assign a category to the course.','<a href="/adm/parmset?action=crsenv">','</a>');
+    if (ref($domconf{'coursecategories'}) eq 'HASH') {
+        if ($domconf{'coursecategories'}{'togglecats'} eq 'crs') {
+            $settable{'togglecats'} = 1;
+        }
+        if ($domconf{'coursecategories'}{'categorize'} eq 'crs') {
+            $settable{'categorize'} = 1;
+        }
+        $cathash = $domconf{'coursecategories'}{'cats'};
+    }
+    if ($settable{'togglecats'} && $settable{'categories'}) {
+        $cansetvis = &mt('You are able to both assign a course category and choose to exclude this course from the catalog.');   
+    } elsif ($settable{'togglecats'}) {
+        $cansetvis = &mt('You are able to choose to exclude this course from the catalog, but only a Domain Coordinator may assign a course category.'); 
+    } elsif ($settable{'categories'}) {
+        $cansetvis = &mt('You may assign a course category, but only a Domain Coordinator may choose to exclude this course from the catalog.');  
+    } else {
+        $cansetvis = &mt('Only a Domain Coordinator may assign a course category or choose to exclude this course from the catalog.'); 
+    }
+     
+    my %currsettings =
+        &Apache::lonnet::get('environment',['hidefromcat','categories','internal.coursecode'],
+                             $cdom,$cnum);
+    my $visible = 0;
+    if ($currsettings{'internal.coursecode'} ne '') {
+        if (ref($domconf{'coursecategories'}) eq 'HASH') {
+            $cathash = $domconf{'coursecategories'}{'cats'};
+            if (ref($cathash) eq 'HASH') {
+                if ($cathash->{'instcode::0'} eq '') {
+                    push(@vismsgs,'dc_addinst'); 
+                } else {
+                    $visible = 1;
+                }
+            } else {
+                $visible = 1;
+            }
+        } else {
+            $visible = 1;
+        }
+    } else {
+        if (ref($cathash) eq 'HASH') {
+            if ($cathash->{'instcode::0'} ne '') {
+                push(@vismsgs,'dc_instcode');
+            }
+        } else {
+            push(@vismsgs,'dc_instcode');
+        }
+    }
+    if ($currsettings{'categories'} ne '') {
+        my $cathash;
+        if (ref($domconf{'coursecategories'}) eq 'HASH') {
+            $cathash = $domconf{'coursecategories'}{'cats'};
+            if (ref($cathash) eq 'HASH') {
+                if (keys(%{$cathash}) == 0) {
+                    push(@vismsgs,'dc_catalog');
+                } elsif ((keys(%{$cathash}) == 1) && ($cathash->{'instcode::0'} ne '')) {
+                    push(@vismsgs,'dc_categories');
+                } else {
+                    my @currcategories = split('&',$currsettings{'categories'});
+                    my $matched = 0;
+                    foreach my $cat (@currcategories) {
+                        if ($cathash->{$cat} ne '') {
+                            $visible = 1;
+                            $matched = 1;
+                            last;
+                        }
+                    }
+                    if (!$matched) {
+                        if ($settable{'categories'}) { 
+                            push(@vismsgs,'chgcat');
+                        } else {
+                            push(@vismsgs,'dc_chgcat');
+                        }
+                    }
+                }
+            }
+        }
+    } else {
+        if (ref($cathash) eq 'HASH') {
+            if ((keys(%{$cathash}) > 1) || 
+                (keys(%{$cathash}) == 1) && ($cathash->{'instcode::0'} eq '')) {
+                if ($settable{'categories'}) {
+                    push(@vismsgs,'addcat');
+                } else {
+                    push(@vismsgs,'dc_addcat');
+                }
+            }
+        }
+    }
+    if ($currsettings{'hidefromcat'} eq 'yes') {
+        $visible = 0;
+        if ($settable{'togglecats'}) {
+            unshift(@vismsgs,'unhide');
+        } else {
+            unshift(@vismsgs,'dc_unhide')
+        }
+    }
+    return ($visible,$cansetvis,\@vismsgs,\%visactions);
+}
+
 sub new_selfenroll_dom_row {
     my ($newdom,$num) = @_;
     my $domdesc = &Apache::lonnet::domain($newdom);
@@ -4717,6 +4857,21 @@
     } else {
         $r->print(&mt('No changes were made to the existing self-enrollment settings in this course.'));
     }
+    my ($visible,$cansetvis,$vismsgs,$visactions) = &visible_in_cat($cdom,$cnum);
+    if (ref($visactions) eq 'HASH') {
+        if (!$visible) {
+            $r->print('<br />'.$visactions->{'miss'}.'<br />'.$visactions->{'yous'}.
+                      '<br />');
+            if (ref($vismsgs) eq 'ARRAY') {
+                $r->print('<br />'.$visactions->{'take'}.'<ul>');
+                foreach my $item (@{$vismsgs}) {
+                    $r->print('<li>'.$visactions->{$item}.'</li>');
+                }
+                $r->print('</ul>');
+            }
+            $r->print($cansetvis);
+        }
+    } 
     return;
 }
 
@@ -4726,8 +4881,8 @@
                 types        => 'Users allowed to self-enroll in this course',
                 registered   => 'Restrict self-enrollment to students officially registered for the course',
                 enroll_dates => 'Dates self-enrollment available',
-                access_dates => 'Course access dates for self-enrolled users',
-                section      => 'Section assigned to self-enrolled users',
+                access_dates => 'Course access dates assigned to self-enrolling users',
+                section      => 'Section assigned to self-enrolling users',
              );
     return (\@row,\%lt);
 }

--raeburn1216209992--