Annotation of loncom/interface/londropadd.pm, revision 1.10
1.1 www 1: # The LearningOnline Network with CAPA
2: # Handler to drop and add students in courses
3: #
4: # (Handler to set parameters for assessments
5: #
6: # (Handler to resolve ambiguous file locations
7: #
8: # (TeX Content Handler
9: #
10: # 05/29/00,05/30,10/11 Gerd Kortemeyer)
11: #
12: # 10/11,10/12,10/16 Gerd Kortemeyer)
13: #
14: # 11/20,11/21,11/22,11/23,11/24,11/25,11/27,11/28,
15: # 12/08,12/12 Gerd Kortemeyer)
16: #
1.7 www 17: # 12/26,12/27,12/28,
1.10 ! www 18: # 01/01/01,01/15,02/10,02/13 Gerd Kortemeyer
1.1 www 19:
20: package Apache::londropadd;
21:
22: use strict;
23: use Apache::lonnet;
24: use Apache::Constants qw(:common :http REDIRECT);
25:
1.10 ! www 26: # ================================================================ Print header
1.1 www 27:
1.10 ! www 28: sub header {
! 29: my $r=shift;
! 30: $r->print(<<ENDHEAD);
1.1 www 31: <html>
32: <head>
33: <title>LON-CAPA Student Drop/Add</title>
34: </head>
35: <body bgcolor="#FFFFFF">
36: <img align=right src=/adm/lonIcons/lonlogos.gif>
37: <h1>Drop/Add Students</h1>
38: <form method="post" enctype="multipart/form-data"
39: action="/adm/dropadd" name="studentform">
40: <h2>Course: $ENV{'course.'.$ENV{'request.course.id'}.'.description'}</h2>
41: ENDHEAD
1.10 ! www 42: }
! 43:
! 44: # ========================================================= Store uploaded file
! 45: # needs $ENV{'form.upfile'}
! 46: # return $datatoken to be put into hidden field
! 47:
! 48: sub upfile_store {
! 49: my $r=shift;
! 50: $ENV{'form.upfile'}=~s/\r/\n/gs;
! 51: $ENV{'form.upfile'}=~s/\f/\n/gs;
! 52: $ENV{'form.upfile'}=~s/\n+/\n/gs;
! 53: $ENV{'form.upfile'}=~s/\n+$//gs;
! 54:
! 55: my $datatoken=$ENV{'user.name'}.'_'.$ENV{'user.domain'}.
! 56: '_enroll_'.$ENV{'request.course.id'}.'_'.time.'_'.$$;
! 57: {
! 58: my $fh=Apache::File->new('>'.$r->dir_config('lonDaemons').
! 59: '/tmp/'.$datatoken.'.tmp');
! 60: print $fh $ENV{'form.upfile'};
! 61: }
! 62: return $datatoken;
! 63: }
! 64:
! 65: # ================================================= Load uploaded file from tmp
! 66: # needs $ENV{'form.datatoken'}
! 67: # sets $ENV{'form.upfile'}
! 68:
! 69: sub load_tmp_file {
! 70: my $r=shift;
! 71: my @studentdata=();
! 72: {
! 73: my $fh;
! 74: if ($fh=Apache::File->new($r->dir_config('lonDaemons').
! 75: '/tmp/'.$ENV{'form.datatoken'}.'.tmp')) {
! 76: @studentdata=<$fh>;
! 77: }
! 78: }
! 79: $ENV{'form.upfile'}=join('',@studentdata);
! 80: }
! 81:
! 82: # ========================================= Separate uploaded file into records
! 83: # returns array of records
! 84:
! 85: sub upfile_record_sep {
! 86: if ($ENV{'form.upfiletype'} eq 'xml') {
! 87: } else {
! 88: return split(/\n/,$ENV{'form.upfile'});
! 89: }
! 90: }
! 91:
! 92: # =============================================== Separate a record into fields
! 93:
! 94: sub record_sep {
! 95: my $record=shift;
! 96: my %components=();
! 97: if ($ENV{'form.upfiletype'} eq 'xml') {
! 98: } elsif ($ENV{'form.upfiletype'} eq 'space') {
! 99: my $i=0;
! 100: map {
! 101: my $field=$_;
! 102: $field=~s/^(\"|\')//;
! 103: $field=~s/(\"|\')$//;
! 104: $components{$i}=$field;
! 105: $i++;
! 106: } split(/\s+/,$record);
! 107: } elsif ($ENV{'form.upfiletype'} eq 'tab') {
! 108: my $i=0;
! 109: map {
! 110: my $field=$_;
! 111: $field=~s/^(\"|\')//;
! 112: $field=~s/(\"|\')$//;
! 113: $components{$i}=$field;
! 114: $i++;
! 115: } split(/\t+/,$record);
! 116: } else {
! 117: my @allfields=split(/\,/,$record);
! 118: my $i=0;
! 119: my $j;
! 120: for ($j=0;$j<=$#allfields;$j++) {
! 121: my $field=$allfields[$j];
! 122: if ($field=~/^\s*(\"|\')/) {
! 123: my $delimiter=$1;
! 124: while (($field!~/$delimiter$/) && ($j<$#allfields)) {
! 125: $j++;
! 126: $field.=','.$allfields[$j];
! 127: }
! 128: $field=~s/^\s*$delimiter//;
! 129: $field=~s/$delimiter\s*$//;
! 130: }
! 131: $components{$i}=$field;
! 132: $i++;
! 133: }
! 134: }
! 135: return %components;
! 136: }
! 137:
! 138: # =========== Drop student from all sections of a course, except optional $csec
! 139:
! 140: sub dropstudent {
! 141: my ($udom,$unam,$courseid,$csec)=@_;
! 142: $courseid=~s/\_/\//g;
! 143: $courseid=~s/^(\w)/\/$1/;
! 144: map {
! 145: my ($key,$value)=split(/\=/,$_);
! 146: $key=&Apache::lonnet::unescape($key);
! 147: if ($key=~/^$courseid(?:\/)*(\w+)*\_st$/) {
! 148: my $section=$1;
! 149: if ($key eq $courseid.'_st') { $section=''; }
! 150: if ($section ne $csec) {
! 151: my ($dummy,$end,$start)=split(/\_/,
! 152: &Apache::lonnet::unescape($value));
! 153: my $now=time;
! 154: my $notactive=0;
! 155: if ($start) {
! 156: if ($now<$start) { $notactive=1; }
! 157: }
! 158: if ($end) {
! 159: if ($now>$end) { $notactive=1; }
! 160: }
! 161: unless ($notactive) {
! 162: my $reply=&Apache::lonnet::modifystudent(
! 163: $udom,$unam,'','','',
! 164: '','','','',$section,time);
! 165: }
! 166: }
! 167: }
! 168: } split(/\&/,&Apache::lonnet::reply('dump:'.$udom.':'.$unam.':roles',
! 169: &Apache::lonnet::homeserver($unam,$udom)));
! 170: }
! 171:
! 172: # ============================================================== Menu Phase One
! 173:
! 174: sub menu_phase_one {
! 175: my $r=shift;
! 176: $r->print(<<ENDUPFORM);
1.2 www 177: <input type=hidden name=phase value=two>
178: <hr>
179: <h3>Upload a courselist</h3>
180: <input type=file name=upfile size=50>
181: <br>Type: <select name=upfiletype>
182: <option value=csv>CSV (comma separated values, spreadsheet)</option>
183: <option value=space>Space separated</option>
184: <option value=tab>Tabulator separated</option>
185: <option value=xml>HTML/XML</option>
186: </select>
187: <p><input type=submit name=fileupload value="Upload Courselist">
188: <hr>
189: <h3>Enroll a single student</h3>
190: <p><input type=submit name=enroll value="Enroll Student">
191: <hr>
192: <h3>Drop a student</h3>
193: <p><input type=submit name=drop value="Drop Student">
194: ENDUPFORM
1.10 ! www 195: }
! 196:
! 197: # ======================================================= Menu Phase Two Upload
! 198:
! 199: sub menu_phase_two_upload {
! 200: my $r=shift;
! 201:
! 202: my $datatoken=&upfile_store($r);
! 203:
! 204: my @records=&upfile_record_sep();
! 205: my $total=$#records;
! 206: my $distotal=$total+1;
! 207:
! 208: $ENV{'SERVER_NAME'}=~/(\w+\.\w+)$/;
! 209: my $krbdefdom=$1;
! 210: $krbdefdom=~tr/a-z/A-Z/;
! 211:
! 212: my $today=time;
! 213: my $halfyear=$today+15552000;
! 214:
! 215: my $defdom=$r->dir_config('lonDefDomain');
! 216:
! 217: $r->print(<<ENDPICK);
1.2 www 218: <input type=hidden name=phase value=three>
219: <input type=hidden name=datatoken value="$datatoken">
220: <input type=hidden name=upfiletype value=$ENV{'form.upfiletype'}>
221: <hr>
222: <h3>Identify fields</h3>
1.10 ! www 223: Total number of records found in file: $distotal
1.3 www 224: <script>
225: function verify(vf) {
226: var founduname=0;
227: var foundpwd=0;
228: var foundname=0;
229: var foundid=0;
230: var foundsec=0;
231: var foundatype=0;
232: var tw;
233: var message='';
234: for (i=0;i<=vf.nfields.value;i++) {
235: tw=eval('vf.f'+i+'.selectedIndex');
236: if (tw==1) { founduname=1; }
237: if ((tw>=2) && (tw<=6)) { foundname=1; }
238: if (tw==7) { foundid=1; }
239: if (tw==8) { foundsec=1; }
240: if (tw==9) { foundpwd=1; }
241: }
242: if (founduname==0) {
243: alert('You need to specify at least the username field');
244: return;
245: }
246: if (vf.login[0].checked) {
247: foundatype=1;
248: if (vf.krbdom.value=='') {
249: alert('You need to specify the Kerberos domain');
250: return;
251: }
252: }
253: if (vf.login[1].checked) {
254: foundatype=1;
255: if ((vf.intpwd.value=='') && (foundpwd==0)) {
256: alert('You need to specify the initial password');
257: return;
258: }
259: }
260: if (foundatype==0) {
261: alert('You need to set the login type');
262: return;
263: }
264: if (foundname==0) { message='No name fields specified. '; }
265: if (foundid==0) { message+='No ID or student number field specified. '; }
266: if (foundsec==0) { message+='No section or group field specified. '; }
1.4 www 267: if (vf.startdate.value=='') {
268: message+='No starting date set. ';
1.3 www 269: }
1.4 www 270: if (vf.enddate.value=='') {
271: message+='No ending date set. ';
272: }
273: if ((vf.enddate.value!='') && (vf.startdate.value!='')) {
1.10 ! www 274: if (Math.round(vf.enddate.value)<Math.round(vf.startdate.value)) {
1.4 www 275: alert('Ending date is before starting date');
276: return;
277: }
278: }
279: if (message!='') {
280: message+='Continue enrollment?';
281: if (confirm(message)) {
282: pclose();
283: vf.submit();
284: }
285: } else {
286: pclose();
287: vf.submit();
288: }
1.3 www 289: }
290:
291: function flip(vf,tf) {
292: var nw=eval('vf.f'+tf+'.selectedIndex');
293: var i;
294: for (i=0;i<=vf.nfields.value;i++) {
295: if ((i!=tf) && (eval('vf.f'+i+'.selectedIndex')==nw)) {
296: eval('vf.f'+i+'.selectedIndex=0;')
297: }
298: }
299: if (nw==2) {
300: for (i=0;i<=vf.nfields.value;i++) {
301: if ((eval('vf.f'+i+'.selectedIndex')>=3) &&
302: (eval('vf.f'+i+'.selectedIndex')<=6)) {
303: eval('vf.f'+i+'.selectedIndex=0;')
304: }
305: }
306: }
307: if ((nw>=3) && (nw<=6)) {
308: for (i=0;i<=vf.nfields.value;i++) {
309: if (eval('vf.f'+i+'.selectedIndex')==2) {
310: eval('vf.f'+i+'.selectedIndex=0;')
311: }
312: }
313: }
314: if (nw==9) {
315: vf.login[1].checked=true;
316: vf.intpwd.value='';
317: vf.krbdom.value='';
318: }
319:
320: }
321:
322: function clearpwd(vf) {
323: var i;
324: for (i=0;i<=vf.nfields.value;i++) {
325: if (eval('vf.f'+i+'.selectedIndex')==9) {
326: eval('vf.f'+i+'.selectedIndex=0;')
327: }
328: }
329: }
330:
331: function setkrb(vf) {
332: if (vf.krbdom.value!='') {
333: clearpwd(vf);
334: vf.login[0].checked=true;
335: vf.krbdom.value=vf.krbdom.value.toUpperCase();
336: vf.intpwd.value='';
337: }
338: }
339:
340: function setint(vf) {
341: if (vf.intpwd.value!='') {
342: clearpwd(vf);
343: vf.login[1].checked=true;
344: vf.krbdom.value='';
345: }
346: }
347:
348: function clickkrb(vf) {
349: vf.krbdom.value='$krbdefdom';
350: clearpwd(vf);
351: vf.intpwd.value='';
352: }
353:
354: function clickint(vf) {
355: vf.krbdom.value='';
356: }
357:
1.4 www 358: function pclose() {
359: parmwin=window.open("/adm/rat/empty.html","LONCAPAparms",
360: "height=350,width=350,scrollbars=no,menubar=no");
361: parmwin.close();
362: }
363:
364: function pjump(type,dis,value,marker,ret,call) {
365: parmwin=window.open("/adm/rat/parameter.html?type="+escape(type)
366: +"&value="+escape(value)+"&marker="+escape(marker)
367: +"&return="+escape(ret)
368: +"&call="+escape(call)+"&name="+escape(dis),"LONCAPAparms",
369: "height=350,width=350,scrollbars=no,menubar=no");
370:
371: }
372:
373: function dateset() {
374: if (document.studentform.pres_marker.value=='end') {
375: document.studentform.enddate.value=
376: document.studentform.pres_value.value;
377: }
378: if (document.studentform.pres_marker.value=='start') {
379: document.studentform.startdate.value=
380: document.studentform.pres_value.value;
381: }
382: pclose();
383: }
1.3 www 384:
385: </script>
1.2 www 386: <table border=2><tr><th>Field</th><th>Samples</th></tr>
387: ENDPICK
1.10 ! www 388: my %sone; my %stwo; my %sthree;
! 389: my $i=0;
! 390:
! 391: if ($total>=0) {
! 392: %sone=&record_sep($records[0]);
! 393: if ($total>=1) {
! 394: %stwo=&record_sep($records[1]);
! 395:
1.2 www 396: }
1.10 ! www 397: if ($total>=2) {
! 398: %sthree=&record_sep($records[2]);
1.2 www 399: }
1.10 ! www 400: map {
1.3 www 401: $r->print('<tr><td><select name=f'.$i.
402: ' onChange="flip(this.form,'.$i.');">');
1.2 www 403: map {
404: my ($value,$display)=split(/\:/,$_);
405: $r->print('<option value='.$value.'>'.$display.
406: '</option>');
407: } ('none: ','username:Username',
408: 'names:Last Name, First Names',
409: 'fname:First Name','mname:Middle Names/Initials',
410: 'lname:Last Name','gen:Generation',
1.3 www 411: 'id:ID/Student Number','sec:Group/Section',
412: 'ipwd:Initial Password');
1.2 www 413: $r->print('</select></td><td>');
1.10 ! www 414: if (defined($sone{$i})) {
! 415: $r->print($sone{$i}."</br>\n");
1.2 www 416: }
1.10 ! www 417: if (defined($stwo{$i})) {
! 418: $r->print($stwo{$i}."</br>\n");
1.2 www 419: }
1.10 ! www 420: if (defined($sthree{$i})) {
! 421: $r->print($sthree{$i}."</br>\n");
1.2 www 422: }
423: $r->print('</td></tr>');
1.10 ! www 424: $i++;
! 425: } sort keys %sone;
! 426: $i--;
1.2 www 427: }
1.10 ! www 428: my $keyfields=join(',',sort keys %sone);
1.3 www 429: $r->print(<<ENDPICK);
430: </table>
1.10 ! www 431: <input type=hidden name=nfields value=$i>
! 432: <input type=hidden name=keyfields value="$keyfields">
1.3 www 433: <h3>Login Type</h3>
434: <input type=radio name=login value=krb onClick="clickkrb(this.form);">
435: Kerberos authenticated with domain
436: <input type=text size=10 name=krbdom onChange="setkrb(this.form);"><p>
437: <input type=radio name=login value=int onClick="clickint(this.form);">
438: Internally authenticated (with initial password
1.5 www 439: <input type=text size=10 name=intpwd onChange="setint(this.form);">)
440: <h3>LON-CAPA Domain for Students</h3>
1.4 www 441: LON-CAPA domain: <input type=text size=10 value=$defdom name=lcdomain><p>
1.5 www 442: <h3>Starting and Ending Dates</h3>
1.4 www 443: <input type="hidden" value='' name="pres_value">
444: <input type="hidden" value='' name="pres_type">
445: <input type="hidden" value='' name="pres_marker">
446: <input type="hidden" value='$today' name=startdate>
447: <input type="hidden" value='$halfyear' name=enddate>
448: <a
449: href="javascript:pjump('date_start','Enrollment Starting Date',document.studentform.startdate.value,'start','studentform.pres','dateset');"
450: >Set Starting Date</a><p>
451:
452: <a
453: href="javascript:pjump('date_end','Enrollment Ending Date',document.studentform.enddate.value,'end','studentform.pres','dateset');"
454: >Set Ending Date</a><p>
1.5 www 455: <h3>Full Update</h3>
456: <input type=checkbox name=fullup value=yes> Full update
457: (also dropping students)<p>
1.6 www 458: <input type=button onClick="verify(this.form)" value="Update Courselist"><br>
459: Note: for large courses, this operation might be time consuming.
1.3 www 460: ENDPICK
1.10 ! www 461: }
! 462:
! 463: # ======================================================= Menu Phase Two Enroll
! 464:
! 465: sub menu_phase_two_enroll {
! 466: my $r=shift;
! 467: }
! 468:
! 469: # ========================================================= Menu Phase Two Drop
! 470:
! 471: sub menu_phase_two_drop {
! 472: my $r=shift;
! 473: }
! 474:
! 475: # ================================================= Drop/Add from uploaded file
! 476:
! 477: sub upfile_drop_add {
! 478: my $r=shift;
! 479: $r->print('<input type=hidden name=phase value=four>');
! 480:
! 481: &load_tmp_file($r);
! 482: my @studentdata=&upfile_record_sep();
! 483:
! 484: my @keyfields=split(/\,/,$ENV{'form.keyfields'});
! 485: my $cid=$ENV{'request.course.id'};
! 486:
1.4 www 487: my %fields=();
488: for (my $i=0;$i<=$ENV{'form.nfields'};$i++) {
1.10 ! www 489: $fields{$ENV{'form.f'.$i}}=$keyfields[$i];
1.4 www 490: }
491: my $startdate=$ENV{'form.startdate'};
492: my $enddate=$ENV{'form.enddate'};
493: if ($startdate=~/\D/) { $startdate=''; }
494: if ($enddate=~/\D/) { $enddate=''; }
1.5 www 495: my $domain=$ENV{'form.lcdomain'};
496: my $amode='';
497: my $genpwd='';
498: if ($ENV{'form.login'} eq 'krb') {
499: $amode='krb4';
500: $genpwd=$ENV{'form.krbdom'};
501: } elsif ($ENV{'form.login'} eq 'int') {
502: $amode='internal';
503: if ((defined($ENV{'form.intpwd'})) && ($ENV{'form.intpwd'})) {
504: $genpwd=$ENV{'form.intpwd'};
505: }
506: }
507: unless (($domain=~/\W/) || ($amode eq '')) {
508: $r->print('<h3>Enrolling Students</h3>');
1.7 www 509: my $count=0;
510: my $flushc=0;
511: my %student=();
1.5 www 512: # ----------------------------------------------------------- Get new classlist
513: # --------------------------------------------------------- Enroll new students
1.2 www 514: map {
1.10 ! www 515: my %entries=&record_sep($_);
! 516:
! 517: unless (($entries{$fields{'username'}} eq '') ||
! 518: (!defined($entries{$fields{'username'}}))) {
1.4 www 519: my $fname=''; my $mname=''; my $lname=''; my $gen='';
520: if (defined($fields{'names'})) {
521: ($lname,$fname,$mname)=
1.10 ! www 522: ($entries{$fields{'names'}}=~/([^\,]+)\,\s*(\w+)\s*(.*)$/);
1.4 www 523: } else {
524: if (defined($fields{'fname'})) {
1.10 ! www 525: $fname=$entries{$fields{'fname'}};
1.4 www 526: }
527: if (defined($fields{'mname'})) {
1.10 ! www 528: $mname=$entries{$fields{'mname'}};
1.4 www 529: }
530: if (defined($fields{'lname'})) {
1.10 ! www 531: $lname=$entries{$fields{'lname'}};
1.4 www 532: }
533: if (defined($fields{'gen'})) {
1.10 ! www 534: $gen=$entries{$fields{'gen'}};
1.4 www 535: }
536: }
1.10 ! www 537: if ($entries{$fields{'username'}}=~/\W/) {
1.4 www 538: $r->print('<p><b>Unacceptable username: '.
1.10 ! www 539: $entries{$fields{'username'}}.' for user '.
1.4 www 540: $fname.' '.$mname.' '.$lname.' '.$gen.'</b><p>');
1.5 www 541: } else {
542: my $sec='';
1.10 ! www 543: my $username=$entries{$fields{'username'}};
1.5 www 544: if (defined($fields{'sec'})) {
1.10 ! www 545: if (defined($entries{$fields{'sec'}})) {
! 546: $sec=$entries{$fields{'sec'}};
1.5 www 547: }
548: }
549: my $id='';
550: if (defined($fields{'id'})) {
1.10 ! www 551: if (defined($entries{$fields{'id'}})) {
! 552: $id=$entries{$fields{'id'}};
1.5 www 553: }
554: $id=~tr/A-Z/a-z/;
555: }
556: my $password='';
557: if ($genpwd) {
558: $password=$genpwd;
559: } else {
560: if (defined($fields{'ipwd'})) {
1.10 ! www 561: if ($entries{$fields{'ipwd'}}) {
! 562: $password=$entries{$fields{'ipwd'}};
1.5 www 563: }
564: }
565: }
1.10 ! www 566: if ($password) {
! 567: &dropstudent($domain,$username,$cid,$sec);
1.5 www 568: my $reply=&Apache::lonnet::modifystudent(
569: $domain,$username,$id,$amode,$password,
570: $fname,$mname,$lname,$gen,$sec,$enddate,$startdate);
571: unless ($reply eq 'ok') {
572: $r->print(
573: "<p><b>Error enrolling $username: $reply</b><p>");
1.10 ! www 574: } else {
1.7 www 575: $count++; $flushc++;
576: $student{$username}=1;
1.6 www 577: $r->print('. ');
1.7 www 578: if ($flushc>15) {
579: $r->rflush;
580: $flushc=0;
581: }
1.6 www 582: }
1.5 www 583: } else {
584: $r->print(
585: "<p><b>No password for $username</b><p>");
586: }
1.4 www 587: }
588: }
589: } @studentdata;
1.7 www 590: $r->print('<p>Processed Students: '.$count);
1.5 www 591: # --------------------------------------------------------------- Drop students
592: if ($ENV{'form.fullup'} eq 'yes') {
593: $r->print('<h3>Dropping Students</h3>');
594: # ------------------------------------------------------- Get current classlist
595: my $classlst=&Apache::lonnet::reply
596: ('dump:'.$ENV{'course.'.$cid.'.domain'}.':'.
597: $ENV{'course.'.$cid.'.num'}.':classlist',
598: $ENV{'course.'.$cid.'.home'});
599: my %currentlist=();
600: my $now=time;
601: unless ($classlst=~/^error\:/) {
1.7 www 602: map {
603: my ($name,$value)=split(/\=/,$_);
1.8 www 604: my ($end,$start)=split(/\:/,
1.7 www 605: &Apache::lonnet::unescape($value));
606: my $active=1;
607: if (($end) && ($now>$end)) { $active=0; }
608: if ($active) {
609: $currentlist{&Apache::lonnet::unescape($name)}=1;
610: }
611: } split(/\&/,$classlst);
1.10 ! www 612: # ------------------------------------------------ Now got up-to-date classlist
! 613: map {
! 614: my %entries=&record_sep($_);
! 615: unless (($entries{$fields{'username'}} eq '') ||
! 616: (!defined($entries{$fields{'username'}}))) {
! 617: delete($currentlist{
! 618: $entries{$fields{'username'}}.':'.
! 619: $domain});
! 620: }
! 621: } @studentdata;
! 622: # ----------------------------------------------------------- Print out choices
! 623: $r->print('<table border=2>');
! 624: map {
! 625: my ($sname,$sdom)=split(/\:/,$_);
! 626: my %reply=&Apache::lonnet::idrget($sdom,$sname);
! 627: my $ssec=&Apache::lonnet::usection($sdom,$sname,$cid);
! 628: my @reply=split(/[\&\=]/,&Apache::lonnet::reply(
! 629: 'get:'.$sdom.':'.$sname.
! 630: ':environment:firstname&middlename&lastname&generation',
! 631: &Apache::lonnet::homeserver($sname,$sdom)));
! 632: $r->print(
! 633: '<tr><td><input type=checkbox name="drop:'.$_.'"></td><td>'.
! 634: $sname.'</td><td>'.$sdom.'</td><td>'.
! 635: $reply{$sname}.'</td><td>'.
! 636: $reply[2].' '.$reply[3],', '.$reply[0].' '.
! 637: $reply[1].'</td><td>'.
! 638: $ssec."</td></tr>\n");
! 639: } sort keys %currentlist;
! 640: $r->print('</table><br>');
! 641: $r->print('<input type=submit value="Drop Students">');
1.7 www 642:
1.5 www 643: } else {
644: $r->print(
645: '<font color=red><h3>Could not access classlist: '.$classlst.
646: '</h3></font>');
647: }
648: }
649: # ------------------------------------------------------------------------ Done
1.10 ! www 650:
! 651: }
! 652: }
! 653:
! 654: # ================================================================ Main Handler
! 655:
! 656: sub handler {
! 657: my $r=shift;
! 658:
! 659: if ($r->header_only) {
! 660: $r->content_type('text/html');
! 661: $r->send_http_header;
! 662: return OK;
! 663: }
! 664:
! 665: # ----------------------------------------------------- Needs to be in a course
! 666:
! 667: if (($ENV{'request.course.fn'}) &&
! 668: (&Apache::lonnet::allowed('cst',$ENV{'request.course.id'}))) {
! 669:
! 670: # ------------------------------------------------------------------ Start page
! 671: $r->content_type('text/html');
! 672: $r->send_http_header;
! 673: &header($r);
! 674:
! 675: # --------------------------------------------------- Phase one, initial screen
! 676: unless ($ENV{'form.phase'}) {
! 677: &menu_phase_one($r);
! 678: }
! 679: # ------------------------------------------------------------------- Phase two
! 680: if ($ENV{'form.phase'} eq 'two') {
! 681: if ($ENV{'form.fileupload'}) {
! 682: &menu_phase_two_upload($r);
! 683: } elsif ($ENV{'form.enroll'}) {
! 684: &menu_phase_two_enroll($r);
! 685: } elsif ($ENV{'form.drop'}) {
! 686: &menu_phase_two_drop($r);
! 687: }
! 688: }
! 689:
! 690:
! 691:
! 692:
! 693: # ----------------------------------------------------------------- Phase three
! 694: if ($ENV{'form.phase'} eq 'three') {
! 695: if ($ENV{'form.datatoken'}) {
! 696: &upfile_drop_add($r);
1.2 www 697: }
698: }
699: # ------------------------------------------------------------------------- End
1.1 www 700: $r->print('</form></body></html>');
701: } else {
702: # ----------------------------- Not in a course, or not allowed to modify parms
703: $ENV{'user.error.msg'}=
704: "/adm/dropadd:cst:0:0:Cannot drop or add students";
705: return HTTP_NOT_ACCEPTABLE;
706: }
707: return OK;
708: }
709:
710: 1;
711: __END__
712:
713:
714:
715:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>