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