[system] / trunk / webwork / system / cgi / cgi-scripts / profLogin.pl Repository:
ViewVC logotype

View of /trunk/webwork/system/cgi/cgi-scripts/profLogin.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 11 - (download) (as text) (annotate)
Mon Jun 18 15:21:51 2001 UTC (11 years, 11 months ago) by sam
File size: 17633 byte(s)
another setup script test (changed #! lines)

    1 #!/usr/local/bin/webwork-perl
    2 
    3 ## $Id$
    4 
    5 ####################################################################
    6 # Copyright @ 1995-1998 University of Rochester
    7 # All Rights Reserved
    8 ####################################################################
    9 
   10 
   11 ## This file is profLogin.pl
   12 ## It provides access to utilities for building, correcting and viewing problem sets
   13 ##
   14 ## It is called from a form with inputs
   15 ## 'user',
   16 ##^'key'
   17 ## 'course'
   18 
   19 use lib '.'; use webworkInit; # WeBWorKInitLine
   20 use CGI qw(:standard);
   21 use Global;
   22 use Auth;
   23 use strict;
   24 
   25 my $logTimingData = 0;
   26 my $beginTime;
   27 
   28 # begin Timing code
   29 if ($logTimingData == 1) {
   30   use Benchmark;
   31   $beginTime = new Benchmark;
   32 }
   33 # end Timing code
   34 
   35 
   36 my $cgi = new CGI;
   37 my %inputs = $cgi->Vars();
   38 
   39 # get information from CGI inputs  (see also below for additional information)
   40 
   41   my $Course    = $cgi->param('course');
   42   my $User    = $cgi->param('user');
   43   my $Session_key   = $cgi->param('key');
   44 
   45 # verify that information has been received
   46   unless($Course && $User && $Session_key) {
   47     &Global::error("Script Error","The script profLogin.pl did not receive the proper input data.","","");
   48     die "The script profLogin.pl did not receive the proper input data.";
   49     }
   50 
   51 # establish environment for this script
   52 
   53   &Global::getCourseEnvironment($Course);
   54 
   55 
   56   my $cgiURL        = $Global::cgiWebworkURL;
   57   my $courseScriptsDirectory  = $Global::courseScriptsDirectory;
   58   my $databaseDirectory     = $Global::databaseDirectory;
   59   my $htmlURL           = $Global::htmlURL;
   60   my $scriptDirectory       = $Global::scriptDirectory;
   61 
   62   require "${scriptDirectory}$Global::DBglue_pl";
   63   require "${scriptDirectory}$Global::classlist_DBglue_pl";
   64   require "${scriptDirectory}$Global::FILE_pl";
   65   require "${scriptDirectory}$Global::HTMLglue_pl";
   66 
   67 # log access
   68   &Global::log_info('', query_string);
   69 
   70 
   71   my $permissionsFile = &Global::getCoursePermissionsFile($Course);
   72   my $permissions = &get_permissions($User, $permissionsFile);
   73   my $keyFile = &Global::getCourseKeyFile($Course);
   74 
   75 #verify session key
   76   &verify_key($User, $Session_key, "$keyFile", $Course);
   77 
   78 # verify permissions are correct
   79   if ($permissions != $Global::instructor_permissions ) {
   80     print "permissions = $permissions instructor_permissions = $Global::instructor_permissions\n";
   81     print &html_NO_PERMISSION;
   82     exit(0);
   83     }
   84 # get the rest of the information from the submitted form
   85   # nothing further to get in this case
   86 
   87   my %availableSets = ();
   88   my @sortedSetNames = ();
   89   my @availableStudents = ();
   90 
   91 # get information from the data base and create database if necessary
   92 
   93 if ( -e "${databaseDirectory}$Global::database" ) {
   94   # a list of all of the currently created sets:
   95   # Keys contains the set numbers and the value is a representative psvn
   96   %availableSets = &getAllProbSetNumbersHash;
   97   @sortedSetNames = &sortSetNamesByDueDate(\%availableSets);
   98   @availableStudents = @{getAllLoginNamesSortedByName()};
   99 }
  100 
  101 # print HTML text
  102 print &htmlTOP("WeBWorK Utilities");
  103 
  104 # print navigation buttons
  105 
  106 print $cgi->a( { -href=>"${cgiURL}login.pl?user=$User&key=$Session_key&course=$Course" },
  107 
  108       $cgi->img({ #  -name=>'upImg', # name is not a legal attribute for images
  109             -src=>"${Global::upImgUrl}",
  110             -align=>'right',
  111             -border=>'1',
  112             -alt=>'[Up]'
  113           })
  114       ),
  115   $cgi->p;
  116 
  117 print "\n",
  118    $cgi->hr, $cgi->br,
  119    "\n\n", $cgi->h3({ -align=>'left' }, "WeBWorK Utility programs for $Course"), "\n",
  120    $cgi->p,
  121    "From this page, you can monitor the progress of students and view their problems, build problem sets,
  122    email students, score sets, edit the classlist database, reset passwords , change properties of built problem sets either for an individual student
  123    or for all students, delete a problem set from the database and perform other tasks.",
  124    $cgi->hr,
  125    $cgi->center(
  126     $cgi->a({-href=>"#Student"}, "Student Progress"), " | ",
  127     $cgi->a({-href=>"#BuildProbSet"}, "Build Problem Set"), " | ",
  128     $cgi->a({-href=>"#Email"}, "Send Email"), " | ",
  129     $cgi->a({-href=>"#Score"}, "Scoring Page"), " | ",
  130     $cgi->a({-href=>"#dataMungerStudent"}, "Change Due Date"), " | ",
  131     $cgi->a({-href=>"#ChangeDates"}, "Edit Problem"), " | ",
  132     $cgi->a({-href=>"#Housekeep"}, "Housekeeping"),
  133    );
  134 
  135 my %sethash; #popup_menu takes a hash for the labels to associate each label with a specific value
  136 my %labels = ();
  137 
  138 if ( -e "${databaseDirectory}$Global::database" ) {
  139 ### show only build problem set part if data base does not exist
  140 
  141 # course data form
  142 print heading('Section', "1. View statistical data on problem sets for the whole course and sections in $Course"),
  143   $cgi->startform(-action=>"${cgiURL}profCourseData.pl"),
  144   $cgi->submit(-value=>'View Course and Section Data'), "\n";
  145 
  146 
  147 foreach (@sortedSetNames) {
  148   $sethash{$_} = "Set $_"; #insert the word Set before each set name
  149 }
  150 
  151 print $cgi->popup_menu(-name=>'setNo', -values=>\@sortedSetNames, -labels=>\%sethash), "\n",
  152   hiddens('user', 'key', 'course'), "\n",
  153   $cgi->endform(), "\n",
  154   "This allows you to see the average score on a set and on individual problems for
  155   the course as a whole and also by section.  The average number of incorrect
  156   attempts per problem is also displayed.";
  157 
  158 # course recitation data form
  159 print heading('Recitation', "2. View statistical data on problem sets for the whole course and recitations in $Course"),
  160   $cgi->startform(-action=>"${cgiURL}profCourseRecData.pl"),
  161   $cgi->submit(-value=>'View Course and Recitation Data'), "\n";
  162 
  163 
  164 
  165 print $cgi->popup_menu(-name=>'setNo', -values=>\@sortedSetNames, -labels=>\%sethash), "\n",
  166   hiddens('user', 'key', 'course'),
  167   $cgi->endform(), "\n",
  168   "This allows you to see the average score on a set and on individual problems for
  169   the course as a whole and also by recitation.  The average number of incorrect
  170   attempts per problem is also displayed.";
  171 
  172 
  173 
  174 # classlist.pl form -- view set data for the entire class
  175 
  176 print heading('Student', "3. View students progress on problem sets in $Course:"),
  177   $cgi->startform(-action=>"${cgiURL}classlist.pl"),
  178   $cgi->submit(-value=>'View Students Progress'), "\n",
  179   $cgi->popup_menu(-name=>'setNo', -values=>\@sortedSetNames, -labels=>\%sethash), "\n",
  180   $cgi->br, "\n",
  181   "Order students \n",
  182   $cgi->radio_group(-name=>'sortOrder', -values=>['byCourse','bySection','byRecitation'], -labels=>{ 'byCourse'=>'Alphabetically', 'bySection'=>'by section ', 'byRecitation'=>'by recitattion '}),
  183   hiddens('user', 'key', 'course'),
  184   $cgi->hidden(-name=>'pCl', -value=>1), "\n",
  185   $cgi->endform(), "\n",
  186   "This also allows you to find the psvn for a given student and to view
  187   the problems as viewed by the student.  You can see the exact answer expected
  188   by WeBWorK and also, if you wish, answer the problem for the student.";
  189 
  190 
  191 } ### end of if ( -e "${databaseDirectory}$Global::database" )
  192 ### show only build problem set part if data base does not exist
  193 
  194 ##  build problem set page form
  195 print heading('BuildProbSet', "4. Build problem sets for $Course:"),
  196   $cgi->startform(-action=>"${cgiURL}profBuildProblemSetPage.pl"),
  197   $cgi->submit(-value=>'Enter Build Problem Set Page'), "\n",
  198   hiddens('user', 'key', 'course'),
  199   $cgi->endform(), "\n",
  200   $cgi->p, "\n",
  201   "You can build problem sets, edit set definition files, etc.";
  202 
  203 
  204 if ( -e "${databaseDirectory}$Global::database" ) {
  205 ### show only build problem set part if data base does not exist
  206 
  207 
  208 #send email to students
  209 print heading('Email', "5. Send Email to Students for $Course:"),
  210   $cgi->startform(-action=>"${cgiURL}profSendMail.pl"),
  211   $cgi->submit(-value=>'Enter Send Mail Page'), "\n",
  212   hiddens('user', 'key', 'course'),
  213   $cgi->endform(), "\n",
  214   $cgi->p, "\n",
  215   "You can create and edit emails and send them to individual students or entire classlist
  216   at one time.  Macros can be used to insert student specific information into each students
  217   email on the fly.";
  218 
  219 ##  scoring page form
  220 print heading('Score', "6. Scoring procedures for $Course:"),
  221   $cgi->startform(-action=>"${cgiURL}profScoring.pl"),
  222   $cgi->submit(-value=>'Enter Scoring Page'), "\n",
  223   hiddens('user', 'key', 'course'),
  224   $cgi->endform(), "\n",
  225   $cgi->p, "\n",
  226   "You can score problem sets, download and upload spreadsheet scoring files, etc.";
  227 
  228 ##  add student form
  229 print heading('AddStudents', "7. Add Student(s) to $Course:"),
  230   $cgi->startform(-action=>"${cgiURL}profAddStudent.pl"),
  231   $cgi->submit(-value=>'Enter Add Student(s) Page'), "\n",
  232   $cgi->hidden(-name=>'number', -value=>'5'), "\n",
  233   $cgi->hidden(-name=>'Action', -value=>'return'), "\n",
  234   hiddens('user', 'key', 'course'),
  235   $cgi->endform(), "\n",
  236   $cgi->p, "\n",
  237   "You can add students to $Course.  This is usually used to add students who enter the course late.";
  238 
  239 ##  classlist page form
  240 
  241 $labels{alph} = 'Alphabetically';
  242 $labels{section} = 'by section';
  243 $labels{recitation} = 'by recitation';
  244 
  245 print heading('profClasslist', "8. Edit classlist database for $Course:"),
  246   $cgi->startform(-action=>"${cgiURL}profClasslist.pl"),
  247   $cgi->submit(-value=>'Enter Classlist Page'), "\n",
  248   $cgi->br, "\n",
  249   "Order students \n",
  250   $cgi->radio_group(-name=>'format', -values=>['alph','section','recitation'], -default=>'alph', -labels=>\%labels),
  251   hiddens('user', 'key', 'course'),
  252   $cgi->endform(), "\n",
  253   $cgi->p, "\n",
  254   "You can edit, export and import the classlist database and also reset passwords.";
  255 
  256 
  257 
  258 
  259 
  260 ##dataMunger form -- allows you to modify data for individualized set
  261 ## psvn is derived from the student name and the set number
  262 
  263 print heading('dataMungerStudent', "9. Examine or modify data for an individual student in $Course:"),
  264    $cgi->startform(-action=>"${cgiURL}dataMunger.pl"),
  265    $cgi->submit(-value=>'Examine or change individual problem set data for:'), "\n";
  266 
  267 my ($key, $id, $lname, $fname, @logins, %fullnames);
  268 foreach $key (@availableStudents) {
  269   &attachCLRecord($key) || print "no Record $key\n";
  270   $lname = &CL_getStudentLastName($key);
  271   $fname = &CL_getStudentFirstName($key);
  272   push (@logins, $key); #array for values of popup_menu
  273   $fullnames{$key} = "$lname, $fname";
  274 }
  275 
  276 print $cgi->br,
  277   $cgi->popup_menu(-name=>"studentLogin", -values=>\@logins, -labels=>\%fullnames), "\n",
  278   $cgi->popup_menu(-name=>'setNo', -values=>\@sortedSetNames, -labels=>\%sethash), "\n",
  279   $cgi->hidden(-name=>'save', -value=>"OFF"), "\n",
  280   $cgi->hidden(-name=>'firsttime', -value=>1), "\n",
  281   hiddens('user', 'key', 'course'),
  282   $cgi->hidden(-name=>'pCD', -value=>'1'), "\n",
  283   $cgi->endform(), "\n",
  284   "Use this to make changes for an individual student. For example, you can extend the due date for an individual student or change the status
  285   (correct, incorrect) or number of allowed attempts on a problem.  You will also be able to download a postscript file of
  286   this version of the problem set.  If you know the psvn number, e.g. from
  287   3 above (\"View Students Progress\"), you can enter this psvn number directly in 10 below
  288   (\"Examine or change database for psvn\").  Note that you will get an error message if the
  289   problem set has not been built for the student you select.\n";
  290 
  291 
  292 
  293 ## dataMunger form -- allows you to modify indidual versions of the problem
  294 print heading('dataMungerPSVN', "10. Examine or modify data for an individual student in $Course:"),
  295   $cgi->startform(-action=>"${cgiURL}dataMunger.pl"),
  296   $cgi->submit(-value=>'Examine or change data for psvn:'), "\n",
  297   $cgi->textfield(-name=>'probSetKey', -col=>'15', -value=>'Enter PSVN'), "\n",
  298   $cgi->hidden(-name=>'save', -value=>'OFF'), "\n",
  299   $cgi->hidden(-name=>'firsttime', -value=>1), "\n",
  300   hiddens('user', 'key', 'course'),
  301   $cgi->endform(), "\n",
  302   "Use this to make changes for an individual student. For example, you can extend the due date for an individual student or change the status
  303   (correct, incorrect) or number of allowed attempts of a problem.  You will also be able to download a postscript file of
  304   this version of the problem set.";
  305 
  306 
  307 ## profChangeDates form -- allows you to modify data for entire sets
  308 
  309 
  310 print heading('ChangeDates', "11. Examine or modify data for all students in $Course:"),
  311   $cgi->startform(-action=>"${cgiURL}profChangeDates.pl"),
  312   $cgi->submit(-value=>'Examine or change database for entire set:'), "\n",
  313   $cgi->popup_menu(-name=>'setNo', -values=>\@sortedSetNames, -labels=>\%sethash),
  314   hiddens('user', 'key', 'course'),
  315   $cgi->hidden(-name=>'pCD', -value=>'1'), "\n",
  316   $cgi->endform(), "\n",
  317   "For example, you can extend the due date for the entire class or change the status
  318   of a problem for all students.";
  319 
  320 
  321 $labels{alph} = 'Alphabetically';
  322 $labels{section} = 'by section';
  323 $labels{recitation} = 'by recitation';
  324 
  325 print heading('PaperCopies', "12. Download paper copies for some or all students in $Course:"),
  326   $cgi->startform(-action=>"${cgiURL}profDownloadPaperCopies.pl"),
  327   $cgi->submit(-value=>'Download paper copies'), "\n",
  328   $cgi->popup_menu(-name=>'setNo', -values=>\@sortedSetNames, -labels=>\%sethash),
  329   $cgi->br, "\n",
  330     "Order students \n",
  331   $cgi->radio_group(-name=>'format', -values=>['alph','section','recitation'], -default=>'alph', -labels=>\%labels),
  332   hiddens('user', 'key', 'course'),
  333   $cgi->hidden(-name=>'pCD', -value=>'1'), "\n",
  334   $cgi->endform(), "\n",
  335   "You can download a postscript (or pfd, tex, dvi) file containing prints outs for selected students.";
  336 
  337 
  338 
  339 # delete an entire problem set
  340 print heading('DeleteProbSet', "13. Delete problem set(s) in $Course:"),
  341   $cgi->startform(-action=>"${cgiURL}profDeleteProbSet.pl"),
  342   $cgi->submit(-value=>'Enter Delete Problem Set Page'), "\n",
  343   hiddens('user', 'key', 'course'),
  344   $cgi->endform(), "\n",
  345   $cgi->p, "\n",
  346   "You can delete Problem Sets for the whole class.";
  347 
  348 
  349 ##  housekeeping page form
  350 print heading('Housekeep', "14. Housekeeping utilities for $Course:"),
  351   $cgi->startform(-action=>"${cgiURL}profHousekeeping.pl"),
  352   $cgi->submit(-value=>'Enter Housekeeping Page'), "\n",
  353   hiddens('user', 'key', 'course'),
  354   $cgi->endform(), "\n",
  355   $cgi->p, "\n",
  356   "You can recover disk space by removing old tmp files,
  357   compress the gdbm database, show users currently logged in, etc.";
  358 
  359 }
  360 
  361 
  362 
  363 ## older scripts are archived here
  364 
  365 
  366 ## View class grades
  367 #print heading("12. View grades for $Course:"),
  368 #  $cgi->startform(-action=>"${cgiURL}classGradeSummary.pl"),
  369 #  $cgi->submit(-value=>'View Grades'), "\n",
  370 #  $cgi->hidden(-name=>'course', -value=>$Course), "\n",
  371 #  $cgi->hidden(-name=>'user', -value=>$User), "\n",
  372 #  $cgi->hidden(-name=>'key', -value=>$Session_key), "\n",
  373 #  $cgi->endform(), "\n",
  374 #  $cgi->p, "\n",
  375 #  "You can view a summary of all grades for all students in all sets.";
  376 #
  377 
  378 
  379 
  380 
  381 ### end of second if ( -e "${databaseDirectory}$Global::database" )
  382 ### show only build problem set part if data base does not exist
  383 
  384 
  385 #print <<EOF;
  386 #<HR SIZE=5 NOSHADE>
  387 #<H3 ALIGN=CENTER>Older scripts:</H3>
  388 #EOF
  389 #
  390 ## oldclasslist.pl -- dumps much of the database for inspection
  391 #print <<EOF;
  392 #<HR>
  393 #<FORM METHOD = "POST" ACTION= "${cgiURL}oldclasslist.pl">
  394 #         <INPUT TYPE="SUBMIT" VALUE="View Class List">
  395 #         <INPUT TYPE="HIDDEN" NAME="user" VALUE="$inputs{'user'}">
  396 #         <INPUT TYPE="HIDDEN" NAME="key" VALUE="$inputs{'key'}">
  397 #         <INPUT TYPE="HIDDEN" NAME="course" VALUE="$inputs{'course'}">
  398 #        </FORM>
  399 #An older version of the view class list script which allows you to view all sets and
  400 #much of the information available in the database.
  401 #EOF
  402 
  403 # other scripts
  404 #print <<EOF;
  405 #<HR>
  406 #Enter WeBWorK as a student
  407 #    <p>
  408 #    <a href="${cgiURL}profProbSet.pl?user=$inputs{'user'}&key=$inputs{'key'}&course=$inputs{'course'}">
  409 #    <img src="$Global::bluesquareImgUrl"
  410 #        border=1
  411 #        alt=""> profProbSet.pl</a> -- not working
  412 #
  413 #<P><HR>
  414 #
  415 #
  416 #
  417 #
  418 #<P>
  419 #
  420 #
  421 #<P>profProbSet.pl script:
  422 #<a href="${cgiURL}profProbSet.pl?user=$inputs{'user'}&key=$inputs{'key'}&course=$inputs{'course'}">
  423 #     <B>Test a Problem Set</B></a> -- not working
  424 #    <BR>
  425 #
  426 #
  427 #
  428 #EOF
  429 #<H3 align="center">List of Problem Sets</H3>
  430 # These are not really needed since there is a separate script for viewing and changing dates.
  431 #my %setNumberHash=&getAllSetNumbersForStudentLoginHash('gage');
  432 #&printProbSets("",\%setNumberHash);
  433 
  434 print &htmlBOTTOM("profLogin.pl", \%inputs);
  435 
  436 # begin Timing code
  437 if ($logTimingData == 1) {
  438   my $endTime = new Benchmark;
  439   &Global::logTimingInfo($beginTime,$endTime,'profLogin.pl',$Course,$User);
  440 }
  441 # end Timing code
  442 exit;
  443 
  444 ################################################################################
  445 #
  446 # HELPFUL METHODS
  447 #
  448 ################################################################################
  449 
  450 #returns the horizontal line, blue square, and heading for each option
  451 #in the list, eliminating the need to repeat this code each time it is needed
  452 #this does NOT PRINT the info, so that it can be incorporated into other text
  453 sub heading {
  454         my $link = shift; #name for internal link (used for shortcuts on some pages)
  455         my $text = shift; #text used as the main heading
  456 
  457         return "\n",
  458                  $cgi->p, "\n",
  459                  $cgi->a({-name=>$link}, ''), "\n",
  460                  $cgi->hr({ -noshade=>undef }), "\n",
  461                  $cgi->h4({ -align=>'LEFT' },
  462                                 "\n" . $cgi->img({-src=>"$Global::bluesquareImgUrl", -border=>1, -alt=>'' }) . "\n" .
  463                                 $text ), "\n";
  464 }
  465 
  466 #prints hidden form fields for each of given cgi parameters
  467 #if a given parameter does not exist, a note is placed in the html to that affect
  468 #this does NOT PRINT the info, so that it can be incorporated into other text
  469 sub hiddens {
  470   my @params = @_;
  471   my $out;
  472 
  473   foreach my $param (@params) {
  474     if (exists $inputs{$param}) {
  475       $out .= $cgi->hidden(-name=>"$param", -value=>"$inputs{$param}") . "\n";
  476     } else {
  477       $out .= $cgi->p . "\nExpected cgi parameter $param does not exist or is empty";
  478     }
  479   }
  480   $out;
  481 }

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9