本文整理匯總了PHP中print_question函數的典型用法代碼示例。如果您正苦於以下問題:PHP print_question函數的具體用法?PHP print_question怎麽用?PHP print_question使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了print_question函數的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: quiz_number_of_pages
</div>
</noscript>
<?php
}
echo '<div>';
/// Print the navigation panel if required
$numpages = quiz_number_of_pages($attempt->layout);
if ($numpages > 1) {
quiz_print_navigation_panel($page, $numpages);
}
/// Print all the questions
$number = quiz_first_questionnumber($attempt->layout, $pagelist);
foreach ($pagequestions as $i) {
$options = quiz_get_renderoptions($quiz->review, $states[$i]);
// Print the question
print_question($questions[$i], $states[$i], $number, $quiz, $options);
save_question_session($questions[$i], $states[$i]);
$number += $questions[$i]->length;
}
/// Print the submit buttons
$strconfirmattempt = addslashes(get_string("confirmclose", "quiz"));
$onclick = "return confirm('{$strconfirmattempt}')";
echo "<div class=\"submitbtns mdl-align\">\n";
echo "<input type=\"submit\" name=\"saveattempt\" value=\"" . get_string("savenosubmit", "quiz") . "\" />\n";
if ($quiz->optionflags & QUESTION_ADAPTIVE) {
echo "<input type=\"submit\" name=\"markall\" value=\"" . get_string("markall", "quiz") . "\" />\n";
}
echo "<input type=\"submit\" name=\"finishattempt\" value=\"" . get_string("finishattempt", "quiz") . "\" onclick=\"{$onclick}\" />\n";
echo "</div>";
// Print the navigation panel if required
if ($numpages > 1) {
示例2: get_string
if ($fillcorrect && !$options->readonly) {
$curstate->responses = $QTYPES[$questions[$id]->qtype]->get_correct_responses($questions[$id], $curstate);
}
$strpreview = get_string('preview', 'quiz') . ' ' . format_string($questions[$id]->name);
$questionlist = array($id);
$headtags = get_html_head_contributions($questionlist, $questions, $states[$historylength]);
print_header($strpreview, '', '', '', $headtags);
print_heading($strpreview);
if (!empty($quizid)) {
echo '<p class="quemodname">' . get_string('modulename', 'quiz') . ': ';
p(format_string($quiz->name));
echo "</p>\n";
}
$number = 1;
echo '<form method="post" action="' . $url->out(true) . '" enctype="multipart/form-data" id="responseform">', "\n";
print_question($questions[$id], $curstate, $number, $quiz, $options);
echo '<div class="controls">';
echo $url->hidden_params_out();
// Print the mark and finish attempt buttons
echo '<input name="markall" type="submit" value="' . get_string('markall', 'quiz') . "\" />\n";
echo '<input name="finishattempt" type="submit" value="' . get_string('finishattempt', 'quiz') . "\" />\n";
echo '<br />';
echo '<br />';
// Print the fill correct button (unless the question is in readonly mode)
if (!$options->readonly) {
echo '<input name="fillcorrect" type="submit" value="' . get_string('fillcorrect', 'quiz') . "\" />\n";
}
// Print the navigation buttons
if ($historylength > 0) {
echo '<input name="back" type="submit" value="' . get_string('previous', 'quiz') . "\" />\n";
}
示例3: print_questions_and_form
/**
* Prints questions with comment and grade form underneath each question
*
* @return void
* @todo Finish documenting this function
**/
function print_questions_and_form($quiz, $question, $userid, $attemptid, $gradeungraded, $gradenextungraded, $ungraded)
{
global $CFG;
// TODO get the context, and put in proper roles an permissions checks.
$context = NULL;
$questions[$question->id] =& $question;
$usehtmleditor = can_use_richtext_editor();
list($select, $from, $where) = $this->attempts_sql($quiz->id, false, $question->id, $userid, $attemptid, $gradeungraded, $gradenextungraded);
$sort = 'ORDER BY u.firstname, u.lastname, qa.attempt ASC';
if ($gradenextungraded) {
$attempts = get_records_sql($select . $from . $where . $sort, 0, QUIZ_REPORT_DEFAULT_GRADING_PAGE_SIZE);
} else {
$attempts = get_records_sql($select . $from . $where . $sort);
}
if ($attempts) {
$firstattempt = current($attempts);
$fullname = fullname($firstattempt);
if ($gradeungraded) {
// getting all ungraded attempts
print_heading(get_string('gradingungraded', 'quiz_grading', $ungraded), '', 3);
} else {
if ($gradenextungraded) {
// getting next ungraded attempts
print_heading(get_string('gradingnextungraded', 'quiz_grading', QUIZ_REPORT_DEFAULT_GRADING_PAGE_SIZE), '', 3);
} else {
if ($userid) {
print_heading(get_string('gradinguser', 'quiz_grading', $fullname), '', 3);
} else {
if ($attemptid) {
$a = new object();
$a->fullname = $fullname;
$a->attempt = $firstattempt->attempt;
print_heading(get_string('gradingattempt', 'quiz_grading', $a), '', 3);
} else {
print_heading(get_string('gradingall', 'quiz_grading', count($attempts)), '', 3);
}
}
}
}
// Display the form with one part for each selected attempt
echo '<form method="post" action="report.php">' . '<input type="hidden" name="mode" value="grading" />' . '<input type="hidden" name="q" value="' . $quiz->id . '" />' . '<input type="hidden" name="sesskey" value="' . sesskey() . '" />' . '<input type="hidden" name="questionid" value="' . $question->id . '" />';
foreach ($attempts as $attempt) {
// Load the state for this attempt (The questions array was created earlier)
$states = get_question_states($questions, $quiz, $attempt);
// The $states array is indexed by question id but because we are dealing
// with only one question there is only one entry in this array
$state =& $states[$question->id];
$options = quiz_get_reviewoptions($quiz, $attempt, $context);
unset($options->questioncommentlink);
$options->noeditlink = true;
$copy = $state->manualcomment;
$state->manualcomment = '';
$options->readonly = 1;
$gradedclass = question_state_is_graded($state) ? ' class="highlightgraded" ' : '';
$gradedstring = question_state_is_graded($state) ? ' ' . get_string('graded', 'quiz_grading') : '';
$a = new object();
$a->fullname = fullname($attempt, true);
$a->attempt = $attempt->attempt;
// print the user name, attempt count, the question, and some more hidden fields
echo '<div class="boxaligncenter" width="80%" style="clear:left;padding:15px;">';
echo "<span{$gradedclass}>" . get_string('gradingattempt', 'quiz_grading', $a);
echo $gradedstring . "</span>";
print_question($question, $state, '', $quiz, $options);
$prefix = "manualgrades[{$attempt->uniqueid}]";
if (!question_state_is_graded($state)) {
$grade = '';
} else {
$grade = round($state->last_graded->grade, 3);
}
$state->manualcomment = $copy;
include $CFG->dirroot . '/question/comment.html';
echo '</div>';
}
echo '<div class="boxaligncenter"><input type="submit" value="' . get_string('savechanges') . '" /></div>' . '</form>';
if ($usehtmleditor) {
use_html_editor();
}
} else {
notify(get_string('noattemptstoshow', 'quiz'));
}
}
示例4: print_questions_and_form
/**
* Prints questions with comment and grade form underneath each question
*
* @return void
* @todo Finish documenting this function
**/
function print_questions_and_form($quiz, $question)
{
global $CFG, $db;
// grade question specific parameters
$gradeall = optional_param('gradeall', 0, PARAM_INT);
$userid = optional_param('userid', 0, PARAM_INT);
$attemptid = optional_param('attemptid', 0, PARAM_INT);
// TODO get the context, and put in proper roles an permissions checks.
$context = NULL;
$questions[$question->id] =& $question;
$usehtmleditor = can_use_richtext_editor();
$users = get_course_students($quiz->course);
$userids = implode(',', array_keys($users));
// this sql joins the attempts table and the user table
$select = 'SELECT ' . sql_concat('u.id', '\'#\'', $db->IfNull('qa.attempt', '0')) . ' AS userattemptid,
qa.id AS attemptid, qa.uniqueid, qa.attempt, qa.timefinish, qa.preview,
u.id AS userid, u.firstname, u.lastname, u.picture ';
$from = 'FROM ' . $CFG->prefix . 'user u LEFT JOIN ' . $CFG->prefix . 'quiz_attempts qa ON (u.id = qa.userid AND qa.quiz = ' . $quiz->id . ') ';
if ($gradeall) {
// get all user attempts
$where = 'WHERE u.id IN (' . $userids . ') ';
} else {
if ($userid) {
// get all the attempts for a specific user
$where = 'WHERE u.id=' . $userid . ' ';
} else {
// get a specific attempt
$where = 'WHERE qa.id=' . $attemptid . ' ';
}
}
// ignore previews
$where .= ' AND preview = 0 ';
$where .= 'AND ' . $db->IfNull('qa.attempt', '0') . ' != 0 ';
$where .= 'AND ' . $db->IfNull('qa.timefinish', '0') . ' != 0 ';
$sort = 'ORDER BY u.firstname, u.lastname, qa.attempt ASC';
$attempts = get_records_sql($select . $from . $where . $sort);
// Display the form with one part for each selected attempt
echo '<form method="post" action="report.php">' . '<input type="hidden" name="mode" value="grading" />' . '<input type="hidden" name="q" value="' . $quiz->id . '" />' . '<input type="hidden" name="sesskey" value="' . sesskey() . '" />' . '<input type="hidden" name="action" value="viewquestion" />' . '<input type="hidden" name="questionid" value="' . $question->id . '" />';
foreach ($attempts as $attempt) {
// Load the state for this attempt (The questions array was created earlier)
$states = get_question_states($questions, $quiz, $attempt);
// The $states array is indexed by question id but because we are dealing
// with only one question there is only one entry in this array
$state =& $states[$question->id];
$options = quiz_get_reviewoptions($quiz, $attempt, $context);
unset($options->questioncommentlink);
$copy = $state->manualcomment;
$state->manualcomment = '';
$options->readonly = 1;
// print the user name, attempt count, the question, and some more hidden fields
echo '<div class="boxaligncenter" width="80%" style="padding:15px;">' . fullname($attempt, true) . ': ' . get_string('attempt', 'quiz') . $attempt->attempt;
print_question($question, $state, '', $quiz, $options);
$prefix = "manualgrades[{$attempt->uniqueid}]";
$grade = round($state->last_graded->grade, 3);
$state->manualcomment = $copy;
include $CFG->dirroot . '/question/comment.html';
echo '</div>';
}
echo '<div class="boxaligncenter"><input type="submit" value="' . get_string('savechanges') . '" /></div>' . '</form>';
if ($usehtmleditor) {
use_html_editor();
}
}
示例5: game_print_questions
function game_print_questions($pagelist, $attempt, $questions, $options, $states, $game)
{
$pagequestions = explode(',', $pagelist);
$number = game_first_questionnumber($attempt->layout, $pagelist);
foreach ($pagequestions as $i) {
if (!isset($questions[$i])) {
print_simple_box_start('center', '90%');
echo '<strong><font size="+1">' . $number . '</font></strong><br />';
notify(get_string('errormissingquestion', 'game', $i));
print_simple_box_end();
$number++;
// Just guessing that the missing question would have lenght 1
continue;
}
$options->validation = QUESTION_EVENTVALIDATE === $states[$i]->event;
//$options->history = ($isteacher and !$attempt->preview) ? 'all' : 'graded';
$options->history = false;
unset($options->questioncommentlink);
// Print the question
if ($i > 0) {
echo "<br />\n";
}
$questions[$i]->maxgrade = 0;
$options->correct_responses = 0;
$options->feedback = 0;
$options->readonly = 0;
global $QTYPES;
unset($cmoptions);
$cmoptions->course = $game->course;
$cmoptions->optionflags->optionflags = 0;
$cmoptions->id = 0;
$cmoptions->shuffleanswers = 1;
$attempt = 0;
$question = $questions[$i];
if (!$QTYPES[$question->qtype]->create_session_and_responses($question, $state, $cmoptions, $attempt)) {
error('game_sudoku_showquestions_quiz: problem');
}
$cmoptions->optionflags = 0;
print_question($question, $states[$i], $number, $cmoptions, $options);
$number += $questions[$i]->length;
}
}
示例6: print_questions_and_form
/**
* Prints questions with comment and grade form underneath each question
*
* @return void
* @todo Finish documenting this function
**/
function print_questions_and_form($quiz, $question, $userid, $attemptid, $gradeungraded, $gradenextungraded, $ungraded)
{
global $CFG, $DB, $OUTPUT;
$context = get_context_instance(CONTEXT_MODULE, $this->cm->id);
$questions[$question->id] =& $question;
$usehtmleditor = can_use_html_editor();
list($select, $from, $where, $params) = $this->attempts_sql($quiz->id, false, $question->id, $userid, $attemptid, $gradeungraded, $gradenextungraded);
$sort = 'ORDER BY u.firstname, u.lastname, qa.attempt ASC';
if ($gradenextungraded) {
$attempts = $DB->get_records_sql($select . $from . $where . $sort, $params, 0, QUIZ_REPORT_DEFAULT_GRADING_PAGE_SIZE);
} else {
$attempts = $DB->get_records_sql($select . $from . $where . $sort, $params);
}
if ($attempts) {
$firstattempt = current($attempts);
$fullname = fullname($firstattempt);
if ($gradeungraded) {
// getting all ungraded attempts
echo $OUTPUT->heading(get_string('gradingungraded', 'quiz_grading', $ungraded), 3);
} else {
if ($gradenextungraded) {
// getting next ungraded attempts
echo $OUTPUT->heading(get_string('gradingnextungraded', 'quiz_grading', QUIZ_REPORT_DEFAULT_GRADING_PAGE_SIZE), 3);
} else {
if ($userid) {
echo $OUTPUT->heading(get_string('gradinguser', 'quiz_grading', $fullname), 3);
} else {
if ($attemptid) {
$a = new object();
$a->fullname = $fullname;
$a->attempt = $firstattempt->attempt;
echo $OUTPUT->heading(get_string('gradingattempt', 'quiz_grading', $a), 3);
} else {
echo $OUTPUT->heading(get_string('gradingall', 'quiz_grading', count($attempts)), 3);
}
}
}
}
// Display the form with one part for each selected attempt
echo '<form method="post" action="report.php" class="mform" id="manualgradingform">' . '<input type="hidden" name="mode" value="grading" />' . '<input type="hidden" name="q" value="' . $quiz->id . '" />' . '<input type="hidden" name="sesskey" value="' . sesskey() . '" />' . '<input type="hidden" name="questionid" value="' . $question->id . '" />';
foreach ($attempts as $attempt) {
// Load the state for this attempt (The questions array was created earlier)
$states = get_question_states($questions, $quiz, $attempt);
// The $states array is indexed by question id but because we are dealing
// with only one question there is only one entry in this array
$state =& $states[$question->id];
$options = quiz_get_reviewoptions($quiz, $attempt, $context);
unset($options->questioncommentlink);
$options->readonly = 1;
if (question_state_is_graded($state)) {
$gradedclass = 'main highlightgraded';
$gradedstring = ' ' . get_string('graded', 'quiz_grading');
} else {
$gradedclass = 'main';
$gradedstring = '';
}
$a = new object();
$a->fullname = fullname($attempt, true);
$a->attempt = $attempt->attempt;
// print the user name, attempt count, the question, and some more hidden fields
echo '<div class="boxaligncenter" width="80%" style="clear:left;padding:15px;">';
echo $OUTPUT->heading(get_string('gradingattempt', 'quiz_grading', $a) . $gradedstring, 3, $gradedclass);
// Print the question, without showing any previous comment.
$copy = $state->manualcomment;
$state->manualcomment = '';
$options->noeditlink = true;
print_question($question, $state, '', $quiz, $options);
// The print the comment and grade fields, putting back the previous comment.
$state->manualcomment = $copy;
question_print_comment_fields($question, $state, 'manualgrades[' . $attempt->uniqueid . ']', $quiz, get_string('manualgrading', 'quiz'));
echo '</div>';
}
echo '<div class="boxaligncenter"><input type="submit" value="' . get_string('savechanges') . '" /></div>' . '</form>';
} else {
echo $OUTPUT->notification(get_string('noattemptstoshow', 'quiz'));
}
}
示例7: print_heading
// for overlib
/// Print heading
print_heading(format_string($question->name));
/// Print infobox
$table->align = array("right", "left");
if ($attempt->userid != $USER->id) {
// Print user picture and name
$student = get_record('user', 'id', $attempt->userid);
$picture = print_user_picture($student, $course->id, $student->picture, false, true);
$table->data[] = array($picture, fullname($student, true));
}
// print quiz name
$table->data[] = array(get_string('modulename', 'quiz') . ':', format_string($quiz->name));
if (has_capability('mod/quiz:viewreports', $context) and count($attempts = get_records_select('quiz_attempts', "quiz = '{$quiz->id}' AND userid = '{$attempt->userid}'", 'attempt ASC')) > 1) {
// print list of attempts
$attemptlist = '';
foreach ($attempts as $at) {
$attemptlist .= $at->id == $attempt->id ? '<b>' . $at->attempt . '</b>, ' : '<a href="' . $baseurl . $at->id . '">' . $at->attempt . '</a>, ';
}
$table->data[] = array(get_string('attempts', 'quiz') . ':', trim($attemptlist, ' ,'));
}
if ($state->timestamp) {
// print time stamp
$table->data[] = array(get_string("completedon", "quiz") . ':', userdate($state->timestamp));
}
// Print info box unless it is empty
if ($table->data) {
print_table($table);
}
print_question($question, $state, $number, $quiz, $options);
print_footer();
示例8: print_question
/**
* Wrapper round print_question from lib/questionlib.php.
*
* @param integer $id the id of a question in this quiz attempt.
* @param boolean $reviewing is the being printed on an attempt or a review page.
* @param string $thispageurl the URL of the page this question is being printed on.
*/
public function print_question($id, $reviewing, $thispageurl = '')
{
global $CFG;
if ($reviewing) {
$options = $this->get_review_options();
} else {
$options = $this->get_render_options($id);
}
if ($thispageurl instanceof moodle_url) {
$thispageurl = $thispageurl->out(false);
}
if ($thispageurl) {
$this->quiz->thispageurl = str_replace($CFG->wwwroot, '', $thispageurl);
} else {
unset($thispageurl);
}
print_question($this->questions[$id], $this->states[$id], $this->questions[$id]->_number, $this->quiz, $options);
}
示例9: print_question
/**
* Wrapper round print_question from lib/questionlib.php.
*
* @param integer $id the id of a question in this quiz attempt.
* @param boolean $reviewing is the being printed on an attempt or a review page.
* @param string $thispageurl the URL of the page this question is being printed on.
*/
public function print_question($id, $reviewing, $thispageurl = '')
{
if ($reviewing) {
$options = $this->get_review_options();
} else {
$options = $this->get_render_options($this->states[$id]);
}
if ($thispageurl) {
$this->quiz->thispageurl = $thispageurl;
} else {
unset($thispageurl);
}
$actual = print_question($this->questions[$id], $this->states[$id], $this->questions[$id]->_number, $this->quiz, $options);
return $actual;
}
示例10: game_snakes_showquestion_question
function game_snakes_showquestion_question($game, $id, $snakes, $query)
{
global $CFG;
$questionlist = $query->questionid;
$questions = game_sudoku_getquestions($questionlist);
/// Start the form
//echo '<br>';
echo "<form id=\"responseform\" method=\"post\" action=\"{$CFG->wwwroot}/mod/game/attempt.php\" onclick=\"this.autocomplete='off'\">\n";
echo "<center><input type=\"submit\" name=\"finishattempt\" value=\"" . get_string('sudoku_submit', 'game') . "\"></center>\n";
// Add a hidden field with the quiz id
echo '<input type="hidden" name="id" value="' . s($id) . "\" />\n";
echo '<input type="hidden" name="action" value="snakescheck" />';
echo '<input type="hidden" name="queryid" value="' . $query->id . "\" />\n";
/// Print all the questions
// Add a hidden field with questionids
echo '<input type="hidden" name="questionids" value="' . $questionlist . "\" />\n";
foreach ($questions as $question) {
global $QTYPES;
unset($cmoptions);
$cmoptions->course = $game->course;
$cmoptions->shuffleanswers = $question->options->shuffleanswers = false;
$cmoptions->optionflags->optionflags = 0;
$cmoptions->id = 0;
$cmoptions->questiondecimalpoints = 2;
$cmoptions->thispageurl = ' ';
$attempt = 0;
if (!$QTYPES[$question->qtype]->create_session_and_responses($question, $state, $cmoptions, $attempt)) {
error('game_sudoku_showquestions_quiz: problem');
}
$state->last_graded = new StdClass();
$state->last_graded->event = QUESTION_EVENTOPEN;
$state->event = QUESTION_EVENTOPEN;
$state->attempt = 0;
$state->question = '';
$state->manualcommentformat = '';
$options->scores->score = 0;
$question->maxgrade = 100;
$state->manualcomment = '';
$cmoptions->optionflags = 0;
$options->correct_responses = 0;
$options->feedback = 0;
$options->readonly = 0;
$options->flags = false;
print_question($question, $state, '', $cmoptions, $options);
break;
}
echo "</form>\n";
}
示例11: game_sudoku_showquestions_quiz
function game_sudoku_showquestions_quiz($id, $game, $attempt, $sudoku, $offsetquestions, $numbers, $correctquestions, $onlyshow, $showsolution)
{
$questionlist = game_sudoku_getquestionlist($offsetquestions);
$questions = game_sudoku_getquestions($questionlist);
//I will sort with the number of each question
$questions2 = array();
foreach ($questions as $q) {
$ofs = $numbers[$q->id];
$questions2[$ofs] = $q;
}
ksort($questions2);
if (count($questions2) == 0) {
game_sudoku_showquestion_onfinish($id, $game, $attempt, $sudoku);
return;
}
global $CFG;
/// Start the form
echo "<form id=\"responseform\" method=\"post\" action=\"{$CFG->wwwroot}/mod/game/attempt.php\" onclick=\"this.autocomplete='off'\">\n";
if ($onlyshow === false and $showsolution === false) {
echo "<br><center><input type=\"submit\" name=\"submit\" value=\"" . get_string($game->gamekind . '_submit', 'game') . "\">";
echo " <input type=\"submit\" name=\"finishattempt\" value=\"" . get_string($game->gamekind . '_finishattemptbutton', 'game') . "\">";
}
// Add a hidden field with the quiz id
echo '<div>';
echo '<input type="hidden" name="id" value="' . s($id) . "\" />\n";
echo '<input type="hidden" name="action" value="' . get_string($game->gamekind) . 'check" />';
/// Print all the questions
// Add a hidden field with questionids
echo '<input type="hidden" name="questionids" value="' . $questionlist . "\" />\n";
$number = 0;
foreach ($questions2 as $question) {
$ofs = $numbers[$question->id];
if (array_key_exists($ofs, $correctquestions)) {
continue;
//I don't show the correct answers
}
$number = "<a name=\"a{$ofs}\">A{$ofs}</a>";
global $QTYPES;
unset($cmoptions);
$cmoptions->course = $game->course;
$cmoptions->optionflags->optionflags = 0;
$cmoptions->id = 0;
$cmoptions->shuffleanswers = 1;
$attempt = 0;
if (!$QTYPES[$question->qtype]->create_session_and_responses($question, $state, $cmoptions, $attempt)) {
error('game_sudoku_showquestions_quiz: problem');
}
$state->last_graded = new StdClass();
$state->last_graded->event = QUESTION_EVENTOPEN;
$state->event = QUESTION_EVENTOPEN;
$options->scores->score = 0;
$question->maxgrade = 100;
$state->manualcomment = '';
$cmoptions->optionflags = 0;
$options->correct_responses = 0;
$options->feedback = 0;
$options->readonly = 0;
if ($showsolution) {
$state->responses = $QTYPES[$question->qtype]->get_correct_responses($question, $state);
}
print_question($question, $state, $number, $cmoptions, $options);
}
echo "</div>";
// Finish the form
echo '</div>';
if ($onlyshow === false and $showsolution === false) {
echo "<center><input type=\"submit\" name=\"submit\" value=\"" . get_string($game->gamekind . '_submit', 'game') . "\"></center>\n";
}
echo "</form>\n";
}
示例12: game_bookquiz_showquestions
function game_bookquiz_showquestions($id, $questionid, $chapterid, $nextchapterid, $scoreattempt, $game)
{
$onlyshow = false;
$showsolution = false;
$questionlist = $questionid;
$questions = game_sudoku_getquestions($questionlist);
global $CFG;
/// Start the form
echo "<form id=\"responseform\" method=\"post\" action=\"{$CFG->wwwroot}/mod/game/attempt.php\" onclick=\"this.autocomplete='off'\">\n";
if ($onlyshow === false and $showsolution === false) {
echo "<center><input type=\"submit\" name=\"finishattempt\" value=\"" . get_string('sudoku_submit', 'game') . "\"></center>\n";
}
// Add a hidden field with the quiz id
echo '<div>';
echo '<input type="hidden" name="id" value="' . s($id) . "\" />\n";
echo '<input type="hidden" name="action" value="bookquizcheck" />';
echo '<input type="hidden" name="chapterid" value="' . $chapterid . '" />';
echo '<input type="hidden" name="scoreattempt" value="' . $scoreattempt . '" />';
echo '<input type="hidden" name="nextchapterid" value="' . $nextchapterid . '" />';
/// Print all the questions
// Add a hidden field with questionids
echo '<input type="hidden" name="questionids" value="' . $questionlist . "\" />\n";
$number = 0;
foreach ($questions as $question) {
global $QTYPES;
unset($cmoptions);
$cmoptions->course = $game->course;
$cmoptions->optionflags->optionflags = 0;
$cmoptions->id = 0;
$cmoptions->shuffleanswers = 1;
$attempt = 0;
if (!$QTYPES[$question->qtype]->create_session_and_responses($question, $state, $cmoptions, $attempt)) {
error('game_bookquiz_showquestions: problem');
}
$state->last_graded = new StdClass();
$state->last_graded->event = QUESTION_EVENTOPEN;
$state->event = QUESTION_EVENTOPEN;
$options->scores->score = 0;
$question->maxgrade = 100;
$state->manualcomment = '';
$cmoptions->optionflags = 0;
$options->correct_responses = 0;
$options->feedback = 0;
$options->readonly = 0;
if ($showsolution) {
$state->responses = $QTYPES[$question->qtype]->get_correct_responses($question, $state);
}
$number++;
print_question($question, $state, $number, $cmoptions, $options);
}
echo "</div>";
// Finish the form
echo '</div>';
if ($onlyshow === false and $showsolution === false) {
echo "<center><input type=\"submit\" name=\"finishattempt\" value=\"" . get_string('sudoku_submit', 'game') . "\"></center>\n";
}
echo "</form>\n";
}