本文整理汇总了PHP中assQuestion::_instanciateQuestion方法的典型用法代码示例。如果您正苦于以下问题:PHP assQuestion::_instanciateQuestion方法的具体用法?PHP assQuestion::_instanciateQuestion怎么用?PHP assQuestion::_instanciateQuestion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类assQuestion
的用法示例。
在下文中一共展示了assQuestion::_instanciateQuestion方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: stageQuestionsFromSourcePool
private function stageQuestionsFromSourcePool($sourcePoolId)
{
$questionIdMapping = array();
$query = 'SELECT question_id FROM qpl_questions WHERE obj_fi = %s AND complete = %s AND original_id IS NULL';
$res = $this->db->queryF($query, array('integer', 'text'), array($sourcePoolId, 1));
while ($row = $this->db->fetchAssoc($res)) {
$question = assQuestion::_instanciateQuestion($row['question_id']);
$duplicateId = $question->duplicate(true, null, null, null, $this->testOBJ->getId());
$nextId = $this->db->nextId('tst_rnd_cpy');
$this->db->insert('tst_rnd_cpy', array('copy_id' => array('integer', $nextId), 'tst_fi' => array('integer', $this->testOBJ->getTestId()), 'qst_fi' => array('integer', $duplicateId), 'qpl_fi' => array('integer', $sourcePoolId)));
$questionIdMapping[$row['question_id']] = $duplicateId;
}
return $questionIdMapping;
}
示例2: copyPoolQuestionIntoPage
/**
* Copy question from pool into page
*
* @param
* @return
*/
function copyPoolQuestionIntoPage($a_q_id, $a_hier_id)
{
include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
$question = assQuestion::_instanciateQuestion($a_q_id);
$duplicate_id = $question->copyObject(0, $question->getTitle());
$duplicate = assQuestion::_instanciateQuestion($duplicate_id);
$duplicate->setObjId(0);
// we remove everything not supported by the non-tiny self
// assessment question editor
$q = $duplicate->getQuestion();
// we try to save all latex tags
$try = true;
$ls = '<span class="latex">';
$le = '</span>';
while ($try) {
// search position of start tag
$pos1 = strpos($q, $ls);
if (is_int($pos1)) {
$pos2 = strpos($q, $le, $pos1);
if (is_int($pos2)) {
// both found: replace end tag
$q = substr($q, 0, $pos2) . "[/tex]" . substr($q, $pos2 + 7);
$q = substr($q, 0, $pos1) . "[tex]" . substr($q, $pos1 + 20);
} else {
$try = false;
}
} else {
$try = false;
}
}
$tags = assQuestionGUI::getSelfAssessmentTags();
$tstr = "";
foreach ($tags as $t) {
$tstr .= "<" . $t . ">";
}
$q = ilUtil::secureString($q, true, $tstr);
// self assessment uses nl2br, not p
$duplicate->setQuestion($q);
$duplicate->saveQuestionDataToDb();
$this->q_node->set_attribute("QRef", "il__qst_" . $duplicate_id);
}
示例3: cloneQuestionSetRelatedData
/**
* removes all question set config related data for cloned/copied test
*
* @param ilObjTest $cloneTestOBJ
*/
public function cloneQuestionSetRelatedData($cloneTestOBJ)
{
global $ilLog;
require_once 'Services/CopyWizard/classes/class.ilCopyWizardOptions.php';
require_once 'Modules/TestQuestionPool/classes/class.assQuestion.php';
$cwo = ilCopyWizardOptions::_getInstance($cloneTestOBJ->getId());
foreach ($this->questions as $key => $question_id) {
$question = assQuestion::_instanciateQuestion($question_id);
$cloneTestOBJ->questions[$key] = $question->duplicate(true, null, null, null, $cloneTestOBJ->getId());
$original_id = assQuestion::_getOriginalId($question_id);
$question = assQuestion::_instanciateQuestion($cloneTestOBJ->questions[$key]);
$question->saveToDb($original_id);
// Save the mapping of old question id <-> new question id
// This will be used in class.ilObjCourse::cloneDependencies to copy learning objectives
$originalKey = $this->testOBJ->getRefId() . '_' . $question_id;
$mappedKey = $cloneTestOBJ->getRefId() . '_' . $cloneTestOBJ->questions[$key];
$cwo->appendMapping($originalKey, $mappedKey);
$ilLog->write(__METHOD__ . ": Added mapping {$originalKey} <-> {$mappedKey}");
}
}
示例4: 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);
}
}
示例5: newQuestionCopies
/**
* Replaces existing question content elements with
* new copies
*/
function newQuestionCopies(&$temp_dom)
{
// Get question IDs
$path = "//Question";
$xpc = xpath_new_context($temp_dom);
$res =& xpath_eval($xpc, $path);
$q_ids = array();
include_once "./Services/Link/classes/class.ilInternalLink.php";
for ($i = 0; $i < count($res->nodeset); $i++) {
$qref = $res->nodeset[$i]->get_attribute("QRef");
$inst_id = ilInternalLink::_extractInstOfTarget($qref);
$q_id = ilInternalLink::_extractObjIdOfTarget($qref);
if (!($inst_id > 0)) {
if ($q_id > 0) {
include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
$question = assQuestion::_instanciateQuestion($q_id);
// check if page for question exists
// due to a bug in early 4.2.x version this is possible
if (!ilPageObject::_exists("qpl", $q_id)) {
$question->createPageObject();
}
// now copy this question and change reference to
// new question id
$duplicate_id = $question->duplicate(false);
$res->nodeset[$i]->set_attribute("QRef", "il__qst_" . $duplicate_id);
}
}
}
}
示例6: 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";
include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
$question = assQuestion::_instanciateQuestion($question_id);
$this->addQuestionChangeListeners($question);
$question->delete($question_id);
}
示例7:
/**
* Creates an instance of a question with a given question id
*
* @param integer $question_id The question id
* @return object The question instance
* @access public
*
* @deprecated use assQuestion::_instanciateQuestion($question_id) instead
*/
function &_instanciateQuestion($question_id)
{
if (strcmp($question_id, "") != 0) {
include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
return assQuestion::_instanciateQuestion($question_id);
}
}
示例8: saveQuestionSolution
/**
* Save the solution of a question
*
* @param string $sid Session ID
* @param long $active_id Active user ID
* @param integer $question_id Question ID
* @param integer $pass Test pass
* @param string $solution XML string containing the solution
*
* @return array String array containing the question solution (in triplets of value1, value2, points)
*/
function saveQuestionSolution($sid, $active_id, $question_id, $pass, $solution)
{
$this->initAuth($sid);
$this->initIlias();
if (!$this->__checkSession($sid)) {
return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
}
if (!$this->isAllowedCall($sid, $active_id)) {
return $this->__raiseError("The required user information is only available for active users.", "");
}
$solutions = array();
if (preg_match("/<values>(.*?)<\\/values>/is", $solution, $matches)) {
if (preg_match_all("/<value>(.*?)<\\/value><value>(.*?)<\\/value><points>(.*?)<\\/points>/is", $solution, $matches, PREG_SET_ORDER)) {
foreach ($matches as $match) {
if (count($match) == 4) {
for ($i = 1; $i < count($match); $i++) {
array_push($solutions, trim($match[$i]));
}
}
}
}
}
if (count($solutions) == 0) {
return $this->__raiseError("Wrong solution data. ILIAS did not find one or more solution triplets: {$solution}", "");
}
// Include main header
$ilDB = $GLOBALS['ilDB'];
if ($active_id > 0 && $question_id > 0 && strlen($pass) > 0) {
$affectedRows = $ilDB->manipulateF("DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s", array('integer', 'integer', 'integer'), array($active_id, $question_id, $pass));
}
$totalrows = 0;
for ($i = 0; $i < count($solutions); $i += 3) {
$next_id = $ilDB->nextId('tst_solutions');
$affectedRows = $ilDB->insert("tst_solutions", array("solution_id" => array("integer", $next_id), "active_fi" => array("integer", $active_id), "question_fi" => array("integer", $question_id), "value1" => array("clob", $solutions[$i]), "value2" => array("clob", $solutions[$i + 1]), "points" => array("float", $solutions[$i + 2]), "pass" => array("integer", $pass), "tstamp" => array("integer", time())));
$totalrows += $affectedRows;
}
if (count($totalrows) == 0) {
return $this->__raiseError("Wrong solution data. ILIAS did not execute any database queries");
} else {
include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
$question = assQuestion::_instanciateQuestion($question_id);
$question->calculateResultsFromSolution($active_id, $pass);
}
return "TRUE";
}
示例9: copyAndLinkQuestionsToPoolObject
/**
* @global ilObjectDataCache $ilObjDataCache
*/
public function copyAndLinkQuestionsToPoolObject()
{
global $ilObjDataCache;
$qplId = $ilObjDataCache->lookupObjId($_REQUEST['sel_qpl']);
$result = $this->copyQuestionsToPool($_REQUEST['q_id'], $qplId);
foreach ($result->ids as $oldId => $newId) {
$questionInstance = assQuestion::_instanciateQuestion($oldId);
if (assQuestion::originalQuestionExists($questionInstance->getOriginalId())) {
$oldOriginal = assQuestion::_instanciateQuestion($questionInstance->getOriginalId());
$oldOriginal->delete($oldOriginal->getId());
}
$questionInstance->setNewOriginalId($newId);
}
$this->ctrl->redirect($this, 'questions');
}
示例10: exportXMLPageObjects
function exportXMLPageObjects($a_target_dir, &$a_xml_writer, $a_inst, &$expLog)
{
global $ilBench;
include_once "./Modules/Scorm2004/classes/class.ilSCORM2004PageNode.php";
include_once "./Modules/Scorm2004/classes/class.ilSCORM2004Page.php";
$tree = new ilTree($this->slm_id);
$tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
$tree->setTreeTablePK("slm_id");
$pages = $tree->getSubTree($tree->getNodeData($this->getId()), true, 'page');
foreach ($pages as $page) {
$expLog->write(date("[y-m-d H:i:s] ") . "Page Object " . $page["obj_id"]);
// export xml to writer object
$page_obj = new ilSCORM2004Page($page["obj_id"]);
$page_obj->exportXML($a_xml_writer, "normal", $a_inst);
//collect media objects
$mob_ids = $page_obj->getMediaObjectIds();
foreach ($mob_ids as $mob_id) {
$this->mob_ids[$mob_id] = $mob_id;
}
// collect all file items
$file_ids = $page_obj->getFileItemIds();
foreach ($file_ids as $file_id) {
$this->file_ids[$file_id] = $file_id;
}
include_once "./Services/COPage/classes/class.ilPCQuestion.php";
$q_ids = ilPCQuestion::_getQuestionIdsForPage("sahs", $page["obj_id"]);
if (count($q_ids) > 0) {
include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
foreach ($q_ids as $q_id) {
$q_obj =& assQuestion::_instanciateQuestion($q_id);
$qti_file = fopen($a_target_dir . "/qti_" . $q_id . ".xml", "w");
fwrite($qti_file, $q_obj->toXML());
fclose($qti_file);
}
}
unset($page_obj);
}
}
示例11: singleResults
/**
* Creates user results for single questions
*
*/
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);
require_once './Modules/TestQuestionPool/classes/class.assQuestion.php';
$question_object = assQuestion::_instanciateQuestion($question_id);
$download = "";
if ($question_object instanceof ilObjFileHandlingQuestionType) {
if ($question_object->hasFileUploads($this->object->getTestId())) {
$download = "<a href=\"" . $this->ctrl->getLinkTarget($this, "exportFileUploadsForAllParticipants") . "\">" . $this->lng->txt("download") . "</a>";
}
}
array_push($rows, array('qid' => $question_id, 'question_title' => $question_title, 'number_of_answers' => $answered, 'output' => "<a href=\"" . $this->ctrl->getLinkTarget($this, "exportQuestionForAllParticipants") . "\">" . $this->lng->txt("pdf_export") . "</a>", 'file_uploads' => $download));
}
if (count($rows)) {
require_once './Modules/Test/classes/tables/class.ilResultsByQuestionTableGUI.php';
$table_gui = new ilResultsByQuestionTableGUI($this, "singleResults");
$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"));
}
}
}
示例12: _getSuggestedSolutionOutput
/**
* Returns the output of the suggested solution
*
* @param integer $question_id The database Id of the question
* @return string Suggested solution
*/
public static function _getSuggestedSolutionOutput($question_id)
{
$question =& assQuestion::_instanciateQuestion($question_id);
if (!is_object($question)) {
return "";
}
return $question->getSuggestedSolutionOutput();
}
示例13: copyAndLinkToQuestionpoolObject
public function copyAndLinkToQuestionpoolObject()
{
global $lng;
include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
foreach ($_REQUEST['q_id'] as $q_id) {
$questionInstance = assQuestion::_instanciateQuestion($q_id);
$type = ilObject::_lookupType($questionInstance->getObjId());
if ($type !== 'tst') {
ilUtil::sendFailure($lng->txt('tst_link_only_unassigned'), true);
$this->backObject();
return;
}
}
$this->createQuestionpoolTargetObject('copyAndLinkQuestionsToPool');
}
示例14: exportPDFPrepareXmlNFiles
function exportPDFPrepareXmlNFiles($a_inst, $a_target_dir, &$expLog, &$a_xml_writer)
{
$this->exportHTML4PDF($a_inst, $a_target_dir, $expLog);
global $tpl, $lng, $ilCtrl;
$this->exportXMLPageObjects($a_target_dir, $a_xml_writer, $a_inst, $expLog);
$this->exportXMLMediaObjects($a_xml_writer, $a_inst, $a_target_dir, $expLog);
$this->exportFileItems($a_target_dir, $expLog);
include_once "./Modules/Scorm2004/classes/class.ilSCORM2004PageNode.php";
include_once "./Modules/Scorm2004/classes/class.ilSCORM2004Page.php";
$tree = new ilTree($this->slm_id);
$tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
$tree->setTreeTablePK("slm_id");
foreach ($tree->getSubTree($tree->getNodeData($this->getId()), true, 'page') as $page) {
$page_obj = new ilSCORM2004Page($page["obj_id"]);
include_once "./Services/COPage/classes/class.ilPCQuestion.php";
$q_ids = ilPCQuestion::_getQuestionIdsForPage("sahs", $page["obj_id"]);
if (count($q_ids) > 0) {
include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
foreach ($q_ids as $q_id) {
$q_obj =& assQuestion::_instanciateQuestion($q_id);
$qti_file = fopen($a_target_dir . "/qti_" . $q_id . ".xml", "w");
fwrite($qti_file, $q_obj->toXML());
fclose($qti_file);
$x = file_get_contents($a_target_dir . "/qti_" . $q_id . ".xml");
$x = str_replace('<?xml version="1.0" encoding="utf-8"?>', '', $x);
$a_xml_writer->appendXML($x);
}
}
unset($page_obj);
}
}
示例15: getQuestionListNew
private function getQuestionListNew($questionList)
{
$questions = array();
foreach ($questionList as $question) {
//get the question type
$assQuestion = assQuestion::_instanciateQuestion($question["question_id"]);
array_push($questions, $this->calculateQuestion($question, $assQuestion));
}
return $questions;
}