Parent Directory
|
Revision Log
changed #! lines to /usr/bin/env perl THIS SHOULD BE THE LAST TIME #! LINES ARE CHANGED!!!!!!!
1 #!/usr/bin/env perl 2 3 ## $Id$ 4 5 $|++; 6 use lib '.'; use webworkInit; # WeBWorKInitLine 7 require 5.001; 8 use strict; 9 10 use Auth; 11 use Global; 12 use CGI qw(:standard) ; 13 14 # Timing code 15 use Benchmark; 16 my $beginTime = new Benchmark; 17 # end Timing code 18 19 # $cgi = new CGI_Lite(); 20 # %inputs = $cgi->parse_form_data(); 21 &CGI::ReadParse; 22 my %inputs = %main::in; 23 24 # get information from CGI inputs (see also below for additional information) 25 my $Course = $inputs{'course'}; 26 my $User = $inputs{'user'}; 27 my $Session_key = $inputs{'key'}; 28 # establish environment for this script 29 &Global::getCourseEnvironment($Course); 30 31 my $Course_display = $Course; 32 $Course_display =~ s/_/ /g; 33 34 35 my $cgiURL = getWebworkCgiURL(); 36 my $scriptDirectory = getWebworkScriptDirectory(); #$Global::scriptDirectory; 37 my $databaseDirectory = getCourseDatabaseDirectory(); #$Global::databaseDirectory; 38 39 require "${scriptDirectory}$Global::DBglue_pl"; 40 require "${scriptDirectory}$Global::classlist_DBglue_pl"; 41 require "${scriptDirectory}$Global::HTMLglue_pl"; 42 require "${scriptDirectory}$Global::FILE_pl"; 43 44 my $permissionsFile = &Global::getCoursePermissionsFile($Course); 45 my $permissions = &get_permissions($User,$permissionsFile); 46 my $keyFile = &Global::getCourseKeyFile($inputs{'course'}); 47 48 # log access 49 &Global::log_info('', query_string); 50 51 52 &verify_key($inputs{'user'}, $inputs{'key'}, "$keyFile", $inputs{'course'}); 53 my $studentLogin=$inputs{'user'}; 54 55 ## If a professor was viewing a student's problem set (coming from the Prof page) and 56 ## then hits the Problem Set button, he or she will see all the students sets. 57 58 if ((defined $inputs{'probSetKey'}) and ($permissions == $Global::instructor_permissions)) { 59 attachProbSetRecord($inputs{'probSetKey'}); 60 $studentLogin = getStudentLogin($inputs{'probSetKey'}); 61 } 62 63 ## check that database exists 64 unless ( -e "${databaseDirectory}$Global::database" ) { 65 wwerror($0, "No problem sets have been built yet"); 66 } 67 68 # obtain list of setNumbers 69 70 71 my %setNumberHash=&getAllSetNumbersForStudentLoginHash($studentLogin); 72 73 # get one PSVN and determine the students name. 74 my @PSVNs = values %setNumberHash; 75 76 # this is so the correct emailaddress gets sent to feedback 77 $inputs{'probSetKey'}=$PSVNs[0]; 78 79 attachCLRecord($studentLogin); 80 81 my $studentName=&CL_getStudentName($studentLogin); 82 my $currentDate = &formatDateAndTime(time); 83 84 # get information on open/due/answer dates for each problem and prepare 85 # HTML output; 86 87 my @SetNumberKeys = keys(%setNumberHash); 88 my @problemDates = (); 89 my $problemDateLine; 90 my ($probSetKey,$odts,$ddts,$adts,$timeNow,$DueDate,$AnswerDate,$OpenDate); 91 my $sortedSetNumber; 92 my $SetNumber; 93 my %problemDateLines =(); 94 my %dueTimes =(); 95 96 foreach $SetNumber(@SetNumberKeys) { 97 $probSetKey=$setNumberHash{$SetNumber}; 98 &attachProbSetRecord($probSetKey); 99 $odts=&getOpenDate($probSetKey); 100 $ddts=&getDueDate($probSetKey); 101 $dueTimes{$SetNumber} = $ddts; 102 $adts=&getAnswerDate($probSetKey); 103 $timeNow = time; 104 105 $DueDate=&formatDateAndTime($ddts); 106 $AnswerDate = &formatDateAndTime($adts); 107 $OpenDate = &formatDateAndTime($odts); 108 109 # prepare message based on current time relative to the Open, Due and Answer dates. 110 $problemDateLine = ""; 111 $problemDateLine = "<OPTION VALUE= \"$probSetKey\">"; 112 113 my $SetNumber_display = $SetNumber; 114 $SetNumber_display =~ s/_/ /g; 115 $problemDateLine .= "Set $SetNumber_display"; 116 ($timeNow < $odts ) && # beforeOpenDateMsg 117 do {$problemDateLine .= " --- Before open date -- Open date is: $OpenDate";}; 118 ( $odts <= $timeNow ) && ($timeNow < $ddts) && # afterOpenDateMsg 119 do {$problemDateLine .= " --- OPEN -- Due date is: $DueDate";}; 120 ( $ddts <= $timeNow ) && ($timeNow < $adts) && # afterDueDateMsg 121 do {$problemDateLine .= " --- Due date has passed -- Answers available on: $AnswerDate";}; 122 ( $adts <= $timeNow ) && # afterAnsDateMsg 123 do {$problemDateLine .= " --- Due date has passed -- answers available.";}; 124 125 126 $problemDateLines{$SetNumber} =$problemDateLine; 127 128 } 129 130 ## Sort setnumbers by due date 131 132 sub by_due_date 133 { 134 $timeNow = time; 135 if ( ($dueTimes{$a} <= $timeNow) and ($dueTimes{$b} <= $timeNow) ) 136 { 137 ($dueTimes{$a} <=> $dueTimes{$b}) 138 or 139 ($a cmp $b) 140 } 141 elsif ( ($dueTimes{$a} > $timeNow) and ($dueTimes{$b} > $timeNow) ) 142 { 143 ($dueTimes{$a} <=> $dueTimes{$b}) 144 or 145 ($a cmp $b) 146 } 147 else 148 { 149 $dueTimes{$b} <=> $dueTimes{$a} 150 } 151 152 } 153 154 my @sortedSetNumberKeys = sort by_due_date keys(%problemDateLines); 155 156 foreach $sortedSetNumber(@sortedSetNumberKeys) 157 { 158 push (@problemDates, $problemDateLines{$sortedSetNumber}); 159 } 160 161 162 # begin printing the WELCOME page 163 print &htmlTOP("WeBWorK Welcome Page"); 164 165 # print navigation buttons 166 print qq! 167 <A HREF="${cgiURL}login.pl?user=$inputs{'user'}&key=$inputs{'key'}&course=$inputs{'course'}"> 168 <IMG SRC="${Global::upImgUrl}" align="right" BORDER=1 ALT="[Up]"></A><p> 169 !; 170 171 print <<"ENDOFHTML1"; 172 <H3 ALIGN="LEFT">WeBWorK welcomes $studentName for class $Course_display.</H3> 173 174 From this page you can view and answer a problem set, download a printed version 175 of the entire problem set in postscript or pdf format, or view a summary 176 of your homework grades. If a set's due date has passed, you can still do the problems and 177 WeBWorK will tell you whether your answers are correct or incorrect, but your 178 answers and scores will not be recorded. 179 ENDOFHTML1 180 181 my $button_style = ' style="width: 10em"'; 182 my $prof_switch = ''; 183 $prof_switch = 'multiple' if ($permissions == $Global::instructor_permissions); 184 185 # FORM for accessing the problem sets via computer 186 print "<form METHOD = \"POST\" action=\"$Global::welcomeAction_CGI\">"; 187 print "<HR NOSHADE>"; 188 print "The date is currently: <B>$currentDate </B>."; 189 190 print "<P>Select a problem set from the list (by clicking on it once), 191 then press one of the buttons below the list.<P>"; 192 print "<SELECT NAME = 'local_psvns' SIZE = \"8\" $prof_switch>\n"; 193 194 print join("\n\n", @problemDates),"\n"; # include open/due/answer dates 195 # prepared above 196 print "</SELECT>\n"; 197 print &sessionKeyInputs(\%inputs); 198 print "<BR>"; 199 print "<BR><input type=\"submit\"name = \"action\" value=\"Do problem set\" $button_style>"; 200 print "<BR><input type=\"submit\"name = \"action\" value=\"Get hard copy\" $button_style>"; 201 #print " in: <INPUT TYPE=RADIO NAME=\"downloadType\" VALUE=\"ps\" CHECKED><B>PostScript</B> form "; 202 #print "<INPUT TYPE=RADIO NAME=\"downloadType\" VALUE=\"pdf\" ><B>PDF</B> form\n"; 203 print " in: <INPUT TYPE=RADIO NAME='downloadType' VALUE='pdf' CHECKED><B>PDF</B> form "; 204 print "<INPUT TYPE=RADIO NAME='downloadType' VALUE='ps'><B>PostScript</B> form\n"; 205 print "<INPUT TYPE=RADIO NAME='downloadType' VALUE='TeX'><B>TeX</B> form\n" if $permissions == $Global::instructor_permissions; 206 print "<INPUT TYPE=RADIO NAME='downloadType' VALUE='dvi'><B>DVI</B> form\n" if $permissions == $Global::instructor_permissions; 207 print "<BR>(Professors can select and download multiple sets.)<BR>" if $permissions == $Global::instructor_permissions; 208 print "<BR><INPUT TYPE=CHECKBOX NAME=\"ShowAns\" VALUE=\"1\"> Show answers in hard copy IF the answers are available.\n" ; 209 print "<BR><INPUT TYPE=CHECKBOX NAME=\"ShowSol\" VALUE=\"1\"> Show solutions in hard copy IF the solutions are available.\n" ; 210 211 print "</FORM>\n "; 212 213 # FORM for viewing student summary 214 215 print "<FORM METHOD = \"POST\" action=\"${Global::cgiWebworkURL}studentSummary.pl\">\n "; 216 print "<HR NOSHADE>Obtain a summary of your WeBWorK scores:<BR>\n "; 217 218 ## If a professor was viewing a student's problem set (coming from the Prof page) and 219 ## then hits the Problem Set button, he or she will get the students summary 220 if ((defined $inputs{'probSetKey'}) and ($permissions == $Global::instructor_permissions)) { 221 print qq! <INPUT TYPE='HIDDEN' NAME='studentLogin' VALUE = $studentLogin>!; 222 } 223 224 print &sessionKeyInputs(\%inputs); 225 print "<input type=\"submit\" value=\"Get Summary\" $button_style>"; 226 print "</FORM>"; 227 228 229 230 print &htmlBOTTOM("welcome.pl",\%inputs); 231 232 # begin Timing code 233 my $endTime = new Benchmark; 234 &Global::logTimingInfo($beginTime,$endTime,"welcome.pl",$inputs{'course'},$inputs{'user'}); 235 # end Timing code 236 exit; 237 238 239 240
| aubreyja at gmail dot com | ViewVC Help |
| Powered by ViewVC 1.0.9 |