Parent Directory
|
Revision Log
This commit was manufactured by cvs2svn to create branch 'rel-2-3-dev'.
1 ################################################################################ 2 # WeBWorK Online Homework Delivery System 3 # Copyright © 2000-2006 The WeBWorK Project, http://openwebwork.sf.net/ 4 # $CVSHeader: webwork-modperl/lib/WeBWorK/ContentGenerator/Home.pm,v 1.18 2006/07/08 14:07:34 gage 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::Home; 18 use base qw(WeBWorK::ContentGenerator); 19 20 =head1 NAME 21 22 WeBWorK::ContentGenerator::Home - display a list of courses. 23 24 =cut 25 26 use strict; 27 use warnings; 28 #use CGI qw(-nosticky ); 29 use WeBWorK::CGI; 30 use WeBWorK::Utils qw(readFile readDirectory); 31 use WeBWorK::Utils::CourseManagement qw/listCourses/; 32 33 sub info { 34 my ($self) = @_; 35 my $r = $self->r; 36 my $ce = $r->ce; 37 38 my $result; 39 40 # This section should be kept in sync with the Login.pm version 41 my $site_info = $ce->{webworkFiles}->{site_info}; 42 if (defined $site_info and $site_info) { 43 # deal with previewing a temporary file 44 # FIXME: DANGER: this code allows viewing of any file 45 # FIXME: this code is disabled because PGProblemEditor no longer uses editFileSuffix 46 #if (defined $r->param("editMode") and $r->param("editMode") eq "temporaryFile" 47 # and defined $r->param("editFileSuffix")) { 48 # $site_info .= $r->param("editFileSuffix"); 49 #} 50 51 if (-f $site_info) { 52 my $text = eval { readFile($site_info) }; 53 if ($@) { 54 $result = CGI::div({class=>"ResultsWithError"}, $@); 55 } elsif ($text =~ /\S/) { 56 $result = $text; 57 } 58 } 59 } 60 61 if (defined $result and $result ne "") { 62 return CGI::div({class=>"info-box", id=>"InfoPanel"}, 63 CGI::h2("Site Information"), $result); 64 } else { 65 return ""; 66 } 67 } 68 69 sub body { 70 my ($self) = @_; 71 my $r = $self->r; 72 73 my $coursesDir = $r->ce->{webworkDirs}->{courses}; 74 my $coursesURL = $r->ce->{webworkURLs}->{root}; 75 76 my @courseIDs = listCourses($r->ce); 77 78 my $haveAdminCourse = 0; 79 foreach my $courseID (@courseIDs) { 80 if ($courseID eq "admin") { 81 $haveAdminCourse = 1; 82 last; 83 } 84 } 85 86 print CGI::p("Welcome to WeBWorK!"); 87 88 if ($haveAdminCourse and !(-f "$coursesDir/admin/hide_directory")) { 89 my $urlpath = $r->urlpath->newFromModule("WeBWorK::ContentGenerator::ProblemSets", courseID => "admin"); 90 print CGI::p(CGI::a({href=>$self->systemLink($urlpath, authen => 0)}, "Course Administration")); 91 } 92 93 print CGI::h2("Courses"); 94 95 print CGI::start_ul(); 96 97 foreach my $courseID (sort {lc($a) cmp lc($b) } @courseIDs) { 98 next if $courseID eq "admin"; # done already above 99 next if -f "$coursesDir/$courseID/hide_directory"; 100 my $urlpath = $r->urlpath->newFromModule("WeBWorK::ContentGenerator::ProblemSets", courseID => $courseID); 101 print CGI::li(CGI::a({href=>$self->systemLink($urlpath, authen => 0)}, $courseID)); 102 } 103 104 print CGI::end_ul(); 105 106 return ""; 107 } 108 109 1;
| aubreyja at gmail dot com | ViewVC Help |
| Powered by ViewVC 1.0.9 |