From: Ben H. <bdv...@us...> - 2010-12-20 12:44:00
|
Update of /cvsroot/stack/stack-dev/lib/reporting In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv27375/lib/reporting Modified Files: json.php StackReport.php ReportWidgets.php Log Message: Made a simplified interface, it has minimal amounts of JS in it but provides almost the same amount of information as the interactive interface. Index: ReportWidgets.php =================================================================== RCS file: /cvsroot/stack/stack-dev/lib/reporting/ReportWidgets.php,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ReportWidgets.php 30 Sep 2010 16:56:15 -0000 1.8 --- ReportWidgets.php 20 Dec 2010 12:43:51 -0000 1.9 *************** *** 35,41 **** * Makes an html selector given an array of value : text pairs. */ ! private function selector($options, $name, $selected = null) { ! $sel .= "<select name=\"$name\">"; foreach ($options as $value => $text) { --- 35,41 ---- * Makes an html selector given an array of value : text pairs. */ ! private function selector($options, $name, $selected = null, $extra = null) { ! $sel .= "<select name=\"$name\" $extra>"; foreach ($options as $value => $text) { *************** *** 50,54 **** /** ! * Makes an HTML select element with questions as options */ public function questionSelector ($selected = null) { --- 50,54 ---- /** ! * Makes an HTML select element with questions as options for the simple reporting interface */ public function questionSelector ($selected = null) { *************** *** 61,73 **** } else { foreach ($qs as $q) { $options[$q[0]] = $q[0] . ' - ' . substr($q[1], 0, 40); // abreviate the name } } ! return $this->selector($options, 'questionSelector', $selected); } /** ! * Makes an HTML select element with questions as options */ public function studentSelector ($selected = null) { --- 61,74 ---- } else { foreach ($qs as $q) { + $options[''] = 'All questions'; $options[$q[0]] = $q[0] . ' - ' . substr($q[1], 0, 40); // abreviate the name } } ! return $this->selector($options, 'questionSelector', $selected, 'onChange = "this.parentElement.submit()"'); } /** ! * Makes an HTML select element with questions as options for the simple reporting interface */ public function studentSelector ($selected = null) { *************** *** 80,88 **** } else { foreach ($students as $s) { $options[$s[0]] = $s[0] . ' - ' . $s[2] . ' ' . $s[3]; // abreviate the name } } ! return $this->selector($options, 'studentSelector', $selected); } --- 81,90 ---- } else { foreach ($students as $s) { + $options[''] = 'All students'; $options[$s[0]] = $s[0] . ' - ' . $s[2] . ' ' . $s[3]; // abreviate the name } } ! return $this->selector($options, 'studentSelector', $selected, 'onChange = this.parentElement.submit()'); } Index: StackReport.php =================================================================== RCS file: /cvsroot/stack/stack-dev/lib/reporting/StackReport.php,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** StackReport.php 1 Dec 2010 12:05:14 -0000 1.27 --- StackReport.php 20 Dec 2010 12:43:51 -0000 1.28 *************** *** 29,32 **** --- 29,36 ---- require_once $root . '/lib/database/StackDBUser.php'; + // used in simple report + require_once $root . '/lib/database/StackDBItem.php'; + require_once $root . '/lib/ui/DisplayItem.php'; + require_once $root . '/lib/dateTime.php'; require_once $root . '/lib/translator.php'; *************** *** 60,64 **** break; ! case 'question': $qID = $posted['questionSelector']; --- 64,74 ---- break; ! case 'simple': ! $xhtml .= $this->simpleInterface(); ! break; ! ! // The rest probably aren't worth considering anymore. ! ! case 'question': $qID = $posted['questionSelector']; *************** *** 66,70 **** $result = $db->questionSearch($posted); ! echo "<pre>here";print_r($result); $xhtml .= $this->questionSummaryBox($result, $posted); --- 76,80 ---- $result = $db->questionSearch($posted); ! echo "<pre>here"; print_r($result); echo "</pre>"; $xhtml .= $this->questionSummaryBox($result, $posted); *************** *** 82,89 **** break; - case 'simple': - $xhtml .= $this->simpleInterface(); - break; - default: --- 92,95 ---- *************** *** 1337,1401 **** public function simpleInterface() { $xhtml = '<div class="section"><h3>Quick report</h3>'; ! $db = new StackDBReporting(); ! $db->connect(); ! $students = $db->studentList(); - $widgets = new ReportWidgets(); - - $xhtml .= print_r($_POST,1); - - $xhtml .= "<form id='form1' method='POST' action='report.php?type=simple'>"; ! $xhtml .= "<select name='studentSelector' onChange='document.getElementById(\"form1\").submit()'>"; ! $xhtml .= "<option value=''>All students</option>"; ! foreach($students as $student) { ! $xhtml .= "<option value='$student[0]'"; ! if($student[0] == $_POST['studentSelector']) $xhtml .= " SELECTED"; ! $xhtml .= ">$student[2] $student[3]</option>"; ! } ! $xhtml .= "</select>"; ! $questions = $db->questionList(); ! $xhtml .= "<select name='questionSelector' onChange='document.getElementById(\"form1\").submit()'>"; ! $xhtml .= "<option value=''>All questions</option>"; ! foreach($questions as $question) { ! $xhtml .= "<option value='$question[0]'"; ! if($question[0] == $_POST['questionSelector']) $xhtml .= " SELECTED"; ! $xhtml .= ">$question[1]</option>"; ! } ! $xhtml .= "</select>"; ! ! ! //$xhtml .= print_r($questions,1); ! /* ! $xhtml .= $db->getStudentSelector('student'). ! ' or '. ! $db->getQuestionSelector('question', 1, $_POST['question']);*/ ! //$xhtml .= $widgets->studentSelector($_POST['studentSelector']); ! //$xhtml .= '<input type="submit" name="submit" value="student report" /><p />'; ! //$xhtml .= $widgets->questionSelector($_POST['questionSelector']); ! // $xhtml .= '<input type="submit" name="submit" value="question report" />'; ! $xhtml .= '</form>'; ! if(!empty($_POST['studentSelector'])) { ! $xhtml .= print_r($db->questionsByStudent($_POST['studentSelector']),1); ! $questions = $db->questionsByStudent($_POST['studentSelector']); ! if($questions) { ! foreach($questions as $key => $val) { ! $q['questionSelector'] = $key; ! $xhtml .= $db->answerNoteStatistics($q); } } ! } ! if(!empty($_POST['questionSelector'])) { ! //$xhtml .= print_r($db->studentAnswerNotes($_POST['questionSelector']),1); ! $xhtml .= print_r($_POST['questionSelector'],1); ! $xhtml .= $db->answerNoteChart($_POST['questionSelector']); } $xhtml .= '</div>'; - $xhtml .= $_POST['questionSelector']; return $xhtml; } --- 1343,1479 ---- public function simpleInterface() { + + $db = new StackDBReporting(); + $widgets = new ReportWidgets(); + $xhtml = '<div class="section"><h3>Quick report</h3>'; ! $xhtml .= "<form method='POST' action='report.php?type=simple'>"; ! $xhtml .= $widgets->studentSelector($_POST['studentSelector']); ! $xhtml .= $widgets->questionSelector($_POST['questionSelector']); ! $selQ = ! empty($_POST['questionSelector']); ! $selS = ! empty($_POST['studentSelector']); ! if ($selQ and $selS) { // both question and student selected ! ! $data = $db->latestAttemptItem($_POST['questionSelector'], $_POST['studentSelector']); ! //$xhtml .= print_r ($data, true); ! ! $xhtml .= '<h4>The student was presented with this question note:</h4><p>' . $data['note'] . '</p><p> ! <a href="http://localhost/stack/lib/ui/questionTest.php?id=19&seed=' ! . $data['item']->getQuestionSeed() ! . '"> Click here to try it in the test question interface.</a></p>'; ! ! $xhtml .= '<h4>They made the following attempts:</h4><p>' . $data['item']->displayAttempts() . '</p>'; ! ! $xhtml .= '<h4>And here is a worked solution:</h4><p>' . $data['item']->getWorkedSolution() . '</p>'; ! ! ! } else if ($selS) { // just a student selected ! ! $qsTried = $db->questionsByStudent($_POST['studentSelector']); ! ! if ($qsTried) { ! $xhtml .= '<table>'; ! $xhtml .= '<thead><tr> ! <th>They tried this question</th> ! <th>This many times</th> ! <th>With a score of</th> ! <th>Select this question for more info about attempts</th> ! </tr></thead>'; ! foreach ($qsTried as $q => $stats) { ! $xhtml .= "<tr> ! <td>$q</td> ! <td>{$stats['attempts']}</td> ! <td>{$stats['mark']}</td> ! <td><input type=\"submit\" value=\"Select $q\" onClick=\"document.getElementsByName('questionSelector')[0].value = $q\" /></td> ! </tr>"; } + + $xhtml .= '</table>'; + } else { + $xhtml .= '<p>It would appear this student has never tried a question.</p>'; } ! ! } else if ($selQ) { // just a question selected ! ! // Some question notes ! ! $xhtml .= '<h4>The question has the following question notes</h4>'; ! ! $qNotes = $db->questionNotes($_POST['questionSelector']); ! ! if ($qNotes) { ! foreach ($qNotes as $note) { ! $xhtml .= "<p>{$note['note']}</p>"; ! } ! } else { ! $xhtml .= "<p>There are no question notes!</p>"; ! } ! ! /* ! // Lots of PRTs ! ! $xhtml .= '<h4>PRTs for this question</h4>'; ! ! $prts = $db->PRTs($_POST['questionSelector']); ! ! $xhtml .= '<div style="display: block; border: 1px solid #000; padding: 10px; margin: 10px;"> ! prts by q gives <pre>' . print_r($prts,1) . '</pre></div>'; ! ! foreach ($prts as $name => $prt) { ! $xhtml .= "<h5>$name has {$prt['total']} had attempt(s) made at it</h5>"; ! $xhtml .= '<table>'; ! $xhtml .= '<tbody><tr><td colspan="2"></td><th colspan="' . count($qNotes) . '">Question Notes</th><td colspan="2"></td></tr>'; ! $xhtml .= '<tr><th>Answer note</th><th>Score</th>'; ! foreach ($qNotes as $n) { ! $xhtml .= "<th>{$n['note']}</th>"; ! } ! $xhtml .= '<th>Total attempts</td><th>Percentage</th></tr>'; ! ! // And the rest is to be done in the MORNING, well later in the morning. ! // refer to report.js:409 ! ! $xhtml .= '</table>'; ! } ! */ ! ! // and lots of students ! ! $xhtml .= '<h4>Students who attempted this question</h4>'; ! ! $ssTried = $db->studentsByQuestion($_POST['questionSelector']); ! ! if ($ssTried) { ! $xhtml .= '<table>'; ! $xhtml .= '<thead><tr> ! <th>Who tried this question</th> ! <th>This many times</th> ! <th>With a score of</th> ! <th>Select this student for more info about attempts</th> ! </tr></thead>'; ! foreach ($ssTried as $s => $stats) { ! ! $xhtml .= "<tr> ! <td>$s</td> ! <td>{$stats['attempts']}</td> ! <td>{$stats['mark']}</td> ! <td><input type=\"submit\" value=\"Select $s\" onClick=\"document.getElementsByName('studentSelector')[0].value = $s\" /></td> ! </tr>"; ! } ! ! $xhtml .= '</table>'; ! } else { ! $xhtml .= '<p>Apparently no attempt has ever been made at this question.</p>'; ! } ! } + + $xhtml .= '</form>'; $xhtml .= '</div>'; return $xhtml; } Index: json.php =================================================================== RCS file: /cvsroot/stack/stack-dev/lib/reporting/json.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** json.php 29 Nov 2010 08:21:46 -0000 1.3 --- json.php 20 Dec 2010 12:43:51 -0000 1.4 *************** *** 83,87 **** $question = $_GET['question']; $result = $db->latestAttemptItem($question, $student); ! if ($db != null) { echo json_encode(array( 'history' => $result['item']->displayAttempts(), --- 83,87 ---- $question = $_GET['question']; $result = $db->latestAttemptItem($question, $student); ! if ($result != null) { echo json_encode(array( 'history' => $result['item']->displayAttempts(), |