fixed bug 1252. But this page could do with a lot more work.

This commit is contained in:
gustav_delius 2004-08-22 19:58:54 +00:00
parent eb28fa7886
commit ecf0cf9ac4

View File

@ -29,11 +29,13 @@ class quiz_report extends quiz_default_report {
$strdiscrimination = get_string('discrimination', 'quiz');
//Get the question ids
//$showtext causes M/C text to whos in top table. This could be made into a user toggle if we want to complicate matters
//$showtext causes M/C text to whos in top table.
//This could be made into a user toggle if we want to complicate matters
$showtext = 1;
$containsMCTF = 0; //used to toggle title in final listing
$thisquizid = $quiz->id;
$qs_in_order =qr_getqs($thisquizid);
if ($qs_in_order = qr_getqs($thisquizid)) {
$qcount = 0;
$max_choices = 0; //for printing tallies we need to know how many rows to print
$table_colcount = 0;
@ -65,6 +67,7 @@ class quiz_report extends quiz_default_report {
//only get choices here if type is SHORTANSWER,TRUEFALSE or MULTICHOICE
//Get the choices for each question and add to object['choice'] each choicd ID and text
$choice_count=0;
if ($choice_data) {
foreach($choice_data as $thiscid=>$thischoice){
$choice_count++;
$quests[$qid]["choice"]["$thiscid"]["answer"] = $thischoice->answer;
@ -84,11 +87,14 @@ class quiz_report extends quiz_default_report {
}
}
}
}
}
if($debug and !$download){
print("<h3>Quests</h3>");
print_object($quests);
}
$user_resps = qr_quiz_responses($thisquizid);
if ($user_resps = qr_quiz_responses($thisquizid)) {
// //print_object($user_resps);
foreach($user_resps as $thiskey => $thisresp){
$userdata[$thisresp->userid][$thisresp->attemptno]['response'][$thisresp->question]=s($thisresp->answer);
@ -96,6 +102,7 @@ class quiz_report extends quiz_default_report {
$userdata[$thisresp->userid][$thisresp->attemptno]['name']=fullname($thisresp);
$userdata[$thisresp->userid][$thisresp->attemptno]['attemptid']=$thisresp->aid;
}
if($debug and !$download){
print("<h3>User Data</h3>");
print_object($userdata);
@ -104,7 +111,7 @@ class quiz_report extends quiz_default_report {
$reportline = 0;
foreach($userdata as $thisuser){
foreach($thisuser as $thiskey=>$thisattempt){
// //print_object($thisattempt);
// //print_object($thisattempt);
$reportline++;
$data_tally[$reportline][$thisattempt['attemptid']][] = $thisattempt['name'];
$data_tally[$reportline][$thisattempt['attemptid']][] =round(($thisattempt['grade']/$quiz->sumgrades)*100,0);
@ -159,6 +166,7 @@ class quiz_report extends quiz_default_report {
}
}
}
$total_user_count = $reportline;
//prepare headers (must do now because $table_colcount calculated here
if($debug and !$download){
@ -175,8 +183,11 @@ class quiz_report extends quiz_default_report {
$scores[$this_aid] = $thisattempt[1];
}
}
arsort($scores);
}
//now go through scores from top to bottom and from $data2 accumulate number correct for top 1/3 and bottom 1/3 of scorers
if ($scores) {
arsort($scores);
$totscores = count($scores);
$numb_to_analyze = floor($totscores/3);
$skipval = $numb_to_analyze + 1;
@ -185,6 +196,7 @@ class quiz_report extends quiz_default_report {
$tempscores = array();
$top_scores = array_pad($tempscores,$table_colcount+1,0);
$bott_scores = array_pad($tempscores,$table_colcount+1,0);
foreach($scores as $aid=>$score){
$count_scores++;
if ($count_scores < $skipval){
@ -210,6 +222,7 @@ class quiz_report extends quiz_default_report {
continue;
}
}
}
if($debug and !$download){
print("<h3>Scores</h3>");
@ -648,7 +661,9 @@ class quiz_report extends quiz_default_report {
$totcolcount = $table_colcount+2;
print("<tr><th colspan=$totcolcount>$strindivresp</th></tr>");
qr_print_headers($data_tally,"$strname","$strgrade");
//now print the lines of answers
if ($data_tally) {
foreach ($data_tally as $thisuserno=>$thisuser){
foreach($thisuser as $thisattemptno=>$thisattempt){
print("<tr>");
@ -681,6 +696,8 @@ class quiz_report extends quiz_default_report {
}
print("</tr>\n");
}
}
print("</table><p>\n");
if($debug and !$download){