Parent Directory
|
Revision Log
nothing should change
1 #!/usr/local/bin/perl 2 3 ## $Id$ 4 5 use lib '.'; use webworkInit; # WeBWorKInitLine 6 use Global; 7 8 9 ## readURClassList 10 ## 11 ## this is a specific routine for reading class lists which come from the registrar's 12 ## office at the Univ of Rochesterand producing a classlist file usable by WeBWorK 13 14 ## IT IS ASSUMED THAT THE REGISTRAR'S LIST IS DELIMITED WITH SEMICOLONS (;) 15 16 ## 17 ## Takes three parameters. 18 ## First, the full file name of the Registrar's class list file with the header 19 ## material stripped off. 20 ## Second, the full file name of the output WeBWorK classlist file 21 ## Third, the name of the section, e.g. Pizer or "Gage MWF" or "" (blank). 22 ## For example classlist files from multiple sections can be concatonated 23 ## one large classlist file for a whole multisection course 24 ## 25 ## NOTE: Be very careful. The registrar's file may get corrupted by e-mail. 26 27 28 require 5.000; 29 30 31 require "$Global::scriptDirectory$Global::FILE_pl"; 32 33 $0 =~ s|.*/||; 34 die "\n usage: $0 registrar's-list outputfile sectionName\n 35 e.g. readURClassList.pl ClassRoster.txt mth140A.lst 'Gage MWF9'\n\n" unless (@ARGV == 3); 36 37 my ($infile, $outfile, $section) = @ARGV; 38 39 open(REGLIST, "$infile") || die "can't open $infile: $!\n"; 40 open(OURLIST, ">$outfile") 41 || die "can't write $outfile: $!\n"; 42 43 while (<REGLIST>) { 44 chomp; 45 next unless($_=~/\w/); ## skip blank lines 46 s/;$/; /; ## make last field non empty 47 my @regArray=split(/;/); ## get fields from registrar's file 48 49 foreach (@regArray) { ## clean 'em up! 50 ($_) = m/^\s*(.*?)\s*$/; ## (remove leading and trailing spaces) 51 } 52 53 ## extract the relevant fields 54 55 my($crn, $id, $grade, $name, $school, $gradyear, 56 $major, $degree, $hours, $status, $login ) 57 = @regArray; 58 59 60 ## massage the data a bit 61 62 my($lname, $fname) = ($name =~ /^(.*),\s*(.*)$/); 63 if ($login =~/\w/) {$email = "$login".'@mail.rochester.edu';} 64 else 65 { 66 $email= " "; 67 $login = $id; 68 } 69 ## dump it in our classArray format 70 ## our format is: $id, $lname, $fname, $status, 'comment ', $dept, $course, $section, 71 ## $hours, $crn, $year, $semester, $school, $gradyear, $major, $degree, $email, $login 72 73 ## At the U of R 'comment' is blank 74 ## At present only $id, $lname, $fname, $status, $email, $section, $recitation and $login are used by WeBWorK 75 76 my @classArray=($id, $lname, $fname, $status, ' ', $section, ' ',$email, $login); 77 78 ## and print that sucker! 79 80 print OURLIST join("$Global::delim", @classArray) , "\n"; 81 } 82 close(OURLIST); 83 84 ## arrange the columns nicely 85 86 &columnPrint("$outfile","$outfile"); 87 88 89
| aubreyja at gmail dot com | ViewVC Help |
| Powered by ViewVC 1.0.9 |