From: Ben H. <bdv...@us...> - 2010-11-24 11:33:59
|
Update of /cvsroot/stack/stack-dev/lib/database In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv26098/lib/database Modified Files: Tag: question_reporting StackDBReporting.php Log Message: Adjusted StackDBReporting.php to account for the question lines feature. Index: StackDBReporting.php =================================================================== RCS file: /cvsroot/stack/stack-dev/lib/database/StackDBReporting.php,v retrieving revision 1.27.2.21 retrieving revision 1.27.2.22 diff -C2 -d -r1.27.2.21 -r1.27.2.22 *** StackDBReporting.php 22 Nov 2010 23:05:52 -0000 1.27.2.21 --- StackDBReporting.php 24 Nov 2010 11:33:51 -0000 1.27.2.22 *************** *** 49,56 **** public function questionList($ids = null) { ! $sql = 'SELECT questionID, questionName, questionDescription FROM stackquestion'; ! if (isset($ids)) { ! $sql .= " WHERE questionID IN ($ids)"; ! } $this->connect(); $this->query($sql); --- 49,60 ---- public function questionList($ids = null) { ! $sql = 'SELECT questionID, questionName, questionDescription ! FROM stackquestion, question_lines ! WHERE line = question_lines.id'; ! ! if (isset($ids)) $sql .= " AND questionID IN ($ids)"; ! ! $sql .= ' GROUP BY line'; ! $this->connect(); $this->query($sql); *************** *** 65,71 **** $this->result($i, 'questionID'), $this->result($i, 'questionName'), ! $this->result($i, 'questionDescription'), ! '', // These two are for the two hidden colums ! '' // the data is popoluated later via AJAX ); } --- 69,73 ---- $this->result($i, 'questionID'), $this->result($i, 'questionName'), ! $this->result($i, 'questionDescription') ); } *************** *** 73,76 **** --- 75,82 ---- return $questions; } + + /** + * + */ /** *************** *** 92,97 **** $student['firstname'], $student['lastname'], - '', // These two are for the two hidden colums - '' // the data is popoluated later via AJAX ); } --- 98,101 ---- *************** *** 414,866 **** return $answerNotes; } ! ! // The following code is believed to be legacy. To be removed. ! // ! // /** ! // * Displays a student selector ! // * ! // * ! // */ ! // public function getStudentSelector($name=NULL, $size=1, $selected=NULL) ! // { ! // if($name == NULL) ! // { ! // $name = 'studentSelector'; ! // } ! // ! // ! // $selector = '<select name="'.$name.'" size="'.$size.'">'; ! // ! // $db = new StackDBUser(); ! // $db->connect(); ! // $users = $db->getAllUsersDetails(); ! // $db->disconnect(); ! // if(empty($users)) ! // { ! // $selector = '<option value="">No Students in Moodle database</option>'; ! // } ! // else ! // { ! // ! // $selector .= '<option value="">All</option>'; ! // ! // foreach($users as $sID => $user) ! // { ! // /*$sID = $this->result($i, 'id'); ! // $username = $this->result($i, 'username');*/ ! // //$sID = $id; ! // $username = $user['username'].' ('.$user['firstname'].' '.$user['lastname'].')'; ! // if($selected == $sID) ! // { ! // $selector .= '<option value="'.$sID.'" selected>'.$username.'</option>'; ! // } ! // else ! // { ! // $selector .= '<option value="'.$sID.'">'.$username.'</option>'; ! // } ! // } ! // } ! // $selector .= '</select>'; ! // ! // return $selector; ! // } ! // ! // /** ! // * Performs a search by student ! // * @return array ! // * @param $param Object ! // */ ! // public function studentSearch($param) ! // { ! // //convert dates to timestamps ! // $startDate = $this->conn->DBTimeStamp(mktime(0,0,0,$param['startMonth'],$param['startDate'],$param['startYear'])); ! // $endDate = $this->conn->DBTimeStamp(mktime(23,59,59,$param['endMonth'],$param['endDate'],$param['endYear'])); //till end of the day ! // ! // //echo '<br /><br />'.date('d-m-Y', $startDate).'<hr>'; ! // //echo '<br /><br />'.date('d-m-Y', $endDate).'<hr>'; ! // //echo "<pre>";print_r($param);echo "</pre>"; ! // ! // if($param['studentSelector'] == "") ! // { ! // $studentSelection = '>= 0'; ! // } ! // else ! // { ! // $studentSelection = "=".$param['studentSelector']; ! // } ! // ! // if($param['questionSelector'] == "") ! // { ! // $questionSelection = '>= 0'; ! // } ! // else ! // { ! // $questionSelection = "=".$param['questionSelector']; ! // } ! // ! // $sql = "SELECT DISTINCT question_attempts.AttemptID, question_attempts.TransitionID, display_cache_sequence.nextNode, question_attempts.UserID, question_attempts.TimeStamp, display_cache.qID, display_cache.currentTotalMark, display_cache.questionNote ! // FROM question_attempts, display_cache, display_cache_sequence ! // WHERE ! // display_cache.qID $questionSelection ! // 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) ! // AND ! // (question_attempts.TimeStamp >= $startDate) AND (question_attempts.TimeStamp <= $endDate) ! // AND ! // UserID $studentSelection ! // ORDER BY UserID, AttemptID"; ! // ! // //echo $sql; ! // $this->query($sql); ! // $no = $this->noRows(); ! // ! // ! // if($no > 0) ! // { ! // for($i=0; $i < $no; $i++) ! // { ! // $trans = $this->result($i,'TransitionID'); ! // $attempt = $this->result($i,'AttemptID'); ! // $userId = $this->result($i, 'UserID'); ! // $timestamp = $this->result($i, 'TimeStamp'); ! // $qu = $this->result($i, 'qID'); ! // $qnote = $this->result($i, 'questionNote'); ! // $mark = $this->result($i, 'currentTotalMark'); ! // $next = $this->result($i, 'nextNode'); ! // $return[] = array('UserID'=>$userId,'TimeStamp'=>$timestamp,'nextNode'=>$next,'QuestionId'=>$qu,'QuestionNote'=>$qnote,'Score'=>$mark,); ! // } ! // ! // return $return; ! // } ! // else ! // { ! // return NULL; ! // } ! // } ! // ! // /** ! // * Performs a search of student answers by question ! // * ! // */ ! // public function questionSearch($param) ! // { ! // $startDate = $this->conn->DBTimeStamp(mktime(0,0,0,$param['startMonth'],$param['startDate'],$param['startYear'])); ! // $endDate = $this->conn->DBTimeStamp(mktime(23,59,59,$param['endMonth'],$param['endDate'],$param['endYear'])); //till end of the day ! // ! // $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 ! // WHERE ! // display_cache.qID = $qid ! // AND ! // (attempt_meta_answer.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 .= "AND (question_attempts.TimeStamp >= $startDate) AND (question_attempts.TimeStamp <= $endDate)"; ! // ! // if($param['status'] !== 'all') ! // { ! // $status = StackDBAttemptAnsMeta::$states[$param['status']]; ! // if ('' !== $status) { ! // $sql .= " AND (attempt_meta_answer.Status = '".$status."')"; ! // } ! // } ! // ! // //echo $sql.$param['status'].$status; ! // ! // $this->query($sql); ! // $no = $this->noRows(); ! // if($no > 0) ! // { ! // $userAttempts = array(); ! // for($i =0; $i < $no; $i++) ! // { ! // $attemptID = $this->result($i, 'AttemptID'); ! // $UserID = $this->result($i, 'UserID'); ! // $QuestionNote = $this->result($i, 'QuestionNote'); ! // $ansName = $this->result($i, 'AnsName'); ! // $rawAns = $this->result($i, 'RawAns'); ! // $status = $this->result($i, 'Status'); ! // $seed = 0; ! // ! // if(!array_key_exists($UserID, $userAttempts)) ! // { ! // $userAttempts[$UserID] = new UserAttempts($UserID, $QuestionNote, $seed); ! // } ! // $userAttempts[$UserID]->addAttempt($attemptID, $ansName, $status, $rawAns); ! // } ! // ! // return $userAttempts; ! // ! // } ! // else ! // { ! // return NULL; ! // } ! // ! // } ! // ! // ! // /* 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 , display_cache.questionNote, 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 display_cache.id ! // ORDER BY attempt_meta_prt.PRTName ASC, attempt_meta_prt.RawMark DESC "; ! // ! // //echo $sql; ! // $this->connect(); ! // $this->query($sql); ! // $no = $this->noRows(); ! // ! // $xhtml = ''; ! // if ($no>0) { ! // ! // $total = array(); ! // $RawMark = array(); ! // $summary = array(); ! // $data = array(); ! // $allAnsNotes = array(); ! // $allQueNotes = array(); ! // for($i=0; $i < $no; $i++) ! // { ! // $PRTName = $this->result($i,'PRTName'); ! // $questionNote = $this->result($i,'questionNote'); ! // $allQueNotes[$questionNote] = true; ! // $AnsNote = $this->result($i,'AnsNote'); ! // $count = $this->result($i,'Count'); ! // $total[$PRTName] += $count; ! // $RawMark[$PRTName][$AnsNote] = $this->result($i,'RawMark'); ! // $summary[$PRTName][$AnsNote] += $count; ! // $data[$PRTName][$AnsNote][$questionNote] += $count; ! // } ! // $allPRTNames = array_keys($data); ! // $allQueNotes = array_keys($allQueNotes); ! // ! // $xhtml .= '<h2>Potential response trees</h2>'; ! // ! // /*$xhtml .= '<table class="reportsStatsTable" border="1" cellpadding="2" cellspacing="0"> ! // <tbody> ! // <tr class="tableHeader"> ! // <td></td> ! // <td>Question Note</td> ! // </tr>'; ! // foreach($allQueNotes as $key => $note) { ! // $xhtml .= "<tr><td>$key</td><td>$note</td></tr>"; ! // } ! // $xhtml .= '</tbody></table>';*/ ! // ! // foreach($allPRTNames as $keyp => $PRT) { ! // ! // $allAnsNotes = array_keys($data[$PRT]); ! // ! // $xhtml .= '<h3>Potential response: '.$PRT.'</h2>'; ! // $xhtml .= '<table class="reportsStatsTable" border="1" cellpadding="2" cellspacing="0"><tbody><tr class="tableHeader"><td></td><td>Raw Mark</td>'; ! // foreach($allQueNotes as $key => $note) { ! // $xhtml .= "<td>$key</td>"; ! // } ! // $xhtml .= "<td>Total</td><td>%</td>"; ! // $xhtml .= '</tr>'; ! // foreach($allAnsNotes as $anote) { ! // $xhtml .= '<tr><td>'.$anote.'</td><td>'.round($RawMark[$PRT][$anote],2).'</td>'; ! // foreach($allQueNotes as $qnote) { ! // $count = $data[$PRT][$anote][$qnote]; ! // $xhtml .= "<td>$count</td>"; ! // } ! // $xhtml .= '<td>'.$summary[$PRT][$anote].'</td>'; ! // $xhtml .= '<td>'.round(100*$summary[$PRT][$anote]/$total[$PRT],1).'</td>'; ! // $xhtml .= '</tr>'; ! // } ! // $xhtml .= '</tbody></table>'; ! // ! // } ! // } ! // ! // return $xhtml; ! // } ! // ! // /** ! // * Displays the number of marks per for a question and the average. ! // * Takes all attempts into account ! // * ! // * ! // */ ! // public function marksStatistics($qid) ! // { ! // $sql = "SELECT PRTName , ModMark , COUNT( ModMark ) AS Count ! // FROM attempt_meta_PRT, display_cache ! // WHERE display_cache.qID = $qid ! // AND display_cache.id = attempt_meta_PRT.CacheID ! // GROUP BY ModMark ! // ORDER BY PRTName "; ! // ! // $this->connect(); ! // $this->query($sql); ! // $this->disconnect(); ! // ! // $no = $this->noRows(); ! // ! // //echo $sql; ! // ! // $xhtml = '<table class="reportsStatsTable" border="1" cellpadding="2" cellspacing="0"> ! // <tbody> ! // <tr> ! // <td>PRT Name</td> ! // <td>Modified Mark</td> ! // <td>Count</td> ! // </tr>'; ! // ! // for($i =0; $i < $no; $i++) ! // { ! // $PRTName = $this->result($i, 'PRTName'); ! // $modMark = $this->result($i, 'ModMark'); ! // $count = $this->result($i, 'Count'); ! // ! // $xhtml .= "<tr> ! // <td>$PRTName</td> ! // <td>$modMark</td> ! // <td>$count</td> ! // </tr>"; ! // ! // } ! // ! // $xhtml .= '</tbody></table>'; ! // ! // return $xhtml; ! // } ! // ! // ! // public function markbookSearch($param) ! // { ! // $startDate = $this->conn->DBTimeStamp(mktime(0,0,0,$param['startMonth'],$param['startDate'],$param['startYear'])); ! // $endDate = $this->conn->DBTimeStamp(mktime(23,59,59,$param['endMonth'],$param['endDate'],$param['endYear'])); //till end of the day ! // ! // $sql = "SELECT questionattempts.AttemptID, QuestionID, UserID, PRTName, attempt_meta_PRT.RawMark, ModMark ! // FROM questionattempts questionattempts, attempt_meta_PRT attempt_meta_PRT ! // WHERE ! // (questionattempts.AttemptID = attempt_meta_PRT.AttemptID) ! // AND ! // (questionattempts.TimeStamp >= $startDate) ! // AND ! // (questionattempts.TimeStamp <= $endDate)"; ! // ! // //set question Id selector ! // if($param["questionSelector"] != '') //ie != all ! // { ! // $qid = $param["questionSelector"]; ! // $sql .= "AND ! // (questionattempts.QuestionID = $qid)"; ! // } ! // ! // //select a certain student ! // if($param['studentSelector'] != '') ! // { ! // $sql .= " AND (questionattempts.UserID = ".$param['studentSelector'].") "; ! // } ! // ! // //set rawmark query ! // switch($param['rawmarks']) ! // { ! // case 'any': ! // //don't add anything ! // break; ! // ! // case 'zero': ! // $sql .= "AND (attempt_meta_PRT.RawMark = 0.0)"; ! // break; ! // ! // case 'notZero': ! // $sql .= "AND (attempt_meta_PRT.RawMark > 0.0)"; ! // break; ! // ! // case 'notFull': ! // $sql .= "AND (attempt_meta_PRT.RawMark < 1.0)"; ! // break; ! // ! // case 'full': ! // $sql .= "AND (attempt_meta_PRT.RawMark = 1.0)"; ! // break; ! // ! // } ! // ! // //set modmark query ! // switch($param['modmarks']) ! // { ! // case 'any': ! // //don't add anything ! // break; ! // ! // case 'zero': ! // $sql .= "AND (attempt_meta_PRT.ModMark = 0.0)"; ! // break; ! // ! // case 'notZero': ! // $sql .= "AND (attempt_meta_PRT.ModMark > 0.0)"; ! // break; ! // ! // case 'notFull': ! // $sql .= "AND (attempt_meta_PRT.ModMark < 1.0)"; ! // break; ! // ! // case 'full': ! // $sql .= "AND (attempt_meta_PRT.ModMark = 1.0)"; ! // break; ! // ! // } ! // ! // $sql .= " ORDER BY QuestionID, UserID, PRTName"; ! // ! // //echo $sql; ! // $this->query($sql); ! // ! // $no = $this->noRows(); ! // $resultsArray = array(); ! // for($i=0; $i < $no; $i++) ! // { ! // $attemptId = $this->result($i, 'AttemptID'); ! // $questionId = $this->result($i, 'QuestionID'); ! // $userId = $this->result($i, 'UserID'); ! // $PRTName = $this->result($i, 'PRTName'); ! // $RawMark = $this->result($i, 'RawMark'); ! // $ModMark = $this->result($i, 'ModMark'); ! // ! // if(!array_key_exists($questionId, $resultsArray) || !array_key_exists($userId, $resultsArray[$questionId])) ! // { ! // $resultsArray[$questionId][$userId] = new MarksAttempt($userId, $questionId); ! // } ! // $resultsArray[$questionId][$userId]->addAttempt($attemptId, $PRTName, $RawMark, $ModMark); ! // } ! // ! // return $resultsArray; ! // } ! // ! } ! ! ?> \ No newline at end of file --- 418,449 ---- return $answerNotes; } ! ! function versions($question) { ! $sql = "SELECT latestVersion, questionID ! FROM stackquestion, question_lines ! WHERE line = SELECT line FROM stackquestion WHERE questionID = $question ! ORDER BY latestVersion DESC"; ! ! $this->connect(); ! $this->query($sql); ! $this->disconnect(); ! ! for ($i=0; $i < $this->noRows(); $i+) { ! $versions[] = array( ! 'version' => $this->result($i, 'latestVersion'); ! 'id' => $this->result($i, 'quesitonID'); ! ) ! } ! return $versions; ! } ! ! function appendTwoFields($arrayOfArrays) { ! foreach ($arrayOfArrays as $key => $array) { ! $array[] = ''; ! $array[] = ''; ! $arrayOfArrays[$key] = $array; ! } ! return $arrayOfArrays; ! } ! ! } \ No newline at end of file |