Example #1
0
 /**
  * @param Question $question
  * @return null|QuestionResponse
  */
 public function getResponseForQuestion(Question $question)
 {
     if (count($this->getResponses()) > 0) {
         foreach ($this->getResponses() as $response) {
             if ($question->getQuestionID() == $response->getQuestionID()) {
                 return $response;
             }
         }
     }
     return null;
 }
Example #2
0
\t<th>Summary</th>
\t<th>Type</th>
\t<th>Quiz</th>
\t<th>Created</th>
\t<th>Reviewed</th>
\t<th></th>
</tr>
EOT;
/** Display questions - could use a table formatter function, but for now coded in this file **/
/* This is very inefficient and results in very slow load times - need to reduce the number of sql queries */
foreach ($questions_array as $this_question_entry) {
    print "<tr>\n";
    //print "<td>$this_question_entry</td>";
    $this_question = new Question($qdb->getQuestion($this_question_entry));
    // Allow either q number or summary to be clicked (as summary may be null - eg. picture quiz)
    print "<td><a href=\"" . ADMIN_EDIT_FILE . "?question=" . $this_question->getQuestionID() . "\">{$this_question_entry}</a></td>";
    // Note hard coded length of summary (this file to be discontinued)
    print "<td><a href=\"" . ADMIN_EDIT_FILE . "?question=" . $this_question->getQuestionID() . "\">" . $this_question->getSummary(45) . "</a></td>";
    print "<td>" . $this_question->getType() . "</td>";
    print "<td>" . $this_question->getQuizzes() . "</td>";
    print "<td>" . $this_question->getCreated() . "</td>";
    print "<td>" . $this_question->getReviewed() . "</td>\n";
    print "<td><a href=\"" . ADMIN_Q_FILE . "?question=" . $this_question->getQuestionID() . "\">Test</a></td>\n";
    print "</tr>\n";
}
print "</table>\n";
if (isset($debug) && $debug) {
    $end_time = time();
    $total_time = $end_time - $start_time;
    print "Start time: {$start_time} \n";
    print "End time: {$end_time} \n";
Example #3
0
}
// no questionid - error and back to index page
// 0 is used for new rather than edit
if ($questionid < 0) {
    $err = Errors::getInstance();
    $err->errorEvent(WARNING_QUESTION, "Unable to load question {$questionid}");
    // redirect to admin index page
    if (!$debug) {
        header("Location: " . ADMIN_FILE . "?status=" . WARNING_QUESTION);
    }
    exit(0);
} elseif ($questionid > 0) {
    // load questionid
    $question = new Question($qdb->getQuestion($questionid));
    // now check that we have loaded question correctly - check that the db read was valid
    if ($questionid != $question->getQuestionID()) {
        $err = Errors::getInstance();
        $err->errorEvent(WARNING_PARAMETER, "Question parameter missing on edit page");
        // redirect to admin index page
        if (!$debug) {
            header("Location: " . ADMIN_FILE . "?status=" . WARNING_PARAMETER);
        }
        exit(0);
    }
}
/* At this point we have loaded the current question - (or it's a new) so display form */
require_once $include_dir . "adminmenu.php";
print "<h2>Edit Question</h2>\n";
print $message . "\n";
print "<p>Do NOT use apostrophes etc, instead use their html equivelant.<br />(e.g. &amp;quot; = &quot;  &amp;amp;=&amp;)</p>\n";
print "<form action=\"" . ADMIN_EDIT_FILE . "\" method=\"post\">\n";