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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 550 - (download) (as text) (annotate)
Fri Sep 13 23:25:08 2002 UTC (10 years, 8 months ago) by jj
File size: 22835 byte(s)
Adjust for new location of dvipng images.

    1 #!/usr/local/bin/webwork-perl
    2 
    3 
    4 ####################################################################
    5 # Copyright @ 1995-1998 University of Rochester
    6 # All Rights Reserved
    7 ####################################################################
    8 
    9 ## This script is profEditClasslistDB.pl ##
   10 
   11 ###############################################################################
   12 ############          PRELIMINARY SETUP                 #######################
   13 ###############################################################################
   14 
   15 use lib '.'; use webworkInit; # WeBWorKInitLine
   16 
   17 use Global;
   18 use CGI qw(:standard);
   19 use Auth;
   20 use TimeLocal; # the module Time::Local.pm has a bug which interacts
   21          # with DProf.  (They call a subroutine assuming @_ doesn't change.
   22 
   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 my $cgi = new CGI;
   36 
   37 &CGI::ReadParse(*main::inputs);
   38 my %inputs=%main::inputs;
   39 
   40 # get primary data from CGI form
   41 my $User       = $inputs{'user'};
   42 my $Course     = $inputs{'course'};
   43 my $Key        = $inputs{'key'};
   44 
   45 
   46 # set course environment
   47 &Global::getCourseEnvironment($Course);
   48 
   49 my  $scriptDirectory   = getWebworkScriptDirectory($Course);
   50 my  $databaseDirectory = getCourseDatabaseDirectory($Course);
   51 my  $cgiURL          = getWebworkCgiURL($Course);
   52 my  $htmlURL           = getCourseHtmlURL($Course);
   53 my  $logsDirectory     = getCourseLogsDirectory($Course);
   54 
   55 require "${scriptDirectory}$Global::DBglue_pl";
   56 require "${scriptDirectory}$Global::classlist_DBglue_pl";
   57 require "${scriptDirectory}$Global::FILE_pl";
   58 require "${scriptDirectory}HTMLglue.pl";
   59 
   60 my $keyFile       = getCourseKeyFile($Course);
   61 &verify_key($inputs{'user'}, $inputs{'key'}, "$keyFile", $inputs{'course'});
   62 
   63 my $passwordFile = &Global::getCoursePasswordFile($inputs{'course'});
   64 my $permissionsFile = &Global::getCoursePermissionsFile($inputs{'course'});
   65 my $permissions = &get_permissions($inputs{'user'}, $permissionsFile);
   66 
   67 if ($permissions != $Global::instructor_permissions ) {
   68   print "permissions = $permissions instructor_permissions = $Global::instructor_permissions\n";
   69   print &html_NO_PERMISSION;
   70   }
   71 
   72 
   73 # get additional data from calling CGI form
   74 my ($Mode, $studentLogin,$action);
   75 
   76 $Mode        = "HTML";   #default viewing mode
   77 $Mode = $inputs{'Mode'} if defined($inputs{'Mode'});
   78 $studentLogin = $inputs{'studentLogin'};
   79 $action = $inputs{'action'};
   80 
   81 wwerror("No Student Selected", "Go back and select the student whose record you want to view or edit")
   82   unless defined $studentLogin;
   83 
   84 # the following are used to send warning messages if a unique section
   85 # or recitation name is saved. They are set in updateDatabase()
   86 my $section_status = 'non_unique';
   87 my $recitation_status = 'non_unique';
   88 my $section_status_ref = \$section_status;
   89 my $recitation_status_ref = \$recitation_status;
   90 
   91 if (defined( $inputs{'save'} ) and ($inputs{'save'} eq "ON" ) and ($action =~ /SAVE/) )  {
   92   # in this case we obtain the data from the CGI from and store it in the database
   93   my $status = get_CL_database_status();
   94   if ($status eq 'locked') {
   95     wwerror("The Classlist Database is LOCKED", "This means the database can not be updated from the internet.
   96 Go back and unlock the Classlist Database before proceeding.");
   97   }
   98   # update the database from the CGI script:
   99 
  100   $studentLogin = &updateDatabase($studentLogin);
  101             # loads the information into %CLRecord,
  102             # modifies the data and saves it back to the database
  103 
  104   #log the changes:  -- the format for loggin the changes needs improvement
  105   &logChanges( getClassListRecord()  );
  106   &print_modification_form;
  107 
  108 }
  109 
  110 elsif (defined( $inputs{'save'} ) and ($inputs{'save'} eq "ON" ) and ($action =~ /REMOVE/) )  {
  111   my $status = get_CL_database_status();
  112   if ($status eq 'locked') {
  113     wwerror("The Classlist Database is LOCKED", "This means the database can not be updated from the internet.
  114 Go back and unlock the Classlist Database before proceeding.");
  115   }
  116   &check_Record($studentLogin);
  117 }
  118 
  119 elsif (defined( $inputs{'save'} ) and ($inputs{'save'} eq "ON" ) and ($action =~ /DO/) )  {
  120   my $status = get_CL_database_status();
  121   if ($status eq 'locked') {
  122     wwerror("The Classlist Database is LOCKED", "This means the database can not be updated from the internet.
  123 Go back and unlock the Classlist Database before proceeding.");
  124   }
  125   &removeRecord($studentLogin);
  126 }
  127 
  128 elsif (defined($inputs{'save'}) && $inputs{'save'} eq "OFF" ){
  129   # No new information in the calling CGI form
  130   # and the information has already been loaded into %probSetRecord using &fetchProbSetRecord($psvn);
  131   # Nothing needs to be done in this case except print the form
  132   &print_modification_form;
  133 
  134 } else {
  135 #   The calling CGI script must define the 'save' variable or the 'deleteMode' variable
  136   wwerror( $0,  "No value for 'save' mode in the calling CGI form");
  137 }
  138 
  139 # begin Timing code
  140 if ($logTimingData == 1) {
  141   my $endTime = new Benchmark;
  142   &Global::logTimingInfo($beginTime,$endTime,'profEditClasslistDB.pl',$Course,$User);
  143 }
  144 # end Timing code
  145 exit;
  146 
  147 #### END of main program
  148 
  149 ###############################################################################
  150 ############################  SUBROUTINES          ############################
  151 ###############################################################################
  152 
  153 
  154 ###############################################################################
  155 ##########################       PRINT FORM      ##############################
  156 ###############################################################################
  157 sub print_modification_form {
  158   print &htmlTOP('Classlist database edit form');
  159   print <<END_OF_HTML;
  160 
  161   <A HREF="${cgiURL}profClasslist.pl?user=$inputs{'user'}&key=$inputs{'key'}&course=$inputs{'course'}&format=section">
  162   <IMG SRC="${Global::upImgUrl}" align="right" BORDER=1 ALT="[Up]"></A><p>
  163   <H3 ALIGN ="CENTER">Course Name: <FONT COLOR="#AA4400"> $inputs{'course'}</FONT>
  164   Data for Student Login: <FONT COLOR="#AA4400">$studentLogin</FONT></H3>
  165   <HR SIZE =2>
  166   <FORM ACTION="${cgiURL}profEditClasslistDB.pl" METHOD=POST>
  167 
  168   Changes can be saved only if the Read/Write Mode button is selected: <BR>
  169 
  170   <INPUT TYPE="radio" CHECKED NAME="save" VALUE="OFF" > Read Only Mode <BR>
  171   <INPUT TYPE="radio" NAME="save" VALUE="ON"> Read/Write Mode  <BR>
  172   <INPUT TYPE='HIDDEN' NAME='firsttime' VALUE= 0>
  173 
  174 END_OF_HTML
  175 
  176 
  177   ######################################################
  178   # return messages
  179   #print message about saving to the database and current mode of CGI form
  180   if (defined( $inputs{'firsttime'} ) && $inputs{'firsttime'} == 0 ) {
  181     if (defined( $inputs{'save'} ) && $inputs{'save'} eq "ON" ) {
  182       print "<P><FONT COLOR='#ff00aa'><B>CLASSLIST DATABASE MODIFIED</B></font> <P>";
  183     } elsif (defined($inputs{'save'}) && $inputs{'save'} eq "OFF" ){
  184 
  185       print "<P><FONT COLOR='#ff00aa'><B>READ ONLY MODE:  CLASSLIST DATABASE UNCHANGED</B></font> <P>";
  186 
  187     } else {
  188   #   When initially entering this CGI the 'save' mode is undefined.
  189       wwerror( $0,  "No value for 'save' mode.</B><P>");
  190     }
  191   }
  192 
  193   # Get set data
  194   attachCLRecord($studentLogin);
  195                          ## student
  196   my $StudentLastName   = CL_getStudentLastName($studentLogin);
  197   my $StudentFirstName  = CL_getStudentFirstName($studentLogin);
  198   my $StudentStatus   = CL_getStudentStatus($studentLogin);
  199   my $StudentComment    = CL_getComment($studentLogin);
  200   my $ClassSection    = CL_getClassSection($studentLogin);
  201   my $ClassRecitation   = CL_getClassRecitation($studentLogin);
  202   my $StudentEmail    = CL_getStudentEmailAddress($studentLogin);
  203   my $StudentID     = CL_getStudentID($studentLogin);
  204 
  205   if ($section_status eq 'unique') {
  206     print "<P><FONT COLOR='#ff00aa'><B>$StudentFirstName $StudentLastName is the only
  207     person in the section $ClassSection</B></font> <P>";
  208   }
  209 
  210   if ($recitation_status eq 'unique') {
  211     print "<P><FONT COLOR='#ff00aa'><B>$StudentFirstName $StudentLastName is the only
  212     person in the recitation $ClassRecitation</B></font> <P>";
  213   }
  214 
  215 
  216   # submit button
  217 
  218   print qq!<INPUT TYPE='SUBMIT' NAME = 'action' VALUE='SAVE CHANGES'><INPUT TYPE = "RESET" VALUE= "RESET FORM"><INPUT TYPE='SUBMIT' NAME = 'action' VALUE='REMOVE THIS RECORD'> <BR>!;
  219 
  220   # Get set data
  221 
  222 
  223   # continue printing form ######################################################
  224   print &sessionKeyInputs(\%inputs);
  225   print qq!<INPUT TYPE='HIDDEN' NAME='studentLogin' VALUE="$studentLogin">!;
  226   print qq! <TABLE BORDER="1" CELLPADDING="1" CELLSPACING="2" > <FONT SIZE=-2>!;
  227 
  228   print "<TR>\n";
  229     print &formatHeaderCell("Last Name");
  230     print &formatHeaderCell("First Name");
  231     print &formatHeaderCell("Student ID" );
  232   print "</TR>\n";
  233   print "<TR>\n";
  234     print &formatDataCell("StudentLastName",$StudentLastName, "20");
  235     print &formatDataCell("StudentFirstName", $StudentFirstName, "20");
  236     print &formatDataCell("StudentID", $StudentID, "30");
  237   print "</TR>\n";
  238 
  239   print "<TR>\n";
  240     print &formatHeaderCell("Student login name");
  241     print &formatHeaderCell("Enrollment Status");
  242     print &formatHeaderCell('Comment' );
  243   print "</TR>\n";
  244   print "<TR>\n";
  245     print &formatDataCell('StudentLogin',$studentLogin, "20");
  246     print &formatDataCell('StudentStatus',$StudentStatus, "20");
  247     print &formatDataCell('Comment', $StudentComment, "30");
  248   print "</TR>\n";
  249 
  250   print "<TR>\n";
  251     print &formatHeaderCell('Section');
  252     print &formatHeaderCell('Recitation');
  253     print &formatHeaderCell('Email Address');
  254   print "</TR>\n";
  255 
  256   print "<TR>\n";
  257     print &formatDataCell('ClassSection', $ClassSection, "20");
  258     print &formatDataCell('ClassRecitation', $ClassRecitation, "20");
  259     print &formatDataCell('StudentEmail', $StudentEmail, "30");
  260   print "</TR>\n";
  261 
  262 
  263 
  264   print ' </FONT></TABLE>';
  265 
  266   print '<BR>The drop down lists below are for information only. Selecting items from them
  267   does nothing.<BR> Enter the section, recitation, and enrollment status, if any, above. <BR>';
  268   # Current Sections list
  269 
  270   print $cgi -> popup_menu( -name => 'currentSections',
  271     -values => ['List of current sections', keys (%{getAllSections()})]
  272         );
  273 
  274   # Current Recitations list
  275   print $cgi -> popup_menu( -name => 'currentRecitations',
  276     -values => ['List of current recitations', keys (%{getAllRecitations()})]
  277         );
  278   # Current Drop List
  279 
  280   my @drop_status_labels = getStatusDrop();
  281 
  282   print $cgi -> popup_menu( -name => 'dropStatus',
  283     -values => ['Valid Drop Status',@drop_status_labels]
  284         );
  285   print 'Any other status (e.g. "C") indicates a current student.';
  286 
  287   print q!</FORM>!;
  288 
  289   print &htmlBOTTOM('profEditClasslistDB.pl', \%inputs);
  290 
  291 }  # end of print_modification_form
  292 
  293 
  294 sub updateDatabase {
  295 
  296   my $studentLogin = shift @_;
  297   attachCLRecord($studentLogin);
  298 
  299   my $orgStudentLastName  = CL_getStudentLastName($studentLogin);
  300   my $orgStudentFirstName = CL_getStudentFirstName($studentLogin);
  301   my $orgStudentID    = CL_getStudentID($studentLogin);
  302   my $orgStudentStatus  = CL_getStudentStatus($studentLogin);
  303   my $orgStudentLogin   = $studentLogin;
  304 
  305   my $newStudentLastName    = stripWhiteSpace($inputs{'StudentLastName'});
  306   my $newStudentFirstName   = stripWhiteSpace($inputs{'StudentFirstName'});
  307   my $newStudentStatus    = stripWhiteSpace($inputs{'StudentStatus'});
  308   my $newComment        = stripWhiteSpace($inputs{'Comment'});
  309   my $newClassSection     = stripWhiteSpace($inputs{'ClassSection'});
  310   my $newClassRecitation    = stripWhiteSpace($inputs{'ClassRecitation'});
  311   my $newStudentEmail     = stripWhiteSpace($inputs{'StudentEmail'});
  312   my $newStudentID      = stripWhiteSpace($inputs{'StudentID'});
  313   my $newStudentLogin     = stripWhiteSpace($inputs{'StudentLogin'});
  314 
  315   ## test entries for bad characters.
  316   my @entries = ($newStudentLastName, $newStudentFirstName, $newStudentStatus, $newComment, $newClassSection,
  317     $newClassRecitation, $newStudentEmail);
  318   my $item ='';
  319   foreach $item (@entries) {
  320     my $msg = test_entry($item);
  321     unless ($msg eq 'OK') {
  322       &wwerror('Bad Entry',$msg);
  323     }
  324      }
  325 
  326   ## test student login and ID for validity.
  327   my $studentLoginChanged = 0;
  328   if ($newStudentLogin ne $orgStudentLogin) {
  329     $studentLoginChanged = 1;
  330     my $msg = testNewStudentLogin($newStudentLogin,$newStudentID);
  331     unless ($msg eq 'OK') {
  332           &wwerror('Bad Login Name',$msg);}
  333   }
  334   my $studentIDChanged = 0;
  335   if ($newStudentID ne $orgStudentID) {
  336     $studentIDChanged = 1;
  337     my $msg = testNewStudentID($newStudentID,$newStudentLogin);
  338     unless ($msg eq 'OK') {
  339           &wwerror('Bad Student ID',"$msg");}
  340   }
  341 
  342   if ($studentLoginChanged and $studentIDChanged) {
  343       warningMsgPage(\%inputs,$orgStudentFirstName,$orgStudentLastName,$newStudentFirstName,$newStudentLastName);
  344       exit(0);
  345   }
  346 
  347   # these will be set to zero if the new section or recitation is unique
  348   my $uniqueSection = 0;
  349   my %section_hash = %{getAllSections()};
  350   $uniqueSection = $section_hash{$newClassSection} if defined $section_hash{$newClassSection};
  351 
  352   my $uniqueRecitation = 0;
  353   my %recitation_hash = %{getAllRecitations()};
  354   $uniqueRecitation = $recitation_hash{$newClassRecitation} if defined $recitation_hash{$newClassRecitation};
  355 
  356   $$section_status_ref = 'unique' unless $uniqueSection;
  357   $$recitation_status_ref = 'unique' unless $uniqueRecitation;
  358 
  359 
  360   if ($studentLoginChanged) {
  361 
  362     # update the webwork database if it exists and sets have been built for the student
  363     if ( -e "${databaseDirectory}$Global::database" ){
  364       if (setsExistForStudentLogin($studentLogin)) {
  365         my %setNumberHash=&getAllSetNumbersForStudentLoginHash($studentLogin);
  366         my @PSVNs = values %setNumberHash;
  367         my $psvn;
  368         foreach $psvn (@PSVNs) {
  369           attachProbSetRecord($psvn);
  370           putStudentLogin($newStudentLogin, $psvn);
  371           detachProbSetRecord($psvn);
  372         }
  373       }
  374     }
  375 
  376     # update the password and permissions databases
  377     change_user_in_password_file($newStudentLogin, $orgStudentLogin,$passwordFile);
  378     change_user_in_permissions_file($newStudentLogin, $orgStudentLogin,$permissionsFile);
  379   }
  380 
  381   if (&dropStatus($newStudentStatus) !=  &dropStatus($orgStudentStatus)) {
  382     if (&dropStatus($newStudentStatus)) {
  383       delete_password($newStudentLogin,$passwordFile);
  384       delete_permissions($newStudentLogin,$permissionsFile);
  385     }
  386     else {
  387       new_password($newStudentLogin,$newStudentID,$passwordFile);
  388       put_permissions(0,$newStudentLogin,$permissionsFile);
  389     }
  390   }
  391   # update the classlist database
  392 
  393   if ($studentLoginChanged) {
  394     deleteClassListRecord($orgStudentLogin);
  395     $studentLogin = $newStudentLogin;
  396   }
  397 
  398   &CL_putStudentLastName(   $newStudentLastName ,$studentLogin);
  399   &CL_putStudentFirstName(  $newStudentFirstName,$studentLogin);
  400   &CL_putStudentStatus(   $newStudentStatus ,$studentLogin);
  401   &CL_putComment(       $newComment     ,$studentLogin);
  402   &CL_putClassSection(    $newClassSection  ,$studentLogin);
  403   &CL_putClassRecitation(   $newClassRecitation ,$studentLogin);
  404   &CL_putStudentEmailAddress( $newStudentEmail  ,$studentLogin);
  405   &CL_putStudentID(     $newStudentID   ,$studentLogin);
  406 
  407   # save the updated information to the database
  408   saveCLRecord($studentLogin);
  409   $studentLogin;               ## return the possibly new studentLogin
  410 
  411 }
  412 sub check_Record {
  413   my $studentLogin = shift @_;
  414 
  415   my $setsExist = 0;
  416   my @SetNumberKeys = ();
  417 
  418   # check to see if there is data for this student in the WW DB
  419 
  420   if ( -e "${databaseDirectory}$Global::database" ){
  421     $setsExist = &setsExistForStudentLogin($studentLogin);
  422     if ($setsExist) {
  423       my %setNumberHash=&getAllSetNumbersForStudentLoginHash($studentLogin);
  424       @SetNumberKeys =  keys(%setNumberHash);
  425     }
  426   }
  427   removeRecordWarningPage(\%inputs,$studentLogin,$setsExist,\@SetNumberKeys );
  428 
  429 }
  430 
  431 sub removeRecord {
  432   my $studentLogin = shift @_;
  433 
  434   my $setsExist = 0;
  435   my @SetNumberKeys = ();
  436   my %setNumberHash = ();
  437 
  438   # check to see if there is data for this student in the WW DB
  439 
  440   if ( -e "${databaseDirectory}$Global::database" ){
  441     $setsExist = &setsExistForStudentLogin($studentLogin);
  442     if ($setsExist) {
  443       %setNumberHash=&getAllSetNumbersForStudentLoginHash($studentLogin);
  444       @SetNumberKeys =  keys(%setNumberHash);
  445     }
  446   }
  447 
  448   ## Now remove all that data in the WeBWorK database, the .sco files,
  449   ## dvipng images, and any LaTeX2HTML images
  450   my ($setName, $psvn);
  451 
  452   if ($setsExist) {
  453     foreach $setName (@SetNumberKeys) {
  454       $psvn = $setNumberHash{$setName};
  455       &attachProbSetRecord($psvn);
  456       &deleteProbSetRecord($psvn);
  457       # remove .sco file if it exists
  458       system ("rm ${databaseDirectory}S${setName}-${psvn}.sco") if (-e "${databaseDirectory}S${setName}-${psvn}.sco");
  459       # remove any l2h files
  460       my $l2hDir = getCoursel2hDirectory();
  461       my $tempDir = convertPath("${l2hDir}set${setName}/*-$psvn");
  462       system ("rm -rf $tempDir");
  463       # remove any dvipng images -- reuse the variable names
  464       $l2hDir = getCourseTempDirectory();
  465       $tempDir = convertPath("${l2hDir}png/${setName}/$psvn");
  466       system ("rm -rf $tempDir");
  467     }
  468   }
  469 
  470   ## Next remove all the classlist data
  471 
  472   attachCLRecord($studentLogin);
  473   deleteClassListRecord($studentLogin);
  474   delete_password($studentLogin,$passwordFile);
  475   delete_permissions($studentLogin,$permissionsFile);
  476 
  477   &record_successfully_deleted_message($studentLogin);
  478 }
  479 
  480 # logs the incremental changes to a log file
  481 sub logChanges {
  482     my @dataArray = @_;
  483     my $fullLogFileName ="${logsDirectory}classlist_DB.log";
  484     open(LOGFILE,">>$fullLogFileName")  ||  &Global::error( "Can't open $fullLogFileName");
  485 
  486     my $timeNow = formatDateAndTime(time);
  487     print LOGFILE "\n$Course, student is $studentLogin, user is $User, time is $timeNow, data is: ";
  488     my $dataString = join( ' ',@dataArray);
  489     print  LOGFILE "@dataArray\n" ;
  490     close(LOGFILE);
  491     }
  492 
  493 
  494 sub formatDataCell {
  495   my ($name,$value,$size) = @_;
  496     # if the data hasn't been entered it appears as a blank:
  497   $value = '' unless defined($value);
  498 
  499   my $out = qq!
  500   <TD ALIGN=CENTER VALIGN=MIDDLE >
  501   <INPUT TYPE="TEXT" NAME="$name" VALUE="$value", SIZE="$size">
  502   </TD>
  503   !;
  504   $out;
  505   }
  506 sub formatFixedDataCell {
  507   my ($name,$value,$size) = @_;
  508     # if the data hasn't been entered it appears as a blank:
  509   $value = '' unless defined($value);
  510 
  511   my $out = qq!
  512   <TD ALIGN=CENTER VALIGN=MIDDLE >
  513   <INPUT TYPE='HIDDEN' NAME="$name" VALUE="$value">
  514   $value
  515   </TD>
  516   !;
  517   $out;
  518   }
  519 sub formatHeaderCell {
  520   my ($item,$options) = @_;
  521   $options = '' unless defined($options);
  522   my $out = qq!
  523   <TH ALIGN=CENTER VALIGN=MIDDLE $options>
  524   $item
  525   </TH>
  526   !;
  527   $out;
  528   }
  529 
  530 
  531 
  532 sub record_successfully_deleted_message {
  533   my $studentLogin =shift;
  534   print &htmlTOP("The student record with login $studentLogin has been deleted from the $Course classlist database.");
  535   print <<END_OF_HTML;
  536   <A HREF="${cgiURL}profLogin.pl?user=$inputs{'user'}&key=$inputs{'key'}&course=$inputs{'course'}">
  537   <IMG SRC="${Global::upImgUrl}" align="right" BORDER=1 ALT="[Up]"></A>
  538 END_OF_HTML
  539   print qq!<P><B> The student record with login $studentLogin has been deleted from the classlist database.
  540   All associated data has been removed from the WeBWorK databases.</B><P>!;
  541   print &htmlBOTTOM('profEditClasslistDB.pl', \%inputs);
  542 
  543 }
  544 
  545 
  546 
  547 sub warningMsgPage {
  548 
  549 my ($inputref,$ofn,$oln,$nfn,$nln)  = @_;
  550 my %inputs = %$inputref;
  551 # print HTML text
  552 print &htmlTOP("Data for the classlist record for $studentLogin");
  553 
  554 # print navigation buttons
  555 print qq!
  556 <A HREF="${Global::cgiWebworkURL}profLogin.pl?user=$inputs{'user'}&key=$inputs{'key'}&course=$inputs{'course'}">
  557 <IMG SRC="${Global::upImgUrl}" align="right" BORDER=1 ALT="[Up]"></A><p>
  558 !;
  559 
  560 print <<EOF;
  561 <HR><BR>
  562 <h3 align="left">WeBWorK WARNING message for Student Login $studentLogin</h3>
  563 EOF
  564 print qq!You have attempted to change (edit) both the Student Login and Student ID for <BR><BR>
  565 Original Name: $ofn $oln <BR>
  566 Edited Name: $nfn $nln <BR><BR>
  567 
  568 <P><FONT COLOR='#ff00aa'><B>NO CHANGES HAVE BEEN MADE</B></font> <P>
  569 It is possible you are making a mistake by trying to use this form to enter a new user. If you want to
  570 enter a new user, goto the Professor's page and click on "Enter Add Student(s) Page". <BR><BR>
  571 
  572 If you really want to make these extensive changes to $ofn ${oln}'s classlist record, you must do it
  573 in two steps.  You can not change both the Student Login and Student ID at the same time. Use your
  574 browser's "Back Button" to go back and change just one of these. Then edit the record again changing the other one.
  575 <BR><BR>
  576 To Quit and return to the Professor's page, select the "Up" button or the button below.!;
  577 
  578 
  579 
  580 print &htmlBOTTOM('profEditClasslistDB.pl', \%inputs);
  581 exit;
  582 } #end of warning Page
  583 
  584 
  585 sub removeRecordWarningPage {
  586   my ($inputref, $studentLogin, $setsExist, $SetNumberKeysref)  = @_;
  587 
  588   my @SetNumberKeys = @$SetNumberKeysref;
  589   my %inputs = %$inputref;
  590 
  591   attachCLRecord($studentLogin);
  592   my $studentLastName = CL_getStudentLastName($studentLogin);
  593   my $studentFirstName  = CL_getStudentFirstName($studentLogin);
  594   my $studentID   = CL_getStudentID($studentLogin);
  595 
  596   my $word = 'informational';
  597   $word = "<FONT COLOR='#ff00aa'>WARNING</font>" if $setsExist;
  598   # print HTML text
  599   print &htmlTOP("Data for the classlist record for $studentLogin");
  600 
  601 
  602   print qq!<h3 align="left">WeBWorK $word message concerning user $studentLogin
  603   ($studentFirstName $studentLastName $studentID)</h3>\n!;
  604 
  605   print qq!You have requested to remove the the classlist records and all associated data for the above user. <BR><BR>
  606 
  607   <P><FONT COLOR='#ff00aa'><B>NO CHANGES HAVE BEEN MADE YET</B></font> <P>!;
  608 
  609   if ($setsExist) {
  610     print qq! Data exists in the WeBWorK databases for following sets for user <b>$studentLogin</b><BR>\n!;
  611     foreach my $set (@SetNumberKeys) {
  612       print "<BR> Set $set\n";
  613     }
  614     print "<BR> <BR>If you choose to remove all records for <b>$studentLogin</b>, all this data will be destroyed.  This action can not be undone.<BR>\n";
  615   }
  616 
  617   print qq! <BR><BR>Generally if the user <b>$studentLogin</b> is a real user, it is preferable to change his or her "Enrollment Status"\n
  618   to "D" (for Drop) rather than to totally remove all records.  That way records are not destroyed\n
  619   and also the student can be reactivated simply by changing his or her "Enrollment Status" back to "C" (for Current).\n!;
  620 
  621   print qq! <BR><BR>If you have scored any of the above sets, scores for user <b>$studentLogin</b> will be contained in the
  622   ${Course}_totals.csv file (and the other scoring files).  These scores will not be removed.\n!;
  623 
  624   print qq! <BR><BR>If you want to change the "Enrollment Status" for $studentLogin to "D" (for Drop), use your browser's "Back" button.<BR>\n!;
  625 
  626 
  627   print qq!<FORM ACTION="${cgiURL}profEditClasslistDB.pl" METHOD=POST>\n!;
  628   print &sessionKeyInputs(\%inputs);
  629   print qq!<INPUT TYPE='HIDDEN' NAME='studentLogin' VALUE="$studentLogin">\n
  630   <INPUT TYPE="HIDDEN" NAME="save" VALUE="ON">\n
  631   <INPUT TYPE="HIDDEN" NAME="firsttime" VALUE= 1>\n
  632   If you really want to remove all records for <b>$studentLogin</b>, click on\n
  633   <INPUT TYPE="SUBMIT" NAME = "action" VALUE="DO IT"> \n
  634   but think before you click since this data, once removed, can not be recovered.\n
  635   </FORM>!;
  636 
  637 print &htmlBOTTOM('profEditClasslistDB.pl', \%inputs);
  638 
  639 } #end of removeRecordWarningPage

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9