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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (download) (as text) (annotate)
Thu Jun 14 17:08:51 2001 UTC (11 years, 11 months ago) by sam
File size: 23613 byte(s)
initial import

    1 #!/usr/bin/perl
    2 
    3 ## This file is profCourseRecData.pl
    4 ## It displays overall data on how students in various recitations
    5 ## are doing on problems. E.g. the instructor can spot difficult
    6 ## problems.
    7 ##
    8 
    9 ####################################################################
   10 # Copyright @ 1995-1998 University of Rochester
   11 # All Rights Reserved
   12 ####################################################################
   13 
   14 use lib '/ww/webwork/development/'; # mainWeBWorKDirectory;
   15 use strict;
   16 use Global;
   17 use Auth;
   18 use CGI qw(:standard);
   19 
   20 # Timing code
   21 use Benchmark;
   22 my $beginTime = new Benchmark;
   23 # end Timing code
   24 
   25 
   26 my %inputs;
   27 my ($classID, $setNumber,$User,$Session_key,$batchMode);
   28 
   29 
   30     &CGI::ReadParse;
   31     %inputs = %main::in;
   32 
   33     # get information from CGI inputs  (see also below for additional information)
   34     $classID     = $inputs{'course'};
   35     $setNumber = $inputs{'setNo'};
   36     $User    = $inputs{'user'};
   37     $Session_key = $inputs{'key'};
   38 
   39     unless ($classID && $User && $Session_key) {
   40         &wwerror("$0","The script profCourseRecData.pl did not receive the proper input data.","","", query_string());
   41     }
   42 
   43 # CAUTION:  FOR THIS SCRIPT TO WORK CORRECTLTY,  ALL STUDENTS
   44 #           MUST HAVE BEEN ASSIGNED THE SAME NUMBER OF PROBLREMS
   45 
   46 # print "set is $setNumber";
   47 # print "classID is $classID";
   48 
   49 &getCourseEnvironment($classID);
   50 
   51 my $scriptDirectory   = getWebworkScriptDirectory;
   52 my $databaseDirectory = getCourseDatabaseDirectory;
   53 my $templateDirectory = getCourseTemplateDirectory;
   54 my $cgiURL            = getWebworkCgiURL;
   55 
   56 require "${scriptDirectory}$Global::DBglue_pl";
   57 require "${scriptDirectory}$Global::FILE_pl";
   58 require "${scriptDirectory}$Global::SCRtools_pl";
   59 require "${scriptDirectory}$Global::HTMLglue_pl";
   60 
   61     my $keyFile = &Global::getCourseKeyFile($classID);
   62     &verify_key($User, $Session_key, $keyFile, $classID);
   63     my $permissionsFile = &Global::getCoursePermissionsFile($classID);
   64     my $permissions = &get_permissions($User, $permissionsFile);
   65 
   66    if (($permissions != $Global::instructor_permissions) and ($permissions != $Global::TA_permissions) ) {
   67         print "permissions = $permissions instructor_permissions= $Global::instructor_permissions\n";
   68         print &html_NO_PERMISSION;
   69         exit(0);
   70     }
   71 my  $DELIM = $Global::delim;
   72 
   73 ## get rest of data from cgi form
   74 $batchMode = $inputs{'batchMode'};  ## if 1 it means user has choosen to ignore warning message
   75 
   76 # get list of problems and values from the database.  Warn user if different students
   77 #have different numbers of problems or different valuse for the same problem
   78 my $cgiMode = 1;
   79 my ($warningMsg,$dueDate, $problemListref,$problemValueListref)
   80     = &readProblemsAndValuesFromDB($setNumber,0,$cgiMode,$batchMode);
   81 
   82 if ($warningMsg ne '') { &warningMsgPage(\%inputs,$warningMsg);}
   83 
   84 my @problemList = @$problemListref;
   85 my @problemValueList = @$problemValueListref;
   86 my $noOfProbs = @problemList;
   87 unshift @problemValueList, 0; ##off by 1 problem
   88 
   89 my (%NHash,%YHash,%attemptedProbHash);
   90 my (%totalScoreHash,%attemptedSetHash,%allStudentsHash);
   91 my $total_possible;
   92 my @recitationNameArray = &getAllClassRecitations($setNumber) ;
   93 my @excludedRecitationNameArray = ();
   94 @excludedRecitationNameArray = @Global::excluse_these_recitations_from_overall_statistics
   95   if defined @Global::excluse_these_recitations_from_overall_statistics;
   96 
   97 &processRecitationNameArrays();  ##separate included and excluded Recitations
   98 
   99 ## initialize hashes and load up data
  100 
  101 my $all = &uniqueCourseName();
  102 &initializeAndLoadUp(\@recitationNameArray,$all);
  103 
  104 # begin printing HTML text
  105 print &htmlTOP("WeBWorK Course Data");
  106 
  107 # print navigation buttons
  108 print qq!
  109 <A HREF="${cgiURL}profLogin.pl?user=$inputs{'user'}&key=$inputs{'key'}&course=$inputs{'course'}">
  110 <IMG SRC="${Global::upImgUrl}" align="right" BORDER=1 ALT="[Up]"></A><p>
  111 !;
  112 
  113 print <<EOF;
  114 <HR><BR>
  115 
  116 <h3 align="left">Current Statistics for set $setNumber in $classID</h3>
  117 
  118 On this page, you can monitor the average progress of students for all recitations or
  119 by individual recitations. You can identify difficult problems by the percentage of students
  120 who have answered the problem correctly and/or by the average number of incorrect attempts
  121 per problem. All percentages and averages (except \% attempting) are based on the number of
  122 students who have attempted a set or problem, not on the total number of students in the recitation
  123 or course.  Note that 50\% correct on a partial credit question could mean all students got half
  124 credit or half the students got full credit and half got no credit.<p>
  125 The first two tables do not contain data from "excluded" recitations. Excluded recitations
  126 typically contain practices uses, T.A.'s, prof's etc.  Data for excluded recitations is displayed
  127 at the bottom of the page.
  128 <p>
  129 EOF
  130 
  131 
  132 
  133 ## create  $dat arrays with the info. on average scores, etc
  134 
  135 my ($recitationName,$i, $dataRow,$item);
  136 my @dataArray =();
  137 
  138 ## first row
  139 
  140 $dataRow = "recitations$DELIM \# of students$DELIM \% attempting set $setNumber$DELIM average score$DELIM possible score";
  141 push @dataArray, $dataRow;
  142 
  143 ## display whole course data
  144 
  145 $dataRow = "$all $DELIM $allStudentsHash{$all} $DELIM";  ## all Recitations and total # of students
  146 
  147 $item =0;  ## % of students who have attempted at least one problem in set
  148 $item = int(100*$attemptedSetHash{$all}/$allStudentsHash{$all}+.5) if $allStudentsHash{$all};
  149 $dataRow .= "$item $DELIM";
  150 
  151 $item =0;  ## avg score of students who have attempted at least one problem in set
  152 $item = (int($totalScoreHash{$all} *10/$attemptedSetHash{$all}+.5))/10 if $attemptedSetHash{$all};
  153 $item = sprintf '%.1f', $item;
  154 $dataRow .= "$item $DELIM";
  155 $dataRow .= "$total_possible";
  156 
  157 push @dataArray, $dataRow;
  158 
  159 
  160 ## display data for Recitations
  161 foreach $recitationName (@recitationNameArray) {
  162     $dataRow = "$recitationName $DELIM $allStudentsHash{$recitationName} $DELIM";  ## all recitations and total # of students
  163 
  164     $item =0;  ## % of students who have attempted at least one problem in set
  165     $item = int(100*$attemptedSetHash{$recitationName}/$allStudentsHash{$recitationName}+.5) if $allStudentsHash{$recitationName};
  166     $dataRow .= "$item $DELIM";
  167 
  168     $item =0;  ## avg score of students who have attempted at least one problem in set
  169     $item = (int($totalScoreHash{$recitationName} *10/$attemptedSetHash{$recitationName}+.5))/10 if $attemptedSetHash{$recitationName};
  170     $item = sprintf '%.1f', $item;
  171     $dataRow .= "$item $DELIM";
  172     $dataRow .= "$total_possible";
  173     push @dataArray, $dataRow;
  174 }
  175 # print "<pre> @dataArray <\pre>";
  176 
  177 print <<EOF;
  178 <HR><BR>
  179 <h3 align="left">Overall Scores by recitation. $all is the total for all included recitations</h3>
  180 EOF
  181 
  182 ## output the html table
  183 my $string = &delimitedArray2htmlTable(\@dataArray, 'htmltable');
  184 print "${string}<BR>";
  185 
  186 ## now output the info on individaul problems
  187 
  188 
  189 ### display whole course data
  190 @dataArray =();
  191 $dataRow = "$all $DELIM";
  192 for ($i=1;$i<=$noOfProbs;$i++) {
  193     $dataRow .= "\# $i  $DELIM";
  194 }
  195 $dataRow =~ s|$DELIM$||;  ## remove last \$DELIM
  196 
  197 push @dataArray, $dataRow;
  198 
  199 $dataRow = "\% attempting $DELIM";
  200 for ($i=1;$i<=$noOfProbs;$i++) {
  201     $item =0;   ## percent of students who have attempted this problem
  202     $item = int(100*$attemptedProbHash{$all}[$i]/$allStudentsHash{$all}+.5) if $allStudentsHash{$all};
  203     $dataRow .= "$item $DELIM";
  204 
  205 }
  206 
  207 
  208 
  209 $dataRow =~ s|$DELIM$||;  ## remove last \$DELIM
  210 push @dataArray, $dataRow;
  211 
  212 
  213 
  214 $dataRow = "percent correct $DELIM";  ## all recitations and total # of students
  215 for ($i=1;$i<=$noOfProbs;$i++) {
  216     $item =0;  ## % of students who have attempted this problem
  217     $item = int(100*$YHash{$all}[$i]/$attemptedProbHash{$all}[$i]+.5) if $attemptedProbHash{$all}[$i];
  218     $dataRow .= "$item $DELIM";
  219 }
  220 $dataRow =~ s|$DELIM$||;  ## remove last \$DELIM
  221 push @dataArray, $dataRow;
  222 
  223 $dataRow = "average incorrect $DELIM";  ## all recitations and total # of students
  224 for ($i=1;$i<=$noOfProbs;$i++) {
  225 
  226     $item =0;   ## avg # of incorrect attempts of students who have attempted this problem
  227     $item = (int(10*$NHash{$all}[$i]/$attemptedProbHash{$all}[$i]+.5))/10 if $attemptedProbHash{$all}[$i];
  228     $item = sprintf '%.1f', $item;
  229     $dataRow .= "$item $DELIM";
  230 }
  231 $dataRow =~ s|$DELIM$||;  ## remove last \$DELIM
  232 push @dataArray, $dataRow;
  233 
  234 print <<EOF;
  235 
  236 <h3 align="left">Data on individual problems by recitation. $all is the total for all included recitations</h3>
  237 EOF
  238 ### output the html table
  239 #$string = &delimitedArray2htmlTable(\@dataArray, 'htmltable');
  240 #print "${string}<BR>";
  241 
  242 
  243 ## display data for recitations
  244 
  245 foreach $recitationName (@recitationNameArray) {
  246 
  247     ## add blank row to table to seperate recitations
  248     $dataRow = '<BR>';
  249     push @dataArray, $dataRow;
  250 #    @dataArray =();
  251     $dataRow = "$recitationName $DELIM";
  252     for ($i=1;$i<=$noOfProbs;$i++) {
  253         $dataRow .= "\# $i  $DELIM";
  254     }
  255     $dataRow =~ s|$DELIM$||;  ## remove last \$DELIM
  256 
  257     push @dataArray, $dataRow;
  258 
  259     $dataRow = "\% attempting $DELIM";
  260     for ($i=1;$i<=$noOfProbs;$i++) {
  261         $item =0;   ## percent of students who have attempted this problem
  262         $item = int(100*$attemptedProbHash{$recitationName}[$i]/$allStudentsHash{$recitationName}+.5) if $allStudentsHash{$recitationName};
  263         $dataRow .= "$item $DELIM";
  264     }
  265 
  266 $dataRow =~ s|$DELIM$||;  ## remove last \$DELIM
  267 push @dataArray, $dataRow;
  268 
  269 
  270 
  271 
  272     $dataRow = "percent correct $DELIM";  ## all recitations and total # of students
  273     for ($i=1;$i<=$noOfProbs;$i++) {
  274         $item =0;  ## % of students who have attempted this problem
  275         $item = int(100*$YHash{$recitationName}[$i]/$attemptedProbHash{$recitationName}[$i]+.5) if $attemptedProbHash{$recitationName}[$i];
  276         $dataRow .= "$item $DELIM";
  277     }
  278     $dataRow =~ s|$DELIM$||;  ## remove last \$DELIM
  279     push @dataArray, $dataRow;
  280 
  281     $dataRow = "average incorrect $DELIM";  ## all recitations and total # of students
  282     for ($i=1;$i<=$noOfProbs;$i++) {
  283 
  284        $item =0;   ## avg # of incorrect attempts of students who have attempted this problem
  285        $item = (int(10*$NHash{$recitationName}[$i]/$attemptedProbHash{$recitationName}[$i]+.5))/10 if $attemptedProbHash{$recitationName}[$i];
  286        $item = sprintf '%.1f', $item;
  287        $dataRow .= "$item $DELIM";
  288     }
  289     $dataRow =~ s|$DELIM$||;  ## remove last \$DELIM
  290     push @dataArray, $dataRow;
  291 
  292 #    ## output the html table
  293 #    my $string = &delimitedArray2htmlTable(\@dataArray, 'htmltable');
  294 #    print "${string}<BR>";
  295 
  296 }
  297 
  298 ## output the html table
  299 $string = &delimitedArray2htmlTable(\@dataArray, 'htmltable');
  300 print "${string}<BR>";
  301 
  302 
  303 
  304 ## Now print everything again for excluded recitations
  305 
  306 ##################################################################################################
  307 
  308 print <<EOF;
  309 <HR><HR><BR>
  310 
  311 <h3 align="left">Current Statistics for Excluded Recitations</h3>
  312 
  313 Excluded recitations typically contain practices uses, T.A.'s, prof's etc.  The list
  314 of excluded recitations in contained in the webworkCourse.ph file and typically consists
  315 of a recitation with an empty name.
  316 <p>
  317 EOF
  318 
  319 
  320 
  321 &initializeAndLoadUp(\@excludedRecitationNameArray,'Excluded');
  322 $all = 'Excluded';
  323 
  324 ## create  $dat arrays with the info. on average scores, etc
  325 
  326 
  327 @dataArray =();
  328 
  329 ## first row
  330 
  331 $dataRow = "recitations$DELIM \# of students$DELIM \% attempting set $setNumber$DELIM average score$DELIM possible score";
  332 push @dataArray, $dataRow;
  333 
  334 ## display whole course data
  335 
  336 $dataRow = "$all $DELIM $allStudentsHash{$all} $DELIM";  ## all recitations and total # of students
  337 
  338 $item =0;  ## % of students who have attempted at least one problem in set
  339 $item = int(100*$attemptedSetHash{$all}/$allStudentsHash{$all}+.5) if $allStudentsHash{$all};
  340 $dataRow .= "$item $DELIM";
  341 
  342 $item =0;  ## avg score of students who have attempted at least one problem in set
  343 $item = (int($totalScoreHash{$all} *10/$attemptedSetHash{$all}+.5))/10 if $attemptedSetHash{$all};
  344 $item = sprintf '%.1f', $item;
  345 $dataRow .= "$item $DELIM";
  346 $dataRow .= "$total_possible";
  347 
  348 push @dataArray, $dataRow;
  349 
  350 
  351 ## display data for recitations
  352 foreach $recitationName (@excludedRecitationNameArray) {
  353     $dataRow = "$recitationName $DELIM $allStudentsHash{$recitationName} $DELIM";  ## all recitations and total # of students
  354 
  355     $item =0;  ## % of students who have attempted at least one problem in set
  356     $item = int(100*$attemptedSetHash{$recitationName}/$allStudentsHash{$recitationName}+.5) if $allStudentsHash{$recitationName};
  357     $dataRow .= "$item $DELIM";
  358 
  359     $item =0;  ## avg score of students who have attempted at least one problem in set
  360     $item = (int($totalScoreHash{$recitationName} *10/$attemptedSetHash{$recitationName}+.5))/10 if $attemptedSetHash{$recitationName};
  361     $item = sprintf '%.1f', $item;
  362     $dataRow .= "$item $DELIM";
  363     $dataRow .= "$total_possible";
  364     push @dataArray, $dataRow;
  365 }
  366 # print "<pre> @dataArray <\pre>";
  367 
  368 print <<EOF;
  369 <HR><BR>
  370 <h3 align="left">Overall Scores by recitation. $all is the total for all excluded recitations</h3>
  371 EOF
  372 
  373 ## output the html table
  374 $string = &delimitedArray2htmlTable(\@dataArray, 'htmltable');
  375 print "${string}<BR>";
  376 
  377 ## now output the info on individaul problems
  378 
  379 
  380 ### display whole course data
  381 @dataArray =();
  382 $dataRow = "$all $DELIM";
  383 for ($i=1;$i<=$noOfProbs;$i++) {
  384     $dataRow .= "\# $i  $DELIM";
  385 }
  386 $dataRow =~ s|$DELIM$||;  ## remove last \$DELIM
  387 
  388 push @dataArray, $dataRow;
  389 
  390 $dataRow = "\% attempting $DELIM";
  391 for ($i=1;$i<=$noOfProbs;$i++) {
  392     $item =0;   ## percent of students who have attempted this problem
  393     $item = int(100*$attemptedProbHash{$all}[$i]/$allStudentsHash{$all}+.5) if $allStudentsHash{$all};
  394     $dataRow .= "$item $DELIM";
  395 
  396 }
  397 
  398 
  399 
  400 $dataRow =~ s|$DELIM$||;  ## remove last \$DELIM
  401 push @dataArray, $dataRow;
  402 
  403 
  404 
  405 $dataRow = "percent correct $DELIM";  ## all recitations and total # of students
  406 for ($i=1;$i<=$noOfProbs;$i++) {
  407     $item =0;  ## % of students who have attempted this problem
  408     $item = int(100*$YHash{$all}[$i]/$attemptedProbHash{$all}[$i]+.5) if $attemptedProbHash{$all}[$i];
  409     $dataRow .= "$item $DELIM";
  410 }
  411 $dataRow =~ s|$DELIM$||;  ## remove last \$DELIM
  412 push @dataArray, $dataRow;
  413 
  414 $dataRow = "average incorrect $DELIM";  ## all recitations and total # of students
  415 for ($i=1;$i<=$noOfProbs;$i++) {
  416 
  417     $item =0;   ## avg # of incorrect attempts of students who have attempted this problem
  418     $item = (int(10*$NHash{$all}[$i]/$attemptedProbHash{$all}[$i]+.5))/10 if $attemptedProbHash{$all}[$i];
  419     $item = sprintf '%.1f', $item;
  420     $dataRow .= "$item $DELIM";
  421 }
  422 $dataRow =~ s|$DELIM$||;  ## remove last \$DELIM
  423 push @dataArray, $dataRow;
  424 
  425 print <<EOF;
  426 
  427 <h3 align="left">Data on individual problems by recitation. $all is the total for all excluded recitations</h3>
  428 EOF
  429 ### output the html table
  430 #$string = &delimitedArray2htmlTable(\@dataArray, 'htmltable');
  431 #print "${string}<BR>";
  432 
  433 
  434 ## display data for recitations
  435 
  436 foreach $recitationName (@excludedRecitationNameArray) {
  437 
  438     ## add blank row to table to seperate recitations
  439     $dataRow = '<BR>';
  440     push @dataArray, $dataRow;
  441 #    @dataArray =();
  442     $dataRow = "$recitationName $DELIM";
  443     for ($i=1;$i<=$noOfProbs;$i++) {
  444         $dataRow .= "\# $i  $DELIM";
  445     }
  446     $dataRow =~ s|$DELIM$||;  ## remove last \$DELIM
  447 
  448     push @dataArray, $dataRow;
  449 
  450     $dataRow = "\% attempting $DELIM";
  451     for ($i=1;$i<=$noOfProbs;$i++) {
  452         $item =0;   ## percent of students who have attempted this problem
  453         $item = int(100*$attemptedProbHash{$recitationName}[$i]/$allStudentsHash{$recitationName}+.5) if $allStudentsHash{$recitationName};
  454         $dataRow .= "$item $DELIM";
  455     }
  456 
  457 $dataRow =~ s|$DELIM$||;  ## remove last \$DELIM
  458 push @dataArray, $dataRow;
  459 
  460 
  461 
  462 
  463     $dataRow = "percent correct $DELIM";  ## all recitations and total # of students
  464     for ($i=1;$i<=$noOfProbs;$i++) {
  465         $item =0;  ## % of students who have attempted this problem
  466         $item = int(100*$YHash{$recitationName}[$i]/$attemptedProbHash{$recitationName}[$i]+.5) if $attemptedProbHash{$recitationName}[$i];
  467         $dataRow .= "$item $DELIM";
  468     }
  469     $dataRow =~ s|$DELIM$||;  ## remove last \$DELIM
  470     push @dataArray, $dataRow;
  471 
  472     $dataRow = "average incorrect $DELIM";  ## all recitations and total # of students
  473     for ($i=1;$i<=$noOfProbs;$i++) {
  474 
  475        $item =0;   ## avg # of incorrect attempts of students who have attempted this problem
  476        $item = (int(10*$NHash{$recitationName}[$i]/$attemptedProbHash{$recitationName}[$i]+.5))/10 if $attemptedProbHash{$recitationName}[$i];
  477        $item = sprintf '%.1f', $item;
  478        $dataRow .= "$item $DELIM";
  479     }
  480     $dataRow =~ s|$DELIM$||;  ## remove last \$DELIM
  481     push @dataArray, $dataRow;
  482 
  483 #    ## output the html table
  484 #    my $string = &delimitedArray2htmlTable(\@dataArray, 'htmltable');
  485 #    print "${string}<BR>";
  486 
  487 }
  488 
  489 ## output the html table
  490 $string = &delimitedArray2htmlTable(\@dataArray, 'htmltable');
  491 print "${string}<BR>";
  492 
  493 
  494 
  495 
  496 
  497 
  498 ####################################################################################################
  499 
  500 print &htmlBOTTOM("profCourseRecData.pl", \%inputs, 'profCourseRecDataHelp.html');
  501 
  502 # begin Timing code
  503 my $endTime = new Benchmark;
  504 &Global::logTimingInfo($beginTime,$endTime,"profCourseRecData.pl",$inputs{'course'},$inputs{'user'});
  505 # end Timing code
  506 exit;
  507 
  508 
  509 ##subroutines
  510 
  511 sub processRecitationNameArrays {
  512     ## first consider all blank entries (i.e. empty or white space) in excludedRecitationNameArray
  513     ## to be the same recitation, namely ' '
  514     my %temp_hash =();
  515     my $recitationName;
  516     foreach $recitationName (@excludedRecitationNameArray) {
  517         if ((!defined ($recitationName)) or ($recitationName =~ m|^\s*$|)) {$recitationName = ' ';}
  518         $temp_hash{$recitationName} =1;
  519     }
  520     @excludedRecitationNameArray = keys %temp_hash;
  521 
  522     ## Make sure excludedRecitationNameArray is a subset of recitationNameArray
  523     %temp_hash =();
  524     grep($temp_hash{$_}++,@recitationNameArray);
  525     @excludedRecitationNameArray = grep($temp_hash{$_},@excludedRecitationNameArray);
  526 
  527     ## Now remove excluded recitations from recitation list
  528     %temp_hash =();
  529     grep($temp_hash{$_}++,@excludedRecitationNameArray);
  530     @recitationNameArray = grep(!$temp_hash{$_},@recitationNameArray);
  531 
  532     @recitationNameArray = sort @recitationNameArray;
  533     @excludedRecitationNameArray = sort @excludedRecitationNameArray;
  534 }
  535 
  536 sub initializeAndLoadUp {
  537     my ($recitationNameArrayref, $wholeCourseName) = @_;
  538     my @recitationNameArray = @$recitationNameArrayref;
  539     my $all = $wholeCourseName;
  540     my ($recitationName,$i,$score);
  541 
  542     ## compute total possible points
  543     $total_possible = 0;
  544     for ($i=1;$i<=$noOfProbs;$i++) {$total_possible += $problemValueList[$i];}
  545 
  546     foreach $recitationName (@recitationNameArray) {
  547         $totalScoreHash{$recitationName} = 0;
  548         $attemptedSetHash{$recitationName} = 0;
  549         $allStudentsHash{$recitationName} = 0;
  550         for ($i=1;$i<=$noOfProbs;$i++) {
  551             $NHash{$recitationName}[$i]=0;   ## contains number of incorrect responses
  552             $YHash{$recitationName}[$i]=0;   ## contains totals of problem scores (i.e. a
  553                                           ## number in [0,1] for each problem
  554             $attemptedProbHash{$recitationName}[$i]=0;
  555         }
  556     }
  557 
  558     ## load up hashes with data
  559 
  560     my @pinNumbersArray = &getAllProbSetKeysForSet($setNumber);
  561     my ($studentAttemptedAProblem, $numIncorr, $pin, $status);
  562         foreach $pin (@pinNumbersArray) {
  563             &attachProbSetRecord($pin);
  564             $status = getStudentStatus($pin);
  565       next if dropStatus($status);
  566             $studentAttemptedAProblem = 0;
  567             $recitationName = &getClassRecitation($pin);
  568             if ((!defined ($recitationName)) or ($recitationName =~ m|^\s*$|)){
  569                         $recitationName = ' ';
  570             }
  571             $allStudentsHash{$recitationName} += 1;
  572 
  573                 for ($i=1;$i<=$noOfProbs;$i++) {
  574                     if (&getProblemAttempted($i,$pin)) {
  575                         $studentAttemptedAProblem = 1;
  576                         $numIncorr = &getProblemNumOfIncorrectAns($i,$pin);
  577                         $numIncorr =0 unless defined $numIncorr;
  578                         $numIncorr = &min($numIncorr,99);
  579                         $NHash{$recitationName}[$i] += $numIncorr;
  580                         $attemptedProbHash{$recitationName}[$i] += 1;
  581                         $score = &getProblemStatus($i,$pin);
  582                         $YHash{$recitationName}[$i] += $score;
  583                         $totalScoreHash{$recitationName} += round_score($score*$problemValueList[$i]);
  584                     }
  585                 }
  586                 if ($studentAttemptedAProblem) {$attemptedSetHash{$recitationName} += 1;}
  587             }
  588 
  589     ## initialize whole course data
  590         $totalScoreHash{$all} = 0;
  591         $attemptedSetHash{$all} = 0;
  592         $allStudentsHash{$all} = 0;
  593         for ($i=1;$i<=$noOfProbs;$i++) {
  594             $NHash{$all}[$i]=0;
  595             $YHash{$all}[$i]=0;
  596             $attemptedProbHash{$all}[$i]=0;
  597         }
  598 
  599     ## compute whole course data
  600     foreach $recitationName (@recitationNameArray) {
  601         $totalScoreHash{$all} += $totalScoreHash{$recitationName};
  602         $attemptedSetHash{$all} += $attemptedSetHash{$recitationName};
  603         $allStudentsHash{$all} += $allStudentsHash{$recitationName};
  604         for ($i=1;$i<=$noOfProbs;$i++) {
  605             $NHash{$all}[$i] += $NHash{$recitationName}[$i];
  606             $YHash{$all}[$i] += $YHash{$recitationName}[$i];
  607             $attemptedProbHash{$all}[$i] += $attemptedProbHash{$recitationName}[$i];
  608         }
  609     }
  610 }
  611 ## find unique name
  612 sub uniqueCourseName {
  613     my $all = $classID;
  614     if (exists $allStudentsHash{$all}) {
  615         my $j = 1;
  616         $all = "${all}$j";
  617         while (exists $allStudentsHash{$all}) {
  618             $j++;
  619             $all = "${all}$j";
  620         }
  621     }
  622 $all
  623 }
  624 
  625 
  626 
  627 sub warningMsgPage {
  628 
  629 my ($inputref,$warningMsg)  = @_;
  630 my %inputs = %$inputref;
  631 # print HTML text
  632 print &htmlTOP("Scoring Utilities");
  633 
  634 # print navigation buttons
  635 print qq!
  636 <A HREF="${Global::cgiWebworkURL}profLogin.pl?user=$inputs{'user'}&key=$inputs{'key'}&course=$inputs{'course'}">
  637 <IMG SRC="${Global::upImgUrl}" align="right" BORDER=1 ALT="[Up]"></A><p>
  638 !;
  639 
  640 print <<EOF;
  641 <HR><BR>
  642 <h3 align="left">WeBWorK scoring WARNING message for $classID:</h3>
  643 EOF
  644 print "<pre>";
  645 print $warningMsg;
  646 print "</pre>";
  647 print "To Continue displaying data for $setNumber, check the \"Continue\" check box and then select
  648 \"Continue displaying data for $setNumber\". <BR> To Quit and return to the Scoring page, select the \"Up\"
  649 buttom.";
  650 
  651 ## profScoring form -- allows you to score problem sets
  652 print <<EOF;
  653 <P>
  654 
  655         <FORM METHOD = "POST" ACTION= "${cgiURL}profCourseRecData.pl">
  656          <INPUT TYPE="SUBMIT" VALUE="Continue displaying data for $setNumber">
  657 
  658 EOF
  659 
  660 
  661     print qq{
  662         <BR><INPUT TYPE=CHECKBOX NAME="batchMode" VALUE=1 >Continue
  663         };
  664 
  665 # resume printing the rest of the form
  666 
  667 print <<EOF;
  668          <INPUT TYPE="HIDDEN" NAME="user" VALUE="$inputs{'user'}">
  669          <INPUT TYPE="HIDDEN" NAME="key" VALUE="$inputs{'key'}">
  670          <INPUT TYPE="HIDDEN" NAME="course" VALUE="$inputs{'course'}">
  671          <INPUT TYPE="HIDDEN" NAME="setNo" VALUE="$inputs{'setNo'}">
  672          </FORM>
  673 EOF
  674 
  675 
  676 print &htmlBOTTOM("profLogin.pl", \%inputs);
  677 exit;
  678 } #end of warning Page
  679 
  680 
  681 
  682 
  683 
  684 

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9