Parent Directory
|
Revision Log
merging with localization files in trunk
1 ################################################################################ 2 # WeBWorK Online Homework Delivery System 3 # Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ 4 # $CVSHeader: webwork2/lib/WeBWorK/ContentGenerator/Home.pm,v 1.19 2006/07/12 01:23:54 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 use WeBWorK::Localize; 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-wrapper"},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 #filter underscores here! 78 79 my $haveAdminCourse = 0; 80 foreach my $courseID (@courseIDs) { 81 if ($courseID eq "admin") { 82 $haveAdminCourse = 1; 83 last; 84 } 85 } 86 87 print CGI::p($r->maketext("Welcome to WeBWorK!")); 88 89 if ($haveAdminCourse and !(-f "$coursesDir/admin/hide_directory")) { 90 my $urlpath = $r->urlpath->newFromModule("WeBWorK::ContentGenerator::ProblemSets", $r, courseID => "admin"); 91 print CGI::p(CGI::a({href=>$self->systemLink($urlpath, authen => 0)}, "Course Administration")); 92 } 93 94 print CGI::h2($r->maketext("Courses")); 95 96 print CGI::start_ul(); 97 98 foreach my $courseID (sort {lc($a) cmp lc($b) } @courseIDs) { 99 next if $courseID eq "admin"; # done already above 100 next if -f "$coursesDir/$courseID/hide_directory"; 101 my $urlpath = $r->urlpath->newFromModule("WeBWorK::ContentGenerator::ProblemSets", $r, courseID => $courseID); 102 print CGI::li(CGI::a({href=>$self->systemLink($urlpath, authen => 0)}, $courseID)); 103 }###place to use underscore sub 104 105 print CGI::end_ul(); 106 107 return ""; 108 } 109 110 1;
| aubreyja at gmail dot com | ViewVC Help |
| Powered by ViewVC 1.0.9 |