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 4 5 ## This file is profClasslist.pl 6 ## It provides access to utilities for building, correcting and viewing classlist files 7 ## 8 9 #################################################################### 10 # Copyright @ 1995-1998 University of Rochester 11 # All Rights Reserved 12 #################################################################### 13 14 use lib '.'; use webworkInit; # WeBWorKInitLine 15 use CGI qw(:standard); 16 use Global; 17 use Auth; 18 use strict; 19 20 my $logTimingData = 0; 21 my $beginTime; 22 23 # begin Timing code 24 if ($logTimingData == 1) { 25 use Benchmark; 26 $beginTime = new Benchmark; 27 } 28 # end Timing code 29 30 31 my $cgi = new CGI; 32 my %inputs = $cgi->Vars(); 33 34 # get information from CGI inputs (see also below for additional information) 35 36 my $Course = $inputs{'course'}; 37 my $User = $inputs{'user'}; 38 my $Session_key = $inputs{'key'}; 39 40 # verify that information has been received 41 unless($Course && $User && $Session_key) { 42 &wwerror("$0","The script did not receive the proper input data.","",""); 43 die "The script profLogin.pl did not receive the proper input data."; 44 } 45 46 # establish environment for this script 47 48 &Global::getCourseEnvironment($inputs{'course'}); 49 50 51 my $cgiURL = getWebworkCgiURL; 52 my $courseScriptsDirectory = getCourseScriptsDirectory; 53 my $databaseDirectory = getCourseDatabaseDirectory; 54 my $htmlURL = getCourseHtmlURL; 55 my $scriptDirectory = getWebworkScriptDirectory; 56 my $templateDirectory = getCourseTemplateDirectory; 57 my $dat = getDat; 58 my $dd = getDirDelim(); 59 60 #require "${scriptDirectory}$Global::DBglue_pl"; 61 require "${scriptDirectory}$Global::FILE_pl"; 62 require "${scriptDirectory}$Global::HTMLglue_pl"; 63 require "${scriptDirectory}$Global::classlist_DBglue_pl"; 64 65 # log access 66 &Global::log_info('', query_string); 67 68 69 my $permissionsFile = &Global::getCoursePermissionsFile($inputs{'course'}); 70 my $permissions = &get_permissions($inputs{'user'}, $permissionsFile); 71 my $keyFile = &Global::getCourseKeyFile($inputs{'course'}); 72 73 #verify session key 74 &verify_key($inputs{'user'}, $inputs{'key'}, $keyFile, $inputs{'course'}); 75 76 # verify permissions are correct 77 if ($permissions != $Global::instructor_permissions ) { 78 print "permissions = $permissions instructor_permissions = $Global::instructor_permissions\n"; 79 print &html_NO_PERMISSION; 80 exit(0); 81 } 82 # get the rest of the information from the submitted form 83 84 my $format = $inputs{'format'}; #alph, section, or recitation 85 my $set_status = $inputs{'set_status'}; #locked or unlocked 86 87 # print HTML text 88 print &htmlTOP("Classlist Utilities"); 89 90 # print navigation buttons 91 print qq! 92 <A HREF="${cgiURL}profLogin.pl?user=$inputs{'user'}&key=$inputs{'key'}&course=$inputs{'course'}"> 93 <IMG SRC="${Global::upImgUrl}" align="right" BORDER=1 ALT="[Up]"></A><p> 94 !; 95 96 print <<EOF; 97 <HR><BR> 98 99 <h3 align="left">WeBWorK classlist editing programs for $Course</h3> 100 101 From this page you can edit classlist database or give a student a new password. 102 You can also import and export the database. <p> 103 EOF 104 105 my $classList_ref; 106 $format = '' unless defined $format; 107 if ($format eq 'section') { 108 $classList_ref = getAllLoginNamesSortedBySectionThenByName(); 109 } 110 elsif ($format eq 'recitation') { 111 $classList_ref = getAllLoginNamesSortedByRecitationThenByName(); 112 } 113 else { 114 $classList_ref = getAllLoginNamesSortedByName(); 115 } 116 117 my @classList = @$classList_ref; 118 119 if ((defined $set_status) and ($set_status eq 'lock')) { 120 lock_CL_database(); 121 } 122 elsif ((defined $set_status) and ($set_status eq 'unlock')) { 123 unlock_CL_database(); 124 } 125 126 my $status = get_CL_database_status(); 127 128 if ($status eq 'locked') { 129 print <<EOF; 130 <P> 131 <FONT COLOR='#ff00aa'><B>CLASSLIST DATABASE IS LOCKED</B></font> <P> 132 This means the database can NOT be updated via the web but the database can be 133 exported to and imported from an ascii comma separated (.cvs) classlist file. 134 135 <HR NOSHADE> 136 <H4 ALIGN=LEFT> 137 <IMG SRC="$Global::bluesquareImgUrl" BORDER=1 ALT=""> 138 1. Unlock the classlist database for $Course. 139 </H4> 140 141 Unlock the database. 142 143 <FORM METHOD = "POST" ACTION= "${cgiURL}profClasslist.pl"> 144 <INPUT TYPE="HIDDEN" NAME='set_status' VALUE='unlock'> 145 <INPUT TYPE="HIDDEN" NAME='user' VALUE="$inputs{'user'}"> 146 <INPUT TYPE="HIDDEN" NAME='key' VALUE="$inputs{'key'}"> 147 <INPUT TYPE="HIDDEN" NAME='course' VALUE="$inputs{'course'}"> 148 <INPUT TYPE="HIDDEN" NAME='format' VALUE="$inputs{'format'}"> 149 <INPUT TYPE="SUBMIT" VALUE= 'Unlock'> 150 </FORM> 151 EOF 152 } 153 154 elsif ($status eq 'unlocked') { 155 156 print <<EOF; 157 <P> 158 <FONT COLOR='#ff00aa'><B>CLASSLIST DATABASE IS UNLOCKED</B></font> <P> 159 This means the database can be updated via the web but the database can NOT be 160 exported to and imported from an ascii comma separated (.cvs) classlist file. 161 162 <HR NOSHADE> 163 <H4 ALIGN=LEFT> 164 <IMG SRC="$Global::bluesquareImgUrl" BORDER=1 ALT=""> 165 1. Lock the classlist database for $Course. 166 </H4> 167 168 Lock the database. 169 170 <FORM METHOD = "POST" ACTION= "${cgiURL}profClasslist.pl"> 171 <INPUT TYPE="HIDDEN" NAME='set_status' VALUE='lock'> 172 <INPUT TYPE="HIDDEN" NAME="user" VALUE="$inputs{'user'}"> 173 <INPUT TYPE="HIDDEN" NAME="key" VALUE="$inputs{'key'}"> 174 <INPUT TYPE="HIDDEN" NAME="course" VALUE="$inputs{'course'}"> 175 <INPUT TYPE="HIDDEN" NAME='format' VALUE="$inputs{'format'}"> 176 <INPUT TYPE="SUBMIT" VALUE= 'Lock'> 177 </FORM> 178 EOF 179 } 180 181 print <<EOF; 182 <P> 183 <HR NOSHADE> 184 <H4 ALIGN=LEFT> 185 <IMG SRC="$Global::bluesquareImgUrl" BORDER=1 ALT=""> 186 2. Edit the classlist database for $Course. 187 </H4> 188 189 Select the student record that you wish to edit. <BR> 190 191 <FORM METHOD = "POST" ACTION= "${cgiURL}profEditClasslistDB.pl"> 192 <INPUT TYPE="SUBMIT" VALUE="Select student"> 193 EOF 194 195 196 197 # enter available individual logins 198 print qq! <BR><SELECT Name='studentLogin' >\n!; 199 my ($lastName, $firstName, $studentID, $login_name, $section, $recitation, $label); 200 201 # get a list of logins to list as option values. save this in a string as we will use it 202 # twice 203 204 my $option_list =''; 205 foreach $login_name (@classList) { 206 attachCLRecord($login_name); 207 ## student 208 $lastName = CL_getStudentLastName($login_name); 209 $firstName = CL_getStudentFirstName($login_name); 210 $studentID = CL_getStudentID($login_name); 211 $section = CL_getClassSection($login_name); 212 $recitation = CL_getClassRecitation($login_name); 213 214 if ($format eq 'section') { 215 $label = ", $section"; 216 } 217 elsif ($format eq 'recitation') { 218 $label = ", $recitation"; 219 } 220 else { 221 $label = ''; 222 } 223 $label = "$lastName, $firstName, $studentID, $login_name". $label; 224 $option_list .= "<OPTION VALUE = \"$login_name\">$label \n"; 225 # print "<OPTION VALUE = \"$login_name\">$label \n"; 226 } 227 print $option_list; 228 print qq! \n</SELECT>\n!; 229 230 # resume printing the rest of the forms 231 232 print <<EOF; 233 <INPUT TYPE="HIDDEN" NAME="user" VALUE="$inputs{'user'}"> 234 <INPUT TYPE="HIDDEN" NAME="key" VALUE="$inputs{'key'}"> 235 <INPUT TYPE="HIDDEN" NAME="course" VALUE="$inputs{'course'}"> 236 <INPUT TYPE="HIDDEN" NAME='save' VALUE='OFF'> 237 <INPUT TYPE="HIDDEN" NAME='firsttime' VALUE=1> 238 239 240 </FORM> 241 EOF 242 243 print <<EOF; 244 <P> 245 <HR NOSHADE> 246 <H4 ALIGN=LEFT> 247 <IMG SRC="$Global::bluesquareImgUrl" BORDER=1 ALT=""> 248 3. Give a student a new password for $Course. 249 </H4> 250 251 Select the student who needs a new password. <BR> 252 253 <FORM METHOD = "POST" ACTION= "${cgiURL}profNewPassword.pl"> 254 <INPUT TYPE="SUBMIT" VALUE="Select student"> 255 EOF 256 257 # enter available individual logins 258 print qq! <BR><SELECT Name='studentLogin' >\n!; 259 print $option_list; 260 print qq! \n</SELECT>\n!; 261 262 # resume printing the rest of the forms 263 264 print <<EOF; 265 <INPUT TYPE="HIDDEN" NAME="user" VALUE="$inputs{'user'}"> 266 <INPUT TYPE="HIDDEN" NAME="key" VALUE="$inputs{'key'}"> 267 <INPUT TYPE="HIDDEN" NAME="course" VALUE="$inputs{'course'}"> 268 <INPUT TYPE="HIDDEN" NAME='save' VALUE='OFF'> 269 <INPUT TYPE="HIDDEN" NAME='firsttime' VALUE=1> 270 271 272 </FORM> 273 EOF 274 275 276 277 print <<EOF; 278 <P> 279 <HR NOSHADE> 280 <H4 ALIGN=LEFT> 281 <IMG SRC="$Global::bluesquareImgUrl" BORDER=1 ALT=""> 282 4. View the classlist database for $Course. 283 </H4> 284 285 Use this to see all the data in the classlist database. You can edit the classlist database 286 by using item 2 above and you can add students to the classlist database from the 287 Add Student(s) Page. You can also use item 5 to 288 export it to a classlist file suitable for editing by a spreadsheet program such as Excel. Item 6 289 imports the classlist database from a classlist file. You can use items 7 and 8 to download and 290 upload classlist files to and from your personal computer. 291 292 EOF 293 294 my %labels = (); 295 $labels{alph} = 'Alphabetically'; 296 $labels{section} = 'By section'; 297 $labels{recitation} = 'By recitation'; 298 299 print $cgi->startform(-action=>"${cgiURL}profViewClasslistDB.pl"), 300 $cgi->submit(-value=>'View classlist Database'), "\n", 301 "Order students \n", 302 $cgi->radio_group( 303 -name=>'format', 304 -values=>['alph','section','recitation'], 305 -default=>'alph', 306 -labels=>\%labels 307 ), 308 $cgi->hidden(-name=>'course', -value=>"$inputs{'course'}"), "\n", 309 $cgi->hidden(-name=>'user', -value=>"$inputs{'user'}"), "\n", 310 $cgi->hidden(-name=>'key', -value=>"$inputs{'key'}"), "\n", 311 $cgi->endform(), "\n", 312 $cgi->p, "\n" ; 313 314 # resume printing the rest of the form 315 316 317 print <<EOF; 318 <P> 319 <HR NOSHADE> 320 <FONT COLOR='#ff00aa'><b>Before exporting or importing the 321 classlist database or downloading or uploading classlist files, make sure you understand 322 the difference between the classlist database and classlist files. Click on help below.</b></font><p> 323 <HR NOSHADE> 324 <H4 ALIGN=LEFT> 325 <IMG SRC="$Global::bluesquareImgUrl" BORDER=1 ALT=""> 326 5. Export the $Course classlist database to a classlist file. 327 </H4> 328 This will export the current classlist database to the 329 selected classlist file. Note the classlist database must locked first. 330 331 EOF 332 333 my $shortFileName = getCourseClasslistFile($Course); 334 if ($shortFileName =~ m|$dd|) { 335 $shortFileName =~ m|$dd([^$dd]*)$|; ## extract filename from full path name 336 $shortFileName = $1; 337 } 338 339 print $cgi->startform(-action=>"${cgiURL}profExportClasslistDatabase.pl"),"\n", 340 $cgi->textfield(-name=>'savefilename', -size => 25, -value=> "$shortFileName", -override=>1), ' ', 341 'Enter a new file name or use the default. The file will be saved with the extension .lst',"\n",p, 342 $cgi->checkbox(-name=>'overWrite',-value => 1, -label => 'Overwrite existing file'),"\n", br, 343 $cgi->checkbox(-name=>'backUp',-value => 1, -label => 'Backup existing file first',-checked, -override),"\n",p, 344 $cgi->submit(-value=>'Export classlist Database'), "\n", 345 $cgi->hidden(-name=>'course', -value=>"$inputs{'course'}"), "\n", 346 $cgi->hidden(-name=>'user', -value=>"$inputs{'user'}"), "\n", 347 $cgi->hidden(-name=>'key', -value=>"$inputs{'key'}"), "\n", 348 $cgi->endform(), "\n", 349 $cgi->p, "\n"; 350 351 352 print <<EOF; 353 <P> 354 <HR NOSHADE> 355 356 <H4 ALIGN=LEFT> 357 <IMG SRC="$Global::bluesquareImgUrl" BORDER=1 ALT=""> 358 6. Import the $Course classlist database from a classlist file. 359 </H4> 360 This will update the classlist database using the information from the 361 selected classlist file. Note the classlist database must locked first. 362 If you have a large classlist and/or have already built many sets, this may 363 take quite a bit of time. Carefully select the classlist file and the 364 options you want.<p> 365 366 EOF 367 368 # get all classlist files 369 my ($ar_sortedNames, $hr_classlistLabels) = getClasslistFilesAndLabels($Course); 370 my @sortedNames = @$ar_sortedNames; 371 my %classlistLabels = %$hr_classlistLabels; 372 373 print $cgi->startform(-action=>"${cgiURL}profImportClasslistDatabase.pl"), 374 $cgi->popup_menu(-name=>'classList', 375 -values=>\@sortedNames, 376 -labels=>\%classlistLabels), ' Select classlist file.',p, 377 378 "If a student is in the current classlist database <FONT COLOR='#ff00aa'><b>and</b></FONT> 379 is in the the selected classlist file:",'<BR>', 380 381 $cgi->checkbox(-name=>'update_firstName',-value => 1, -label => 'update first name', -override), '<BR>', 382 $cgi->checkbox(-name=>'update_lastName',-value => 1, -label => 'update last name', -override),'<BR>', 383 $cgi->checkbox(-name=>'update_status',-value => 1, -label => 'update status', -checked, -override),'<BR>', 384 $cgi->checkbox(-name=>'update_comment',-value => 1, -label => 'update comment', -override), '<BR>', 385 $cgi->checkbox(-name=>'update_section',-value => 1, -label => 'update section', -override),'<BR>', 386 $cgi->checkbox(-name=>'update_recitation',-value => 1, -label => 'update recitation', -override),'<BR>', 387 $cgi->checkbox(-name=>'update_email_address',-value => 1, -label => 'update email_address', -override), '<p>', 388 389 "If a student is in the current classlist database <FONT COLOR='#ff00aa'><b>but is not</b></FONT> 390 in the the selected classlist file:",'<BR>', 391 392 $cgi->input({-type=>'radio', -name=>'update_drop', -value=>'drop',-checked=>1}), " \n", 393 "Change student's status to 'drop' in the classlist database. This removes the student's login privileges and is the 394 recommended action. \n", $cgi->br, 395 $cgi->input({-type=>'radio', -name=>'update_drop', -value=>'leave'}), " \n", 396 "Leave the student's records in the classlist database unchanged.\n", $cgi->br, 397 $cgi->input({-type=>'radio', -name=>'update_drop', -value=>'remove' }), " \n", 398 "Remove the student's records from the classlist database.\n", $cgi->br, 399 400 $cgi->submit(-value=>'Import classlist Database'), "\n",p, 401 $cgi->hidden(-name=>'course', -value=>"$inputs{'course'}"), "\n", 402 $cgi->hidden(-name=>'user', -value=>"$inputs{'user'}"), "\n", 403 $cgi->hidden(-name=>'key', -value=>"$inputs{'key'}"), "\n", 404 $cgi->endform(), "\n", 405 $cgi->p, "\n"; 406 407 408 print <<EOF; 409 <P> 410 <HR NOSHADE> 411 412 <H4 ALIGN=LEFT> 413 <IMG SRC="$Global::bluesquareImgUrl" BORDER=1 ALT=""> 414 415 7. Download (or view) $Course classlist file(s) to your personal computer. 416 </H4> 417 418 You can download files for editing or viewing in either cvs (i.e. comma delimited), html, text, or 419 tab (i.e. tab delimited) format. <BR> 420 csv is a supported format for Excel and is the recommended format if you use Excel. <BR> <BR> 421 422 423 <FORM METHOD = "POST" ACTION= "${cgiURL}profDownloadClasslistFiles.pl"> 424 format: 425 <INPUT TYPE=RADIO NAME="format" VALUE="csv" CHECKED>csv 426 <INPUT TYPE=RADIO NAME="format" VALUE="html" >html 427 <INPUT TYPE=RADIO NAME="format" VALUE="text" >text 428 <INPUT TYPE=RADIO NAME="format" VALUE="tab" >tab <BR> 429 430 <INPUT TYPE="SUBMIT" VALUE="Select file(s)"> 431 432 EOF 433 434 # resume printing the rest of the form 435 436 print <<EOF; 437 <INPUT TYPE="HIDDEN" NAME="user" VALUE="$inputs{'user'}"> 438 <INPUT TYPE="HIDDEN" NAME="key" VALUE="$inputs{'key'}"> 439 <INPUT TYPE="HIDDEN" NAME="course" VALUE="$inputs{'course'}"> 440 <INPUT TYPE="HIDDEN" NAME="download" VALUE= 0 > 441 <INPUT TYPE="HIDDEN" NAME="fileName" VALUE= "" > 442 </FORM> 443 EOF 444 445 446 447 print <<EOF; 448 <P> 449 <HR NOSHADE> 450 <H4 ALIGN=LEFT> 451 <IMG SRC="$Global::bluesquareImgUrl" BORDER=1 ALT=""> 452 8. Upload $Course classlist files from your personal computer. 453 </H4> 454 455 You can upload classlist files from your personal computer in cvs (i.e. comma delimited), 456 tab (i.e. tab delimited), or html format. Usually you would do this after exporting the 457 classlist database to a file, downloading and then editing the file in Excel or some other 458 editor or spreadsheet program. Only valid classlist files 459 can be uploaded. For csv format, the filename on your personal computer must have extension 460 .csv or .lst. For tab format, the extension must be .txt and for html format, the extension 461 must be .html or .htm. The file will be saved on the server with extension .lst (e.g. MTH140A.csv would be 462 saved as MTH140A.lst). Be very careful. Students can change their own email 463 addresses and it is possible that a student my have changed his or her address after you 464 started working on the file. This can only happen if you explicitly unlocked the classlist 465 database after exporting it. 466 467 <FORM METHOD = 'POST' enctype='multipart/form-data' ACTION= "${cgiURL}profUploadClasslistFile.pl"> 468 469 format on personal computer: 470 <INPUT TYPE=RADIO NAME="format" VALUE="csv" CHECKED>csv 471 <INPUT TYPE=RADIO NAME="format" VALUE="tab" >tab 472 <INPUT TYPE=RADIO NAME="format" VALUE="html" >html <BR> 473 <INPUT TYPE=CHECKBOX NAME="overWrite" VALUE=1 unchecked> Overwrite existing file 474 <INPUT TYPE=CHECKBOX NAME="backUp" VALUE=1 checked> Backup existing file first <BR> 475 476 File to upload: <input type=file name=upload><br> 477 <br> 478 <input type=submit value=UpLoad> the file. 479 480 <INPUT TYPE="HIDDEN" NAME="user" VALUE="$inputs{'user'}"> 481 <INPUT TYPE="HIDDEN" NAME="key" VALUE="$inputs{'key'}"> 482 <INPUT TYPE="HIDDEN" NAME="course" VALUE="$inputs{'course'}"> 483 </FORM> 484 EOF 485 486 print <<EOF; 487 <P> 488 <HR NOSHADE> 489 <H4 ALIGN=LEFT> 490 <IMG SRC="$Global::bluesquareImgUrl" BORDER=1 ALT=""> 491 9. Simple editing of $Course classlist files. 492 </H4> 493 494 Use this for simple editing, e.g. changing a few items or adding a couple of new students. 495 For more complicated editing, download the file to a preadsheet program such as Excel by option 7 above. 496 <FONT COLOR='#ff00aa'><b>Note that editing a classlist files has no effect on the classlist database.</b></font> 497 498 <FORM METHOD = "POST" ACTION= "${cgiURL}profFormEditClasslistFiles.pl"> 499 500 <INPUT TYPE="SUBMIT" VALUE="Select file(s)"> 501 502 EOF 503 504 505 506 # resume printing the rest of the form 507 508 print <<EOF; 509 <INPUT TYPE="HIDDEN" NAME="user" VALUE="$inputs{'user'}"> 510 <INPUT TYPE="HIDDEN" NAME="key" VALUE="$inputs{'key'}"> 511 <INPUT TYPE="HIDDEN" NAME="course" VALUE="$inputs{'course'}"> 512 <INPUT TYPE="HIDDEN" NAME="action" VALUE= "" > 513 <INPUT TYPE="HIDDEN" NAME="fileName" VALUE= "" > 514 <INPUT TYPE="HIDDEN" NAME="readWrite" VALUE= "readOnly" > 515 </FORM> 516 EOF 517 518 519 520 521 print &htmlBOTTOM("profClasslist.pl", \%inputs,'profClasslistHelp.html'); 522 523 # begin Timing code 524 if ($logTimingData == 1) { 525 my $endTime = new Benchmark; 526 &Global::logTimingInfo($beginTime,$endTime,'profClasslist.pl',$Course,$User); 527 } 528 # end Timing code 529 exit; 530 531 532 533
| aubreyja at gmail dot com | ViewVC Help |
| Powered by ViewVC 1.0.9 |