|
From: Chris S. <san...@us...> - 2009-06-26 16:01:25
|
Update of /cvsroot/stack/stack-dev/lib/database In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv25058/lib/database Modified Files: StackDBReporting.php Log Message: Index: StackDBReporting.php =================================================================== RCS file: /cvsroot/stack/stack-dev/lib/database/StackDBReporting.php,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** StackDBReporting.php 23 Jun 2009 16:31:42 -0000 1.23 --- StackDBReporting.php 26 Jun 2009 16:01:22 -0000 1.24 *************** *** 217,221 **** $qid = $param["questionSelector"]; - $sql = "SELECT DISTINCT question_attempts.AttemptID, question_attempts.UserID, display_cache.questionNote, attempt_meta_answer.AnsName, attempt_meta_answer.RawAns, attempt_meta_answer.Status FROM question_attempts, attempt_meta_answer, display_cache, display_cache_sequence --- 217,220 ---- *************** *** 376,379 **** --- 375,447 ---- } + /* Generates an XHTML table with statistics about the entered question Id's answers + * @param int questionid + * @return string + */ + public function answerNoteStatistics($param) + { + + $qid = $param["questionSelector"]; + + $sql = "SELECT attempt_meta_prt.PRTName , attempt_meta_prt.RawMark , attempt_meta_prt.AnsNote, COUNT( attempt_meta_prt.AnsNote ) as Count + FROM question_attempts, attempt_meta_prt, display_cache, display_cache_sequence + WHERE + display_cache.qID = $qid + AND + (attempt_meta_prt.CacheID = display_cache.id) + AND + (display_cache_sequence.nextNode = display_cache.id) + AND + (question_attempts.TransitionID = display_cache_sequence.id) + AND + (display_cache_sequence.nextNode != display_cache_sequence.currentNode)"; + + $sql.= "GROUP BY AnsNote + ORDER BY PRTName ASC, RawMark DESC "; + + //echo $sql; + $this->connect(); + $this->query($sql); + $no = $this->noRows(); + + $xhtml = '<table class="reportsStatsTable" border="1" cellpadding="2" cellspacing="0"> + <tbody> + <tr class="tableHeader"> + <td>PRTName</td> + <td>RawMark</td> + <td>AnsNote</td> + <td>Count</td> + <td>%</td> + </tr>'; + + $total = array(); + for($i=0; $i < $no; $i++) + { + $PRTName = $this->result($i,'PRTName'); + $count = $this->result($i,'Count'); + $total[$PRTName] += $count; + } + + for($i=0; $i < $no; $i++) + { + $PRTName = $this->result($i,'PRTName'); + $RawMark = $this->result($i,'RawMark'); + $AnsNote = $this->result($i,'AnsNote'); + $count = $this->result($i,'Count'); + $per = round(100*$count/$total[$PRTName],1); + $xhtml .= "<tr> + <td>$PRTName</td> + <td>$RawMark</td> + <td>$AnsNote</td> + <td>$count</td> + <td>$per</td> + </tr>"; + } + //total attempts + //$xhtml .= "<tr> <td></td><td></td><td>Total Attempts</td><td>$total</td></tr>"; + + $xhtml .= '</tbody></table>'; + return $xhtml; + } /** |