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