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