本文整理汇总了PHP中ilObjTest::_instanciateQuestion方法的典型用法代码示例。如果您正苦于以下问题:PHP ilObjTest::_instanciateQuestion方法的具体用法?PHP ilObjTest::_instanciateQuestion怎么用?PHP ilObjTest::_instanciateQuestion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ilObjTest
的用法示例。
在下文中一共展示了ilObjTest::_instanciateQuestion方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createRandomSolutions
function createRandomSolutions($number)
{
global $ilDB;
// 1. get a user
$query = "SELECT usr_id FROM usr_data";
$result = $ilDB->query($query);
while ($data = $ilDB->fetchAssoc($result)) {
$activequery = sprintf("SELECT user_fi FROM tst_active WHERE test_fi = %s AND user_fi = %s", $ilDB->quote($this->getTestId()), $ilDB->quote($data['usr_id']));
$activeresult = $ilDB->query($activequery);
if ($activeresult->numRows() == 0) {
$user_id = $data['usr_id'];
if ($user_id != 13) {
include_once "./Modules/Test/classes/class.ilTestSession.php";
$testSession = FALSE;
$testSession = new ilTestSession();
$testSession->setRefId($this->getRefId());
$testSession->setTestId($this->getTestId());
$testSession->setUserId($user_id);
$testSession->saveToDb();
$passes = $this->getNrOfTries() ? $this->getNrOfTries() : 10;
$nr_of_passes = rand(1, $passes);
$active_id = $testSession->getActiveId();
for ($pass = 0; $pass < $nr_of_passes; $pass++) {
include_once "./Modules/Test/classes/class.ilTestSequence.php";
$testSequence = new ilTestSequence($active_id, $pass, $this->isRandomTest());
if (!$testSequence->hasSequence()) {
$testSequence->createNewSequence($this->getQuestionCount(), $shuffle);
$testSequence->saveToDb();
}
for ($seq = 1; $seq <= count($this->questions); $seq++) {
$question_id = $testSequence->getQuestionForSequence($seq);
$objQuestion = ilObjTest::_instanciateQuestion($question_id);
$objQuestion->createRandomSolution($testSession->getActiveId(), $pass);
}
if ($pass < $nr_of_passes - 1) {
$testSession->increasePass();
$testSession->setLastSequence(0);
$testSession->saveToDb();
} else {
$testSession->setSubmitted(1);
$testSession->setSubmittedTimestamp(date('Y-m-d H:i:s'));
$testSession->saveToDb();
}
}
$number--;
if ($number == 0) {
return;
}
}
}
}
}
示例2: exportToExcel
//.........这里部分代码省略.........
}
$resultsheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt('test')), $format_title);
foreach ($titles as $title) {
$resultsheet->write($row, $col++, ilExcelUtils::_convert_text($title), $format_title);
}
$row++;
foreach ($data->getParticipants() as $active_id => $userdata) {
$username = !is_null($userdata) && ilExcelUtils::_convert_text($userdata->getName()) ? ilExcelUtils::_convert_text($userdata->getName()) : "ID {$active_id}";
if (array_key_exists($username, $usernames)) {
$usernames[$username]++;
$username .= " ({$i})";
} else {
$usernames[$username] = 1;
}
$col = 0;
$resultsheet->write($row, $col++, $username);
$resultsheet->write($row, $col++, $userdata->getLogin());
if (count($additionalFields)) {
$userfields = ilObjUser::_lookupFields($userdata->getUserID());
foreach ($additionalFields as $fieldname) {
if (strcmp($fieldname, "matriculation") == 0) {
if (strlen($userfields[$fieldname])) {
$resultsheet->write($row, $col++, ilExcelUtils::_convert_text($userfields[$fieldname]));
} else {
$col++;
}
}
}
}
$resultsheet->write($row, $col++, ilExcelUtils::_convert_text($this->test_obj->getTitle()));
$pass = $userdata->getScoredPass();
if (is_object($userdata) && is_array($userdata->getQuestions($pass))) {
foreach ($userdata->getQuestions($pass) as $question) {
$objQuestion =& $this->test_obj->_instanciateQuestion($question["aid"]);
if (is_object($objQuestion) && strcmp($objQuestion->getQuestionType(), 'assSingleChoice') == 0) {
$solution = $objQuestion->getSolutionValues($active_id, $pass);
$pos = $positions[$question["aid"]];
$selectedanswer = "x";
foreach ($objQuestion->getAnswers() as $id => $answer) {
if (strlen($solution[0]["value1"]) && $id == $solution[0]["value1"]) {
$selectedanswer = $answer->getAnswertext();
}
}
$resultsheet->write($row, $col + $pos, ilExcelUtils::_convert_text($selectedanswer));
}
}
}
$row++;
}
if ($this->test_obj->isSingleChoiceTestWithoutShuffle()) {
// special tab for single choice tests without shuffle option
$pos = 0;
$row = 0;
$usernames = array();
$allusersheet = false;
$pages = 0;
$resultsheet =& $workbook->addWorksheet($this->lng->txt("eval_all_users") . " (2)");
$col = 0;
$resultsheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt('name')), $format_title);
$resultsheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt('login')), $format_title);
if (count($additionalFields)) {
foreach ($additionalFields as $fieldname) {
if (strcmp($fieldname, "matriculation") == 0) {
$resultsheet->write($row, $col++, ilExcelUtils::_convert_text($this->lng->txt('matriculation')), $format_title);
}
}
示例3: array
function &getSequenceSummary($obligationsFilter = false)
{
$correctedsequence = $this->getCorrectedSequence();
$result_array = array();
include_once "./Modules/Test/classes/class.ilObjTest.php";
$solved_questions = ilObjTest::_getSolvedQuestions($this->active_id);
$key = 1;
foreach ($correctedsequence as $sequence) {
$question =& ilObjTest::_instanciateQuestion($this->getQuestionForSequence($sequence));
if (is_object($question)) {
$worked_through = $question->_isWorkedThrough($this->active_id, $question->getId(), $this->pass);
$solved = 0;
if (array_key_exists($question->getId(), $solved_questions)) {
$solved = $solved_questions[$question->getId()]["solved"];
}
$is_postponed = $this->isPostponedQuestion($question->getId());
$row = array("nr" => "{$key}", "title" => $question->getTitle(), "qid" => $question->getId(), "visited" => $worked_through, "solved" => $solved ? "1" : "0", "description" => $question->getComment(), "points" => $question->getMaximumPoints(), "worked_through" => $worked_through, "postponed" => $is_postponed, "sequence" => $sequence, "obligatory" => ilObjTest::isQuestionObligatory($question->getId()), 'isAnswered' => $question->isAnswered($this->active_id, $this->pass));
if (!$obligationsFilter || $row['obligatory']) {
array_push($result_array, $row);
}
$key++;
}
}
return $result_array;
}
示例4: __read
function __read()
{
global $ilDB, $tree;
include_once './Modules/Test/classes/class.ilObjTest.php';
include_once 'Modules/Course/classes/class.ilCourseObjective.php';
$container_ref_ids = ilObject::_getAllReferences(ilCourseObjective::_lookupContainerIdByObjectiveId($this->objective_id));
$container_ref_id = current($container_ref_ids);
// Read test data
$query = "SELECT * FROM crs_objective_tst " . "WHERE objective_id = " . $ilDB->quote($this->getObjectiveId(), 'integer') . " ";
$res = $this->db->query($query);
while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
$this->tests[$row->ref_id]['test_objective_id'] = $row->test_objective_id;
$this->tests[$row->ref_id]['ref_id'] = $row->ref_id;
$this->tests[$row->ref_id]['obj_id'] = $row->obj_id;
$this->tests[$row->ref_id]['status'] = $row->tst_status;
$this->tests[$row->ref_id]['limit'] = $row->tst_limit_p;
}
$this->questions = array();
$query = "SELECT * FROM crs_objective_qst coq " . "JOIN qpl_questions qq ON coq.question_id = qq.question_id " . "WHERE objective_id = " . $ilDB->quote($this->getObjectiveId(), 'integer') . " " . "ORDER BY title";
$res = $this->db->query($query);
while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
if (!$tree->isInTree($row->ref_id) or !$tree->isGrandChild($container_ref_id, $row->ref_id)) {
$this->__deleteTest($row->ref_id);
continue;
}
if (!($question = ilObjTest::_instanciateQuestion($row->question_id))) {
$this->delete($row->question_id);
continue;
}
$qst['ref_id'] = $row->ref_id;
$qst['obj_id'] = $row->obj_id;
$qst['question_id'] = $row->question_id;
$qst['qst_ass_id'] = $row->qst_ass_id;
$qst['title'] = $question->getTitle();
$qst['description'] = $question->getComment();
$qst['test_type'] = $this->tests[$row->ref_id]['status'];
$qst['points'] = $question->getPoints();
$this->questions[$row->qst_ass_id] = $qst;
}
return true;
}
示例5: parse
/**
* parse
*
* @access public
* @param array array of assignable nodes (tree node data)
* @return
*/
public function parse($a_assignable)
{
global $objDefinition;
// begin-patch lok
$a_assignable = $this->getTestNode();
// end-patch lok
$tests = array();
foreach ($a_assignable as $node) {
$tmp_data = array();
$subobjects = array();
if (!($tmp_tst = ilObjectFactory::getInstanceByRefId((int) $node['ref_id'], false))) {
continue;
}
include_once './Modules/Test/classes/class.ilObjTest.php';
$tmp_data['random'] = ilObjTest::_lookupRandomTest($node['obj_id']);
$tmp_data['random'] = false;
foreach ($qst = $this->sortQuestions($tmp_tst->getAllQuestions()) as $question_data) {
$tmp_question = ilObjTest::_instanciateQuestion($question_data['question_id']);
#$sub['qst_txt'] = $tmp_question->_getQuestionText($question_data['question_id']);
$sub['qst_txt'] = '';
$sub['qst_points'] = $tmp_question->_getMaximumPoints($question_data['question_id']);
$sub['title'] = $tmp_question->getTitle();
$sub['description'] = $tmp_question->getComment();
$sub['id'] = $question_data['question_id'];
$subobjects[] = $sub;
}
$tmp_data['title'] = $node['title'];
$tmp_data['description'] = $node['description'];
$tmp_data['type'] = $node['type'];
$tmp_data['id'] = $node['child'];
$tmp_data['obj_id'] = $node['obj_id'];
$tmp_data['sub'] = $subobjects;
$tests[] = $tmp_data;
}
$this->setData($tests);
}
示例6: singleResults
/**
* Creates user results for single questions
*
* @access public
*/
function singleResults()
{
global $ilAccess;
if (!$ilAccess->checkAccess("tst_statistics", "", $this->ref_id) && !$ilAccess->checkAccess("write", "", $this->ref_id)) {
// allow only evaluation access
ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
$this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
}
$data =& $this->object->getCompleteEvaluationData();
$color_class = array("tblrow1", "tblrow2");
$counter = 0;
$this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_eval_single_answers.html", "Modules/Test");
$foundParticipants =& $data->getParticipants();
if (count($foundParticipants) == 0) {
ilUtil::sendInfo($this->lng->txt("tst_no_evaluation_data"));
return;
} else {
$rows = array();
foreach ($data->getQuestionTitles() as $question_id => $question_title) {
$answered = 0;
$reached = 0;
$max = 0;
foreach ($foundParticipants as $userdata) {
$pass = $userdata->getScoredPass();
if (is_object($userdata->getPass($pass))) {
$question =& $userdata->getPass($pass)->getAnsweredQuestionByQuestionId($question_id);
if (is_array($question)) {
$answered++;
}
}
}
$counter++;
$this->ctrl->setParameter($this, "qid", $question_id);
$question_object =& ilObjTest::_instanciateQuestion($question_id);
$download = "";
if (method_exists($question_object, "hasFileUploads")) {
if ($question_object->hasFileUploads($this->object->getTestId())) {
$download = "<a href=\"" . $this->ctrl->getLinkTarget($this, "exportFileUploadsForAllParticipants") . "\">" . $this->lng->txt("download") . "</a>";
}
}
array_push($rows, array($question_title, $answered, "<a href=\"" . $this->ctrl->getLinkTarget($this, "exportQuestionForAllParticipants") . "\">" . $this->lng->txt("pdf_export") . "</a>", $download));
}
if (count($rows)) {
include_once "./Modules/Test/classes/tables/class.ilResultsByQuestionTableGUI.php";
$table_gui = new ilResultsByQuestionTableGUI($this, "singleResults", $this->object->hasPDFProcessing());
$table_gui->setTitle($this->lng->txt("tst_answered_questions_test"));
$table_gui->setData($rows);
$this->tpl->setVariable("TBL_SINGLE_ANSWERS", $table_gui->getHTML());
} else {
$this->tpl->setVariable("TBL_SINGLE_ANSWERS", $this->lng->txt("adm_no_special_users"));
}
}
}
示例7: deleteQuestion
/**
* Deletes a question from the question pool
*
* @param integer $question_id The database id of the question
* @access private
*/
function deleteQuestion($question_id)
{
include_once "./Modules/Test/classes/class.ilObjTest.php";
$question =& ilObjTest::_instanciateQuestion($question_id);
$question->delete($question_id);
}