Parent Directory
|
Revision Log
another setup script test (changed #! lines)
1 #!/usr/local/bin/webwork-perl 2 3 4 5 ## This file is profDeleteProSetPage.pl 6 ## 7 8 #################################################################### 9 # Copyright @ 1995-1999 University of Rochester 10 # All Rights Reserved 11 #################################################################### 12 13 use lib '.'; use webworkInit; # WeBWorKInitLine 14 use CGI qw(:standard); 15 use Global; 16 use Auth; 17 use strict; 18 19 # begin Timing code 20 use Benchmark; 21 my $beginTime = new Benchmark; 22 # end Timing code 23 24 &CGI::ReadParse; 25 my %inputs =%main::in; 26 27 # get information from CGI inputs (see also below for additional information) 28 29 my $Course = $inputs{'course'}; 30 my $User = $inputs{'user'}; 31 my $Session_key = $inputs{'key'}; 32 33 # verify that information has been received 34 unless($Course && $User && $Session_key) { 35 &wwerror("$0","The script did not receive the proper input data."); 36 } 37 38 # establish environment for this script 39 40 &Global::getCourseEnvironment($inputs{'course'}); 41 42 43 my $cgiURL = getWebworkCgiURL; 44 my $courseScriptsDirectory = getCourseScriptsDirectory; 45 my $databaseDirectory = getCourseDatabaseDirectory; 46 my $scriptDirectory = getWebworkScriptDirectory; 47 48 49 require "${scriptDirectory}$Global::DBglue_pl"; 50 require "${scriptDirectory}$Global::FILE_pl"; 51 require "${scriptDirectory}$Global::HTMLglue_pl"; 52 53 # log access 54 &Global::log_info('', query_string); 55 56 57 my $permissionsFile = &Global::getCoursePermissionsFile($inputs{'course'}); 58 my $permissions = &get_permissions($inputs{'user'}, $permissionsFile); 59 my $keyFile = &Global::getCourseKeyFile($inputs{'course'}); 60 my $defaultClasslistFile = getCourseClasslistFile($Course); 61 62 #verify session key 63 &verify_key($inputs{'user'}, $inputs{'key'}, $keyFile, $inputs{'course'}); 64 65 # verify permissions are correct 66 if ($permissions != $Global::instructor_permissions ) { 67 print "permissions = $permissions instructor_permissions = $Global::instructor_permissions\n"; 68 print &html_NO_PERMISSION; 69 exit(0); 70 } 71 ####################################Page 1#################################### 72 unless ($inputs{'pDPS1'}) { 73 print &htmlTOP("Delete Problem Sets"); 74 my $Course = $inputs{'course'}; 75 print <<EOF; 76 <H3 align="center">Delete Problem Sets Page for $Course</H3> 77 78 On this page, you may delete one or more problem sets (and associated .sco files) from the 79 database, leaving nothing but the uncompiled set definition file(s) and problem template 80 files themselves in/under the templates directory. <b> Be very careful.</b> Whereas a 81 deleted set can be rebuilt with the exact same problems for all students, the current 82 information on scoring and status in the webwork-database and the .sco files <b>can not</b> be 83 recovered. If you want to save the current scoring information for a set to be 84 deleted, score the set before deleting it (goto the scoring page) and/or move the .sco files out 85 of the DATA directory. <b> Be very careful and 86 think before you click.</b> 87 <p><HR> 88 Select problem set(s) to delete: 89 EOF 90 91 print "<form action=\"${cgiURL}profDeleteProbSet.pl\">\n"; 92 # %setNumberHash=&getAllProbSetNumbersHash; 93 # &printProbSets("setNo",\%setNumberHash); 94 my %availableSets = &getAllProbSetNumbersHash; 95 my @sortedSetNames = &sortSetNamesByDueDate(\%availableSets); 96 97 # enter the available set numbers 98 print qq! <SELECT Name = 'setNo' Size =4 multiple>\n!; 99 my $ind; 100 for $ind (@sortedSetNames) { 101 print "<OPTION VALUE = \"$ind\">Set $ind\n"; 102 } 103 print qq!</SELECT><BR>\n!; 104 # resume printing the rest of the forms 105 106 print <<EOF; 107 <INPUT TYPE=RADIO NAME='outputFormat' VALUE='no_students' CHECKED> Don't display actions for individual students<BR> 108 <INPUT TYPE=RADIO NAME='outputFormat' VALUE='all_students'> Display actions for all students<BR> 109 <INPUT TYPE=HIDDEN NAME='pDPS1' VALUE=1> 110 EOF 111 print &sessionKeyInputs(\%inputs); 112 print <<EOF; 113 <BR><INPUT TYPE=SUBMIT VALUE='Delete Problem Sets'</FORM> 114 <INPUT TYPE=RADIO NAME='confirm' VALUE= 0 CHECKED> Off 115 <INPUT TYPE=RADIO NAME='confirm' VALUE= 1> Delete enabled<BR> 116 EOF 117 exit; 118 } 119 120 ####################################Page 2#################################### 121 122 if ($inputs{'confirm'}) { 123 print &htmlTOP("DONE Deleting Your Problem Set(s)"); 124 125 my $query = $main::in{CGI}; 126 my @setNumbers = $query -> param('setNo' ); 127 my $setNumber; 128 my $outputFormat = $inputs{'outputFormat'}; 129 130 foreach $setNumber (@setNumbers) { 131 132 my @PINs=&getAllProbSetKeysForSet($setNumber); 133 my @a=<${databaseDirectory}S${setNumber}*>; 134 135 print "Deleting problems in set $setNumber<BR>\n"; 136 print "Problem set keys are: <BR>" if ($outputFormat eq 'all_students'); 137 my $PIN; 138 my $PINcount = 0; 139 foreach $PIN (@PINs) { 140 &attachProbSetRecord($PIN); 141 if (&deleteProbSetRecord($PIN)) { 142 $PINcount++; 143 print ( $PIN, " deleted<BR>\n" ) if ($outputFormat eq 'all_students'); 144 } 145 } 146 print "<BR> A total of $PINcount records have been deleted<BR><BR>\n"; 147 print "deleting .sco files: ${databaseDirectory}S$setNumber-*.sco<BR>"; 148 system ("rm ${databaseDirectory}S${setNumber}-*.sco"); 149 150 my $l2hDir = getCoursel2hDirectory(); 151 print "\ndeleting Latex2html tmp files and the directory:<BR>\n"; 152 print " ${l2hDir}set$setNumber<BR>"; 153 system ("rm -rf ${l2hDir}set$setNumber"); 154 print '<HR>'; 155 } 156 print "<H1><B>DONE.</B></H1>"; 157 &sendBack; 158 } 159 else { 160 print &htmlTOP("NO Set(s) were deleted"); 161 print "No sets were deleted since Delete was not enabled. If you want to delete sets, go back and select 162 "Delete enabled" before deleing the sets.<BR>"; 163 print "<H1><B>NO SETS DELETED.</B></H1>"; 164 &sendBack; 165 } 166 167 # begin Timing code 168 my $endTime = new Benchmark; 169 &Global::logTimingInfo($beginTime,$endTime,"profDeleteProbSetPage.pl",$inputs{'course'},$inputs{'user'}); 170 # end Timing code 171 172 exit; 173 174 #####################################END###################################### 175 176 sub sendBack { 177 print <<EOF; 178 <A HREF="${cgiURL}profLogin.pl?user=$inputs{'user'}&key=$inputs{'key'}&course=$inputs{'course'}"> 179 <IMG SRC="$Global::upImgUrl" BORDER=1></A> 180 EOF 181 }
| aubreyja at gmail dot com | ViewVC Help |
| Powered by ViewVC 1.0.9 |