| 1 | #!/usr/bin/perl |
1 | #!/usr/local/bin/webwork-perl |
| 2 | |
2 | |
| 3 | |
3 | |
| 4 | ## This file is profHousekeeping.pl |
4 | ## This file is profHousekeeping.pl |
| 5 | ## It provides access to utilities deleting uneeded files, etc. |
5 | ## It provides access to utilities deleting uneeded files, etc. |
| 6 | ## |
6 | ## |
| … | |
… | |
| 47 | my $databaseDirectory = getCourseDatabaseDirectory; |
47 | my $databaseDirectory = getCourseDatabaseDirectory; |
| 48 | my $htmlURL = getCourseHtmlURL; |
48 | my $htmlURL = getCourseHtmlURL; |
| 49 | my $scriptDirectory = getWebworkScriptDirectory; |
49 | my $scriptDirectory = getWebworkScriptDirectory; |
| 50 | my $htmlDirectory = getCourseHtmlDirectory; |
50 | my $htmlDirectory = getCourseHtmlDirectory; |
| 51 | my $templateDirectory = getCourseTemplateDirectory; |
51 | my $templateDirectory = getCourseTemplateDirectory; |
| 52 | my $dat = getDat; |
52 | my $dat = getDat; |
| 53 | |
53 | |
| 54 | require "${scriptDirectory}$Global::DBglue_pl"; |
54 | require "${scriptDirectory}$Global::DBglue_pl"; |
| 55 | require "${scriptDirectory}$Global::FILE_pl"; |
55 | require "${scriptDirectory}$Global::FILE_pl"; |
| 56 | require "${scriptDirectory}$Global::HTMLglue_pl"; |
56 | require "${scriptDirectory}$Global::HTMLglue_pl"; |
| 57 | |
57 | |
| … | |
… | |
| 63 | my $permissions = &get_permissions($User, $permissionsFile); |
63 | my $permissions = &get_permissions($User, $permissionsFile); |
| 64 | my $keyFile = &Global::getCourseKeyFile($Course); |
64 | my $keyFile = &Global::getCourseKeyFile($Course); |
| 65 | |
65 | |
| 66 | #verify session key |
66 | #verify session key |
| 67 | &verify_key($User, $Session_key, $keyFile, $Course); |
67 | &verify_key($User, $Session_key, $keyFile, $Course); |
| 68 | |
68 | |
| 69 | # verify permissions are correct |
69 | # verify permissions are correct |
| 70 | if ($permissions != $Global::instructor_permissions ) { |
70 | if ($permissions != $Global::instructor_permissions ) { |
| 71 | print "permissions = $permissions instructor_permissions = $Global::instructor_permissions\n"; |
71 | print "permissions = $permissions instructor_permissions = $Global::instructor_permissions\n"; |
| 72 | print &html_NO_PERMISSION; |
72 | print &html_NO_PERMISSION; |
| 73 | exit(0); |
73 | exit(0); |
| … | |
… | |
| 95 | "\n\n", $cgi->h3({ -align=>'left' }, "WeBWorK Housekeeping Utilities for $Course"), "\n", |
95 | "\n\n", $cgi->h3({ -align=>'left' }, "WeBWorK Housekeeping Utilities for $Course"), "\n", |
| 96 | $cgi->p, |
96 | $cgi->p, |
| 97 | "From this page, you can recover disk space by removing old tmp files, |
97 | "From this page, you can recover disk space by removing old tmp files, |
| 98 | compress the gdbm database, show active users, edit the Course Environment file, etc."; |
98 | compress the gdbm database, show active users, edit the Course Environment file, etc."; |
| 99 | |
99 | |
| 100 | # remove tmp files |
100 | # remove tmp files |
| 101 | print heading('Cleanup', "1. Cleanup $Course:"), |
101 | print heading('Cleanup', "1. Cleanup $Course:"), |
| 102 | $cgi->startform(-action=>"${cgiURL}profRemoveTmpFiles.pl"), |
102 | $cgi->startform(-action=>"${cgiURL}profRemoveTmpFiles.pl"), |
| 103 | $cgi->submit(-value=>'Remove unnecessary tmp files'), "\n", |
103 | $cgi->submit(-value=>'Remove unnecessary tmp files'), "\n", |
| 104 | hiddens('user', 'key', 'course'), |
104 | hiddens('user', 'key', 'course'), |
| 105 | $cgi->endform(), "\n", |
105 | $cgi->endform(), "\n", |
| … | |
… | |
| 119 | $cgi->startform(-action=>"${cgiURL}profShowActiveUsers.pl"), |
119 | $cgi->startform(-action=>"${cgiURL}profShowActiveUsers.pl"), |
| 120 | $cgi->submit(-value=>'Show Active Users'), "\n", |
120 | $cgi->submit(-value=>'Show Active Users'), "\n", |
| 121 | hiddens('user', 'key', 'course'), |
121 | hiddens('user', 'key', 'course'), |
| 122 | $cgi->endform(), "\n", |
122 | $cgi->endform(), "\n", |
| 123 | $cgi->p, "This lists all users who are currently logged into $Course."; |
123 | $cgi->p, "This lists all users who are currently logged into $Course."; |
| 124 | |
124 | |
| 125 | # templates/motd.txt |
125 | # templates/motd.txt |
| 126 | my $filename = "${templateDirectory}motd.txt"; |
126 | my $filename = "${templateDirectory}motd.txt"; |
| 127 | my ($date, $label, @stat); |
127 | my ($date, $label, @stat); |
| 128 | |
128 | |
| 129 | if (-e $filename) { |
129 | if (-e $filename) { |
| … | |
… | |
| 139 | $cgi->submit(-value=>'Edit Course motd.txt File'), "$label\n", |
139 | $cgi->submit(-value=>'Edit Course motd.txt File'), "$label\n", |
| 140 | hiddens('user', 'key', 'course'), |
140 | hiddens('user', 'key', 'course'), |
| 141 | $cgi->hidden(-name=>'filename', -value=>"motd.txt"), "\n", |
141 | $cgi->hidden(-name=>'filename', -value=>"motd.txt"), "\n", |
| 142 | $cgi->hidden(-name=>'ext', -value=>'txt'), "\n", |
142 | $cgi->hidden(-name=>'ext', -value=>'txt'), "\n", |
| 143 | $cgi->endform(), "\n", |
143 | $cgi->endform(), "\n", |
| 144 | $cgi->p, "This lets you edit the Course motd.txt File for $Course."; |
144 | $cgi->p, "This lets you edit the Course motd.txt File for $Course."; |
| 145 | |
145 | |
| 146 | # webworkcourse.ph |
146 | # webworkcourse.ph |
| 147 | $filename = "${courseDirectory}$Global::courseEnvironmentFile"; |
147 | $filename = "${courseDirectory}$Global::courseEnvironmentFile"; |
| 148 | #($date, $label, @stat); |
148 | #($date, $label, @stat); |
| 149 | if (-e $filename) { |
149 | if (-e $filename) { |
| … | |
… | |
| 181 | hiddens('user', 'key', 'course'), |
181 | hiddens('user', 'key', 'course'), |
| 182 | $cgi->hidden(-name=>'filename', -value=>"index.html"), "\n", |
182 | $cgi->hidden(-name=>'filename', -value=>"index.html"), "\n", |
| 183 | $cgi->hidden(-name=>'ext', -value=>'html'), "\n", |
183 | $cgi->hidden(-name=>'ext', -value=>'html'), "\n", |
| 184 | $cgi->endform(), "\n", |
184 | $cgi->endform(), "\n", |
| 185 | $cgi->p, "This lets you edit the Course index.html File for $Course."; |
185 | $cgi->p, "This lets you edit the Course index.html File for $Course."; |
| 186 | |
186 | |
| 187 | print heading('dataMungerPSVN', "7. Cange data for a PSVN in $Course:"), |
187 | print heading('dataMungerPSVN', "7. Change data for a PSVN in $Course:"), |
| 188 | $cgi->startform(-action=>"${cgiURL}dataMunger.pl"), |
188 | $cgi->startform(-action=>"${cgiURL}dataMunger.pl"), |
| 189 | $cgi->submit(-value=>'Examine or change data for psvn:'), "\n", |
189 | $cgi->submit(-value=>'Examine or change data for psvn:'), "\n", |
| 190 | $cgi->textfield(-name=>'probSetKey', -col=>'15', -value=>'Enter PSVN'), "\n", |
190 | $cgi->textfield(-name=>'probSetKey', -col=>'15', -value=>'Enter PSVN'), "\n", |
| 191 | $cgi->hidden(-name=>'save', -value=>'OFF'), "\n", |
191 | $cgi->hidden(-name=>'save', -value=>'OFF'), "\n", |
| 192 | $cgi->hidden(-name=>'firsttime', -value=>1), "\n", |
192 | $cgi->hidden(-name=>'firsttime', -value=>1), "\n", |
| … | |
… | |
| 232 | #if a given parameter does not exist, a note is placed in the html to that affect |
232 | #if a given parameter does not exist, a note is placed in the html to that affect |
| 233 | #this does NOT PRINT the info, so that it can be incorporated into other text |
233 | #this does NOT PRINT the info, so that it can be incorporated into other text |
| 234 | sub hiddens { |
234 | sub hiddens { |
| 235 | my @params = @_; |
235 | my @params = @_; |
| 236 | my $out; |
236 | my $out; |
| 237 | |
237 | |
| 238 | foreach my $param (@params) { |
238 | foreach my $param (@params) { |
| 239 | if (exists $inputs{$param}) { |
239 | if (exists $inputs{$param}) { |
| 240 | $out .= $cgi->hidden(-name=>"$param", -value=>"$inputs{$param}") . "\n"; |
240 | $out .= $cgi->hidden(-name=>"$param", -value=>"$inputs{$param}") . "\n"; |
| 241 | } else { |
241 | } else { |
| 242 | $out .= $cgi->p . "\nExpected cgi parameter $param does not exist or is empty"; |
242 | $out .= $cgi->p . "\nExpected cgi parameter $param does not exist or is empty"; |
| 243 | } |
243 | } |
| 244 | } |
244 | } |
| 245 | |
245 | |
| 246 | $out; |
246 | $out; |
| 247 | } |
247 | } |