File:  [LON-CAPA] / loncom / interface / Attic / londropadd.pm
Revision 1.42: download - view: text, annotated - select for diffs
Thu May 9 15:56:02 2002 UTC (22 years, 2 months ago) by matthew
Branches: MAIN
CVS tags: version_0_4, stable_2002_july, STABLE, HEAD
Comma Seperated Values function added to loncommon (along with a little
documentation on get_unprocessed_cgi() ), and londropadd now uses the new
csv function.  I forgot which bug this is for and I can't find it now.

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

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