File:  [LON-CAPA] / loncom / interface / Attic / londropadd.pm
Revision 1.47: download - view: text, annotated - select for diffs
Thu Aug 22 21:05:25 2002 UTC (21 years, 10 months ago) by albertel
Branches: MAIN
CVS tags: HEAD
- adding krb5 support

    1: # The LearningOnline Network with CAPA
    2: # Handler to drop and add students in courses 
    3: #
    4: # $Id: londropadd.pm,v 1.47 2002/08/22 21:05:25 albertel Exp $
    5: #
    6: # Copyright Michigan State University Board of Trustees
    7: #
    8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
    9: #
   10: # LON-CAPA is free software; you can redistribute it and/or modify
   11: # it under the terms of the GNU General Public License as published by
   12: # the Free Software Foundation; either version 2 of the License, or
   13: # (at your option) any later version.
   14: #
   15: # LON-CAPA is distributed in the hope that it will be useful,
   16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   18: # GNU General Public License for more details.
   19: #
   20: # You should have received a copy of the GNU General Public License
   21: # along with LON-CAPA; if not, write to the Free Software
   22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   23: #
   24: # /home/httpd/html/adm/gpl.txt
   25: #
   26: # http://www.lon-capa.org/
   27: #
   28: # (Handler to set parameters for assessments
   29: #
   30: # (Handler to resolve ambiguous file locations
   31: #
   32: # (TeX Content Handler
   33: #
   34: # YEAR=2000
   35: # 05/29/00,05/30,10/11 Gerd Kortemeyer)
   36: #
   37: # 10/11,10/12,10/16 Gerd Kortemeyer)
   38: #
   39: # 11/20,11/21,11/22,11/23,11/24,11/25,11/27,11/28,
   40: # 12/08,12/12 Gerd Kortemeyer)
   41: #
   42: # 12/26,12/27,12/28,
   43: # YEAR=2001
   44: # 01/01/01,01/15,02/10,02/13,02/14,02/22 Gerd Kortemeyer
   45: # 8/6 Scott Harrison
   46: # Guy Albertelli
   47: # 9/25 Gerd Kortemeyer
   48: # 12/19 Guy Albertelli
   49: # YEAR=2002
   50: # 1/4 Gerd Kortemeyer
   51: 
   52: package Apache::londropadd;
   53: 
   54: use strict;
   55: use Apache::lonnet();
   56: use Apache::loncommon();
   57: use Apache::Constants qw(:common :http REDIRECT);
   58: 
   59: # ================================================================ Print header
   60: 
   61: sub header {
   62:     my $bodytag=&Apache::loncommon::bodytag('Enrollment Manager');
   63:     return(<<ENDHEAD);
   64: <html>
   65: <head>
   66: <title>LON-CAPA Enrollment Manager</title>
   67: </head>
   68: $bodytag
   69: <form method="post" enctype="multipart/form-data"  
   70:       action="/adm/dropadd" name="studentform">
   71: ENDHEAD
   72: }
   73: 
   74: # =========== Drop student from all sections of a course, except optional $csec
   75: sub modifystudent {
   76:     my ($udom,$unam,$courseid,$csec,$desiredhost)=@_;
   77:     # if $csec is undefined, drop the student from all the courses matching
   78:     # this one.  If $csec is defined, drop them from all other sections of 
   79:     # this course and add them to section $csec
   80:     $courseid=~s/\_/\//g;
   81:     $courseid=~s/^(\w)/\/$1/;
   82:     my %roles = &Apache::lonnet::dump('roles',$udom,$unam);
   83:     my ($tmp) = keys(%roles);
   84:     # Bail out if we were unable to get the students roles
   85:     return "$1" if ($tmp =~ /^(con_lost|error|no_such_host)/i);
   86:     # Go through the roles looking for enrollment in this course
   87:     my $result = '';
   88:     foreach my $course (keys(%roles)) {
   89:         if ($course=~/^$courseid(?:\/)*(?:\s+)*(\w+)*\_st$/) {
   90:             # We are in this course
   91:             my $section=$1;
   92:             $section='' if ($course eq $courseid.'_st');
   93:             if ( ((!$section) && (!$csec)) || ($section ne $csec) ) {
   94:                 my (undef,$end,$start)=split(/\_/,$roles{$course});
   95:                 my $now=time;
   96:                 if (!($start && ($now<$start)) || !($end && ($now>$end))) {
   97:                     my $reply=&Apache::lonnet::modifystudent
   98:                         ($udom,$unam,'','','','','','','',
   99:                          $section,time,undef,undef,$desiredhost);
  100:                     $result .= $reply.':';
  101:                 }
  102:             }
  103:         }
  104:     }
  105:     if ($result eq '') {
  106:         $result eq 'Unable to find section for this student';
  107:     } else {
  108:         $result =~ s/(ok:)+/ok/g;
  109:     }
  110:     return $result;
  111: }
  112: 
  113: # ============ build a domain and server selection form
  114: sub domain_form {
  115:     my ($defdom) = @_;
  116:     # Set up domain and server selection forms
  117:     #
  118:     # Get the domains
  119:     my @domains = &Apache::loncommon::get_domains();
  120:     # build up the menu information to be passed to 
  121:     # &Apache::loncommon::linked_select_forms
  122:     my %select_menus;
  123:     foreach my $dom (@domains) {
  124:         # set up the text for this domain
  125:         $select_menus{$dom}->{'text'}= $dom;
  126:         # we want a choice of 'default' as the default in the second menu
  127:         $select_menus{$dom}->{'default'}= 'default';
  128:         $select_menus{$dom}->{'select2'}->{'default'} = 'default';
  129:         # Now build up the other items in the second menu
  130:         my %servers = &Apache::loncommon::get_library_servers($dom);
  131:         foreach my $server (keys(%servers)) {
  132:             $select_menus{$dom}->{'select2'}->{$server} 
  133:                                             = "$server $servers{$server}";
  134:         }
  135:     }
  136:     my $result  = &Apache::loncommon::linked_select_forms
  137:         ('studentform',' with home server ',$defdom,
  138:          'lcdomain','lcserver',\%select_menus);
  139:     return $result;
  140: }
  141: 
  142: # ============================================================== Menu Phase One
  143: sub menu_phase_one {
  144:     my $r=shift;
  145:     my $upfile_select=&Apache::loncommon::upfile_select_html();
  146:     my $create_classlist_help = 
  147: 	&Apache::loncommon::help_open_topic("Course_Create_Class_List",
  148:            "How do I create a class list from a spreadsheet");
  149:     my $create_csv_help =
  150: 	&Apache::loncommon::help_open_topic("Course_Convert_To_CSV",
  151:            "How do I create a CSV file from a spreadsheet");
  152:     $r->print(<<ENDUPFORM);
  153: <input type=hidden name=phase value=two>
  154: <hr>
  155: <h3>Upload a courselist</h3>
  156: $upfile_select
  157: <p><input type=submit name="fileupload" value="Upload Courselist">
  158: <br />
  159: $create_classlist_help <br />
  160: $create_csv_help
  161: 
  162: <hr />
  163: <h3>Enroll a single student</h3>
  164: <p><input type=submit name="enroll" value="Enroll Student"></p>
  165: <hr />
  166: <h3>Classlist</h3>
  167: <p><input type=submit name="view" value="View Class List">
  168: <input type=submit name="viewcsv" value="Comma Separated Class List"></p>
  169: <hr />
  170: <h3>Drop students</h3>
  171: <p><input type=submit name="drop" value="Selection List"></p>
  172: ENDUPFORM
  173: }
  174: 
  175: sub phase_two_header {
  176:     my ($r,$datatoken,$distotal,$krbdefdom)=@_;
  177:     my $javascript;
  178:     if ($ENV{'form.upfile_associate'} eq 'reverse') {
  179: 	$javascript=&phase_two_javascript_reverse_associate();
  180:     } else {
  181: 	$javascript=&phase_two_javascript_forward_associate();
  182:     }
  183:     my $javascript_validations=&javascript_validations($krbdefdom);
  184:     $r->print(<<ENDPICK);
  185: <h3>Uploading Class List</h3>
  186: <hr>
  187: <h3>Identify fields</h3>
  188: Total number of records found in file: $distotal <hr />
  189: Enter as many fields as you can. The system will inform you and bring you back
  190: to this page if the data selected is insufficient to run your class.<hr />
  191: <input type="button" value="Reverse Association" onClick="javascript:this.form.associate.value='Reverse Association';submit(this.form);" />
  192: <input type="hidden" name="associate"  value="" />
  193: <input type="hidden" name="phase"      value="three" />
  194: <input type="hidden" name="datatoken"  value="$datatoken" />
  195: <input type="hidden" name="fileupload" value="$ENV{'form.fileupload'}" />
  196: <input type="hidden" name="upfiletype" value="$ENV{'form.upfiletype'}" />
  197: <input type="hidden" name="upfile_associate" 
  198:                                        value="$ENV{'form.upfile_associate'}" />
  199: <hr />
  200: <script type="text/javascript" language="Javascript">
  201: $javascript
  202: $javascript_validations
  203: </script>
  204: ENDPICK
  205: }
  206: 
  207: sub javascript_validations {
  208:     my ($krbdefdom)=@_;
  209:     my %param = ( formname => 'studentform',
  210:                   kerb_def_dom => $krbdefdom );
  211:     my $authheader = &Apache::loncommon::authform_header(%param);
  212:     return (<<ENDPICK);
  213: function verify_message (vf,founduname,foundpwd,foundname,foundid,foundsec) {
  214:     var foundatype=0;
  215:     var message='';
  216:     if (founduname==0) {
  217: 	alert('You need to specify the username field');
  218:         return;
  219:     }
  220:     if (current.radiovalue == null || current.radiovalue == 'nochange') {
  221:         // They did not check any of the login radiobuttons.
  222:         alert('You must choose an authentication type');
  223:         return;
  224:     }
  225:     foundatype=1;
  226:     if (current.argfield == null || current.argfield == '') {
  227:         var alertmsg = '';
  228:         switch (current.value) {
  229:             case 'krb': 
  230:                 alertmsg = 'You need to specify the Kerberos domain';
  231:                 break;
  232:             case 'loc':
  233:             case 'fsys':
  234:                 alertmsg = 'You need to specify the initial password';
  235:                 break;
  236:             case 'fsys':
  237:                 alertmsg = '';
  238:                 break;
  239:             default: 
  240:                 alertmsg = '';
  241:         }
  242:         if (alertmsg != '') {
  243:             alert(alertmsg);
  244:             return;
  245:         }
  246:     }
  247: 
  248:     if (foundname==0) { message='No name fields specified. '; }
  249:     if (foundid==0) { message+='No ID or student number field specified. '; }
  250:     if (foundsec==0) { message+='No section or group field specified. '; }
  251:     if (vf.startdate.value=='') {
  252: 	message+='No starting date set. ';
  253:     }
  254:     if (vf.enddate.value=='') {
  255:         message+='No ending date set. ';
  256:     }
  257:     if ((vf.enddate.value!='') && (vf.startdate.value!='')) {
  258:        if (Math.round(vf.enddate.value)<Math.round(vf.startdate.value)) {
  259:           alert('Ending date is before starting date');
  260:           return;
  261:        }
  262:     }
  263:     if (message!='') {
  264:        message+='Continue enrollment?';
  265:        if (confirm(message)) {
  266: 	  pclose();
  267: 	  vf.submit();
  268:        }
  269:     } else {
  270:       pclose();
  271:       vf.submit();
  272:     }
  273: }
  274: 
  275: 
  276:     function pclose() {
  277:         parmwin=window.open("/adm/rat/empty.html","LONCAPAparms",
  278:                  "height=350,width=350,scrollbars=no,menubar=no");
  279:         parmwin.close();
  280:     }
  281: 
  282:     function pjump(type,dis,value,marker,ret,call) {
  283:         parmwin=window.open("/adm/rat/parameter.html?type="+escape(type)
  284:                  +"&value="+escape(value)+"&marker="+escape(marker)
  285:                  +"&return="+escape(ret)
  286:                  +"&call="+escape(call)+"&name="+escape(dis),"LONCAPAparms",
  287:                  "height=350,width=350,scrollbars=no,menubar=no");
  288: 
  289:     }
  290: 
  291:     function dateset() {
  292:         if (document.studentform.pres_marker.value=='end') {
  293:            document.studentform.enddate.value=
  294: 	       document.studentform.pres_value.value;
  295:         }
  296:         if (document.studentform.pres_marker.value=='start') {
  297:            document.studentform.startdate.value=
  298: 	       document.studentform.pres_value.value;
  299:         }
  300:         pclose();
  301:     }
  302: 
  303: $authheader
  304: ENDPICK
  305: 
  306: }
  307: 
  308: sub phase_two_javascript_forward_associate {
  309:     return(<<ENDPICK);
  310: function verify(vf) {
  311:     var founduname=0;
  312:     var foundpwd=0;
  313:     var foundname=0;
  314:     var foundid=0;
  315:     var foundsec=0;
  316:     var tw;
  317:     for (i=0;i<=vf.nfields.value;i++) {
  318:         tw=eval('vf.f'+i+'.selectedIndex');
  319:         if (tw==1) { founduname=1; }
  320:         if ((tw>=2) && (tw<=6)) { foundname=1; }
  321:         if (tw==7) { foundid=1; }
  322:         if (tw==8) { foundsec=1; }
  323:         if (tw==9) { foundpwd=1; }
  324:     }
  325:     verify_message(vf,founduname,foundpwd,foundname,foundid,foundsec);
  326: }
  327: 
  328: function flip(vf,tf) {
  329:    var nw=eval('vf.f'+tf+'.selectedIndex');
  330:    var i;
  331:    for (i=0;i<=vf.nfields.value;i++) {
  332:       if ((i!=tf) && (eval('vf.f'+i+'.selectedIndex')==nw)) {
  333:           eval('vf.f'+i+'.selectedIndex=0;')
  334:       }
  335:    }
  336:    if (tf==1 && nw!=0) {
  337:       for (i=2;i<=5;i++) {
  338:          eval('vf.f'+i+'.selectedIndex=0;')
  339:       }
  340:    }
  341:    if (nw==2) {
  342:       for (i=0;i<=vf.nfields.value;i++) {
  343:          if ((eval('vf.f'+i+'.selectedIndex')>=3) &&
  344:              (eval('vf.f'+i+'.selectedIndex')<=6)) {
  345:              eval('vf.f'+i+'.selectedIndex=0;')
  346:          }
  347:       }
  348:    }
  349:    if ((nw>=3) && (nw<=6)) {
  350:       for (i=0;i<=vf.nfields.value;i++) {
  351:          if (eval('vf.f'+i+'.selectedIndex')==2) {
  352:              eval('vf.f'+i+'.selectedIndex=0;')
  353:          }
  354:       }
  355:    }
  356:    if (nw==9) {
  357:        changed_radio('int',document.studentform);
  358:        set_auth_radio_buttons('int',document.studentform);
  359:        vf.intarg.value='';
  360:        vf.krbarg.value='';
  361:        vf.locarg.value='';
  362:    }
  363: }
  364: 
  365: function clearpwd(vf) {
  366:     var i;
  367:     for (i=0;i<=vf.nfields.value;i++) {
  368:         if (eval('vf.f'+i+'.selectedIndex')==9) {
  369:             eval('vf.f'+i+'.selectedIndex=0;')
  370:         }
  371:     }
  372: }
  373: 
  374: ENDPICK
  375: }
  376: 
  377: sub phase_two_javascript_reverse_associate {
  378:     return(<<ENDPICK);
  379: function verify(vf) {
  380:     var founduname=0;
  381:     var foundpwd=0;
  382:     var foundname=0;
  383:     var foundid=0;
  384:     var foundsec=0;
  385:     var tw;
  386:     for (i=0;i<=vf.nfields.value;i++) {
  387:         tw=eval('vf.f'+i+'.selectedIndex');
  388:         if (i==0 && tw!=0) { founduname=1; }
  389:         if (((i>=1) && (i<=5)) && tw!=0 ) { foundname=1; }
  390:         if (i==6 && tw!=0) { foundid=1; }
  391:         if (i==7 && tw!=0) { foundsec=1; }
  392:         if (i==8 && tw!=0) { foundpwd=1; }
  393:     }
  394:     verify_message(vf,founduname,foundpwd,foundname,foundid,foundsec);
  395: }
  396: 
  397: function flip(vf,tf) {
  398:    var nw=eval('vf.f'+tf+'.selectedIndex');
  399:    var i;
  400:    // picked the all one one name field, reset the other name ones to blank
  401:    if (tf==1 && nw!=0) {
  402:       for (i=2;i<=5;i++) {
  403:          eval('vf.f'+i+'.selectedIndex=0;')
  404:       }
  405:    }
  406:    //picked one of the piecewise name fields, reset the all in
  407:    //one field to blank
  408:    if ((tf>=2) && (tf<=5) && (nw!=0)) {
  409:       eval('vf.f1.selectedIndex=0;')
  410:    }
  411:    // intial password specified, pick internal authentication
  412:    if (tf==8 && nw!=0) {
  413:        changed_radio('int',document.studentform);
  414:        set_auth_radio_buttons('int',document.studentform);
  415:        vf.krbarg.value='';
  416:        vf.intarg.value='';
  417:        vf.locarg.value='';
  418:    }
  419: }
  420: 
  421: function clearpwd(vf) {
  422:     var i;
  423:     if (eval('vf.f8.selectedIndex')!=0) {
  424:         eval('vf.f8.selectedIndex=0;')
  425:     }
  426: }
  427: ENDPICK
  428: }
  429: 
  430: sub phase_two_end {
  431:     my ($r,$i,$keyfields,$defdom,$today,$halfyear)=@_;
  432:     my %param = ( formname => 'document.studentform');
  433:     my $krbform = &Apache::loncommon::authform_kerberos(%param);
  434:     my $intform = &Apache::loncommon::authform_internal(%param);
  435:     my $locform = &Apache::loncommon::authform_local(%param);
  436:     my $domform = &domain_form($defdom);
  437:     $r->print(<<ENDPICK);
  438: </table>
  439: <input type=hidden name=nfields value=$i>
  440: <input type=hidden name=keyfields value="$keyfields">
  441: <h3>Login Type</h3>
  442: <p>Note: this will not take effect if the user already exists</p>
  443: <p>
  444: $krbform
  445: </p>
  446: <p>
  447: $intform
  448: </p>
  449: <p>
  450: $locform
  451: </p>
  452: <h3>LON-CAPA Domain for Students</h3>
  453: LON-CAPA domain: $domform <p>
  454: <h3>Starting and Ending Dates</h3>
  455: <input type="hidden" value=''          name="pres_value"  >
  456: <input type="hidden" value=''          name="pres_type"   >
  457: <input type="hidden" value=''          name="pres_marker" >
  458: <input type="hidden" value='$today'    name="startdate"   >
  459: <input type="hidden" value='$halfyear' name="enddate"     >
  460: <a 
  461:  href="javascript:pjump('date_start','Enrollment Starting Date',document.studentform.startdate.value,'start','studentform.pres','dateset');"
  462: >Set Starting Date</a><p>
  463: 
  464: <a 
  465:  href="javascript:pjump('date_end','Enrollment Ending Date',document.studentform.enddate.value,'end','studentform.pres','dateset');"
  466: >Set Ending Date</a><p>
  467: <h3>Full Update</h3>
  468: <input type=checkbox name=fullup value=yes> Full update 
  469: (also print list of users not enrolled anymore)<p>
  470: <h3>ID/Student Number</h3>
  471: <input type=checkbox name=forceid value=yes> 
  472: Disable ID/Student Number Safeguard and Force Change of Conflicting IDs
  473: (only do if you know what you are doing)<p>
  474: <input type="button" onClick="javascript:verify(this.form)" value="Update Courselist" /><br />
  475: Note: for large courses, this operation might be time consuming.
  476: ENDPICK
  477: }
  478: 
  479: # ======================================================= Menu Phase Two Upload
  480: sub menu_phase_two_upload {
  481:     my $r=shift;
  482: 
  483:     my $datatoken;
  484:     if (!$ENV{'form.datatoken'}) {
  485:       $datatoken=&Apache::loncommon::upfile_store($r);
  486:     } else {
  487:       $datatoken=$ENV{'form.datatoken'};
  488:       &Apache::loncommon::load_tmp_file($r);
  489:     }
  490:     my @records=&Apache::loncommon::upfile_record_sep();
  491:     my $total=$#records;
  492:     my $distotal=$total+1;
  493:     $ENV{'SERVER_NAME'}=~/(\w+\.\w+)$/;
  494:     my $krbdefdom=$1;
  495:     $krbdefdom=~tr/a-z/A-Z/;
  496:     my $today=time;
  497:     my $halfyear=$today+15552000;
  498:     my $defdom=$r->dir_config('lonDefDomain');
  499:     &phase_two_header($r,$datatoken,$distotal,$krbdefdom);
  500:     my $i;
  501:     my $keyfields;
  502:     if ($total>=0) {
  503: 	my @d=(['username','Username'],['names','Last Name, First Names'],
  504: 	       ['fname','First Name'],['mname','Middle Names/Initials'],
  505: 	       ['lname','Last Name'],['gen','Generation'],
  506: 	       ['id','ID/Student Number'],['sec','Group/Section'],
  507: 	       ['ipwd','Initial Password']);
  508: 	if ($ENV{'form.upfile_associate'} eq 'reverse') {	
  509: 	    &Apache::loncommon::csv_print_samples($r,\@records);
  510: 	    $i=&Apache::loncommon::csv_print_select_table($r,\@records,\@d);
  511: 	    foreach (@d) { $keyfields.=$_->[0].','; }
  512: 	    chop($keyfields);
  513: 	} else {
  514: 	    unshift(@d,['none','']);
  515: 	    $i=&Apache::loncommon::csv_samples_select_table($r,\@records,\@d);
  516: 	    my %sone=&Apache::loncommon::record_sep($records[0]);
  517: 	    $keyfields=join(',',sort(keys(%sone)));
  518: 	}
  519:     }
  520:     &phase_two_end($r,$i,$keyfields,$defdom,$today,$halfyear);
  521: }
  522: 
  523: # ======================================================= Enroll single student
  524: sub enroll_single_student {
  525:     my $r=shift;
  526:     $r->print('<h3>Enrolling Student</h3>');
  527:     $r->print('<p>Enrolling '.$ENV{'form.cuname'}." in domain ".
  528:               $ENV{'form.lcdomain'}.'</p>');
  529:     if (($ENV{'form.cuname'})&&($ENV{'form.cuname'}!~/\W/)&&
  530:         ($ENV{'form.lcdomain'})&&($ENV{'form.lcdomain'}!~/\W/)) {
  531:         # Deal with home server selection
  532:         my $domain=$ENV{'form.lcdomain'};
  533:         my $desiredhost = $ENV{'form.lcserver'};
  534:         if (lc($desiredhost) eq 'default') {
  535:             $desiredhost = undef;
  536:         } else {
  537:             my %home_servers =&Apache::loncommon::get_library_servers($domain);
  538:             if (! exists($home_servers{$desiredhost})) {
  539:                 $r->print('<font color="#ff0000">Error:</font>'.
  540:                           'Invalid home server specified');
  541:                 return;
  542:             }
  543:         }
  544:         $r->print(" with server $desiredhost :") if (defined($desiredhost));
  545:         # End of home server selection logic
  546: 	my $amode='';
  547:         my $genpwd='';
  548:         if ($ENV{'form.login'} eq 'krb') {
  549:            $amode='krb';
  550: 	   $amode.=$ENV{'form.krbver'};
  551:            $genpwd=$ENV{'form.krbarg'};
  552:         } elsif ($ENV{'form.login'} eq 'int') {
  553:            $amode='internal';
  554:            $genpwd=$ENV{'form.intarg'};
  555:         }  elsif ($ENV{'form.login'} eq 'loc') {
  556: 	    $amode='localauth';
  557: 	    $genpwd=$ENV{'form.locarg'};
  558: 	    if (!$genpwd) { $genpwd=" "; }
  559: 	}
  560:         my $home = &Apache::lonnet::homeserver($ENV{'form.cuname'},
  561:                                                    $ENV{'form.lcdomain'});
  562:         if ((($amode) && ($genpwd)) || ($home ne 'no_host')) {
  563:             &modifystudent($ENV{'form.lcdomain'},$ENV{'form.cuname'},
  564:                            $ENV{'request.course.id'},$ENV{'form.csec'},
  565:                             $desiredhost);
  566:           $r->print(&Apache::lonnet::modifystudent(
  567:                       $ENV{'form.lcdomain'},$ENV{'form.cuname'},
  568:                       $ENV{'form.cstid'},$amode,$genpwd,
  569:  	              $ENV{'form.cfirst'},$ENV{'form.cmiddle'},
  570:                       $ENV{'form.clast'},$ENV{'form.cgen'},
  571:                       $ENV{'form.csec'},$ENV{'form.enddate'},
  572:                       $ENV{'form.startdate'},$ENV{'form.forceid'},
  573:                     $desiredhost));
  574: 	} else {
  575:             $r->print('<p><font color="#ff0000">ERROR</font>&nbsp;'.
  576:                       'Invalid login mode or password.  '.
  577:                       'Unable to enroll '.$ENV{'form.cuname'}.'.</p>');
  578:         }          
  579:     } else {
  580:         $r->print('Invalid username or domain');
  581:     }    
  582: }
  583: 
  584: # ======================================================= Menu Phase Two Enroll
  585: sub menu_phase_two_enroll {
  586:     my $r=shift;
  587:     $r->print("<h3>Enroll One Student</h3>");
  588:     my ($krbdefdom) = $ENV{'SERVER_NAME'}=~/(\w+\.\w+)$/;
  589:     $krbdefdom=~tr/a-z/A-Z/;
  590:     my $today    = time;
  591:     my $halfyear = $today+15552000;
  592:     my $defdom=$r->dir_config('lonDefDomain');
  593:     my $javascript_validations=&javascript_validations($krbdefdom);
  594:     # Set up authentication forms
  595:     my %param = ( formname => 'document.studentform');
  596:     my $krbform = &Apache::loncommon::authform_kerberos(%param);
  597:     my $intform = &Apache::loncommon::authform_internal(%param);
  598:     my $locform = &Apache::loncommon::authform_local(%param);
  599:     # Set up domain selection form
  600:     my $domform = &domain_form($defdom);
  601:     # Print it all out
  602:     $r->print(<<ENDSENROLL);
  603: <script type="text/javascript" language="Javascript">
  604: function verify(vf) {
  605:     var founduname=0;
  606:     var foundpwd=0;
  607:     var foundname=0;
  608:     var foundid=0;
  609:     var foundsec=0;
  610:     var tw;
  611:     if ((typeof(vf.cuname.value) !="undefined") && (vf.cuname.value!='') && 
  612: 	(typeof(vf.lcdomain.value)!="undefined") && (vf.lcdomain.value!='')) {
  613:         founduname=1;
  614:     }
  615:     if ((typeof(vf.cfirst.value)!="undefined") && (vf.cfirst.value!='') &&
  616: 	(typeof(vf.clast.value) !="undefined") && (vf.clast.value!='')) {
  617:         foundname=1;
  618:     }
  619:     if ((typeof(vf.csec.value)!="undefined") && (vf.csec.value!='')) {
  620:         foundsec=1;
  621:     }
  622:     if ((typeof(vf.cstid.value)!="undefined") && (vf.cstid.value!='')) {
  623: 	foundid=1;
  624:     }
  625:     if (founduname==0) {
  626: 	alert('You need to specify at least the username and domain fields');
  627:         return;
  628:     }
  629:     verify_message(vf,founduname,foundpwd,foundname,foundid,foundsec);
  630: }
  631: 
  632: $javascript_validations
  633: 
  634: function clearpwd(vf) {
  635:     //nothing else needs clearing
  636: }
  637: 
  638: </script>
  639: <h3>Personal Data</h3>
  640: First Name:  <input type="text" name="cfirst"  size="15"><br>
  641: Middle Name: <input type="text" name="cmiddle" size="15"><br>
  642: Last Name:   <input type="text" name="clast"   size="15"><br>
  643: Generation:  <input type="text" name="cgen"    size="5"> 
  644: 
  645: <p>ID/Student Number: <input type="text" name="cstid" size="10"></p>
  646: 
  647: <p>Group/Section: <input type=text name=csec size=5></p>
  648: 
  649: <h3>Login Data</h3>
  650: <p>Username: <input type="text" name="cuname"  size="15"></p>
  651: <p>Domain:   $domform</p>
  652: <p>Note: login settings below  will not take effect if the user already exists
  653: </p><p>
  654: $krbform
  655: </p><p>
  656: $intform
  657: </p><p>
  658: $locform
  659: </p><p>
  660: <h3>Starting and Ending Dates</h3>
  661: <input type="hidden" value='' name="pres_value">
  662: <input type="hidden" value='' name="pres_type">
  663: <input type="hidden" value='' name="pres_marker">
  664: <input type="hidden" value='$today' name=startdate>
  665: <input type="hidden" value='$halfyear' name=enddate>
  666: </p><p>
  667: <a 
  668:  href="javascript:pjump('date_start','Enrollment Starting Date',document.studentform.startdate.value,'start','studentform.pres','dateset');"
  669: >Set Starting Date</a>
  670: </p><p>
  671: <a 
  672:  href="javascript:pjump('date_end','Enrollment Ending Date',document.studentform.enddate.value,'end','studentform.pres','dateset');"
  673: >Set Ending Date</a>
  674: </p><p>
  675: <h3>ID/Student Number</h3>
  676: <input type="checkbox" name="forceid" value="yes"> 
  677: Disable ID/Student Number Safeguard and Force Change of Conflicting IDs
  678: (only do if you know what you are doing)<p>
  679: <input type="button" onClick="verify(this.form)" value="Enroll as student"><br>
  680: <input type="hidden" name="phase" value="five">
  681: </p>
  682: ENDSENROLL
  683: }
  684: 
  685: # =================================================== get the current classlist
  686: sub get_current_classlist {
  687:     my ($domain,$identifier) = @_;
  688:     # domain is the domain the class is being run in
  689:     # identifier is the internal, unique identifier for the class.
  690:     my %currentlist=();
  691:     my $now=time;
  692:     my %results=&Apache::lonnet::dump('classlist',$domain,$identifier);
  693:     my ($tmp) = keys(%results);
  694:     if ($tmp !~ /^(con_lost|error|no_such_host)/i) {
  695:         foreach my $student (keys(%results)) {
  696:             # Extract the start and end dates
  697:             my ($end,$start)=split(/\:/,$results{$student});
  698:             # If the class isn't over, put it in the list
  699:             unless (($end) && ($now>$end)) { 
  700:                 $currentlist{$student}=1;
  701:             }
  702:         }
  703:         return (undef,%currentlist);
  704:     } else {
  705:         $tmp =~ s/^error://;
  706:         return ($tmp,undef);
  707:     }
  708: }
  709: 
  710: # ========================================================= Menu Phase Two Drop
  711: sub menu_phase_two_drop {
  712:     my $r=shift;
  713:     $r->print("<h3>Drop Students</h3>");
  714:     my $cid=$ENV{'request.course.id'};
  715:     my ($error,%currentlist)=&get_current_classlist
  716:         ($ENV{'course.'.$cid.'.domain'},$ENV{'course.'.$cid.'.num'});
  717:     if (defined($error)) {
  718:         if ($error =~ /^No such file or directory/) {
  719:             $r->print("There are no students currently enrolled.\n");
  720:         } else {
  721:             $r->print("<pre>ERROR:$error</pre>");
  722:         }
  723:     } elsif (!defined(%currentlist)) { 
  724:         $r->print("There are no students currently enrolled.\n");
  725:     } else {
  726:         # Print out the available choices
  727:         &show_drop_list($r,%currentlist);
  728:     }
  729: }
  730: 
  731: # ============================================== view classlist
  732: sub menu_phase_two_view {
  733:     my $r=shift;
  734:     $r->print("<h3>Current Classlist</h3>");
  735:     my $cid=$ENV{'request.course.id'};
  736:     my ($error,%currentlist)=&get_current_classlist
  737:         ($ENV{'course.'.$cid.'.domain'},$ENV{'course.'.$cid.'.num'});
  738:     if (defined($error)) {
  739:         if ($error =~ /^No such file or directory/) {
  740:             $r->print("There are no students currently enrolled.\n");
  741:         } else {
  742:             $r->print("<pre>ERROR:$error</pre>");
  743:         }
  744:     } elsif (!defined(%currentlist)) { 
  745:         $r->print("There are no students currently enrolled.\n");
  746:     } else {
  747:         # Print out the available choices
  748:         &show_class_list($r,'view',%currentlist);
  749:     }
  750: }
  751: 
  752: # ============================================== view classlist
  753: sub menu_phase_two_viewcsv {
  754:     my $r=shift;
  755:     my $cid=$ENV{'request.course.id'};
  756:     my ($error,%currentlist)=&get_current_classlist
  757:         ($ENV{'course.'.$cid.'.domain'},$ENV{'course.'.$cid.'.num'});
  758:     if (defined($error)) {
  759:         if ($error =~ /^No such file or directory/) {
  760:             $r->print("There are no students currently enrolled.\n");
  761:         } else {
  762:             $r->print("<pre>ERROR:$error</pre>");
  763:         }
  764:     } elsif (!defined(%currentlist)) { 
  765:         $r->print("There are no students currently enrolled.\n");
  766:     } else {
  767:         &show_class_list($r,'csv',%currentlist);
  768:     }
  769: }
  770: 
  771: # =================================================== Show student list to drop
  772: sub show_class_list {
  773:     my ($r,$mode,%currentlist)=@_;
  774:     my $cid=$ENV{'request.course.id'};
  775:     # Print out header 
  776:     if ($mode eq 'view') {
  777:         $r->print(<<END);
  778: <p>
  779: <table border=2>
  780: <tr><th>username</th><th>domain</th><th>ID</th>
  781:     <th>student name</th><th>generation</th><th>section</th></tr>
  782: END
  783:     } elsif ($mode eq 'csv') {
  784:         $r->print(<<END);
  785: username,domain,ID,last name,first name,middle name,generation,section
  786: END
  787:     }
  788:     foreach (sort keys %currentlist) {
  789:         my ($sname,$sdom)=split(/\:/,$_);
  790:         my %reply=&Apache::lonnet::idrget($sdom,$sname);
  791:         my $ssec=&Apache::lonnet::usection($sdom,$sname,$cid);
  792:         my %info=&Apache::lonnet::get('environment',
  793:                                       ['firstname','middlename',
  794:                                        'lastname','generation'],
  795:                                       $sdom, $sname);
  796:         my ($tmp) = keys(%info);
  797:         if ($tmp =~ /^(con_lost|error|no_such_host)/i) {
  798:             $r->print( ($mode eq 'view' ? 
  799:                        '<tr><td colspan="6"><font color="red">' :'').
  800:                        'Internal error: unable to get environment '.
  801:                        'for '.$sname.' in domain '.$sdom.
  802:                        ( $mode eq 'view' ?'</font></td></tr>' :''));
  803:         } else {
  804:             if ($mode eq 'view') {
  805:                 $r->print(<<"END");
  806: <tr>
  807:     <td>$sname</td>
  808:     <td>$sdom</td>
  809:     <td>$reply{$sname}</td>
  810:     <td>$info{'lastname'}, $info{'firstname'} $info{'middlename'}</td>
  811:     <td>$info{'generation'}</td>
  812:     <td>$ssec</td>
  813: </tr>
  814: END
  815:             } elsif ($mode eq 'csv') {
  816:                 my @line = ();
  817:                 foreach ($sname,$sdom,$reply{$sname},
  818:                          $info{'lastname'},$info{'firstname'},
  819:                          $info{'middlename'},$info{'generation'},$ssec) {
  820:                     push @line,&Apache::loncommon::csv_translate($_);
  821:                 }
  822:                 my $tmp = $";
  823:                 $" = '","';
  824:                 $r->print("\"@line\"\n");
  825:                 $" = $tmp;
  826:             }
  827:         }
  828:     }
  829:     $r->print('</table><br>') if ($mode eq 'view');
  830: }
  831: 
  832: # =================================================== Show student list to drop
  833: sub show_drop_list {
  834:     my ($r,%currentlist)=@_;
  835:     my $cid=$ENV{'request.course.id'};
  836:     $r->print(<<'END');
  837: <script>
  838: function checkAll(field)
  839: {
  840:     for (i = 0; i < field.length; i++)
  841:         field[i].checked = true ;
  842: }
  843: 
  844: function uncheckAll(field)
  845: {
  846:     for (i = 0; i < field.length; i++)
  847:         field[i].checked = false ;
  848: }
  849: </script>
  850: <p>
  851: <input type="hidden" name="phase" value="four">
  852: <table border=2>
  853: <tr><th>&nbsp;</th><th>username</th><th>domain</th>
  854: <th>ID</th><th>student name</th><th>generation</th>
  855: <th>section</th></tr>
  856: END
  857:     foreach (sort keys %currentlist) {
  858:         my ($sname,$sdom)=split(/\:/,$_);
  859:         my %reply=&Apache::lonnet::idrget($sdom,$sname);
  860:         my $ssec=&Apache::lonnet::usection($sdom,$sname,$cid);
  861:         my %info=&Apache::lonnet::get('environment',
  862:                                       ['firstname','middlename',
  863:                                        'lastname','generation'],
  864:                                       $sdom, $sname);
  865:         my ($tmp) = keys(%info);
  866:         if ($tmp =~ /^(con_lost|error|no_such_host)/i) {
  867:             $r->print('<tr><td colspan="7"><font color="red">'.
  868:                       'Internal error: unable to get environment '.
  869:                       'for '.$sname.' in domain '.$sdom.'</font></td></tr>');
  870:         } else {
  871:             $r->print(<<"END");
  872: <tr>
  873:     <td><input type="checkbox" name="droplist" value="$_"></td>
  874:     <td>$sname</td>
  875:     <td>$sdom</td>
  876:     <td>$reply{$sname}</td>
  877:     <td>$info{'lastname'}, $info{'firstname'} $info{'middlename'}</td>
  878:     <td>$info{'generation'}</td>
  879:     <td>$ssec</td>
  880: </tr>
  881: END
  882:         }
  883:     }
  884:     $r->print('</table><br>');
  885:     $r->print(<<"END");
  886: </p><p>
  887: <input type="button" value="check all" onclick="javascript:checkAll(document.studentform.droplist)"> &nbsp;
  888: <input type="button" value="uncheck all" onclick="javascript:uncheckAll(document.studentform.droplist)"> 
  889: <p><input type=submit value="Drop Students"></p>
  890: END
  891: }
  892: 
  893: # ================================================= Drop/Add from uploaded file
  894: sub upfile_drop_add {
  895:     my $r=shift;
  896:     &Apache::loncommon::load_tmp_file($r);
  897:     my @studentdata=&Apache::loncommon::upfile_record_sep();
  898:     my @keyfields = split(/\,/,$ENV{'form.keyfields'});
  899:     my $cid = $ENV{'request.course.id'};
  900:     my %fields=();
  901:     for (my $i=0; $i<=$ENV{'form.nfields'}; $i++) {
  902:         if ($ENV{'form.upfile_associate'} eq 'reverse') {
  903:             if ($ENV{'form.f'.$i} ne 'none') {
  904:                 $fields{$keyfields[$i]}=$ENV{'form.f'.$i};
  905:             }
  906:         } else {
  907:             $fields{$ENV{'form.f'.$i}}=$keyfields[$i];
  908:         }
  909:     }
  910:     #
  911:     my $startdate = $ENV{'form.startdate'};
  912:     my $enddate   = $ENV{'form.enddate'};
  913:     if ($startdate=~/\D/) { $startdate=''; }
  914:     if ($enddate=~/\D/)   { $enddate=''; }
  915:     # Determine domain and desired host (home server)
  916:     my $domain=$ENV{'form.lcdomain'};
  917:     my $desiredhost = $ENV{'form.lcserver'};
  918:     if (lc($desiredhost) eq 'default') {
  919:         $desiredhost = undef;
  920:     } else {
  921:         my %home_servers = &Apache::loncommon::get_library_servers($domain);
  922:         if (! exists($home_servers{$desiredhost})) {
  923:             $r->print('<font color="#ff0000">Error:</font>'.
  924:                       'Invalid home server specified');
  925:             return;
  926:         }
  927:     }
  928:     # Determine authentication mechanism
  929:     my $amode  = '';
  930:     my $genpwd = '';
  931:     if ($ENV{'form.login'} eq 'krb') {
  932:         $amode='krb';
  933: 	$amode.=$ENV{'form.krbver'};
  934:         $genpwd=$ENV{'form.krbarg'};
  935:     } elsif ($ENV{'form.login'} eq 'int') {
  936:         $amode='internal';
  937:         if ((defined($ENV{'form.intarg'})) && ($ENV{'form.intarg'})) {
  938:             $genpwd=$ENV{'form.intarg'};
  939:         }
  940:     } elsif ($ENV{'form.login'} eq 'loc') {
  941:         $amode='localauth';
  942:         if ((defined($ENV{'form.locarg'})) && ($ENV{'form.locarg'})) {
  943:             $genpwd=$ENV{'form.locarg'};
  944:         }
  945:     }
  946:     unless (($domain=~/\W/) || ($amode eq '')) {
  947:         #######################################
  948:         ##         Enroll Students           ##
  949:         #######################################
  950:         $r->print('<h3>Enrolling Students</h3>');
  951:         my $count=0;
  952:         my $flushc=0;
  953:         my %student=();
  954:         # Get new classlist
  955:         foreach (@studentdata) {
  956:             my %entries=&Apache::loncommon::record_sep($_);
  957:             # Determine student name
  958:             unless (($entries{$fields{'username'}} eq '') ||
  959:                     (!defined($entries{$fields{'username'}}))) {
  960:                 my ($fname, $mname, $lname,$gen) = ('','','','');
  961:                 if (defined($fields{'names'})) {
  962:                     ($lname,$fname,$mname)=($entries{$fields{'names'}}=~
  963:                                             /([^\,]+)\,\s*(\w+)\s*(.*)$/);
  964:                 } else {
  965:                     if (defined($fields{'fname'})) {
  966:                         $fname=$entries{$fields{'fname'}};
  967:                     }
  968:                     if (defined($fields{'mname'})) {
  969:                         $mname=$entries{$fields{'mname'}};
  970:                     }
  971:                     if (defined($fields{'lname'})) {
  972:                         $lname=$entries{$fields{'lname'}};
  973:                     }
  974:                     if (defined($fields{'gen'})) {
  975:                         $gen=$entries{$fields{'gen'}};
  976:                     }
  977:                 }
  978:                 if ($entries{$fields{'username'}}=~/\W/) {
  979:                     $r->print('<p><b>Unacceptable username: '.
  980:                               $entries{$fields{'username'}}.' for user '.
  981:                               $fname.' '.$mname.' '.$lname.' '.$gen.'</b><p>');
  982:                 } else {
  983:                     # determine section number
  984:                     my $sec='';
  985:                     my $username=$entries{$fields{'username'}};
  986:                     if (defined($fields{'sec'})) {
  987:                         if (defined($entries{$fields{'sec'}})) {
  988:                             $sec=$entries{$fields{'sec'}};
  989:                         }
  990:                     }
  991:                     # determine student id number
  992:                     my $id='';
  993:                     if (defined($fields{'id'})) {
  994:                         if (defined($entries{$fields{'id'}})) {
  995:                             $id=$entries{$fields{'id'}};
  996:                         }
  997:                         $id=~tr/A-Z/a-z/;
  998:                     }
  999:                     # determine student password
 1000:                     my $password='';
 1001:                     if ($genpwd) { 
 1002:                         $password=$genpwd; 
 1003:                     } else {
 1004:                         if (defined($fields{'ipwd'})) {
 1005:                             if ($entries{$fields{'ipwd'}}) {
 1006:                                 $password=$entries{$fields{'ipwd'}};
 1007:                             }
 1008:                         }
 1009:                     }
 1010:                     if ($password) {
 1011:                         &modifystudent($domain,$username,$cid,$sec,
 1012:                                        $desiredhost);
 1013:                         my $reply=&Apache::lonnet::modifystudent
 1014:                             ($domain,$username,$id,$amode,$password,
 1015:                              $fname,$mname,$lname,$gen,$sec,$enddate,
 1016:                              $startdate,$ENV{'form.forceid'},$desiredhost);
 1017:                         if ($reply ne 'ok') {
 1018:                             $r->print('<p><b>'.
 1019:                                       'Error enrolling '.$username.': '.
 1020:                                       $reply.'</b></p>');
 1021:          		} else {
 1022:                             $count++; $flushc++;
 1023:                             $student{$username}=1;
 1024:                             $r->print('. ');
 1025:                             if ($flushc>15) {
 1026: 				$r->rflush;
 1027:                                 $flushc=0;
 1028:                             }
 1029:                         }
 1030:                     } else {
 1031:                         $r->print("<p><b>No password for $username</b><p>");
 1032:                     }
 1033:                 }
 1034:             }
 1035:         } # end of foreach (@studentdata)
 1036:         $r->print('<p>Processed Students: '.$count);
 1037:         #####################################
 1038:         #           Drop students           #
 1039:         #####################################
 1040:         if ($ENV{'form.fullup'} eq 'yes') {
 1041:             $r->print('<h3>Dropping Students</h3>');
 1042:             #  Get current classlist
 1043:             my ($error,%currentlist)=&get_current_classlist
 1044:                 ($ENV{'course.'.$cid.'.domain'},
 1045:                  $ENV{'course.'.$cid.'.num'});
 1046:             if (defined($error)) {
 1047:                 $r->print('<pre>ERROR:$error</pre>');
 1048:             }
 1049:             if (defined(%currentlist)) {
 1050:                 # Drop the students
 1051:                 foreach (@studentdata) {
 1052:                     my %entries=&Apache::loncommon::record_sep($_);
 1053:                     unless (($entries{$fields{'username'}} eq '') ||
 1054:                             (!defined($entries{$fields{'username'}}))) {
 1055:                         delete($currentlist{$entries{$fields{'username'}}.
 1056:                                                 ':'.$domain});
 1057:                     }
 1058:                 }
 1059:                 # Print out list of dropped students
 1060:                 &show_drop_list($r,%currentlist);
 1061:             } else {
 1062:                 $r->print("There are no students currently enrolled.\n");
 1063:             }
 1064:         }
 1065:     } # end of unless
 1066: }
 1067: 
 1068: # ================================================================== Phase four
 1069: sub drop_student_list {
 1070:     my $r=shift;
 1071:     my $count=0;
 1072:     my @droplist;
 1073:     if (ref($ENV{'form.droplist'})) {
 1074:         @droplist = @{$ENV{'form.droplist'}};
 1075:     } else {
 1076:         @droplist = ($ENV{'form.droplist'});
 1077:     }
 1078:     foreach (@droplist) {
 1079:         my ($uname,$udom)=split(/\:/,$_);
 1080:         my $result = &modifystudent($udom,$uname,$ENV{'request.course.id'});
 1081:         if ($result eq 'ok' || $result eq 'ok:') {
 1082:             $r->print('Dropped '.$uname.' at '.$udom.'<br>');
 1083:         } else {
 1084:             $r->print('Error dropping '.$uname.' at '.$udom.': '.$result.
 1085:                       '<br />');
 1086:         }
 1087:         $count++;
 1088:     }
 1089:     $r->print('<p><b>Dropped '.$count.' student(s).</b>');
 1090:     $r->print('<p>Re-enrollment will re-activate data.');
 1091: }
 1092: 
 1093: # ================================================================ Main Handler
 1094: sub handler {
 1095:     my $r=shift;
 1096:     if ($r->header_only) {
 1097:         $r->content_type('text/html');
 1098:         $r->send_http_header;
 1099:         return OK;
 1100:     }
 1101:     #  Needs to be in a course
 1102:     if (($ENV{'request.course.fn'}) && 
 1103:         (&Apache::lonnet::allowed('cst',$ENV{'request.course.id'}))) {
 1104:         # Start page
 1105:         $r->content_type('text/html') if (! exists($ENV{'form.viewcsv'}));
 1106:         $r->send_http_header;
 1107:         $r->print(&header()) if (! exists($ENV{'form.viewcsv'}));
 1108:         # Phase one, initial screen
 1109:         unless ($ENV{'form.phase'}) {
 1110:             &menu_phase_one($r);
 1111:         }
 1112:         # Phase two
 1113:         if ($ENV{'form.associate'} eq 'Reverse Association') {
 1114:             $ENV{'form.phase'} = 'two';
 1115:             if ( $ENV{'form.upfile_associate'} ne 'reverse' ) {
 1116:                 $ENV{'form.upfile_associate'} = 'reverse';
 1117:             } else {
 1118:                 $ENV{'form.upfile_associate'} = 'forward';
 1119:             }
 1120:         }
 1121:         if ($ENV{'form.phase'} eq 'two') {
 1122:             if ($ENV{'form.fileupload'}) {
 1123:                 &menu_phase_two_upload($r);
 1124:             } elsif ($ENV{'form.enroll'}) {
 1125:                 &menu_phase_two_enroll($r);
 1126:             } elsif ($ENV{'form.drop'}) {
 1127:                 &menu_phase_two_drop($r);
 1128:             } elsif ($ENV{'form.view'}) {
 1129:                 &menu_phase_two_view($r);
 1130:             } elsif ($ENV{'form.viewcsv'}) {
 1131:                 &menu_phase_two_viewcsv($r);
 1132:             }
 1133:         }
 1134:         # Phase three
 1135:         if ($ENV{'form.phase'} eq 'three') {
 1136:             if ($ENV{'form.datatoken'}) {
 1137:                 &upfile_drop_add($r);
 1138:             }
 1139:         }
 1140:         # Phase four
 1141:         if ($ENV{'form.phase'} eq 'four') {
 1142:             &drop_student_list($r);
 1143:         }
 1144:         # Phase five
 1145:         if ($ENV{'form.phase'} eq 'five') {
 1146:             &enroll_single_student($r);
 1147:         }
 1148:          # End
 1149:         $r->print('</form></body></html>') if (! exists($ENV{'form.viewcsv'}));
 1150:     } else {
 1151:         # Not in a course, or not allowed to modify parms
 1152:         $ENV{'user.error.msg'}=
 1153:             "/adm/dropadd:cst:0:0:Cannot drop or add students";
 1154:         return HTTP_NOT_ACCEPTABLE; 
 1155:     }
 1156:     return OK;
 1157: }
 1158: 
 1159: 1;
 1160: __END__
 1161: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>