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