Parent Directory
|
Revision Log
this module summarizes database problems and gives professors a chance to fix them.
1 ################################################################################ 2 # WeBWorK Online Homework Delivery System 3 # Copyright © 2000-2003 The WeBWorK Project, http://openwebwork.sf.net/ 4 # $CVSHeader: webwork-modperl/lib/WeBWorK/ContentGenerator/Login.pm,v 1.22 2004/03/17 08:16:35 sh002i Exp $ 5 # 6 # This program is free software; you can redistribute it and/or modify it under 7 # the terms of either: (a) the GNU General Public License as published by the 8 # Free Software Foundation; either version 2, or (at your option) any later 9 # version, or (b) the "Artistic License" which comes with this package. 10 # 11 # This program is distributed in the hope that it will be useful, but WITHOUT 12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 # FOR A PARTICULAR PURPOSE. See either the GNU General Public License or the 14 # Artistic License for more details. 15 ################################################################################ 16 17 package WeBWorK::ContentGenerator::FixDB; 18 use base qw(WeBWorK::ContentGenerator); 19 20 =head1 NAME 21 22 WeBWorK::ContentGenerator::FixDB - prompt the user to fix a broken database. 23 24 =cut 25 26 use strict; 27 use warnings; 28 use CGI::Pretty qw(); 29 30 sub title { 31 return "Fix Database"; 32 } 33 34 sub body { 35 my ($self) = @_; 36 my $r = $self->r; 37 my $db = $r->db; 38 my $authz = $r->authz; 39 40 my $can_fix = $authz->hasPermissions($r->param("user"), "fix_course_databases"); 41 my $fix_database = $r->param("fix"); 42 43 if ($fix_database and $can_fix) { 44 # fix database 45 my ($dbOK, @dbMessages) = $db->hashDatabaseOK(1); # 1 == fix 46 47 # no problems found? weird. maybe it'll go away. 48 if ($dbOK) { 49 print CGI::p("The following problems were corrected:"); 50 print CGI::ul(CGI::li(\@dbMessages)); 51 52 print CGI::startform({-method=>"POST", -action=>$r->uri}); 53 54 # preserve the form data posted to the requested URI 55 my @fields_to_print = grep { $_ ne "fix" } $r->param; 56 print $self->hidden_fields(@fields_to_print); 57 58 print CGI::submit(-name=>"continue", -value=>"Continue"); 59 print CGI::endform(); 60 } else { 61 print CGI::p("Failed to fix the following problems this course's database:"); 62 print CGI::ul(CGI::li(\@dbMessages)); 63 print CGI::p("You cannot use this course with WeBWorK 2 until fixing the database."); 64 65 print CGI::startform({-method=>"POST", -action=>$r->uri}); 66 67 # preserve the form data posted to the requested URI 68 my @fields_to_print = grep { $_ ne "fix" } $r->param; 69 print $self->hidden_fields(@fields_to_print); 70 71 print CGI::submit(-name=>"fix", -value=>"Fix Database"); 72 print CGI::endform(); 73 } 74 } else { 75 # check only, don't fix 76 my ($dbOK, @dbMessages) = $db->hashDatabaseOK(0); # 0 == don't fix 77 78 # no problems found? weird. maybe it'll go away. 79 if ($dbOK) { 80 return CGI::p("FixDB was called, but no problems were found. Try reloading the page."); 81 } else { 82 print CGI::p("Problems were found in this course's database:"); 83 print CGI::ul(CGI::li(\@dbMessages)); 84 print CGI::p("You cannot use this course with WeBWorK 2 until fixing the database."); 85 86 if ($can_fix) { 87 print CGI::startform({-method=>"POST", -action=>$r->uri}); 88 89 # preserve the form data posted to the requested URI 90 my @fields_to_print = grep { $_ ne "fix" } $r->param; 91 print $self->hidden_fields(@fields_to_print); 92 93 print CGI::submit(-name=>"fix", -value=>"Fix Database"); 94 print CGI::endform(); 95 } else { 96 print CGI::p("You do not have permission to fix course databases."); 97 } 98 } 99 } 100 101 return ""; 102 } 103 104 1;
| aubreyja at gmail dot com | ViewVC Help |
| Powered by ViewVC 1.0.9 |