#!/usr/local/bin/webwork-perl ## $Id$ use lib '.'; use webworkInit; # WeBWorKInitLine use Global; # This file is sortDataSet.pl ## takes three command line arguments. The first is the course name. ## the second is a filename without the extension, ## e.g. s5ful or s5scr. The third optional parameter determined the ## sorting order. The default will be to sort alpabetically by section, ## then by student name. If the third parameter is 'A', 'AbySec, 'AbyRec', 'S', or ## 'SbySec','SbyRec', the sort order will be by student name, by section then by ## student name, by recitation then by student name, by studentID, by section ##then by studemtID, by recitation then by studemtID, ## e.g. sortDataSet.pl s5ful or sortDataSet.pl s5ful S if (@ARGV != 2 && @ARGV != 3) {print "\nSyntax is\n\n sortDataSet.pl courseID newdataSetFile \n"; print " giving the default sortType of Alphabetical by Section ('AbySec')\n"; print "OR \n"; print " sortDataSet.pl courseID dataSetFile sortType \n\n"; print "where sortType is 'A' or 'AbySec' or 'AbyRec' or 'S' or 'SbySec' or 'SbyRec' \n\n"; print "File names are entered with or without the extension, e.g. enter s7scr or s7scr.csv \n"; print " (e.g. sortDataSet.pl MTH140A 140atotal ) \n"; print "OR \n"; print " (e.g. sortDataSet.pl MTH140A 140atotal SbySec ) \n\n"; exit(0); } #require "webwork.ph"; #require "${scriptDirectory}$DBglue_pl"; #require "${scriptDirectory}$SCRtools_pl"; #require "${scriptDirectory}FILE.pl"; local($courseID,$fileName1,$sortOrderTag)=@ARGV; $scriptDirectory = $Global::scriptDirectory; &Global::getCourseEnvironment($courseID); #require "${scriptDirectory}$Global::DBglue_pl"; require "${scriptDirectory}$Global::FILE_pl"; require "${scriptDirectory}$Global::SCRtools_pl"; $fileName1 =~ s/\.$Global::dat$//; ## remove dat extension if present unless (($sortOrderTag eq 'A') or ($sortOrderTag eq 'S') or ($sortOrderTag eq 'SbySec') or ($sortOrderTag eq 'AbyRec') or ($sortOrderTag eq 'SbyRec') ) {$sortOrderTag="AbySec";} local(*assocArray); %assocArray = &dat2aa("$fileName1"); &aa2dat(*assocArray,"$fileName1", $sortOrderTag); ##sort