Annotation of loncom/interface/londropadd.pm, revision 1.47
1.1 www 1: # The LearningOnline Network with CAPA
2: # Handler to drop and add students in courses
3: #
1.47 ! albertel 4: # $Id: londropadd.pm,v 1.46 2002/08/21 17:18:08 www 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.46 www 62: my $bodytag=&Apache::loncommon::bodytag('Enrollment Manager');
1.27 matthew 63: return(<<ENDHEAD);
1.1 www 64: <html>
65: <head>
1.40 matthew 66: <title>LON-CAPA Enrollment Manager</title>
1.1 www 67: </head>
1.46 www 68: $bodytag
1.40 matthew 69: <form method="post" enctype="multipart/form-data"
70: action="/adm/dropadd" name="studentform">
1.1 www 71: ENDHEAD
1.10 www 72: }
73:
74: # =========== Drop student from all sections of a course, except optional $csec
1.26 matthew 75: sub modifystudent {
1.33 matthew 76: my ($udom,$unam,$courseid,$csec,$desiredhost)=@_;
1.26 matthew 77: # if $csec is undefined, drop the student from all the courses matching
78: # this one. If $csec is defined, drop them from all other sections of
79: # this course and add them to section $csec
1.25 matthew 80: $courseid=~s/\_/\//g;
81: $courseid=~s/^(\w)/\/$1/;
1.26 matthew 82: my %roles = &Apache::lonnet::dump('roles',$udom,$unam);
83: my ($tmp) = keys(%roles);
84: # Bail out if we were unable to get the students roles
1.35 matthew 85: return "$1" if ($tmp =~ /^(con_lost|error|no_such_host)/i);
1.26 matthew 86: # Go through the roles looking for enrollment in this course
1.35 matthew 87: my $result = '';
1.26 matthew 88: foreach my $course (keys(%roles)) {
1.35 matthew 89: if ($course=~/^$courseid(?:\/)*(?:\s+)*(\w+)*\_st$/) {
1.26 matthew 90: # We are in this course
1.25 matthew 91: my $section=$1;
1.26 matthew 92: $section='' if ($course eq $courseid.'_st');
1.35 matthew 93: if ( ((!$section) && (!$csec)) || ($section ne $csec) ) {
1.27 matthew 94: my (undef,$end,$start)=split(/\_/,$roles{$course});
1.25 matthew 95: my $now=time;
1.27 matthew 96: if (!($start && ($now<$start)) || !($end && ($now>$end))) {
1.25 matthew 97: my $reply=&Apache::lonnet::modifystudent
1.33 matthew 98: ($udom,$unam,'','','','','','','',
99: $section,time,undef,undef,$desiredhost);
1.35 matthew 100: $result .= $reply.':';
1.25 matthew 101: }
1.10 www 102: }
103: }
1.20 harris41 104: }
1.35 matthew 105: if ($result eq '') {
106: $result eq 'Unable to find section for this student';
1.37 matthew 107: } else {
108: $result =~ s/(ok:)+/ok/g;
1.35 matthew 109: }
110: return $result;
1.10 www 111: }
112:
1.31 matthew 113: # ============ build a domain and server selection form
114: sub domain_form {
115: my ($defdom) = @_;
116: # Set up domain and server selection forms
117: #
118: # Get the domains
119: my @domains = &Apache::loncommon::get_domains();
120: # build up the menu information to be passed to
121: # &Apache::loncommon::linked_select_forms
122: my %select_menus;
123: foreach my $dom (@domains) {
124: # set up the text for this domain
125: $select_menus{$dom}->{'text'}= $dom;
126: # we want a choice of 'default' as the default in the second menu
127: $select_menus{$dom}->{'default'}= 'default';
128: $select_menus{$dom}->{'select2'}->{'default'} = 'default';
129: # Now build up the other items in the second menu
1.45 matthew 130: my %servers = &Apache::loncommon::get_library_servers($dom);
1.31 matthew 131: foreach my $server (keys(%servers)) {
132: $select_menus{$dom}->{'select2'}->{$server}
133: = "$server $servers{$server}";
134: }
135: }
136: my $result = &Apache::loncommon::linked_select_forms
137: ('studentform',' with home server ',$defdom,
138: 'lcdomain','lcserver',\%select_menus);
139: return $result;
140: }
141:
1.10 www 142: # ============================================================== Menu Phase One
143: sub menu_phase_one {
144: my $r=shift;
1.24 albertel 145: my $upfile_select=&Apache::loncommon::upfile_select_html();
1.43 bowersj2 146: my $create_classlist_help =
1.44 bowersj2 147: &Apache::loncommon::help_open_topic("Course_Create_Class_List",
148: "How do I create a class list from a spreadsheet");
1.43 bowersj2 149: my $create_csv_help =
1.44 bowersj2 150: &Apache::loncommon::help_open_topic("Course_Convert_To_CSV",
151: "How do I create a CSV file from a spreadsheet");
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 />
1.44 bowersj2 159: $create_classlist_help <br />
160: $create_csv_help
1.43 bowersj2 161:
1.40 matthew 162: <hr />
1.2 www 163: <h3>Enroll a single student</h3>
1.40 matthew 164: <p><input type=submit name="enroll" value="Enroll Student"></p>
165: <hr />
166: <h3>Classlist</h3>
1.41 matthew 167: <p><input type=submit name="view" value="View Class List">
168: <input type=submit name="viewcsv" value="Comma Separated Class List"></p>
1.40 matthew 169: <hr />
1.11 www 170: <h3>Drop students</h3>
1.40 matthew 171: <p><input type=submit name="drop" value="Selection List"></p>
1.2 www 172: ENDUPFORM
1.10 www 173: }
174:
1.23 albertel 175: sub phase_two_header {
176: my ($r,$datatoken,$distotal,$krbdefdom)=@_;
1.24 albertel 177: my $javascript;
178: if ($ENV{'form.upfile_associate'} eq 'reverse') {
179: $javascript=&phase_two_javascript_reverse_associate();
180: } else {
181: $javascript=&phase_two_javascript_forward_associate();
182: }
183: my $javascript_validations=&javascript_validations($krbdefdom);
1.10 www 184: $r->print(<<ENDPICK);
1.40 matthew 185: <h3>Uploading Class List</h3>
1.2 www 186: <hr>
187: <h3>Identify fields</h3>
1.22 albertel 188: Total number of records found in file: $distotal <hr />
189: Enter as many fields as you can. The system will inform you and bring you back
190: to this page if the data selected is insufficient to run your class.<hr />
1.36 albertel 191: <input type="button" value="Reverse Association" onClick="javascript:this.form.associate.value='Reverse Association';submit(this.form);" />
192: <input type="hidden" name="associate" value="" />
1.26 matthew 193: <input type="hidden" name="phase" value="three" />
194: <input type="hidden" name="datatoken" value="$datatoken" />
1.24 albertel 195: <input type="hidden" name="fileupload" value="$ENV{'form.fileupload'}" />
196: <input type="hidden" name="upfiletype" value="$ENV{'form.upfiletype'}" />
1.26 matthew 197: <input type="hidden" name="upfile_associate"
198: value="$ENV{'form.upfile_associate'}" />
1.24 albertel 199: <hr />
1.28 matthew 200: <script type="text/javascript" language="Javascript">
1.24 albertel 201: $javascript
202: $javascript_validations
203: </script>
204: ENDPICK
205: }
206:
207: sub javascript_validations {
208: my ($krbdefdom)=@_;
1.28 matthew 209: my %param = ( formname => 'studentform',
210: kerb_def_dom => $krbdefdom );
211: my $authheader = &Apache::loncommon::authform_header(%param);
1.24 albertel 212: return (<<ENDPICK);
213: function verify_message (vf,founduname,foundpwd,foundname,foundid,foundsec) {
1.3 www 214: var foundatype=0;
215: var message='';
216: if (founduname==0) {
1.28 matthew 217: alert('You need to specify the username field');
1.3 www 218: return;
219: }
1.29 matthew 220: if (current.radiovalue == null || current.radiovalue == 'nochange') {
1.28 matthew 221: // They did not check any of the login radiobuttons.
222: alert('You must choose an authentication type');
223: return;
224: }
225: foundatype=1;
1.29 matthew 226: if (current.argfield == null || current.argfield == '') {
1.28 matthew 227: var alertmsg = '';
1.29 matthew 228: switch (current.value) {
1.28 matthew 229: case 'krb':
230: alertmsg = 'You need to specify the Kerberos domain';
231: break;
232: case 'loc':
233: case 'fsys':
234: alertmsg = 'You need to specify the initial password';
235: break;
236: case 'fsys':
237: alertmsg = '';
238: break;
239: default:
240: alertmsg = '';
1.3 www 241: }
1.28 matthew 242: if (alertmsg != '') {
243: alert(alertmsg);
1.3 www 244: return;
245: }
246: }
1.28 matthew 247:
1.3 www 248: if (foundname==0) { message='No name fields specified. '; }
249: if (foundid==0) { message+='No ID or student number field specified. '; }
250: if (foundsec==0) { message+='No section or group field specified. '; }
1.4 www 251: if (vf.startdate.value=='') {
252: message+='No starting date set. ';
1.3 www 253: }
1.4 www 254: if (vf.enddate.value=='') {
255: message+='No ending date set. ';
256: }
257: if ((vf.enddate.value!='') && (vf.startdate.value!='')) {
1.10 www 258: if (Math.round(vf.enddate.value)<Math.round(vf.startdate.value)) {
1.4 www 259: alert('Ending date is before starting date');
260: return;
261: }
262: }
263: if (message!='') {
264: message+='Continue enrollment?';
265: if (confirm(message)) {
266: pclose();
267: vf.submit();
268: }
269: } else {
270: pclose();
271: vf.submit();
1.24 albertel 272: }
1.3 www 273: }
274:
275:
1.4 www 276: function pclose() {
277: parmwin=window.open("/adm/rat/empty.html","LONCAPAparms",
278: "height=350,width=350,scrollbars=no,menubar=no");
279: parmwin.close();
280: }
281:
282: function pjump(type,dis,value,marker,ret,call) {
283: parmwin=window.open("/adm/rat/parameter.html?type="+escape(type)
284: +"&value="+escape(value)+"&marker="+escape(marker)
285: +"&return="+escape(ret)
286: +"&call="+escape(call)+"&name="+escape(dis),"LONCAPAparms",
287: "height=350,width=350,scrollbars=no,menubar=no");
288:
289: }
290:
291: function dateset() {
292: if (document.studentform.pres_marker.value=='end') {
293: document.studentform.enddate.value=
294: document.studentform.pres_value.value;
295: }
296: if (document.studentform.pres_marker.value=='start') {
297: document.studentform.startdate.value=
298: document.studentform.pres_value.value;
299: }
300: pclose();
301: }
1.3 www 302:
1.28 matthew 303: $authheader
1.24 albertel 304: ENDPICK
1.28 matthew 305:
1.24 albertel 306: }
307:
308: sub phase_two_javascript_forward_associate {
309: return(<<ENDPICK);
310: function verify(vf) {
311: var founduname=0;
312: var foundpwd=0;
313: var foundname=0;
314: var foundid=0;
315: var foundsec=0;
316: var tw;
317: for (i=0;i<=vf.nfields.value;i++) {
318: tw=eval('vf.f'+i+'.selectedIndex');
319: if (tw==1) { founduname=1; }
320: if ((tw>=2) && (tw<=6)) { foundname=1; }
321: if (tw==7) { foundid=1; }
322: if (tw==8) { foundsec=1; }
323: if (tw==9) { foundpwd=1; }
324: }
325: verify_message(vf,founduname,foundpwd,foundname,foundid,foundsec);
326: }
327:
328: function flip(vf,tf) {
329: var nw=eval('vf.f'+tf+'.selectedIndex');
330: var i;
331: for (i=0;i<=vf.nfields.value;i++) {
332: if ((i!=tf) && (eval('vf.f'+i+'.selectedIndex')==nw)) {
333: eval('vf.f'+i+'.selectedIndex=0;')
334: }
335: }
336: if (tf==1 && nw!=0) {
337: for (i=2;i<=5;i++) {
338: eval('vf.f'+i+'.selectedIndex=0;')
339: }
340: }
341: if (nw==2) {
342: for (i=0;i<=vf.nfields.value;i++) {
343: if ((eval('vf.f'+i+'.selectedIndex')>=3) &&
344: (eval('vf.f'+i+'.selectedIndex')<=6)) {
345: eval('vf.f'+i+'.selectedIndex=0;')
346: }
347: }
348: }
349: if ((nw>=3) && (nw<=6)) {
350: for (i=0;i<=vf.nfields.value;i++) {
351: if (eval('vf.f'+i+'.selectedIndex')==2) {
352: eval('vf.f'+i+'.selectedIndex=0;')
353: }
354: }
355: }
356: if (nw==9) {
1.28 matthew 357: changed_radio('int',document.studentform);
358: set_auth_radio_buttons('int',document.studentform);
359: vf.intarg.value='';
360: vf.krbarg.value='';
1.24 albertel 361: vf.locarg.value='';
362: }
363: }
364:
365: function clearpwd(vf) {
366: var i;
367: for (i=0;i<=vf.nfields.value;i++) {
368: if (eval('vf.f'+i+'.selectedIndex')==9) {
369: eval('vf.f'+i+'.selectedIndex=0;')
370: }
371: }
372: }
373:
374: ENDPICK
375: }
376:
377: sub phase_two_javascript_reverse_associate {
378: return(<<ENDPICK);
379: function verify(vf) {
380: var founduname=0;
381: var foundpwd=0;
382: var foundname=0;
383: var foundid=0;
384: var foundsec=0;
385: var tw;
386: for (i=0;i<=vf.nfields.value;i++) {
387: tw=eval('vf.f'+i+'.selectedIndex');
388: if (i==0 && tw!=0) { founduname=1; }
389: if (((i>=1) && (i<=5)) && tw!=0 ) { foundname=1; }
390: if (i==6 && tw!=0) { foundid=1; }
391: if (i==7 && tw!=0) { foundsec=1; }
392: if (i==8 && tw!=0) { foundpwd=1; }
393: }
394: verify_message(vf,founduname,foundpwd,foundname,foundid,foundsec);
395: }
396:
397: function flip(vf,tf) {
398: var nw=eval('vf.f'+tf+'.selectedIndex');
399: var i;
400: // picked the all one one name field, reset the other name ones to blank
401: if (tf==1 && nw!=0) {
402: for (i=2;i<=5;i++) {
403: eval('vf.f'+i+'.selectedIndex=0;')
404: }
405: }
406: //picked one of the piecewise name fields, reset the all in
407: //one field to blank
408: if ((tf>=2) && (tf<=5) && (nw!=0)) {
409: eval('vf.f1.selectedIndex=0;')
410: }
411: // intial password specified, pick internal authentication
412: if (tf==8 && nw!=0) {
1.28 matthew 413: changed_radio('int',document.studentform);
414: set_auth_radio_buttons('int',document.studentform);
415: vf.krbarg.value='';
416: vf.intarg.value='';
1.24 albertel 417: vf.locarg.value='';
418: }
419: }
420:
421: function clearpwd(vf) {
422: var i;
423: if (eval('vf.f8.selectedIndex')!=0) {
424: eval('vf.f8.selectedIndex=0;')
425: }
426: }
1.2 www 427: ENDPICK
1.23 albertel 428: }
1.10 www 429:
1.23 albertel 430: sub phase_two_end {
431: my ($r,$i,$keyfields,$defdom,$today,$halfyear)=@_;
1.28 matthew 432: my %param = ( formname => 'document.studentform');
433: my $krbform = &Apache::loncommon::authform_kerberos(%param);
434: my $intform = &Apache::loncommon::authform_internal(%param);
435: my $locform = &Apache::loncommon::authform_local(%param);
1.31 matthew 436: my $domform = &domain_form($defdom);
1.23 albertel 437: $r->print(<<ENDPICK);
1.3 www 438: </table>
1.10 www 439: <input type=hidden name=nfields value=$i>
440: <input type=hidden name=keyfields value="$keyfields">
1.3 www 441: <h3>Login Type</h3>
1.15 albertel 442: <p>Note: this will not take effect if the user already exists</p>
443: <p>
1.28 matthew 444: $krbform
1.15 albertel 445: </p>
446: <p>
1.28 matthew 447: $intform
1.15 albertel 448: </p>
449: <p>
1.28 matthew 450: $locform
1.15 albertel 451: </p>
1.5 www 452: <h3>LON-CAPA Domain for Students</h3>
1.29 matthew 453: LON-CAPA domain: $domform <p>
1.5 www 454: <h3>Starting and Ending Dates</h3>
1.26 matthew 455: <input type="hidden" value='' name="pres_value" >
456: <input type="hidden" value='' name="pres_type" >
457: <input type="hidden" value='' name="pres_marker" >
458: <input type="hidden" value='$today' name="startdate" >
459: <input type="hidden" value='$halfyear' name="enddate" >
1.4 www 460: <a
461: href="javascript:pjump('date_start','Enrollment Starting Date',document.studentform.startdate.value,'start','studentform.pres','dateset');"
462: >Set Starting Date</a><p>
463:
464: <a
465: href="javascript:pjump('date_end','Enrollment Ending Date',document.studentform.enddate.value,'end','studentform.pres','dateset');"
466: >Set Ending Date</a><p>
1.5 www 467: <h3>Full Update</h3>
468: <input type=checkbox name=fullup value=yes> Full update
1.11 www 469: (also print list of users not enrolled anymore)<p>
1.18 www 470: <h3>ID/Student Number</h3>
471: <input type=checkbox name=forceid value=yes>
472: Disable ID/Student Number Safeguard and Force Change of Conflicting IDs
1.19 www 473: (only do if you know what you are doing)<p>
1.36 albertel 474: <input type="button" onClick="javascript:verify(this.form)" value="Update Courselist" /><br />
1.6 www 475: Note: for large courses, this operation might be time consuming.
1.3 www 476: ENDPICK
1.23 albertel 477: }
1.24 albertel 478:
1.23 albertel 479: # ======================================================= Menu Phase Two Upload
480: sub menu_phase_two_upload {
481: my $r=shift;
1.26 matthew 482:
1.24 albertel 483: my $datatoken;
484: if (!$ENV{'form.datatoken'}) {
1.26 matthew 485: $datatoken=&Apache::loncommon::upfile_store($r);
1.24 albertel 486: } else {
1.26 matthew 487: $datatoken=$ENV{'form.datatoken'};
488: &Apache::loncommon::load_tmp_file($r);
1.24 albertel 489: }
490: my @records=&Apache::loncommon::upfile_record_sep();
1.23 albertel 491: my $total=$#records;
492: my $distotal=$total+1;
493: $ENV{'SERVER_NAME'}=~/(\w+\.\w+)$/;
494: my $krbdefdom=$1;
495: $krbdefdom=~tr/a-z/A-Z/;
496: my $today=time;
497: my $halfyear=$today+15552000;
498: my $defdom=$r->dir_config('lonDefDomain');
499: &phase_two_header($r,$datatoken,$distotal,$krbdefdom);
1.24 albertel 500: my $i;
501: my $keyfields;
1.23 albertel 502: if ($total>=0) {
1.24 albertel 503: my @d=(['username','Username'],['names','Last Name, First Names'],
504: ['fname','First Name'],['mname','Middle Names/Initials'],
505: ['lname','Last Name'],['gen','Generation'],
506: ['id','ID/Student Number'],['sec','Group/Section'],
507: ['ipwd','Initial Password']);
508: if ($ENV{'form.upfile_associate'} eq 'reverse') {
509: &Apache::loncommon::csv_print_samples($r,\@records);
510: $i=&Apache::loncommon::csv_print_select_table($r,\@records,\@d);
511: foreach (@d) { $keyfields.=$_->[0].','; }
512: chop($keyfields);
513: } else {
514: unshift(@d,['none','']);
515: $i=&Apache::loncommon::csv_samples_select_table($r,\@records,\@d);
516: my %sone=&Apache::loncommon::record_sep($records[0]);
517: $keyfields=join(',',sort(keys(%sone)));
1.23 albertel 518: }
519: }
520: &phase_two_end($r,$i,$keyfields,$defdom,$today,$halfyear);
1.10 www 521: }
522:
1.12 www 523: # ======================================================= Enroll single student
524: sub enroll_single_student {
525: my $r=shift;
526: $r->print('<h3>Enrolling Student</h3>');
1.34 matthew 527: $r->print('<p>Enrolling '.$ENV{'form.cuname'}." in domain ".
528: $ENV{'form.lcdomain'}.'</p>');
1.12 www 529: if (($ENV{'form.cuname'})&&($ENV{'form.cuname'}!~/\W/)&&
1.31 matthew 530: ($ENV{'form.lcdomain'})&&($ENV{'form.lcdomain'}!~/\W/)) {
531: # Deal with home server selection
532: my $domain=$ENV{'form.lcdomain'};
533: my $desiredhost = $ENV{'form.lcserver'};
534: if (lc($desiredhost) eq 'default') {
535: $desiredhost = undef;
536: } else {
1.45 matthew 537: my %home_servers =&Apache::loncommon::get_library_servers($domain);
1.31 matthew 538: if (! exists($home_servers{$desiredhost})) {
539: $r->print('<font color="#ff0000">Error:</font>'.
540: 'Invalid home server specified');
541: return;
542: }
543: }
1.34 matthew 544: $r->print(" with server $desiredhost :") if (defined($desiredhost));
1.31 matthew 545: # End of home server selection logic
1.12 www 546: my $amode='';
547: my $genpwd='';
548: if ($ENV{'form.login'} eq 'krb') {
1.47 ! albertel 549: $amode='krb';
! 550: $amode.=$ENV{'form.krbver'};
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 {
1.45 matthew 921: my %home_servers = &Apache::loncommon::get_library_servers($domain);
1.31 matthew 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') {
1.47 ! albertel 932: $amode='krb';
! 933: $amode.=$ENV{'form.krbver'};
1.28 matthew 934: $genpwd=$ENV{'form.krbarg'};
1.25 matthew 935: } elsif ($ENV{'form.login'} eq 'int') {
936: $amode='internal';
1.28 matthew 937: if ((defined($ENV{'form.intarg'})) && ($ENV{'form.intarg'})) {
938: $genpwd=$ENV{'form.intarg'};
1.25 matthew 939: }
940: } elsif ($ENV{'form.login'} eq 'loc') {
941: $amode='localauth';
942: if ((defined($ENV{'form.locarg'})) && ($ENV{'form.locarg'})) {
943: $genpwd=$ENV{'form.locarg'};
944: }
945: }
946: unless (($domain=~/\W/) || ($amode eq '')) {
1.26 matthew 947: #######################################
948: ## Enroll Students ##
949: #######################################
1.25 matthew 950: $r->print('<h3>Enrolling Students</h3>');
951: my $count=0;
952: my $flushc=0;
953: my %student=();
1.26 matthew 954: # Get new classlist
1.25 matthew 955: foreach (@studentdata) {
956: my %entries=&Apache::loncommon::record_sep($_);
1.26 matthew 957: # Determine student name
1.25 matthew 958: unless (($entries{$fields{'username'}} eq '') ||
959: (!defined($entries{$fields{'username'}}))) {
1.26 matthew 960: my ($fname, $mname, $lname,$gen) = ('','','','');
1.25 matthew 961: if (defined($fields{'names'})) {
1.26 matthew 962: ($lname,$fname,$mname)=($entries{$fields{'names'}}=~
963: /([^\,]+)\,\s*(\w+)\s*(.*)$/);
1.25 matthew 964: } else {
965: if (defined($fields{'fname'})) {
966: $fname=$entries{$fields{'fname'}};
967: }
968: if (defined($fields{'mname'})) {
969: $mname=$entries{$fields{'mname'}};
970: }
971: if (defined($fields{'lname'})) {
972: $lname=$entries{$fields{'lname'}};
973: }
974: if (defined($fields{'gen'})) {
975: $gen=$entries{$fields{'gen'}};
976: }
977: }
978: if ($entries{$fields{'username'}}=~/\W/) {
979: $r->print('<p><b>Unacceptable username: '.
1.10 www 980: $entries{$fields{'username'}}.' for user '.
1.4 www 981: $fname.' '.$mname.' '.$lname.' '.$gen.'</b><p>');
1.25 matthew 982: } else {
1.26 matthew 983: # determine section number
1.25 matthew 984: my $sec='';
985: my $username=$entries{$fields{'username'}};
986: if (defined($fields{'sec'})) {
987: if (defined($entries{$fields{'sec'}})) {
988: $sec=$entries{$fields{'sec'}};
989: }
990: }
1.26 matthew 991: # determine student id number
1.25 matthew 992: my $id='';
993: if (defined($fields{'id'})) {
994: if (defined($entries{$fields{'id'}})) {
995: $id=$entries{$fields{'id'}};
996: }
997: $id=~tr/A-Z/a-z/;
998: }
1.26 matthew 999: # determine student password
1.25 matthew 1000: my $password='';
1001: if ($genpwd) {
1002: $password=$genpwd;
1003: } else {
1004: if (defined($fields{'ipwd'})) {
1005: if ($entries{$fields{'ipwd'}}) {
1006: $password=$entries{$fields{'ipwd'}};
1007: }
1008: }
1009: }
1010: if ($password) {
1.33 matthew 1011: &modifystudent($domain,$username,$cid,$sec,
1012: $desiredhost);
1.25 matthew 1013: my $reply=&Apache::lonnet::modifystudent
1014: ($domain,$username,$id,$amode,$password,
1015: $fname,$mname,$lname,$gen,$sec,$enddate,
1.31 matthew 1016: $startdate,$ENV{'form.forceid'},$desiredhost);
1.26 matthew 1017: if ($reply ne 'ok') {
1018: $r->print('<p><b>'.
1019: 'Error enrolling '.$username.': '.
1020: $reply.'</b></p>');
1.10 www 1021: } else {
1.7 www 1022: $count++; $flushc++;
1023: $student{$username}=1;
1.6 www 1024: $r->print('. ');
1.7 www 1025: if ($flushc>15) {
1026: $r->rflush;
1027: $flushc=0;
1028: }
1.6 www 1029: }
1.25 matthew 1030: } else {
1031: $r->print("<p><b>No password for $username</b><p>");
1032: }
1033: }
1.26 matthew 1034: }
1035: } # end of foreach (@studentdata)
1.25 matthew 1036: $r->print('<p>Processed Students: '.$count);
1.26 matthew 1037: #####################################
1038: # Drop students #
1039: #####################################
1.25 matthew 1040: if ($ENV{'form.fullup'} eq 'yes') {
1041: $r->print('<h3>Dropping Students</h3>');
1.26 matthew 1042: # Get current classlist
1.27 matthew 1043: my ($error,%currentlist)=&get_current_classlist
1.26 matthew 1044: ($ENV{'course.'.$cid.'.domain'},
1045: $ENV{'course.'.$cid.'.num'});
1.27 matthew 1046: if (defined($error)) {
1047: $r->print('<pre>ERROR:$error</pre>');
1048: }
1.26 matthew 1049: if (defined(%currentlist)) {
1050: # Drop the students
1.25 matthew 1051: foreach (@studentdata) {
1052: my %entries=&Apache::loncommon::record_sep($_);
1053: unless (($entries{$fields{'username'}} eq '') ||
1054: (!defined($entries{$fields{'username'}}))) {
1.26 matthew 1055: delete($currentlist{$entries{$fields{'username'}}.
1056: ':'.$domain});
1.25 matthew 1057: }
1058: }
1.26 matthew 1059: # Print out list of dropped students
1.25 matthew 1060: &show_drop_list($r,%currentlist);
1061: } else {
1.27 matthew 1062: $r->print("There are no students currently enrolled.\n");
1.25 matthew 1063: }
1064: }
1.26 matthew 1065: } # end of unless
1.10 www 1066: }
1067:
1.11 www 1068: # ================================================================== Phase four
1069: sub drop_student_list {
1070: my $r=shift;
1071: my $count=0;
1.35 matthew 1072: my @droplist;
1073: if (ref($ENV{'form.droplist'})) {
1074: @droplist = @{$ENV{'form.droplist'}};
1075: } else {
1076: @droplist = ($ENV{'form.droplist'});
1077: }
1078: foreach (@droplist) {
1.26 matthew 1079: my ($uname,$udom)=split(/\:/,$_);
1.35 matthew 1080: my $result = &modifystudent($udom,$uname,$ENV{'request.course.id'});
1.37 matthew 1081: if ($result eq 'ok' || $result eq 'ok:') {
1.35 matthew 1082: $r->print('Dropped '.$uname.' at '.$udom.'<br>');
1083: } else {
1084: $r->print('Error dropping '.$uname.' at '.$udom.': '.$result.
1085: '<br />');
1086: }
1.26 matthew 1087: $count++;
1.20 harris41 1088: }
1.11 www 1089: $r->print('<p><b>Dropped '.$count.' student(s).</b>');
1090: $r->print('<p>Re-enrollment will re-activate data.');
1091: }
1092:
1.10 www 1093: # ================================================================ Main Handler
1094: sub handler {
1.26 matthew 1095: my $r=shift;
1096: if ($r->header_only) {
1097: $r->content_type('text/html');
1098: $r->send_http_header;
1099: return OK;
1100: }
1101: # Needs to be in a course
1102: if (($ENV{'request.course.fn'}) &&
1103: (&Apache::lonnet::allowed('cst',$ENV{'request.course.id'}))) {
1104: # Start page
1.41 matthew 1105: $r->content_type('text/html') if (! exists($ENV{'form.viewcsv'}));
1.26 matthew 1106: $r->send_http_header;
1.41 matthew 1107: $r->print(&header()) if (! exists($ENV{'form.viewcsv'}));
1.26 matthew 1108: # Phase one, initial screen
1109: unless ($ENV{'form.phase'}) {
1110: &menu_phase_one($r);
1111: }
1112: # Phase two
1113: if ($ENV{'form.associate'} eq 'Reverse Association') {
1114: $ENV{'form.phase'} = 'two';
1115: if ( $ENV{'form.upfile_associate'} ne 'reverse' ) {
1116: $ENV{'form.upfile_associate'} = 'reverse';
1117: } else {
1118: $ENV{'form.upfile_associate'} = 'forward';
1119: }
1120: }
1121: if ($ENV{'form.phase'} eq 'two') {
1122: if ($ENV{'form.fileupload'}) {
1123: &menu_phase_two_upload($r);
1124: } elsif ($ENV{'form.enroll'}) {
1125: &menu_phase_two_enroll($r);
1126: } elsif ($ENV{'form.drop'}) {
1127: &menu_phase_two_drop($r);
1.40 matthew 1128: } elsif ($ENV{'form.view'}) {
1129: &menu_phase_two_view($r);
1.41 matthew 1130: } elsif ($ENV{'form.viewcsv'}) {
1131: &menu_phase_two_viewcsv($r);
1.26 matthew 1132: }
1133: }
1134: # Phase three
1135: if ($ENV{'form.phase'} eq 'three') {
1136: if ($ENV{'form.datatoken'}) {
1137: &upfile_drop_add($r);
1138: }
1139: }
1140: # Phase four
1141: if ($ENV{'form.phase'} eq 'four') {
1142: &drop_student_list($r);
1143: }
1144: # Phase five
1145: if ($ENV{'form.phase'} eq 'five') {
1146: &enroll_single_student($r);
1147: }
1148: # End
1.41 matthew 1149: $r->print('</form></body></html>') if (! exists($ENV{'form.viewcsv'}));
1.26 matthew 1150: } else {
1151: # Not in a course, or not allowed to modify parms
1152: $ENV{'user.error.msg'}=
1153: "/adm/dropadd:cst:0:0:Cannot drop or add students";
1154: return HTTP_NOT_ACCEPTABLE;
1155: }
1156: return OK;
1.1 www 1157: }
1158:
1159: 1;
1160: __END__
1161:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>