Annotation of loncom/interface/londropadd.pm, revision 1.35

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

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