本文整理汇总了PHP中Question::selectTitle方法的典型用法代码示例。如果您正苦于以下问题:PHP Question::selectTitle方法的具体用法?PHP Question::selectTitle怎么用?PHP Question::selectTitle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Question
的用法示例。
在下文中一共展示了Question::selectTitle方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Question
// kai me to katallhlo hidden pedio
echo "<form method='GET' action='backFromExercise.php'><input type='hidden' name='course' value='$course_code'>" .
"<input type='hidden' name='op' value='finish'>";
$i = $totalScore = $totalWeighting = 0;
// for each question
foreach ($_SESSION['questionList'][$exerciseId] as $questionId) {
// gets the student choice for this question
$choice = @$_SESSION['exerciseResult'][$exerciseId][$questionId];
// creates a temporary Question object
$objQuestionTmp = new Question();
$objQuestionTmp->read($questionId);
$questionName = $objQuestionTmp->selectTitle();
$questionDescription = $objQuestionTmp->selectDescription();
$questionDescription_temp = nl2br(make_clickable($questionDescription));
$questionDescription_temp = mathfilter($questionDescription_temp, 12, "$webDir/courses/mathimg/");
$questionWeighting = $objQuestionTmp->selectWeighting();
$answerType = $objQuestionTmp->selectType();
// destruction of the Question object
unset($objQuestionTmp);
if ($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER || $answerType == TRUE_FALSE) {
$colspan = 4;
} elseif ($answerType == MATCHING) {
$colspan = 2;
} else {
$colspan = 1;
示例2: showQuestion
/**
* Shows a question
* @param Question $objQuestionTmp
* @param bool $only_questions if true only show the questions, no exercise title
* @param bool $origin origin i.e = learnpath
* @param string $current_item current item from the list of questions
* @param bool $show_title
* @param bool $freeze
* @param array $user_choice
* @param bool $show_comment
* @param null $exercise_feedback
* @param bool $show_answers
* @param null $modelType
* @param bool $categoryMinusOne
* @return bool|null|string
*/
public function showQuestion(Question $objQuestionTmp, $only_questions = false, $origin = false, $current_item = '', $show_title = true, $freeze = false, $user_choice = array(), $show_comment = false, $exercise_feedback = null, $show_answers = false, $modelType = null, $categoryMinusOne = true)
{
// Text direction for the current language
//$is_ltr_text_direction = api_get_text_direction() != 'rtl';
// Change false to true in the following line to enable answer hinting
$debug_mark_answer = $show_answers;
//api_is_allowed_to_edit() && false;
// Reads question information
if (!$objQuestionTmp) {
// Question not found
return false;
}
$html = null;
$questionId = $objQuestionTmp->id;
if ($exercise_feedback != EXERCISE_FEEDBACK_TYPE_END) {
$show_comment = false;
}
$answerType = $objQuestionTmp->selectType();
$pictureName = $objQuestionTmp->selectPicture();
$s = null;
$form = new FormValidator('question');
$renderer = $form->defaultRenderer();
$form_template = '{content}';
$renderer->setFormTemplate($form_template);
if ($answerType != HOT_SPOT && $answerType != HOT_SPOT_DELINEATION) {
// Question is not a hotspot
if (!$only_questions) {
$questionDescription = $objQuestionTmp->selectDescription();
if ($show_title) {
$categoryName = TestCategory::getCategoryNamesForQuestion($objQuestionTmp->id, null, true, $categoryMinusOne);
$html .= $categoryName;
$html .= Display::div($current_item . '. ' . $objQuestionTmp->selectTitle(), array('class' => 'question_title'));
if (!empty($questionDescription)) {
$html .= Display::div($questionDescription, array('class' => 'question_description'));
}
} else {
$html .= '<div class="media">';
$html .= '<div class="pull-left">';
$html .= '<div class="media-object">';
$html .= Display::div($current_item, array('class' => 'question_no_title'));
$html .= '</div>';
$html .= '</div>';
$html .= '<div class="media-body">';
if (!empty($questionDescription)) {
$html .= Display::div($questionDescription, array('class' => 'question_description'));
}
$html .= '</div>';
$html .= '</div>';
}
}
if (in_array($answerType, array(FREE_ANSWER, ORAL_EXPRESSION)) && $freeze) {
return null;
}
$html .= '<div class="question_options">';
// construction of the Answer object (also gets all answers details)
$objAnswerTmp = new Answer($questionId, null, $this);
$nbrAnswers = $objAnswerTmp->selectNbrAnswers();
$course_id = api_get_course_int_id();
$quiz_question_options = Question::readQuestionOption($questionId, $course_id);
// For "matching" type here, we need something a little bit special
// because the match between the suggestions and the answers cannot be
// done easily (suggestions and answers are in the same table), so we
// have to go through answers first (elems with "correct" value to 0).
$select_items = array();
//This will contain the number of answers on the left side. We call them
// suggestions here, for the sake of comprehensions, while the ones
// on the right side are called answers
$num_suggestions = 0;
if ($answerType == MATCHING || $answerType == DRAGGABLE) {
if ($answerType == DRAGGABLE) {
$s .= '<div class="ui-widget ui-helper-clearfix">
<ul class="drag_question ui-helper-reset ui-helper-clearfix">';
} else {
$s .= '<div id="drag' . $questionId . '_question" class="drag_question">';
$s .= '<table class="data_table">';
}
$j = 1;
//iterate through answers
$letter = 'A';
//mark letters for each answer
$answer_matching = array();
$capital_letter = array();
//for ($answerId=1; $answerId <= $nbrAnswers; $answerId++) {
foreach ($objAnswerTmp->answer as $answerId => $answer_item) {
//.........这里部分代码省略.........
示例3: prepareQuiz
/**
* Exports an exercise as a SCO.
* This method is intended to be called from the prepare method.
*
* @note There's a lot of nearly cut-and-paste from exercise.lib.php here
* because of some little differences...
* Perhaps something that could be refactorised ?
*
* @see prepare
* @param $quizId The quiz
* @param $raw_to_pass The needed score to attain
* @return False on error, True if everything went well.
* @author Thanos Kyritsis <atkyritsis@upnet.gr>
* @author Amand Tihon <amand@alrj.org>
*/
function prepareQuiz($quizId, $raw_to_pass = 50) {
global $langQuestion, $langOk, $langScore, $claro_stylesheet, $clarolineRepositorySys;
global $charset, $langExerciseDone;
// those two variables are needed by display_attached_file()
global $attachedFilePathWeb;
global $attachedFilePathSys;
$attachedFilePathWeb = 'Exercises';
$attachedFilePathSys = $this->destDir . '/Exercises';
// Generate standard page header
$pageHeader = '<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=' . $charset . '">
<meta http-equiv="expires" content="Tue, 05 DEC 2000 07:00:00 GMT">
<meta http-equiv="Pragma" content="no-cache">
<link rel="stylesheet" type="text/css" href="bootstrap-custom.css" />
<link rel="stylesheet" type="text/css" href="' . $claro_stylesheet . '" media="screen, projection, tv" />
<script language="javascript" type="text/javascript" src="APIWrapper.js"></script>
<script language="javascript" type="text/javascript" src="scores.js"></script>
' . "\n";
$pageBody = '<body onload="loadPage()">
<div id="claroBody"><form id="quiz">
<table class="table-default"><tr><td>' . "\n";
// read the exercise
$quiz = new Exercise();
if (!$quiz->read($quizId)) {
$this->error[] = $GLOBALS['langErrorLoadingExercise'];
return false;
}
// Get the question list
$questionList = $quiz->selectQuestionList();
$questionCount = $quiz->selectNbrQuestions();
// Keep track of raw scores (ponderation) for each question
$questionPonderationList = array();
// Keep track of correct texts for fill-in type questions
$fillAnswerList = array();
// Counter used to generate the elements' id. Incremented after every <input> or <select>
$idCounter = 0;
// Display each question
$questionCount = 0;
foreach ($questionList as $questionId) {
// Update question number
$questionCount++;
// read the question, abort on error
$question = new Question();
if (!$question->read($questionId)) {
$this->error[] = $GLOBALS['langErrorLoadingQuestion'];
return false;
}
$qtype = $question->selectType();
$qtitle = $question->selectTitle();
$qdescription = $question->selectDescription();
$questionPonderationList[$questionId] = $question->selectWeighting();
// Generic display, valid for all kind of question
$pageBody .= '<table class="table-default">
<tr><th valign="top" colspan="2">' . $langQuestion . ' ' . $questionCount . '</th></tr>
<tfoot>
<tr><td valign="top" colspan="2">' . $qtitle . '</td></tr>
<tr><td valign="top" colspan="2"><i>' . parse_user_text($qdescription) . '</i></td></tr>' . "\n";
// Attached file, if it exists.
//$attachedFile = $question->selectAttachedFile();
if (!empty($attachedFile)) {
// copy the attached file
if (!claro_copy_file($this->srcDirExercise . '/' . $attachedFile, $this->destDir . '/Exercises')) {
$this->error[] = $GLOBALS['langErrorCopyAttachedFile'] . $attachedFile;
return false;
}
// Ok, if it was an mp3, we need to copy the flash mp3-player too.
$extension = substr(strrchr($attachedFile, '.'), 1);
if ($extension == 'mp3') {
$this->mp3Found = true;
}
//.........这里部分代码省略.........
示例4: export_exercise
/**
* This function exports the given Chamilo test
* @param integer Test ID
* @return string The test itself as an HTML string
*/
function export_exercise($item_id)
{
global $expdir, $_course, $_configuration, $_SESSION, $_SERVER, $language_interface, $langExerciseNotFound, $langQuestion, $langOk, $origin, $questionNum;
$exerciseId = $item_id;
require_once '../exercice/exercise.class.php';
require_once '../exercice/question.class.php';
require_once '../exercice/answer.class.php';
$TBL_EXERCISES = Database::get_course_table(TABLE_QUIZ_TEST);
/* Clears the exercise session */
if (isset($_SESSION['objExercise'])) {
Session::erase('objExercise');
}
if (isset($_SESSION['objQuestion'])) {
Session::erase('objQuestion');
}
if (isset($_SESSION['objAnswer'])) {
Session::erase('objAnswer');
}
if (isset($_SESSION['questionList'])) {
Session::erase('questionList');
}
if (isset($_SESSION['exerciseResult'])) {
Session::erase('exerciseResult');
}
// If the object is not in the session:
if (!isset($_SESSION['objExercise'])) {
// Construction of Exercise.
$objExercise = new Exercise();
$sql = "SELECT title,description,sound,type,random,active FROM {$TBL_EXERCISES} WHERE iid='{$exerciseId}'";
// If the specified exercise doesn't exist or is disabled:
if (!$objExercise->read($exerciseId) || !$objExercise->selectStatus() && !api_is_allowed_to_edit() && $origin != 'learnpath') {
die($langExerciseNotFound);
}
// Saves the object into the session.
Session::write('objExercise', $objExercise);
}
$exerciseTitle = $objExercise->selectTitle();
$exerciseDescription = $objExercise->selectDescription();
$exerciseSound = $objExercise->selectSound();
$randomQuestions = $objExercise->isRandom();
$exerciseType = $objExercise->selectType();
if (!isset($_SESSION['questionList'])) {
// Selects the list of question ID.
$questionList = $randomQuestions ? $objExercise->selectRandomList() : $objExercise->selectQuestionList();
// Saves the question list into the session.
Session::write('questionList', $questionList);
}
$nbrQuestions = sizeof($questionList);
// If questionNum comes from POST and not from GET:
if (!$questionNum || $_POST['questionNum']) {
// Only used for sequential exercises (see $exerciseType).
if (!$questionNum) {
$questionNum = 1;
} else {
$questionNum++;
}
}
$test .= "<h3>" . $exerciseTitle . "</h3>";
if (!empty($exerciseSound)) {
$test .= "<a href=\"../document/download.php?doc_url=%2Faudio%2F" . $exerciseSound . "\"&SQMSESSID=36812c2dea7d8d6e708d5e6a2f09b0b9 target=\"_blank\"><img src=\"../img/sound.gif\" border=\"0\" align=\"absmiddle\" alt=" . get_lang("Sound") . "\" /></a>";
}
// Writing the .js file with to check the correct answers begin.
$scriptfilename = "Exercice" . $item_id . ".js";
$s = "<script type=\"text/javascript\" src='../js/" . $scriptfilename . "'></script>";
$test .= $s;
$content = "function evaluate() {\n alert('Test evaluated.');\n }\n ";
if (!($handle = fopen($expdir . '/js/' . $scriptfilename, 'w'))) {
echo "Cannot open file ({$scriptfilename})";
}
if (fwrite($handle, $content) === false) {
echo "Cannot write to file ({$filename})";
exit;
}
fclose($handle);
// Writing the .js file with to check the correct answers end.
$s = "\n <p>{$exerciseDescription}</p>\n <table width='100%' border='0' cellpadding='1' cellspacing='0'>\n <form method='post' action=''><input type=\"hidden\" name=\"SQMSESSID\" value=\"36812c2dea7d8d6e708d5e6a2f09b0b9\" />\n <input type='hidden' name='formSent' value='1' />\n <input type='hidden' name='exerciseType' value='" . $exerciseType . "' />\n <input type='hidden' name='questionNum' value='" . $questionNum . "' />\n <input type='hidden' name='nbrQuestions' value='" . $nbrQuestions . "' />\n <tr>\n <td>\n <table width='100%' cellpadding='4' cellspacing='2' border='0'>";
$exerciseType = 1;
// So to list all questions in one page.
$test .= $s;
$i = 0;
foreach ($questionList as $questionId) {
$i++;
// For sequential exercises.
if ($exerciseType == 2) {
// If it is not the right question, goes to the next loop iteration.
if ($questionNum != $i) {
continue;
} else {
// if the user has already answered this question:
if (isset($exerciseResult[$questionId])) {
// Construction of the Question object.
$objQuestionTmp = new Question();
// Reads question informations.
$objQuestionTmp->read($questionId);
$questionName = $objQuestionTmp->selectTitle();
//.........这里部分代码省略.........
示例5: showQuestion
function showQuestion($questionId, $onlyAnswers = false)
{
global $picturePath, $urlServer;
global $langNoAnswer, $langColumnA, $langColumnB, $langMakeCorrespond;
// construction of the Question object
$objQuestionTmp = new Question();
// reads question informations
if (!$objQuestionTmp->read($questionId)) {
// question not found
return false;
}
$answerType = $objQuestionTmp->selectType();
if (!$onlyAnswers) {
$questionName = $objQuestionTmp->selectTitle();
$questionDescription = $objQuestionTmp->selectDescription();
$questionDescription_temp = standard_text_escape($questionDescription);
echo "<tr class='even'>\n <td colspan='2'><b>" . q($questionName) . "</b><br />\n {$questionDescription_temp}\n </td>\n </tr>";
if (file_exists($picturePath . '/quiz-' . $questionId)) {
echo "<tr class='even'>\n <td class='center' colspan='2'><img src='{$urlServer}/{$picturePath}/quiz-{$questionId}' /></td>\n </tr>";
}
}
// end if(!$onlyAnswers)
// construction of the Answer object
$objAnswerTmp = new Answer($questionId);
$nbrAnswers = $objAnswerTmp->selectNbrAnswers();
// only used for the answer type "Matching"
if ($answerType == MATCHING) {
$cpt1 = 'A';
$cpt2 = 1;
$select = array();
echo "\n <tr class='even'>\n <td colspan='2'>\n <table class='tbl_border' width='100%'>\n <tr>\n <th width='200'>{$langColumnA}</th>\n <th width='130'>{$langMakeCorrespond}</th>\n <th width='200'>{$langColumnB}</th>\n </tr>\n </table>\n </td>\n </tr>";
}
for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) {
$answer = $objAnswerTmp->selectAnswer($answerId);
$answer = mathfilter($answer, 12, '../../courses/mathimg/');
$answerCorrect = $objAnswerTmp->isCorrect($answerId);
if ($answerType == FILL_IN_BLANKS) {
// splits text and weightings that are joined with the character '::'
list($answer) = explode('::', $answer);
// replaces [blank] by an input field
$answer = preg_replace('/\\[[^]]+\\]/', '<input type="text" name="choice[' . $questionId . '][]" size="10" />', standard_text_escape($answer));
}
// unique answer
if ($answerType == UNIQUE_ANSWER) {
echo "\n <tr class='even'>\n <td class='center' width='1'>\n <input type='radio' name='choice[{$questionId}]' value='{$answerId}' />\n </td>\n <td>" . standard_text_escape($answer) . "</td>\n </tr>";
} elseif ($answerType == MULTIPLE_ANSWER) {
echo "\n <tr class='even'>\n <td width='1' align='center'>\n <input type='checkbox' name='choice[{$questionId}][{$answerId}]' value='1' />\n </td>\n <td>" . standard_text_escape($answer) . "</td>\n </tr>";
} elseif ($answerType == FILL_IN_BLANKS) {
echo "\n <tr class='even'>\n <td colspan='2'>" . $answer . "</td>\n </tr>";
} elseif ($answerType == MATCHING) {
if (!$answerCorrect) {
// options (A, B, C, ...) that will be put into the list-box
$select[$answerId]['Lettre'] = $cpt1++;
// answers that will be shown at the right side
$select[$answerId]['Reponse'] = standard_text_escape($answer);
} else {
echo "<tr class='even'>\n <td colspan='2'>\n <table class='tbl'>\n <tr>\n <td width='200'><b>{$cpt2}.</b> " . standard_text_escape($answer) . "</td>\n <td width='130'><div align='center'>\n <select name='choice[{$questionId}][{$answerId}]'>\n <option value='0'>--</option>";
// fills the list-box
foreach ($select as $key => $val) {
echo "<option value=\"{$key}\">{$val['Lettre']}</option>";
}
echo "</select></div></td>\n <td width='200'>";
if (isset($select[$cpt2])) {
echo '<b>' . $select[$cpt2]['Lettre'] . '.</b> ' . $select[$cpt2]['Reponse'];
} else {
echo ' ';
}
echo "</td></tr></table></td></tr>";
$cpt2++;
// if the left side of the "matching" has been completely shown
if ($answerId == $nbrAnswers) {
// if it remains answers to shown at the right side
while (isset($select[$cpt2])) {
echo "<tr class='even'>\n <td colspan='2'>\n <table>\n <tr>\n <td width='60%' colspan='2'> </td>\n <td width='40%' align='right' valign='top'>" . "<b>" . $select[$cpt2]['Lettre'] . ".</b> " . $select[$cpt2]['Reponse'] . "</td>\n </tr>\n </table>\n </td>\n </tr>";
$cpt2++;
}
// end while()
}
// end if()
}
} elseif ($answerType == TRUE_FALSE) {
echo "<tr class='even'>\n <td width='1' align='center'>\n <input type='radio' name='choice[{$questionId}]' value='{$answerId}' />\n </td><td>{$answer}</td>\n </tr>";
}
}
// end for()
if (!$nbrAnswers) {
echo "<tr><td colspan='2'><div class='alert alert-danger'>{$langNoAnswer}</div></td></tr>";
}
// destruction of the Answer object
unset($objAnswerTmp);
// destruction of the Question object
unset($objQuestionTmp);
return $nbrAnswers;
}
示例6: Question
$deleteQuestion = $_GET['deleteQuestion'];
// construction of the Question object
$objQuestionTmp = new Question();
// if the question exists
if ($objQuestionTmp->read($deleteQuestion)) {
$objQuestionTmp->delete($exerciseId);
// if the question has been removed from the exercise
if ($objExercise->removeFromList($deleteQuestion)) {
$nbrQuestions--;
}
}
redirect_to_home_page("modules/exercise/admin.php?course={$course_code}&exerciseId={$exerciseId}");
}
$tool_content .= action_bar(array(array('title' => $langNewQu, 'url' => "{$_SERVER['SCRIPT_NAME']}?course={$course_code}&exerciseId={$exerciseId}&newQuestion=yes", 'icon' => 'fa-plus-circle', 'level' => 'primary-label', 'button-class' => 'btn-success'), array('title' => $langSelection . ' ' . $langWithCriteria, 'class' => 'randomSelection', 'url' => "#", 'icon' => 'fa-random', 'level' => 'primary-label'), array('title' => $langSelection . ' ' . $langFrom2 . ' ' . $langQuestionPool, 'url' => "question_pool.php?course={$course_code}&fromExercise={$exerciseId}", 'icon' => 'fa-bank', 'level' => 'primary-label')));
if ($nbrQuestions) {
$questionList = $objExercise->selectQuestionList();
$i = 1;
$tool_content .= "\n <div class='table-responsive'>\n\t <table class='table-default'>\n\t <tr>\n\t <th colspan='2' class='text-left'>{$langQuestionList}</th>\n\t <th class='text-center'>" . icon('fa-gears', $langActions) . "</th>\n\t </tr>";
foreach ($questionList as $id) {
$objQuestionTmp = new Question();
$objQuestionTmp->read($id);
$tool_content .= "<tr>\n\t\t\t<td align='right' width='1'>" . $i . ".</td>\n\t\t\t<td> " . q($objQuestionTmp->selectTitle()) . "<br />\n\t\t\t" . $aType[$objQuestionTmp->selectType() - 1] . "</td>\n\t\t\t<td class='option-btn-cell'>" . action_button(array(array('title' => $langModify, 'url' => "{$_SERVER['SCRIPT_NAME']}?course={$course_code}&exerciseId={$exerciseId}&editQuestion={$id}", 'icon-class' => 'warnLink', 'icon-extra' => $objQuestionTmp->selectNbrExercises() > 1 ? "data-toggle='modal' data-target='#modalWarning' data-remote='false'" : "", 'icon' => 'fa-edit'), array('title' => $langDelete, 'url' => "?course={$course_code}&exerciseId={$exerciseId}&deleteQuestion={$id}", 'icon' => 'fa-times', 'class' => 'delete', 'confirm' => $langConfirmYourChoice, 'show' => !isset($fromExercise)), array('title' => $langUp, 'url' => "{$_SERVER['SCRIPT_NAME']}?course={$course_code}&exerciseId={$exerciseId}&moveUp={$id}", 'level' => 'primary', 'icon' => 'fa-arrow-up', 'disabled' => $i == 1), array('title' => $langDown, 'url' => "{$_SERVER['SCRIPT_NAME']}?course={$course_code}&exerciseId={$exerciseId}&moveDown={$id}", 'level' => 'primary', 'icon' => 'fa-arrow-down', 'disabled' => $i == $nbrQuestions))) . "</td></tr>";
$i++;
unset($objQuestionTmp);
}
$tool_content .= "</table></div>";
}
$tool_content .= "\n<!-- Modal -->\n<div class='modal fade' id='modalWarning' tabindex='-1' role='dialog' aria-labelledby='modalWarningLabel' aria-hidden='true'>\n <div class='modal-dialog'>\n <div class='modal-content'>\n <div class='modal-header'>\n <button type='button' class='close' data-dismiss='modal'><span aria-hidden='true'>×</span><span class='sr-only'>Close</span></button>\n </div>\n <div class='modal-body'>\n {$langUsedInSeveralExercises}\n </div>\n <div class='modal-footer'>\n <a href='#' id='modifyAll' class='btn btn-primary'>{$langModifyInAllExercises}</a>\n <a href='#' id='modifyOne' class='btn btn-success'>{$langModifyInThisExercise}</a>\n </div>\n </div>\n </div>\n</div> \n";
if ($nbrQuestions == 0) {
$tool_content .= "<div class='alert alert-warning'>{$langNoQuestion}</div>";
}
示例7: Exercise
include 'question.class.php';
$exerciseId = $_GET['exerciseId'];
$objExercise = new Exercise();
$objExercise->read($exerciseId);
$pageName = $langExerciseStats;
$navigation[] = array("url" => "index.php?course={$course_code}", "name" => $langExercices);
$tool_content .= action_bar(array(array('title' => $langBack, 'level' => 'primary-label', 'icon' => 'fa-reply', 'url' => "index.php?course={$course_code}")));
$completedAttempts = Database::get()->querySingle("SELECT count(*) AS count FROM exercise_user_record WHERE eid = ?d AND attempt_status = ?d", $exerciseId, ATTEMPT_COMPLETED)->count;
$pausedAttempts = Database::get()->querySingle("SELECT count(*) AS count FROM exercise_user_record WHERE eid = ?d AND attempt_status = ?d", $exerciseId, ATTEMPT_PAUSED)->count;
$pendingAttempts = Database::get()->querySingle("SELECT count(*) AS count FROM exercise_user_record WHERE eid = ?d AND attempt_status = ?d", $exerciseId, ATTEMPT_PENDING)->count;
$cancelledAttempts = Database::get()->querySingle("SELECT count(*) AS count FROM exercise_user_record WHERE eid = ?d AND attempt_status = ?d", $exerciseId, ATTEMPT_CANCELED)->count;
$total_attempts = $completedAttempts + $pausedAttempts + $pendingAttempts + $cancelledAttempts;
$grade_stats = Database::get()->querySingle("SELECT COUNT(DISTINCT uid) AS unique_users, AVG(TIME_TO_SEC(TIMEDIFF(record_end_date, record_start_date))) AS avg_time, AVG(total_score) AS avg_grade, MIN(total_score) AS min_grade, MAX(total_score) AS max_grade FROM exercise_user_record WHERE eid = ?d AND attempt_status = ?d", $exerciseId, ATTEMPT_COMPLETED);
$max_grade = $grade_stats->max_grade;
$min_grade = $grade_stats->min_grade;
$avg_grade = $grade_stats->avg_grade;
$avg_time = $grade_stats->avg_time;
$unique_users = $grade_stats->unique_users;
//average number of attempts
//avg completion time
$tool_content .= "\n <div class='table-responsive'>\n <table class='table-default'>\n <thead>\n <tr>\n <th colspan='4' class='text-center'>{$langAttempts}</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <td>{$langAttemptsCompleted}</th>\n <td>{$completedAttempts}</td>\n <td>{$langAttemptsPaused}</th>\n <td>{$pausedAttempts}</td> \n </tr>\n <tr>\n <td>{$langAttemptPending}</th>\n <td>{$pendingAttempts}</td>\n <td>{$langAttemptsCanceled}</th>\n <td>{$cancelledAttempts}</td> \n </tr>\n </tbody>\n <tfoot>\n <tr class='active'>\n <th colspan='3'>{$langTotal}:</th>\n <th colspan='1'>{$total_attempts}</th>\n </tr> \n </tfoot>\n </table>\n </div>\n <div class='table-responsive'>\n <table class='table-default'>\n <thead>\n <tr>\n <th colspan='2' class='text-center'>{$langScore}</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <td>{$langHighestGrade}</th>\n <td>{$max_grade}</td>\n \n </tr>\n <tr>\n <td>{$langLowestGrade}</th>\n <td>{$min_grade}</td> \n </tr>\n <tr>\n <td>{$langRatingAverage}</th>\n <td>{$avg_grade}</td> \n </tr> \n </tbody>\n </table>\n </div>\n <div class='table-responsive'>\n <table class='table-default'>\n <thead>\n <tr>\n <th colspan='2' class='text-center'>{$langStudents}</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <td>{$langStudentsExerciseCompleted}</th>\n <td>{$unique_users}</td> \n </tr> \n <tr>\n <td>{$langAverage} {$langExerciseDuration}</th>\n <td>" . format_time_duration($avg_time) . "</td> \n </tr> \n </tbody>\n </table>\n </div>";
//Questions Table
$questionList = $objExercise->selectQuestionList();
$tool_content .= "\n <h3>{$langQuestions}</h3>\n <div class='table-responsive'>\n <table class='table-default'>\n <thead>\n <tr>\n <th>{$langTitle}</th>\n <th>Ποσοστό Επιτυχίας</th>\n </tr>\n </thead>\n <tbody>";
foreach ($questionList as $id) {
$objQuestionTmp = new Question();
$objQuestionTmp->read($id);
$tool_content .= "\n <tr>\n <td>" . $objQuestionTmp->selectTitle() . "</th>\n <td>\n <div class='progress'>\n <div class='progress-bar progress-bar-success progress-bar-striped' role='progressbar' aria-valuenow='" . $objQuestionTmp->successRate($exerciseId) . "' aria-valuemin='0' aria-valuemax='100' style='width: " . $objQuestionTmp->successRate($exerciseId) . "%;'>\n " . $objQuestionTmp->successRate($exerciseId) . "%\n </div>\n </div></td> \n </tr>";
}
$tool_content .= "\n </tbody>\n </table>\n </div>";
draw($tool_content, 2, null, $head_content);
示例8: Question
<h3>$langQuestions</h3>
<div class='table-responsive'>
<table class='table-default'>
<thead>
<tr>
<th>$langTitle</th>
<th>Ποσοστό Επιτυχίας</th>
</tr>
</thead>
<tbody>";
foreach($questionList as $id){
$objQuestionTmp = new Question();
$objQuestionTmp->read($id);
$tool_content .= "
<tr>
<td>".q_math($objQuestionTmp->selectTitle())."</th>
<td>
<div class='progress'>
<div class='progress-bar progress-bar-success progress-bar-striped' role='progressbar' aria-valuenow='".$objQuestionTmp->successRate($exerciseId)."' aria-valuemin='0' aria-valuemax='100' style='width: ".$objQuestionTmp->successRate($exerciseId)."%;'>
".$objQuestionTmp->successRate($exerciseId)."%
</div>
</div></td>
</tr>";
}
$tool_content .= "
</tbody>
</table>
</div>";
draw($tool_content, 2, null, $head_content);