From: trobb Date: Tue, 25 Nov 2003 12:35:43 +0000 (+0000) Subject: *** empty log message *** X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=036162ea9ab219817a255a5e0df8b797cd4d4b34;p=moodle.git *** empty log message *** --- diff --git a/lang/en/quiz.php b/lang/en/quiz.php index 32761a08db..00fd004263 100644 --- a/lang/en/quiz.php +++ b/lang/en/quiz.php @@ -50,6 +50,7 @@ $string['defaultgrade'] = 'Default question grade'; $string['defaultinfo'] = 'The default category for questions.'; $string['deletequestioncheck'] = 'Are you absolutely sure you want to delete \'$a\'?'; $string['description'] = 'Description'; +$string['discrimination'] = "Discrim. Index"; $string['eachattemptbuildsonthelast'] = 'Each attempt builds on the last'; $string['editcategories'] = 'Edit categories'; $string['editingdescription'] = 'Editing a Description'; diff --git a/mod/quiz/report/fullstat/report.php b/mod/quiz/report/fullstat/report.php index 93cd1ba7ee..9a3c4eef0c 100755 --- a/mod/quiz/report/fullstat/report.php +++ b/mod/quiz/report/fullstat/report.php @@ -1,6 +1,8 @@ id; $qs_in_order =qr_getqs($thisquizid); $qcount = 0; @@ -51,6 +57,7 @@ $string[''] = ""; $quests[$qid]["qtype"] = $thiskey; $quests[$qid]["qtext"] = $question_data[$thiskey]->questiontext; } + if($quests[$qid]['qtype'] == 3 or $quests[$qid]['qtype'] == 2){ $containsMCTF = 1;} if($quests[$qid]['qtype'] == 5){ //for MATCH items we need to know how many items there are $thismatch = get_record("quiz_match","question","$qid"); @@ -169,6 +176,61 @@ $string[''] = ""; print("

Data Tally

"); print_object($data_tally); } + + //Create a list of all attempts with their scores for item analysis + //Also create $data2 that has attempt id as key + foreach ($data_tally as $thistally){ + foreach($thistally as $this_aid=>$thisattempt){ + //this is the attempt id and the score + $data2[$this_aid] = $thisattempt; + $scores[$this_aid] = $thisattempt[1]; + } + } + arsort($scores); + //now go through scores from top to bottom and from $data2 accumulate no correct for top 1/3 and bottom 1/3 of scorers + $totscores = count($scores); + $numb_to_analyze = floor($totscores/3); + $skipval = $numb_to_analyze + 1; + $first_lowval = $totscores - $numb_to_analyze +1; + $count_scores = 0; + $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){ + //array items 0 & 1 contain user name & tot score, not item data + $i = 2; + while($data2[$aid][$i]){ + //let this array start from 1 + if ($data2[$aid][$i]['score'] == 1){ + $top_scores[$i-1]++; + } + $i++; + } + } elseif ($count_scores >= $first_lowval) { + $i = 2; + while($data2[$aid][$i]){ + //let this array start from 1 + if ($data2[$aid][$i]['score'] == 1){ + $bott_scores[$i-1]++; + } + $i++; + } + } else { + continue; + } + } + + if($debug and !$download){ + print("

Scores

"); + print_object($scores); + print("

Top Scores

"); + print_object($top_scores); + print("

Bottom Scores

"); + print_object($bott_scores); + } + //Create here an array with the response analysis data for use with both screen display & Excel // 2 dimensional array has as many cells across as items + title, as many down as $max_choices // plus one row [0] for correct items @@ -418,13 +480,32 @@ $string[''] = ""; $row = $row+2; } - //Finally output the total percent correct + //Output the total percent correct $row++; $myxls->write_string($row,1,"Percent Correct:",$formatbrt); for ($i = 1; $i<= $table_colcount;$i++){ $myxls->write_string($row,$i,$pct_correct[$i],$formatbc); } + //Finally display the itemanalysis + $row++; + $myxls->write_string($row,0,"Discrimination Index",$formatbc); + $myxls->write_string($row+1,0,"Top third",$formatbc); + $myxls->write_string($row+2,0,"Bottom third",$formatbc); + for ($i = 1; $i<= $table_colcount;$i++){ + if($bott_scores[$i] > 0) { + $val = round(($top_scores[$i]/$bott_scores[$i]),1); + } elseif ($top_scores[$i] ){ + $val = 10; + } else { + $val = 0; + } + $myxls->write_string($row,$i,$val,$formatbc); + $myxls->write_string($row+1,$i,$top_scores[$i],$formatbc); + $myxls->write_string($row+2,$i,$bott_scores[$i],$formatbc); + } + + //Print the questions with responses on a new worksheet $myxls = &$workbook->add_worksheet('Questions and Responses'); $sheettitle = "Questions and Responses"; @@ -570,6 +651,12 @@ $string[''] = ""; if ($thisitem['score'] == 1) {$thiscolor = "blue";} if(!$thisitem['data'][1]){$thisitem['data'][1]="($strnoresponse)";} print("{$thisitem['data'][0]}
{$thisitem['data'][1]}
"); + } elseif ($thisitem['qtype'] == 3) { + if ($showtext) { + print("  {$thisitem['data']}  "); + } else { + print("  {$thisitem['data']}  "); + } } else { print("  {$thisitem['data']}  "); } @@ -577,12 +664,14 @@ $string[''] = ""; } print("\n"); } - + print("

\n"); + if($debug and !$download){ print("

Qtally

"); print_object($qtally); } //print tally of how many selected each choice + print ("

\n"); print(""); qr_print_headers($data_tally,"Item"," "); //display row with correct answers @@ -611,29 +700,66 @@ $string[''] = ""; } } print("\n"); - //Finally display the total percent correct + //Display the total percent correct print(""); for ($i = 0; $i< $table_colcount;$i++){ print (" "); } print("\n"); + //Finally display the itemanalysis + print(""); + for ($i = 1; $i<= $table_colcount;$i++){ + if($bott_scores[$i] > 0) { + $val = round(($top_scores[$i]/$bott_scores[$i]),1); + } elseif ($top_scores[$i] ){ + $val = 10; + } else { + $val = 0; + } + print (" "); + } + print("\n"); print("
$stritemanal
$strpercentcorrect:{$pct_correct[$i]}
"); + helpbutton("discrimination", "", "quiz"); + print(" $strdiscrimination:$val ({$top_scores[$i]}/{$bott_scores[$i]})
\n"); //Now printout the questions (and M/C answers if $containsMC print ("

\n"); - print("\n"); + if ($containsMCTF){$ws = " ". $strwithsummary;} else {$ws = "";} + print("\n"); $qcount = 0; + $itemcount = 0; //needed since matching Qs adds additional columns of data in $analysis foreach ($qs_in_order as $qid){ $qcount++; - print("\n"); + if ($quests[$qid]['qtype']==5) { $itemcount = $itemcount + $match_number[$qid];} else {$itemcount++;} + print("\n"); if($quests[$qid]['qtype']==3){ $nowchoices = $quests[$qid]['choice']; foreach($nowchoices as $thischoice){ - print(""); - print("\n"); + $cno = $thischoice['choiceno']; + $nowstat = $analysis[$cno][$itemcount]; + $pct_cor = qr_make_pct($nowstat,$total_user_count); + print(""); + print("\n"); } } + if($quests[$qid]['qtype']==2){ + //"True" responses + $nowstat = $analysis[1][$qcount]; + $colpos = strpos($nowstat,":"); + $nowresp = substr($nowstat,$colpos+1); + $pct_cor = qr_make_pct($nowresp,$total_user_count); + print(""); + print("\n"); + //"False" responses + $nowstat = $analysis[2][$qcount]; + $colpos = strpos($nowstat,":"); + $nowresp = substr($nowstat,$colpos+1); + $pct_cor = qr_make_pct($nowresp,$total_user_count); + print(""); + print("\n"); + } } print("
QUIZ: $quiz->name   --   $strlistitems
QUIZ: $quiz->name   --   $strlistitems$ws
Q-$qcount{$quests[$qid]['qtext']}
Q-$qcount{$quests[$qid]['qtext']}
 A-{$thischoice['choiceno']}{$thischoice['answer']}
$nowstat ($pct_cor) A-$cno{$thischoice['answer']}
$nowresp ($pct_cor) True
$nowresp ($pct_cor) False
\n"); @@ -756,29 +882,29 @@ function qr_make_footers(){ if($quests[$qid]['qtype'] == 5) { foreach ($qtally[$qid] as $thisitem){ $this_correct = $thisitem['correct']; - $footers[] = qr_make_pct($this_correct); + $footers[] = qr_make_pct($this_correct,$total_user_count); } } else { $this_correct = $qtally[$qid]['correct']; - $footers[] = qr_make_pct($this_correct); + $footers[] = qr_make_pct($this_correct,$total_user_count); } } return $footers; } -function qr_make_pct($this_correct){ +function qr_make_pct($this_correct,$totusers){ global $qs_in_order,$qtally,$quests,$total_user_count; - if($this_correct>0){ - $pct_cor =round(($this_correct/$total_user_count)*100,1); + if($this_correct>0 and $totusers > 0){ + $pct_cor =round((($this_correct/$totusers)*100),1); } else { - $pct_cor = 0; + $pct_cor = 0; } return $pct_cor ."%"; } function qr_answer_lookup($qid,$thisanswer){ //For each type of question, this needs to determine answer string to report and whether right or wrong - global $quests,$qtally,$max_choices,$thismin,$thismax; + global $quests,$qtally,$max_choices,$thismin,$thismax,$showtext; $thistype = $quests[$qid]['qtype']; $returndata['data'] = "--"; $returndata['score'] = 0; @@ -804,8 +930,14 @@ function qr_answer_lookup($qid,$thisanswer){ } break; case 3: //MULTICHOICE - $returndata['data'] = $quests[$qid]['choice'][$thisanswer]['choiceno']; - if($max_choices < $returndata['data']) {$max_choices = $returndata['data'];} + $thischoiceno = $quests[$qid]['choice'][$thisanswer]['choiceno']; + if ($showtext){ + $returndata['data'] = $quests[$qid]['choice'][$thisanswer]['answer']; + } else { + $returndata['data'] = $thischoiceno; + } +// if($max_choices < $returndata['data']) {$max_choices = $returndata['data'];} + if ($max_choices < $thischoiceno) {$max_choices = $thischoiceno;} $qtally[$qid][$quests[$qid]['choice'][$thisanswer]['choiceno']]++; if (strtolower($quests[$qid]['correct'])==strtolower($quests[$qid]['choice'][$thisanswer]['choiceno'])){ $returndata['score'] = 1; @@ -877,4 +1009,4 @@ function qr_match_table($resplist){ $tbl = $tbl . "\n\n"; return $tbl; } -?> +?> \ No newline at end of file