From 7b656c9707ac299247da7b1dcebeb9bc4467e15b Mon Sep 17 00:00:00 2001 From: trobb Date: Sun, 18 Jan 2004 09:52:52 +0000 Subject: [PATCH] Further problems with the percentage displays fixed --- mod/quiz/report/fullstat/report.php | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/mod/quiz/report/fullstat/report.php b/mod/quiz/report/fullstat/report.php index 141f89a628..3848bbe67f 100755 --- a/mod/quiz/report/fullstat/report.php +++ b/mod/quiz/report/fullstat/report.php @@ -1,9 +1,7 @@ add_format(); $formatbc->set_bold(1); $formatbc->set_align('center'); + $formatbpct =& $workbook->add_format(); + $formatbpct->set_bold(1); + $formatbpct->set_num_format('0.0%'); $formatbrt =& $workbook->add_format(); $formatbrt->set_bold(1); $formatbrt->set_align('right'); @@ -472,9 +473,10 @@ class quiz_report extends quiz_default_report { //Output the total percent correct $row++; - $myxls->write_string($row,1,"Percent Correct:",$formatbrt); + + $myxls->write_string($row,0,"Percent Correct:",$formatbrt); for ($i = 1; $i<= $table_colcount;$i++){ - $myxls->write_string($row,$i,$pct_correct[$i],$formatbc); + $myxls->write_number($row,$i,$pct_correct[$i]/100,$formatbpct); } //Finally display the itemanalysis @@ -519,7 +521,7 @@ class quiz_report extends quiz_default_report { $row++; $label = "A-$thischoice[choiceno]"; $nowstat = $analysis[$cno][$itemcount]; - $pct = qr_make_pct($nowstat,$total_user_count); + $pct = qr_make_pct($nowstat,$total_user_count)/100; $myxls->write_number($row,1,$nowstat,$formatb); $myxls->write_number($row,2,$pct,$formatbpct); $myxls->write_string($row,3,$thischoice[answer],$formatb); @@ -530,7 +532,7 @@ class quiz_report extends quiz_default_report { $row++; $nowstat = $analysis[1][$itemcount]; $nowresp = substr($nowstat,5); - $pct = qr_make_pct($nowresp,$total_user_count); + $pct = qr_make_pct($nowresp,$total_user_count)/100; $myxls->write_number($row,1,$nowresp,$formatb); $myxls->write_number($row,2,$pct,$formatbpct); $myxls->write_string($row,3,'True',$formatb); @@ -538,7 +540,7 @@ class quiz_report extends quiz_default_report { $row++; $nowstat = $analysis[2][$itemcount]; $nowresp = substr($nowstat,6); - $pct = qr_make_pct($nowresp,$total_user_count); + $pct = qr_make_pct($nowresp,$total_user_count)/100; $myxls->write_number($row,1,$nowresp,$formatb); $myxls->write_number($row,2,$pct,$formatbpct); $myxls->write_string($row,3,'False',$formatb); @@ -714,6 +716,7 @@ class quiz_report extends quiz_default_report { print("\n"); //Display the total percent correct print("$strpercentcorrect:"); + for ($i = 0; $i< $table_colcount;$i++){ print ("{$pct_correct[$i]} "); } @@ -752,7 +755,7 @@ class quiz_report extends quiz_default_report { $cno = $thischoice['choiceno']; $nowstat = $analysis[$cno][$itemcount]; $pct_cor = qr_make_pct($nowstat,$total_user_count); - print("$nowstat ($pct_cor) "); + print("$nowstat ($pct_cor%) "); print("A-$cno{$thischoice['answer']}\n"); } } @@ -907,12 +910,11 @@ function qr_make_footers(){ function qr_make_pct($this_correct,$totusers){ global $qs_in_order,$qtally,$quests,$total_user_count; if($this_correct>0 and $totusers > 0){ -// $pct_cor =round((($this_correct/$totusers)*100),1); $pct_cor =(floor(($this_correct/$totusers)*1000)/10); } else { $pct_cor = 0; } - return $pct_cor ."%"; + return $pct_cor ; } function qr_answer_lookup($qid,$thisanswer){ -- 2.39.5