Skip to content
......@@ -6,77 +6,75 @@
* Date: 06.11.13
* Time: 11:24
* @author Thomas Joußen <tjoussen@databay.de>
*/
*/
abstract class ilPluginModelList
{
/**
* @var ilDB
*/
protected $db;
/**
* @var ilDB
*/
protected $db;
/**
* @var array
*/
private $data;
/**
* @var array
*/
private $data;
/**
* @var boolean
*/
protected $loaded;
/**
* @var boolean
*/
protected $loaded;
public function __construct()
{
global $DIC;
public function __construct()
{
global $DIC;
$this->db = $DIC->database();
}
$this->db = $DIC->database();
}
/**
* @return array
*/
public function getData()
{
if(!$this->isLoaded())
{
$data = $this->loadData();
$this->data = $this->createObjectsFromData($data);
$this->setLoaded(true);
}
/**
* @return array
*/
public function getData()
{
if (!$this->isLoaded()) {
$data = $this->loadData();
$this->data = $this->createObjectsFromData($data);
$this->setLoaded(true);
}
return $this->data;
}
return $this->data;
}
/**
* @param boolean $loaded
*/
public function setLoaded($loaded)
{
$this->loaded = $loaded;
}
/**
* @param boolean $loaded
*/
public function setLoaded($loaded)
{
$this->loaded = $loaded;
}
/**
* @return boolean
*/
public function isLoaded()
{
return $this->loaded;
}
/**
* @return boolean
*/
public function isLoaded()
{
return $this->loaded;
}
/**
* @param array $params
* @param array $filter
*
* @return array
*/
abstract public function loadData($params = array(), $filter = array());
/**
* @param array $params
* @param array $filter
*
* @return array
*/
abstract public function loadData($params = array(), $filter = array());
/**
* @param array $data
*
* @return array
*/
abstract public function createObjectsFromData($data);
/**
* @param array $data
*
* @return array
*/
abstract public function createObjectsFromData($data);
}
\ No newline at end of file
......@@ -8,58 +8,55 @@ require_once "./Customizing/global/plugins/Services/Repository/RepositoryObject/
* Date: 06.11.13
* Time: 14:56
* @author Thomas Joußen <tjoussen@databay.de>
*/
*/
class ilQuestionPoolQuestionList extends ilPluginModelList
{
/**
* @var ilObjQuestionSetPool
*/
protected $question_set_pool;
/**
* @param \ilObjQuestionSetPool $question_set_pool
*/
public function setQuestionSetPool($question_set_pool)
{
$this->question_set_pool = $question_set_pool;
}
/**
* @param array $params
* @param array $filter
*
* @return array
*/
public function loadData($params = array(), $filter = array())
{
require_once "./Customizing/global/plugins/Services/Repository/RepositoryObject/QuestionSetPool/classes/providers/class.ilQuestionSetPoolQuestionsBrowserProvider.php";
require_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
$available_pools = array_keys(ilObjQuestionPool::_getAvailableQuestionpools(true,false, false, false, false));
if(is_array($available_pools) && count($available_pools) == 0)
{
return null;
}
$filter["question_pools"] = $available_pools;
$filter["xqsp_id"] = $this->question_set_pool->getId();
$provider = new ilQuestionSetPoolQuestionsBrowserProvider();
$data = $provider->loadData($filter, $params);
return $data;
}
/**
* @param array $data
*
* @return array
*/
public function createObjectsFromData($data)
{
return $data;
}
/**
* @var ilObjQuestionSetPool
*/
protected $question_set_pool;
/**
* @param \ilObjQuestionSetPool $question_set_pool
*/
public function setQuestionSetPool($question_set_pool)
{
$this->question_set_pool = $question_set_pool;
}
/**
* @param array $params
* @param array $filter
*
* @return array
*/
public function loadData($params = array(), $filter = array())
{
require_once "./Customizing/global/plugins/Services/Repository/RepositoryObject/QuestionSetPool/classes/providers/class.ilQuestionSetPoolQuestionsBrowserProvider.php";
$available_pools = array_keys(ilObjQuestionPool::_getAvailableQuestionpools(true, false, false, false, false));
if (is_array($available_pools) && count($available_pools) == 0) {
return null;
}
$filter["question_pools"] = $available_pools;
$filter["xqsp_id"] = $this->question_set_pool->getId();
$provider = new ilQuestionSetPoolQuestionsBrowserProvider();
$data = $provider->loadData($filter, $params);
return $data;
}
/**
* @param array $data
*
* @return array
*/
public function createObjectsFromData($data)
{
return $data;
}
}
\ No newline at end of file
<?php
require_once "abstract.ilPluginModel.php";
require_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
require_once "class.ilQuestionSetPoolNode.php";
/**
......@@ -10,360 +9,346 @@ require_once "class.ilQuestionSetPoolNode.php";
* Date: 04.12.13
* Time: 17:00
* @author Thomas Joußen <tjoussen@databay.de>
*/
*/
class ilQuestionSetPoolJumpCondition extends ilPluginModel
{
/**
* @var string
*/
protected $jump_condition;
/**
* @var assQuestion
*/
private $question;
/**
* @var ilQuestionSetPoolNode
*/
protected $node;
/**
* @var int
*/
protected $repititions = NULL;
/**
* @var int
*/
protected $sorting;
/**
* @var string null
*/
protected $true_feedback = NULL;
/**
* @var string null
*/
protected $true_jump_feedback = NULL;
/**
* @var string null
*/
protected $false_feedback = NULL;
/**
* @param string $jump_condition
*/
public function setJumpCondition($jump_condition)
{
$this->jump_condition = $jump_condition;
}
/**
* @return string
*/
public function getJumpCondition()
{
return $this->jump_condition;
}
/**
* @param \ilQuestionSetPoolNode $node
*/
public function setNode($node)
{
$this->node = $node;
}
/**
* @return \ilQuestionSetPoolNode
*/
public function getNode()
{
return $this->node;
}
/**
* @param \assQuestion $question
*/
public function setQuestion($question)
{
$this->question = $question;
}
/**
* @return \assQuestion
*/
public function getQuestion()
{
return $this->question;
}
/**
* @param int $repititions
*/
public function setRepititions($repititions)
{
$this->repititions = $repititions;
}
/**
* @return int
*/
public function getRepititions()
{
return $this->repititions;
}
/**
* @param int $sorting
*/
public function setSorting($sorting)
{
$this->sorting = $sorting;
}
/**
* @return int
*/
public function getSorting()
{
return $this->sorting;
}
public function update()
{
global $DIC;
$ilDB = $DIC->database();
$question_id = null;
if($this->getQuestion() != null)
{
$question_id = $this->getQuestion()->getId();
}
if($this->id > 0)
{
return (bool)$ilDB->update(
"rep_robj_xqsp_jmp_con",
array(
"question_fi" => array("integer", $question_id),
"jump_condition" => array("text", $this->getJumpCondition()),
"repititions" => array("integer", $this->getRepititions()),
"sorting" => array("integer", $this->getSorting()),
'true_feedback' => array('clob', $this->getTrueFeedback()),
'true_jmp_feedback' => array('clob', $this->getTrueJumpFeedback()),
'false_feedback' => array('clob', $this->getFalseFeedback()),
),
array(
"id" => array("integer", $this->getId())
)
);
}
else
{
$this->setId($ilDB->nextId("rep_robj_xqsp_jmp_con"));
$this->setSorting(time());
return $ilDB->insert(
"rep_robj_xqsp_jmp_con",
array(
"id" => array("integer", $this->getId()),
"jump_condition" => array("text", $this->getJumpCondition()),
"node_fi" => array("integer", $this->getNode()->getId()),
"question_fi" => array("integer", $question_id),
"repititions" => array("integer", $this->getRepititions()),
"sorting" => array("integer", $this->getSorting()),
'true_feedback' => array('clob', $this->getTrueFeedback()),
'true_jmp_feedback' => array('clob', $this->getTrueJumpFeedback()),
'false_feedback' => array('clob', $this->getFalseFeedback()),
)
);
}
}
public function read()
{
global $DIC;
$ilDB = $DIC->database();
$result = $ilDB->queryF(
"SELECT * FROM rep_robj_xqsp_jmp_con WHERE id = %s",
array("integer"),
array($this->id)
);
$data = $ilDB->fetchAssoc($result);
$id = (isset($data['node_fi']))? $data['node_fi'] : $_REQUEST['node_fi'];
$node = new ilQuestionSetPoolNode($id);
$node->read();
$question = assQuestion::_instanciateQuestion($data["question_fi"]);
$this->setId($data['id']);
$this->setJumpCondition($data['jump_condition']);
$this->setQuestion($question);
$this->setNode($node);
$this->setRepititions($data["repititions"]);
$this->setSorting($data["sorting"]);
require_once 'Services/RTE/classes/class.ilRTE.php';
$this->setTrueFeedback(ilRTE::_replaceMediaObjectImageSrc($data['true_feedback'], 1));
$this->setTrueJumpFeedback(ilRTE::_replaceMediaObjectImageSrc($data['true_jmp_feedback'], 1));
$this->setFalseFeedback(ilRTE::_replaceMediaObjectImageSrc($data['false_feedback'], 1));
}
/**
* @param ilQuestionSetPoolNode $node
* @param array $question_ids
*
* @return bool
*/
public function duplicate($node, $question_ids)
{
global $DIC;
$ilDB = $DIC->database();
$clone = clone $this;
$clone->setId($ilDB->nextId("rep_robj_xqsp_jmp_con"));
$clone->setNode($node);
$clone->setSorting($this->getSorting());
$question_id = null;
if($this->getQuestion() != null)
{
$question_id = $this->getQuestion()->getId();
}
return $ilDB->insert(
"rep_robj_xqsp_jmp_con",
array(
"id" => array("integer", $clone->getId()),
"jump_condition" => array("text", $clone->getJumpCondition()),
"question_fi" => array("integer", $question_ids[$question_id]),
"node_fi" => array("integer", $clone->getNode()->getId()),
"repititions" => array("integer", $this->getRepititions()),
"sorting" => array("integer", $this->getSorting()),
'true_feedback' => array('clob', $this->getTrueFeedback()),
'true_jmp_feedback' => array('clob', $this->getTrueJumpFeedback()),
'false_feedback' => array('clob', $this->getFalseFeedback()),
)
);
}
public function remove()
{
global $DIC;
$ilDB = $DIC->database();
return $ilDB->manipulateF(
"DELETE FROM rep_robj_xqsp_jmp_con WHERE id = %s",
array("integer"),
array($this->getId())
);
}
/**
* @param ilPropertyFormGUI $form
*/
public function bindForm(ilPropertyFormGUI $form)
{
$this->setJumpCondition($form->getInput("jump_condition"));
$this->setQuestion(assQuestion::_instanciateQuestion($form->getInput("question")));
if($form->getInput("repititions") != "")
{
$this->setRepititions($form->getInput("repititions"));
}
else
{
$this->setRepititions(null);
}
require_once 'Services/RTE/classes/class.ilRTE.php';
$this->setTrueFeedback(ilRTE::_replaceMediaObjectImageSrc($form->getInput('true_feedback'), 0));
$this->setTrueJumpFeedback(ilRTE::_replaceMediaObjectImageSrc($form->getInput('true_jump_feedback'), 0));
$this->setFalseFeedback(ilRTE::_replaceMediaObjectImageSrc($form->getInput('false_feedback'), 0));
}
/**
* @return string
*/
public function getFalseFeedback()
{
return $this->false_feedback;
}
/**
* @param string $false_feedback
*/
public function setFalseFeedback($false_feedback)
{
$this->false_feedback = $false_feedback;
}
/**
* @return string
*/
public function getTrueFeedback()
{
return $this->true_feedback;
}
/**
* @param string $true_feedback
*/
public function setTrueFeedback($true_feedback)
{
$this->true_feedback = $true_feedback;
}
/**
* @return string
*/
public function getTrueJumpFeedback()
{
return $this->true_jump_feedback;
}
/**
* @param string $true_jump_feedback
*/
public function setTrueJumpFeedback($true_jump_feedback)
{
$this->true_jump_feedback = $true_jump_feedback;
}
public function import()
{
global $DIC;
$ilDB = $DIC->database();B;
$this->setId($ilDB->nextId("rep_robj_xqsp_jmp_con"));
$question_id = null;
if($this->getQuestion() != null)
{
$question_id = $this->getQuestion()->getId();
}
$this->setSorting(time());
$ilDB->insert(
"rep_robj_xqsp_jmp_con",
array(
"id" => array("integer", $this->getId()),
"jump_condition" => array("text", $this->getJumpCondition()),
"node_fi" => array("integer", $this->getNode()->getId()),
"question_fi" => array("integer", $question_id),
"repititions" => array("integer", $this->getRepititions()),
"sorting" => array("integer", $this->getSorting()),
'true_feedback' => array('clob', $this->getTrueFeedback()),
'true_jmp_feedback' => array('clob', $this->getTrueJumpFeedback()),
'false_feedback' => array('clob', $this->getFalseFeedback())
)
);
}
/**
* @var string
*/
protected $jump_condition;
/**
* @var assQuestion
*/
private $question;
/**
* @var ilQuestionSetPoolNode
*/
protected $node;
/**
* @var int
*/
protected $repititions = null;
/**
* @var int
*/
protected $sorting;
/**
* @var string null
*/
protected $true_feedback = null;
/**
* @var string null
*/
protected $true_jump_feedback = null;
/**
* @var string null
*/
protected $false_feedback = null;
/**
* @param string $jump_condition
*/
public function setJumpCondition($jump_condition)
{
$this->jump_condition = $jump_condition;
}
/**
* @return string
*/
public function getJumpCondition()
{
return $this->jump_condition;
}
/**
* @param \ilQuestionSetPoolNode $node
*/
public function setNode($node)
{
$this->node = $node;
}
/**
* @return \ilQuestionSetPoolNode
*/
public function getNode()
{
return $this->node;
}
/**
* @param \assQuestion $question
*/
public function setQuestion($question)
{
$this->question = $question;
}
/**
* @return \assQuestion
*/
public function getQuestion()
{
return $this->question;
}
/**
* @param int $repititions
*/
public function setRepititions($repititions)
{
$this->repititions = $repititions;
}
/**
* @return int
*/
public function getRepititions()
{
return $this->repititions;
}
/**
* @param int $sorting
*/
public function setSorting($sorting)
{
$this->sorting = $sorting;
}
/**
* @return int
*/
public function getSorting()
{
return $this->sorting;
}
public function update()
{
global $DIC;
$ilDB = $DIC->database();
$question_id = null;
if ($this->getQuestion() != null) {
$question_id = $this->getQuestion()->getId();
}
if ($this->id > 0) {
return (bool) $ilDB->update(
"rep_robj_xqsp_jmp_con",
array(
"question_fi" => array("integer", $question_id),
"jump_condition" => array("text", $this->getJumpCondition()),
"repititions" => array("integer", $this->getRepititions()),
"sorting" => array("integer", $this->getSorting()),
'true_feedback' => array('clob', $this->getTrueFeedback()),
'true_jmp_feedback' => array('clob', $this->getTrueJumpFeedback()),
'false_feedback' => array('clob', $this->getFalseFeedback()),
),
array(
"id" => array("integer", $this->getId())
)
);
} else {
$this->setId($ilDB->nextId("rep_robj_xqsp_jmp_con"));
$this->setSorting(time());
return $ilDB->insert(
"rep_robj_xqsp_jmp_con",
array(
"id" => array("integer", $this->getId()),
"jump_condition" => array("text", $this->getJumpCondition()),
"node_fi" => array("integer", $this->getNode()->getId()),
"question_fi" => array("integer", $question_id),
"repititions" => array("integer", $this->getRepititions()),
"sorting" => array("integer", $this->getSorting()),
'true_feedback' => array('clob', $this->getTrueFeedback()),
'true_jmp_feedback' => array('clob', $this->getTrueJumpFeedback()),
'false_feedback' => array('clob', $this->getFalseFeedback()),
)
);
}
}
public function read()
{
global $DIC;
$ilDB = $DIC->database();
$result = $ilDB->queryF(
"SELECT * FROM rep_robj_xqsp_jmp_con WHERE id = %s",
array("integer"),
array($this->id)
);
$data = $ilDB->fetchAssoc($result);
$id = (isset($data['node_fi']))? $data['node_fi'] : $_REQUEST['node_fi'];
$node = new ilQuestionSetPoolNode($id);
$node->read();
$question = assQuestion::_instanciateQuestion($data["question_fi"]);
$this->setId($data['id']);
$this->setJumpCondition($data['jump_condition']);
$this->setQuestion($question);
$this->setNode($node);
$this->setRepititions($data["repititions"]);
$this->setSorting($data["sorting"]);
$this->setTrueFeedback(ilRTE::_replaceMediaObjectImageSrc($data['true_feedback'], 1));
$this->setTrueJumpFeedback(ilRTE::_replaceMediaObjectImageSrc($data['true_jmp_feedback'], 1));
$this->setFalseFeedback(ilRTE::_replaceMediaObjectImageSrc($data['false_feedback'], 1));
}
/**
* @param ilQuestionSetPoolNode $node
* @param array $question_ids
*
* @return bool
*/
public function duplicate($node, $question_ids)
{
global $DIC;
$ilDB = $DIC->database();
$clone = clone $this;
$clone->setId($ilDB->nextId("rep_robj_xqsp_jmp_con"));
$clone->setNode($node);
$clone->setSorting($this->getSorting());
$question_id = null;
if ($this->getQuestion() != null) {
$question_id = $this->getQuestion()->getId();
}
return $ilDB->insert(
"rep_robj_xqsp_jmp_con",
array(
"id" => array("integer", $clone->getId()),
"jump_condition" => array("text", $clone->getJumpCondition()),
"question_fi" => array("integer", $question_ids[$question_id]),
"node_fi" => array("integer", $clone->getNode()->getId()),
"repititions" => array("integer", $this->getRepititions()),
"sorting" => array("integer", $this->getSorting()),
'true_feedback' => array('clob', $this->getTrueFeedback()),
'true_jmp_feedback' => array('clob', $this->getTrueJumpFeedback()),
'false_feedback' => array('clob', $this->getFalseFeedback()),
)
);
}
public function remove()
{
global $DIC;
$ilDB = $DIC->database();
return $ilDB->manipulateF(
"DELETE FROM rep_robj_xqsp_jmp_con WHERE id = %s",
array("integer"),
array($this->getId())
);
}
/**
* @param ilPropertyFormGUI $form
*/
public function bindForm(ilPropertyFormGUI $form)
{
$this->setJumpCondition($form->getInput("jump_condition"));
$this->setQuestion(assQuestion::_instanciateQuestion($form->getInput("question")));
if ($form->getInput("repititions") != "") {
$this->setRepititions($form->getInput("repititions"));
} else {
$this->setRepititions(null);
}
$this->setTrueFeedback(ilRTE::_replaceMediaObjectImageSrc($form->getInput('true_feedback'), 0));
$this->setTrueJumpFeedback(ilRTE::_replaceMediaObjectImageSrc($form->getInput('true_jump_feedback'), 0));
$this->setFalseFeedback(ilRTE::_replaceMediaObjectImageSrc($form->getInput('false_feedback'), 0));
}
/**
* @return string
*/
public function getFalseFeedback()
{
return $this->false_feedback;
}
/**
* @param string $false_feedback
*/
public function setFalseFeedback($false_feedback)
{
$this->false_feedback = $false_feedback;
}
/**
* @return string
*/
public function getTrueFeedback()
{
return $this->true_feedback;
}
/**
* @param string $true_feedback
*/
public function setTrueFeedback($true_feedback)
{
$this->true_feedback = $true_feedback;
}
/**
* @return string
*/
public function getTrueJumpFeedback()
{
return $this->true_jump_feedback;
}
/**
* @param string $true_jump_feedback
*/
public function setTrueJumpFeedback($true_jump_feedback)
{
$this->true_jump_feedback = $true_jump_feedback;
}
public function import()
{
global $DIC;
$ilDB = $DIC->database();
B;
$this->setId($ilDB->nextId("rep_robj_xqsp_jmp_con"));
$question_id = null;
if ($this->getQuestion() != null) {
$question_id = $this->getQuestion()->getId();
}
$this->setSorting(time());
$ilDB->insert(
"rep_robj_xqsp_jmp_con",
array(
"id" => array("integer", $this->getId()),
"jump_condition" => array("text", $this->getJumpCondition()),
"node_fi" => array("integer", $this->getNode()->getId()),
"question_fi" => array("integer", $question_id),
"repititions" => array("integer", $this->getRepititions()),
"sorting" => array("integer", $this->getSorting()),
'true_feedback' => array('clob', $this->getTrueFeedback()),
'true_jmp_feedback' => array('clob', $this->getTrueJumpFeedback()),
'false_feedback' => array('clob', $this->getFalseFeedback())
)
);
}
}
\ No newline at end of file
......@@ -8,47 +8,46 @@ require_once "abstract.ilPluginModelList.php";
* Date: 05.12.13
* Time: 10:16
* @author Thomas Joußen <tjoussen@databay.de>
*/
*/
class ilQuestionSetPoolJumpConditionList extends ilPluginModelList
{
/**
* @var ilQuestionSetPoolNode
*/
protected $node;
public function __construct($node)
{
$this->node = $node;
parent::__construct();
}
/**
* @param array $params
* @param array $filter
*
* @return array
*/
public function loadData($params = array(), $filter = array())
{
require_once "./Customizing/global/plugins/Services/Repository/RepositoryObject/QuestionSetPool/classes/providers/class.ilQuestionSetPoolJumpConditionsProvider.php";
$provider = new ilQuestionSetPoolJumpConditionsProvider();
$filter["node_fi"] = $this->node->getId();
$data = $provider->loadData($filter, $params);
return $data;
}
/**
* @param array $data
*
* @return array
*/
public function createObjectsFromData($data)
{
return $data;
}
/**
* @var ilQuestionSetPoolNode
*/
protected $node;
public function __construct($node)
{
$this->node = $node;
parent::__construct();
}
/**
* @param array $params
* @param array $filter
*
* @return array
*/
public function loadData($params = array(), $filter = array())
{
require_once "./Customizing/global/plugins/Services/Repository/RepositoryObject/QuestionSetPool/classes/providers/class.ilQuestionSetPoolJumpConditionsProvider.php";
$provider = new ilQuestionSetPoolJumpConditionsProvider();
$filter["node_fi"] = $this->node->getId();
$data = $provider->loadData($filter, $params);
return $data;
}
/**
* @param array $data
*
* @return array
*/
public function createObjectsFromData($data)
{
return $data;
}
}
\ No newline at end of file
<?php
require_once "abstract.ilPluginModel.php";
require_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
/**
* Class ilQuestionSetPoolNode
......@@ -9,434 +8,422 @@ require_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
* Date: 21.11.13
* Time: 11:42
* @author Thomas Joußen <tjoussen@databay.de>
*/
*/
class ilQuestionSetPoolNode extends ilPluginModel
{
/**
* @var integer
*/
protected $id;
/**
* @var integer
*/
protected $index;
/**
* @var assQuestion
*/
protected $question;
/**
* @var int
*/
protected $question_index;
/**
* @var string|null
*/
protected $initial_condition;
/**
* @var ilQuestionSetPoolPath
*/
protected $path;
/**
* @var ilQuestionSetPoolJumpConditionList
*/
protected $jump_condition_list;
/**
* @var int
*/
protected $dominant_scoring = NULL;
/**
* @var string null
*/
protected $true_feedback = NULL;
/**
* @var string null
*/
protected $false_feedback = NULL;
public function __construct($id = 0)
{
require_once "class.ilQuestionSetPoolJumpConditionList.php";
$this->jump_condition_list = new ilQuestionSetPoolJumpConditionList($this);
parent::__construct($id);
}
/**
* @param int $id
*/
public function setId($id)
{
$this->id = $id;
}
/**
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* @param int $index
*/
public function setIndex($index)
{
$this->index = $index;
}
/**
* @return int
*/
public function getIndex()
{
return $this->index;
}
/**
* @param null|string $initial_condition
*/
public function setInitialCondition($initial_condition)
{
$this->initial_condition = $initial_condition;
}
/**
* @return null|string
*/
public function getInitialCondition()
{
return $this->initial_condition;
}
/**
* @param \assQuestion $question
*/
public function setQuestion($question)
{
$this->question = $question;
}
/**
* @return \assQuestion
*/
public function getQuestion()
{
return $this->question;
}
/**
* @param \ilQuestionSetPoolPath $path
*/
public function setPath(ilQuestionSetPoolPath $path)
{
$this->path = $path;
}
/**
* @return \ilQuestionSetPoolPath
*/
public function getPath()
{
return $this->path;
}
/**
* @param \ilQuestionSetPoolJumpConditionList $jump_condition_list
*/
public function setJumpConditionList($jump_condition_list)
{
$this->jump_condition_list = $jump_condition_list;
}
/**
* @return \ilQuestionSetPoolJumpConditionList
*/
public function getJumpConditionList()
{
return $this->jump_condition_list;
}
/**
* @return int
*/
public function getQuestionIndex()
{
return $this->question_index;
}
/**
* @param int $dominant_scoring
*/
public function setDominantScoring($dominant_scoring)
{
$this->dominant_scoring = $dominant_scoring;
}
/**
* @return int
*/
public function getDominantScoring()
{
return $this->dominant_scoring;
}
/**
* @param integer $id
* @return bool
*/
public static function exists($id)
{
global $DIC;
$ilDB = $DIC->database();
$result = $ilDB->queryF(
"SELECT COUNT(*) cnt FROM rep_robj_xqsp_node WHERE id = %s",
array("integer"),
array($id)
);
$data = $ilDB->fetchAssoc($result);
return (int)$data['cnt'] == 1 ? true : false;
}
public function update()
{
global $DIC;
$ilDB = $DIC->database();
if($this->id > 0)
{
return (bool)$ilDB->update(
"rep_robj_xqsp_node",
array(
"question_fi" => array('integer', $this->getQuestion()->getId()),
"initial_condition" => array('text', $this->getInitialCondition()),
"dominant_scoring" => array("integer", $this->getDominantScoring()),
"true_feedback" => array('clob', $this->getTrueFeedback()),
"false_feedback" => array('clob', $this->getFalseFeedback()),
),
array(
'id' => array("integer", $this->getId())
)
);
}
else
{
$this->setId($ilDB->nextId("rep_robj_xqsp_node"));
return $ilDB->queryF(
"INSERT INTO rep_robj_xqsp_node (id, path_fi, question_fi, node_index)
/**
* @var integer
*/
protected $id;
/**
* @var integer
*/
protected $index;
/**
* @var assQuestion
*/
protected $question;
/**
* @var int
*/
protected $question_index;
/**
* @var string|null
*/
protected $initial_condition;
/**
* @var ilQuestionSetPoolPath
*/
protected $path;
/**
* @var ilQuestionSetPoolJumpConditionList
*/
protected $jump_condition_list;
/**
* @var int
*/
protected $dominant_scoring = null;
/**
* @var string null
*/
protected $true_feedback = null;
/**
* @var string null
*/
protected $false_feedback = null;
public function __construct($id = 0)
{
require_once "class.ilQuestionSetPoolJumpConditionList.php";
$this->jump_condition_list = new ilQuestionSetPoolJumpConditionList($this);
parent::__construct($id);
}
/**
* @param int $id
*/
public function setId($id)
{
$this->id = $id;
}
/**
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* @param int $index
*/
public function setIndex($index)
{
$this->index = $index;
}
/**
* @return int
*/
public function getIndex()
{
return $this->index;
}
/**
* @param null|string $initial_condition
*/
public function setInitialCondition($initial_condition)
{
$this->initial_condition = $initial_condition;
}
/**
* @return null|string
*/
public function getInitialCondition()
{
return $this->initial_condition;
}
/**
* @param \assQuestion $question
*/
public function setQuestion($question)
{
$this->question = $question;
}
/**
* @return \assQuestion
*/
public function getQuestion()
{
return $this->question;
}
/**
* @param \ilQuestionSetPoolPath $path
*/
public function setPath(ilQuestionSetPoolPath $path)
{
$this->path = $path;
}
/**
* @return \ilQuestionSetPoolPath
*/
public function getPath()
{
return $this->path;
}
/**
* @param \ilQuestionSetPoolJumpConditionList $jump_condition_list
*/
public function setJumpConditionList($jump_condition_list)
{
$this->jump_condition_list = $jump_condition_list;
}
/**
* @return \ilQuestionSetPoolJumpConditionList
*/
public function getJumpConditionList()
{
return $this->jump_condition_list;
}
/**
* @return int
*/
public function getQuestionIndex()
{
return $this->question_index;
}
/**
* @param int $dominant_scoring
*/
public function setDominantScoring($dominant_scoring)
{
$this->dominant_scoring = $dominant_scoring;
}
/**
* @return int
*/
public function getDominantScoring()
{
return $this->dominant_scoring;
}
/**
* @param integer $id
* @return bool
*/
public static function exists($id)
{
global $DIC;
$ilDB = $DIC->database();
$result = $ilDB->queryF(
"SELECT COUNT(*) cnt FROM rep_robj_xqsp_node WHERE id = %s",
array("integer"),
array($id)
);
$data = $ilDB->fetchAssoc($result);
return (int) $data['cnt'] == 1 ? true : false;
}
public function update()
{
global $DIC;
$ilDB = $DIC->database();
if ($this->id > 0) {
return (bool) $ilDB->update(
"rep_robj_xqsp_node",
array(
"question_fi" => array('integer', $this->getQuestion()->getId()),
"initial_condition" => array('text', $this->getInitialCondition()),
"dominant_scoring" => array("integer", $this->getDominantScoring()),
"true_feedback" => array('clob', $this->getTrueFeedback()),
"false_feedback" => array('clob', $this->getFalseFeedback()),
),
array(
'id' => array("integer", $this->getId())
)
);
} else {
$this->setId($ilDB->nextId("rep_robj_xqsp_node"));
return $ilDB->queryF(
"INSERT INTO rep_robj_xqsp_node (id, path_fi, question_fi, node_index)
(SELECT %s,%s, %s,
CASE WHEN MAX(node_index) IS NULL
THEN 1
ELSE MAX(node_index) + 1
END
FROM rep_robj_xqsp_node WHERE path_fi = %s)",
array("integer", "integer", "integer","integer"),
array($this->getId(), $this->getPath()->getId(), $this->getQuestion()->getId(), $this->getPath()->getId())
);
}
}
public function read()
{
require_once "class.ilQuestionSetPoolPath.php";
global $DIC;
$ilDB = $DIC->database();
$result = $ilDB->queryF(
"SELECT node.*, qst.question_index FROM rep_robj_xqsp_node node
array("integer", "integer", "integer","integer"),
array($this->getId(), $this->getPath()->getId(), $this->getQuestion()->getId(), $this->getPath()->getId())
);
}
}
public function read()
{
require_once "class.ilQuestionSetPoolPath.php";
global $DIC;
$ilDB = $DIC->database();
$result = $ilDB->queryF(
"SELECT node.*, qst.question_index FROM rep_robj_xqsp_node node
INNER JOIN rep_robj_xqsp_qs_qst qst ON qst.question_fi = node.question_fi
WHERE id = %s",
array("integer"),
array($this->id)
);
$data = $ilDB->fetchAssoc($result);
$this->setId($data['id']);
$this->setIndex($data['node_index']);
$this->setInitialCondition($data['initial_condition']);
$this->setDominantScoring($data["dominant_scoring"]);
$this->setQuestion(assQuestion::_instantiateQuestion($data['question_fi']));
$this->question_index = $data["question_index"];
require_once 'Services/RTE/classes/class.ilRTE.php';
$this->setTrueFeedback(ilRTE::_replaceMediaObjectImageSrc($data['true_feedback'], 1));
$this->setFalseFeedback(ilRTE::_replaceMediaObjectImageSrc($data['false_feedback'], 1));
$path_fi = (isset($_GET['path_id']))? $_GET['path_id'] : $data['path_fi'];
$path = new ilQuestionSetPoolPath($path_fi);
$path->read();
$this->setPath($path);
}
/**
* @param ilQuestionSetPoolPath $path
* @param array $question_ids
*/
public function duplicate($path, $question_ids)
{
global $DIC;
$ilDB = $DIC->database();
$clone = clone $this;
$clone->setId($ilDB->nextId("rep_robj_xqsp_node"));
$clone->setPath($path);
$ilDB->insert(
"rep_robj_xqsp_node",
array(
"id" => array("integer", $clone->getId()),
"path_fi" => array("integer", $clone->getPath()->getId()),
"question_fi" => array("integer", $question_ids[$this->getQuestion()->getId()]),
"node_index" => array("integer", $clone->getIndex()),
"initial_condition" => array("text", $clone->getInitialCondition()),
"dominant_scoring" => array("integer", $this->getDominantScoring()),
"true_feedback" => array("clob", $clone->getTrueFeedback()),
"false_feedback" => array("clob", $clone->getFalseFeedback()),
)
);
require_once "class.ilQuestionSetPoolJumpCondition.php";
$data = $this->getJumpConditionList()->getData();
foreach($data as $element)
{
$condition = new ilQuestionSetPoolJumpCondition($element["id"]);
$condition->read();
$condition->duplicate($clone, $question_ids);
}
return true;
}
public function remove()
{
global $DIC;
$ilDB = $DIC->database();
$this->removeJumpConditions();
return $ilDB->manipulateF(
"DELETE FROM rep_robj_xqsp_node WHERE id = %s",
array("integer"),
array($this->getId())
);
}
/**
* @param ilPropertyFormGUI $form
*/
public function bindForm(ilPropertyFormGUI $form)
{
require_once 'Services/RTE/classes/class.ilRTE.php';
if(($input = $form->getInput("initial_condition")) !== null)
{
$this->setInitialCondition($input);
}
if(($input = $form->getInput("question_fi")) != null)
{
$this->setQuestion(assQuestion::_instanciateQuestion($input));
}
if(($input = $form->getInput("true_feedback"))!= NULL)
{
$this->setTrueFeedback(ilRTE::_replaceMediaObjectImageSrc($input, 0));
}
if(($input = $form->getInput("false_feedback"))!= NULL)
{
$this->setFalseFeedback(ilRTE::_replaceMediaObjectImageSrc($input, 0));
}
}
private function removeJumpConditions()
{
require_once "class.ilQuestionSetPoolJumpCondition.php";
$data = $this->getJumpConditionList()->getData();
foreach ($data as $element)
{
$condition = new ilQuestionSetPoolJumpCondition($element["id"]);
$condition->read();
$condition->remove();
}
}
/**
* @return string
*/
public function getFalseFeedback()
{
return $this->false_feedback;
}
/**
* @param string $false_feedback
*/
public function setFalseFeedback($false_feedback)
{
$this->false_feedback = $false_feedback;
}
/**
* @return string
*/
public function getTrueFeedback()
{
return $this->true_feedback;
}
/**
* @param string $true_feedback
*/
public function setTrueFeedback($true_feedback)
{
$this->true_feedback = $true_feedback;
}
public function import()
{
global $DIC;
$ilDB = $DIC->database();
$this->setId($ilDB->nextId("rep_robj_xqsp_node"));
$ilDB->queryF(
"INSERT INTO rep_robj_xqsp_node (id, path_fi, question_fi, node_index)
array("integer"),
array($this->id)
);
$data = $ilDB->fetchAssoc($result);
$this->setId($data['id']);
$this->setIndex($data['node_index']);
$this->setInitialCondition($data['initial_condition']);
$this->setDominantScoring($data["dominant_scoring"]);
$this->setQuestion(assQuestion::_instantiateQuestion($data['question_fi']));
$this->question_index = $data["question_index"];
$this->setTrueFeedback(ilRTE::_replaceMediaObjectImageSrc($data['true_feedback'], 1));
$this->setFalseFeedback(ilRTE::_replaceMediaObjectImageSrc($data['false_feedback'], 1));
$path_fi = (isset($_GET['path_id']))? $_GET['path_id'] : $data['path_fi'];
$path = new ilQuestionSetPoolPath($path_fi);
$path->read();
$this->setPath($path);
}
/**
* @param ilQuestionSetPoolPath $path
* @param array $question_ids
*/
public function duplicate($path, $question_ids)
{
global $DIC;
$ilDB = $DIC->database();
$clone = clone $this;
$clone->setId($ilDB->nextId("rep_robj_xqsp_node"));
$clone->setPath($path);
$ilDB->insert(
"rep_robj_xqsp_node",
array(
"id" => array("integer", $clone->getId()),
"path_fi" => array("integer", $clone->getPath()->getId()),
"question_fi" => array("integer", $question_ids[$this->getQuestion()->getId()]),
"node_index" => array("integer", $clone->getIndex()),
"initial_condition" => array("text", $clone->getInitialCondition()),
"dominant_scoring" => array("integer", $this->getDominantScoring()),
"true_feedback" => array("clob", $clone->getTrueFeedback()),
"false_feedback" => array("clob", $clone->getFalseFeedback()),
)
);
require_once "class.ilQuestionSetPoolJumpCondition.php";
$data = $this->getJumpConditionList()->getData();
foreach ($data as $element) {
$condition = new ilQuestionSetPoolJumpCondition($element["id"]);
$condition->read();
$condition->duplicate($clone, $question_ids);
}
return true;
}
public function remove()
{
global $DIC;
$ilDB = $DIC->database();
$this->removeJumpConditions();
return $ilDB->manipulateF(
"DELETE FROM rep_robj_xqsp_node WHERE id = %s",
array("integer"),
array($this->getId())
);
}
/**
* @param ilPropertyFormGUI $form
*/
public function bindForm(ilPropertyFormGUI $form)
{
if (($input = $form->getInput("initial_condition")) !== null) {
$this->setInitialCondition($input);
}
if (($input = $form->getInput("question_fi")) != null) {
$this->setQuestion(assQuestion::_instanciateQuestion($input));
}
if (($input = $form->getInput("true_feedback")) != null) {
$this->setTrueFeedback(ilRTE::_replaceMediaObjectImageSrc($input, 0));
}
if (($input = $form->getInput("false_feedback")) != null) {
$this->setFalseFeedback(ilRTE::_replaceMediaObjectImageSrc($input, 0));
}
}
private function removeJumpConditions()
{
require_once "class.ilQuestionSetPoolJumpCondition.php";
$data = $this->getJumpConditionList()->getData();
foreach ($data as $element) {
$condition = new ilQuestionSetPoolJumpCondition($element["id"]);
$condition->read();
$condition->remove();
}
}
/**
* @return string
*/
public function getFalseFeedback()
{
return $this->false_feedback;
}
/**
* @param string $false_feedback
*/
public function setFalseFeedback($false_feedback)
{
$this->false_feedback = $false_feedback;
}
/**
* @return string
*/
public function getTrueFeedback()
{
return $this->true_feedback;
}
/**
* @param string $true_feedback
*/
public function setTrueFeedback($true_feedback)
{
$this->true_feedback = $true_feedback;
}
public function import()
{
global $DIC;
$ilDB = $DIC->database();
$this->setId($ilDB->nextId("rep_robj_xqsp_node"));
$ilDB->queryF(
"INSERT INTO rep_robj_xqsp_node (id, path_fi, question_fi, node_index)
(SELECT %s,%s, %s,
CASE WHEN MAX(node_index) IS NULL
THEN 1
ELSE MAX(node_index) + 1
END
FROM rep_robj_xqsp_node WHERE path_fi = %s)",
array("integer", "integer", "integer","integer"),
array($this->getId(), $this->getPath()->getId(), $this->getQuestion()->getId(), $this->getPath()->getId())
);
$ilDB->update(
"rep_robj_xqsp_node",
array(
"initial_condition" => array('text', $this->getInitialCondition()),
"dominant_scoring" => array("integer", $this->getDominantScoring()),
"true_feedback" => array('clob', $this->getTrueFeedback()),
"false_feedback" => array('clob', $this->getFalseFeedback())
),
array('id' => array("integer", $this->getId())
)
);
}
array("integer", "integer", "integer","integer"),
array($this->getId(), $this->getPath()->getId(), $this->getQuestion()->getId(), $this->getPath()->getId())
);
$ilDB->update(
"rep_robj_xqsp_node",
array(
"initial_condition" => array('text', $this->getInitialCondition()),
"dominant_scoring" => array("integer", $this->getDominantScoring()),
"true_feedback" => array('clob', $this->getTrueFeedback()),
"false_feedback" => array('clob', $this->getFalseFeedback())
),
array('id' => array("integer", $this->getId())
)
);
}
}
......@@ -8,140 +8,131 @@ require_once "abstract.ilPluginModelList.php";
* Date: 21.11.13
* Time: 12:21
* @author Thomas Joußen <tjoussen@databay.de>
*/
*/
class ilQuestionSetPoolNodeList extends ilPluginModelList
{
/**
* @var ilQuestionSetPoolPath
*/
protected $path;
public function __construct($path)
{
$this->path = $path;
parent::__construct();
}
/**
* @param array $params
* @param array $filter
*
* @return array
*/
public function loadData($params = array(), $filter = array())
{
require_once "./Customizing/global/plugins/Services/Repository/RepositoryObject/QuestionSetPool/classes/providers/class.ilQuestionSetPoolNodeProvider.php";
$provider = new ilQuestionSetPoolNodeProvider();
$filter["path_fi"] = $this->path->getId();
return $provider->loadData($filter, $params);
}
public function update($data)
{
return $this->db->update(
"rep_robj_xqsp_node",
array(
"node_index" => array("integer", $data["node_index"])
),
array(
"id" => array("integer", $data["id"])
)
);
}
public function getQuestionIds()
{
}
/**
* @param ilQuestionSetPoolNode $current_node
*
* @return ilQuestionSetPoolNode
*/
public function getNextNode($current_node)
{
$data = $this->getData();
foreach($data as $item)
{
if($item["node_index"] > $current_node->getIndex())
{
$node = new ilQuestionSetPoolNode($item["id"]);
$node->read();
return $node;
}
}
return null;
}
/**
* @param ilQuestionSetPoolNode $current_node
*
* @return IlQuestionSetPoolNode|null
*/
public function getPreviousNode($current_node)
{
$data = $this->getData();
$prev = null;
foreach($data as $item)
{
if($item["node_index"] == $current_node->getIndex() && $prev != null)
{
$prev = new ilQuestionSetPoolNode($prev["id"]);
$prev->read();
return $prev;
}
$prev = $item;
}
return null;
}
/**
* @param int $question_id
*
* @return ilQuestionSetPoolNode|null
*/
public function getNodeByQuestionId($question_id)
{
$data = $this->getData();
foreach($data as $item)
{
if($item["question_fi"] == $question_id)
{
$node = new ilQuestionSetPoolNode($item["id"]);
$node->read();
return $node;
}
}
return null;
}
/**
* @param array $data
*
* @return array
*/
public function createObjectsFromData($data)
{
require_once "class.ilQuestionSetPoolJumpConditionList.php";
require_once "class.ilQuestionSetPoolNode.php";
foreach($data as $key => $element)
{
$node = new ilQuestionSetPoolNode($element["id"]);
$node->read();
$list = new ilQuestionSetPoolJumpConditionList($node);
$data[$key]["jump_conditions"] = $list->getData();
}
return $data;
}
/**
* @var ilQuestionSetPoolPath
*/
protected $path;
public function __construct($path)
{
$this->path = $path;
parent::__construct();
}
/**
* @param array $params
* @param array $filter
*
* @return array
*/
public function loadData($params = array(), $filter = array())
{
require_once "./Customizing/global/plugins/Services/Repository/RepositoryObject/QuestionSetPool/classes/providers/class.ilQuestionSetPoolNodeProvider.php";
$provider = new ilQuestionSetPoolNodeProvider();
$filter["path_fi"] = $this->path->getId();
return $provider->loadData($filter, $params);
}
public function update($data)
{
return $this->db->update(
"rep_robj_xqsp_node",
array(
"node_index" => array("integer", $data["node_index"])
),
array(
"id" => array("integer", $data["id"])
)
);
}
public function getQuestionIds()
{
}
/**
* @param ilQuestionSetPoolNode $current_node
*
* @return ilQuestionSetPoolNode
*/
public function getNextNode($current_node)
{
$data = $this->getData();
foreach ($data as $item) {
if ($item["node_index"] > $current_node->getIndex()) {
$node = new ilQuestionSetPoolNode($item["id"]);
$node->read();
return $node;
}
}
return null;
}
/**
* @param ilQuestionSetPoolNode $current_node
*
* @return IlQuestionSetPoolNode|null
*/
public function getPreviousNode($current_node)
{
$data = $this->getData();
$prev = null;
foreach ($data as $item) {
if ($item["node_index"] == $current_node->getIndex() && $prev != null) {
$prev = new ilQuestionSetPoolNode($prev["id"]);
$prev->read();
return $prev;
}
$prev = $item;
}
return null;
}
/**
* @param int $question_id
*
* @return ilQuestionSetPoolNode|null
*/
public function getNodeByQuestionId($question_id)
{
$data = $this->getData();
foreach ($data as $item) {
if ($item["question_fi"] == $question_id) {
$node = new ilQuestionSetPoolNode($item["id"]);
$node->read();
return $node;
}
}
return null;
}
/**
* @param array $data
*
* @return array
*/
public function createObjectsFromData($data)
{
require_once "class.ilQuestionSetPoolJumpConditionList.php";
require_once "class.ilQuestionSetPoolNode.php";
foreach ($data as $key => $element) {
$node = new ilQuestionSetPoolNode($element["id"]);
$node->read();
$list = new ilQuestionSetPoolJumpConditionList($node);
$data[$key]["jump_conditions"] = $list->getData();
}
return $data;
}
}
\ No newline at end of file
......@@ -8,368 +8,356 @@ require_once "abstract.ilPluginModel.php";
* Date: 21.11.13
* Time: 11:02
* @author Thomas Joußen <tjoussen@databay.de>
*/
*/
class ilQuestionSetPoolPath extends ilPluginModel
{
/**
* @var integer
*/
protected $id;
/**
* @var string
*/
protected $title;
/**
* @var ilQuestionSetPoolNodeList
*/
protected $nodes;
/**
* @var ilQuestionSetPoolSet
*/
protected $set;
/**
* @var integer
*/
private $start_question_id;
/**
* @var int
*/
private $index;
/**
* @param int $id
*/
public function setId($id)
{
$this->id = $id;
}
/**
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* @param \ilQuestionSetPoolNodeList $nodes
*/
public function setNodes($nodes)
{
$this->nodes = $nodes;
}
/**
* @return \ilQuestionSetPoolNodeList
*/
public function getNodes()
{
return $this->nodes;
}
/**
* @param string $title
*/
public function setTitle($title)
{
$this->title = $title;
}
/**
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* @param \ilQuestionSetPoolSet $set
*/
public function setSet($set)
{
$this->set = $set;
}
/**
* @return \ilQuestionSetPoolSet
*/
public function getSet()
{
return $this->set;
}
/**
* @param int $index
*/
public function setIndex($index)
{
$this->index = $index;
}
/**
* @return int
*/
public function getIndex()
{
return $this->index;
}
/**
* @param int $question_id
*
* @return bool
*/
public function isQuestionInPath($question_id)
{
$data = $this->getNodes()->getData();
foreach($data as $item)
{
if($item["question_fi"] == $question_id)
{
return true;
}
}
return false;
}
/**
* @param integer $id
* @return bool
*/
public static function exists($id)
{
global $DIC;
$ilDB = $DIC->database();
$result = $ilDB->queryF(
"SELECT COUNT(*) cnt FROM rep_robj_xqsp_path WHERE id = %s",
array("integer"),
array($id)
);
$data = $ilDB->fetchAssoc($result);
return (int)$data['cnt'] == 1 ? true : false;
}
public function update()
{
global $DIC;
$ilDB = $DIC->database();
if($this->id > 0)
{
$ilDB->update(
"rep_robj_xqsp_path",
array("title" => array("text", $this->getTitle())),
array("id" => array("integer", $this->getId()))
);
}
else
{
$this->setId($ilDB->nextId("rep_robj_xqsp_path"));
$success = $ilDB->queryF(
"INSERT INTO rep_robj_xqsp_path (id, title, questionset_fi, path_index)
/**
* @var integer
*/
protected $id;
/**
* @var string
*/
protected $title;
/**
* @var ilQuestionSetPoolNodeList
*/
protected $nodes;
/**
* @var ilQuestionSetPoolSet
*/
protected $set;
/**
* @var integer
*/
private $start_question_id;
/**
* @var int
*/
private $index;
/**
* @param int $id
*/
public function setId($id)
{
$this->id = $id;
}
/**
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* @param \ilQuestionSetPoolNodeList $nodes
*/
public function setNodes($nodes)
{
$this->nodes = $nodes;
}
/**
* @return \ilQuestionSetPoolNodeList
*/
public function getNodes()
{
return $this->nodes;
}
/**
* @param string $title
*/
public function setTitle($title)
{
$this->title = $title;
}
/**
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* @param \ilQuestionSetPoolSet $set
*/
public function setSet($set)
{
$this->set = $set;
}
/**
* @return \ilQuestionSetPoolSet
*/
public function getSet()
{
return $this->set;
}
/**
* @param int $index
*/
public function setIndex($index)
{
$this->index = $index;
}
/**
* @return int
*/
public function getIndex()
{
return $this->index;
}
/**
* @param int $question_id
*
* @return bool
*/
public function isQuestionInPath($question_id)
{
$data = $this->getNodes()->getData();
foreach ($data as $item) {
if ($item["question_fi"] == $question_id) {
return true;
}
}
return false;
}
/**
* @param integer $id
* @return bool
*/
public static function exists($id)
{
global $DIC;
$ilDB = $DIC->database();
$result = $ilDB->queryF(
"SELECT COUNT(*) cnt FROM rep_robj_xqsp_path WHERE id = %s",
array("integer"),
array($id)
);
$data = $ilDB->fetchAssoc($result);
return (int) $data['cnt'] == 1 ? true : false;
}
public function update()
{
global $DIC;
$ilDB = $DIC->database();
if ($this->id > 0) {
$ilDB->update(
"rep_robj_xqsp_path",
array("title" => array("text", $this->getTitle())),
array("id" => array("integer", $this->getId()))
);
} else {
$this->setId($ilDB->nextId("rep_robj_xqsp_path"));
$success = $ilDB->queryF(
"INSERT INTO rep_robj_xqsp_path (id, title, questionset_fi, path_index)
(SELECT %s,%s, %s,
CASE WHEN MAX(path_index) IS NULL
THEN 1
ELSE MAX(path_index) + 1
END
FROM rep_robj_xqsp_path WHERE questionset_fi = %s)",
array("integer", "text", "integer", "integer"),
array($this->getId(), $this->getTitle(), (int)$_GET['set_id'],(int)$_GET['set_id'])
);
$node_id = $ilDB->nextId("rep_robj_xqsp_node");
return $success && $ilDB->insert(
"rep_robj_xqsp_node",
array(
"id" => array("integer", $node_id),
"question_fi" => array("integer", $this->start_question_id),
"path_fi" => array("integer", $this->getId()),
"node_index" => array("integer", 1),
"initial_condition" => array("text", "")
)
);
}
}
/**
* Extracted from update method for XML-Import procedure
*
* @return bool
*/
public function import()
{
global $DIC;
$ilDB = $DIC->database();
$this->setId($ilDB->nextId("rep_robj_xqsp_path"));
$success = $ilDB->queryF(
"INSERT INTO rep_robj_xqsp_path (id, title, questionset_fi, path_index)
array("integer", "text", "integer", "integer"),
array($this->getId(), $this->getTitle(), (int) $_GET['set_id'],(int) $_GET['set_id'])
);
$node_id = $ilDB->nextId("rep_robj_xqsp_node");
return $success && $ilDB->insert(
"rep_robj_xqsp_node",
array(
"id" => array("integer", $node_id),
"question_fi" => array("integer", $this->start_question_id),
"path_fi" => array("integer", $this->getId()),
"node_index" => array("integer", 1),
"initial_condition" => array("text", "")
)
);
}
}
/**
* Extracted from update method for XML-Import procedure
*
* @return bool
*/
public function import()
{
global $DIC;
$ilDB = $DIC->database();
$this->setId($ilDB->nextId("rep_robj_xqsp_path"));
$success = $ilDB->queryF(
"INSERT INTO rep_robj_xqsp_path (id, title, questionset_fi, path_index)
(SELECT %s,%s, %s,
CASE WHEN MAX(path_index) IS NULL
THEN 1
ELSE MAX(path_index) + 1
END
FROM rep_robj_xqsp_path WHERE questionset_fi = %s)",
array("integer", "text", "integer", "integer"),
array($this->getId(), $this->getTitle(), (int)$this->getSet()->getId(),(int)$this->getSet()->getId())
);
return $success;
}
public function read()
{
require_once "class.ilQuestionSetPoolNodeList.php";
require_once "class.ilQuestionSetPoolSet.php";
global $DIC;
$ilDB = $DIC->database();
$result = $ilDB->queryF(
"SELECT * FROM rep_robj_xqsp_path WHERE id = %s",
array("integer"),
array($this->id)
);
$data = $ilDB->fetchAssoc($result);
$this->setId($data['id']);
$this->setTitle($data['title']);
$this->setIndex($data["path_index"]);
$this->setNodes(new ilQuestionSetPoolNodeList($this));
$id = isset($data["questionset_fi"])? $data["questionset_fi"] : $_GET['set_id'];
$set = new ilQuestionSetPoolSet($id);
$set->read();
$this->setSet($set);
}
/**
* @param array $question_ids
*/
public function duplicate($question_ids, $title = "")
{
global $DIC;
$ilDB = $DIC->database();
$clone = clone $this;
$clone->setId($ilDB->nextId("rep_robj_xqsp_path"));
if($title != "")
{
$clone->setTitle($title);
}
$ilDB->queryF(
"INSERT INTO rep_robj_xqsp_path (id, title, questionset_fi, path_index)
array("integer", "text", "integer", "integer"),
array($this->getId(), $this->getTitle(), (int) $this->getSet()->getId(),(int) $this->getSet()->getId())
);
return $success;
}
public function read()
{
require_once "class.ilQuestionSetPoolNodeList.php";
require_once "class.ilQuestionSetPoolSet.php";
global $DIC;
$ilDB = $DIC->database();
$result = $ilDB->queryF(
"SELECT * FROM rep_robj_xqsp_path WHERE id = %s",
array("integer"),
array($this->id)
);
$data = $ilDB->fetchAssoc($result);
$this->setId($data['id']);
$this->setTitle($data['title']);
$this->setIndex($data["path_index"]);
$this->setNodes(new ilQuestionSetPoolNodeList($this));
$id = isset($data["questionset_fi"])? $data["questionset_fi"] : $_GET['set_id'];
$set = new ilQuestionSetPoolSet($id);
$set->read();
$this->setSet($set);
}
/**
* @param array $question_ids
*/
public function duplicate($question_ids, $title = "")
{
global $DIC;
$ilDB = $DIC->database();
$clone = clone $this;
$clone->setId($ilDB->nextId("rep_robj_xqsp_path"));
if ($title != "") {
$clone->setTitle($title);
}
$ilDB->queryF(
"INSERT INTO rep_robj_xqsp_path (id, title, questionset_fi, path_index)
(SELECT %s,%s, %s,
CASE WHEN MAX(path_index) IS NULL
THEN 1
ELSE MAX(path_index) + 1
END
FROM rep_robj_xqsp_path WHERE questionset_fi = %s)",
array("integer", "text", "integer", "integer"),
array($clone->getId(), $clone->getTitle(),$clone->getSet()->getId(),$clone->getSet()->getId())
);
require_once "class.ilQuestionSetPoolNode.php";
$data = $this->getNodes()->getData();
foreach($data as $element)
{
$node = new ilQuestionSetPoolNode($element["id"]);
$node->read();
$node->duplicate($clone, $question_ids);
}
}
public function remove()
{
global $DIC;
$ilDB = $DIC->database();
$this->removeNodes();
return $ilDB->manipulateF(
"DELETE FROM rep_robj_xqsp_path WHERE id = %s",
array("integer"),
array($this->getId())
);
}
public function getQuestionsLowerAndEqualsIndex($index)
{
global $DIC;
$ilDB = $DIC->database();
$result = $ilDB->queryF(
"SELECT qs_qst.question_index, q.title, q.question_id
array("integer", "text", "integer", "integer"),
array($clone->getId(), $clone->getTitle(),$clone->getSet()->getId(),$clone->getSet()->getId())
);
require_once "class.ilQuestionSetPoolNode.php";
$data = $this->getNodes()->getData();
foreach ($data as $element) {
$node = new ilQuestionSetPoolNode($element["id"]);
$node->read();
$node->duplicate($clone, $question_ids);
}
}
public function remove()
{
global $DIC;
$ilDB = $DIC->database();
$this->removeNodes();
return $ilDB->manipulateF(
"DELETE FROM rep_robj_xqsp_path WHERE id = %s",
array("integer"),
array($this->getId())
);
}
public function getQuestionsLowerAndEqualsIndex($index)
{
global $DIC;
$ilDB = $DIC->database();
$result = $ilDB->queryF(
"SELECT qs_qst.question_index, q.title, q.question_id
FROM rep_robj_xqsp_qs_qst qs_qst
INNER JOIN rep_robj_xqsp_node n ON n.question_fi = qs_qst.question_fi
INNER JOIN qpl_questions q ON q.question_id = qs_qst.question_fi
WHERE n.path_fi = %s AND n.node_index <= %s
ORDER BY n.node_index",
array("integer", "integer"),
array($this->getId(), $index)
);
$data = array();
while(($row = $ilDB->fetchAssoc($result)) != null)
{
$data[] = $row;
}
return $data;
}
/**
* @param ilQuestionSetPoolPath $path
* @param int $index
*
* @return bool
*/
public function isEqualsUntilIndex($path, $index)
{
$current_nodes = $this->getNodes()->getData();
$compate_nodes = $path->getNodes()->getData();
for($i = 0; $i < $index; $i++)
{
if(
$current_nodes[$i]["question_index"] != $compate_nodes[$i]["question_index"]
)
{
return false;
}
}
return true;
}
/**
* @param ilPropertyFormGUI $form
*/
public function bindForm(ilPropertyFormGUI $form)
{
$this->setTitle($form->getInput("title"));
$this->start_question_id = $form->getInput("start_question");
}
private function removeNodes()
{
require_once "class.ilQuestionSetPoolNode.php";
$data = $this->getNodes()->getData();
foreach ($data as $element)
{
$node = new ilQuestionSetPoolNode($element["id"]);
$node->read();
$node->remove();
}
}
array("integer", "integer"),
array($this->getId(), $index)
);
$data = array();
while (($row = $ilDB->fetchAssoc($result)) != null) {
$data[] = $row;
}
return $data;
}
/**
* @param ilQuestionSetPoolPath $path
* @param int $index
*
* @return bool
*/
public function isEqualsUntilIndex($path, $index)
{
$current_nodes = $this->getNodes()->getData();
$compate_nodes = $path->getNodes()->getData();
for ($i = 0; $i < $index; $i++) {
if (
$current_nodes[$i]["question_index"] != $compate_nodes[$i]["question_index"]
) {
return false;
}
}
return true;
}
/**
* @param ilPropertyFormGUI $form
*/
public function bindForm(ilPropertyFormGUI $form)
{
$this->setTitle($form->getInput("title"));
$this->start_question_id = $form->getInput("start_question");
}
private function removeNodes()
{
require_once "class.ilQuestionSetPoolNode.php";
$data = $this->getNodes()->getData();
foreach ($data as $element) {
$node = new ilQuestionSetPoolNode($element["id"]);
$node->read();
$node->remove();
}
}
}
\ No newline at end of file
......@@ -8,94 +8,92 @@ require_once "abstract.ilPluginModelList.php";
* Date: 10.10.13
* Time: 10:49
* @author Thomas Joußen <tjoussen@databay.de>
*/
*/
class ilQuestionSetPoolPathList extends ilPluginModelList
{
/**
* @var ilQuestionSetPoolSet
*/
protected $set;
/**
* @var ilQuestionSetPoolSet
*/
protected $set;
public function __construct($set)
{
$this->set = $set;
public function __construct($set)
{
$this->set = $set;
parent::__construct();
}
parent::__construct();
}
/**
* @param array $params
* @param array $filter
*
* @return array
*/
public function loadData($params = array(), $filter = array())
{
require_once "./Customizing/global/plugins/Services/Repository/RepositoryObject/QuestionSetPool/classes/providers/class.ilQuestionSetPoolPathProvider.php";
/**
* @param array $params
* @param array $filter
*
* @return array
*/
public function loadData($params = array(), $filter = array())
{
require_once "./Customizing/global/plugins/Services/Repository/RepositoryObject/QuestionSetPool/classes/providers/class.ilQuestionSetPoolPathProvider.php";
$provider = new ilQuestionSetPoolPathProvider();
$filter["questionset_fi"] = $this->set->getId();
return $provider->loadData($filter, $params);
}
$provider = new ilQuestionSetPoolPathProvider();
$filter["questionset_fi"] = $this->set->getId();
return $provider->loadData($filter, $params);
}
public function update($data)
{
return $this->db->update(
"rep_robj_xqsp_path",
array(
"path_index" => array("integer", $data["path_index"])
),
array(
"id" => array("integer", $data["id"])
)
);
}
public function update($data)
{
return $this->db->update(
"rep_robj_xqsp_path",
array(
"path_index" => array("integer", $data["path_index"])
),
array(
"id" => array("integer", $data["id"])
)
);
}
public function getPath($id)
{
$data = $this->getData();
public function getPath($id)
{
$data = $this->getData();
foreach($data as $item)
{
if($item->getId() == $id)
{
return $item;
}
}
foreach ($data as $item) {
if ($item->getId() == $id) {
return $item;
}
}
return null;
}
return null;
}
public function insert($question_ids)
{
return true;
}
public function insert($question_ids)
{
return true;
}
public function remove($question_ids)
{
return true;
}
public function remove($question_ids)
{
return true;
}
/**
* @param array $data
*
* @return array
*/
public function createObjectsFromData($data)
{
return $data;
/*$objects = array();
foreach($data as $item)
{
require_once 'class.ilQuestionSetPoolSet.php';
$set = new ilQuestionSetPoolSet($this->question_set_pool);
$set->setId($item['id']);
$set->setTitle($item['title']);
$set->setDescription($item['description']);
/**
* @param array $data
*
* @return array
*/
public function createObjectsFromData($data)
{
return $data;
/*$objects = array();
foreach($data as $item)
{
require_once 'class.ilQuestionSetPoolSet.php';
$set = new ilQuestionSetPoolSet($this->question_set_pool);
$set->setId($item['id']);
$set->setTitle($item['title']);
$set->setDescription($item['description']);
$objects[] = $set;
}
$objects[] = $set;
}
return $objects;*/
}
return $objects;*/
}
}
......@@ -8,480 +8,467 @@ require_once "abstract.ilPluginModel.php";
* Date: 02.10.13
* Time: 12:18
* @author Thomas Joußen <tjoussen@databay.de>
*/
class ilQuestionSetPoolSet extends ilPluginModel{
/**
* @var integer
*/
protected $id;
/**
* @var string
*/
protected $title;
/**
* @var string
*/
protected $description;
/**
* @var ilQuestionSetPoolSetQuestionList
*/
protected $question_list;
/**
* @var ilQuestionSetPoolPathList
*/
protected $path_list;
/**
* @var int|null
*/
protected $original_id;
/**
* @var int
*/
protected $container_obj_id;
/**
* needed for formatest-importer
* @var array
*/
public $xqsp_qst_mapping = array();
/**
* ilQuestionSetPoolSet constructor.
* @param int $id question_set_id
*/
public function __construct($id = 0)
{
require_once 'class.ilQuestionSetPoolSetQuestionList.php';
require_once 'class.ilQuestionSetPoolPathList.php';
$this->question_list = new ilQuestionSetPoolSetQuestionList($this);
$this->path_list = new ilQuestionSetPoolPathList($this);
parent::__construct($id);
}
/**
* @param integer $id
* @return bool
*/
public static function exists($id)
{
global $DIC;
$ilDB = $DIC->database();
$result = $ilDB->queryF(
"SELECT COUNT(*) cnt FROM rep_robj_xqsp_qs WHERE id = %s",
array("integer"),
array($id)
);
$data = $ilDB->fetchAssoc($result);
return (int)$data['cnt'] == 1 ? true : false;
}
/**
* @param string $description
*/
public function setDescription($description)
{
$this->description = $description;
}
/**
* @return string
*/
public function getDescription()
{
return $this->description;
}
/**
* @param int $id
*/
public function setId($id)
{
$this->id = $id;
}
/**
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* @param string $title
*/
public function setTitle($title)
{
$this->title = $title;
}
/**
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* @return ilQuestionSetPoolSetQuestionList
*/
public function getQuestionList()
{
return $this->question_list;
}
/**
* @return ilQuestionSetPoolPathList
*/
public function getPathList()
{
return $this->path_list;
}
/**
* @param int|null $original_id
*/
public function setOriginalId($original_id)
{
$this->original_id = $original_id;
}
/**
* @return int|null
*/
public function getOriginalId()
{
return $this->original_id;
}
/**
* @param int $container_obj_id
*/
public function setContainerObjId($container_obj_id)
{
$this->container_obj_id = $container_obj_id;
}
/**
* @return int
*/
public function getContainerObjId()
{
return $this->container_obj_id;
}
public function update()
{
global $DIC;
$ilDB = $DIC->database();
if($this->id > 0)
{
return (bool)$ilDB->update(
"rep_robj_xqsp_qs",
array(
"title" => array("text", $this->getTitle()),
"description" => array("text", $this->getDescription()),
"original_id" => array("integer", $this->getOriginalId())
),
array(
"id" => array("integer", $this->getId())
)
);
}
else
{
$this->setId($ilDB->nextId("rep_robj_xqsp_qs"));
return $ilDB->insert(
"rep_robj_xqsp_qs",
array(
"id" => array("integer", $this->getId()),
"title" => array("text", $this->getTitle()),
"description" => array("text", $this->getDescription()),
"questionsetpool_fi" => array("integer", $this->getContainerObjId()),
"original_id" => array("integer", $this->getOriginalId())
)
);
}
}
public function read()
{
global $DIC;
$ilDB = $DIC->database();
$result = $ilDB->queryF(
"SELECT * FROM rep_robj_xqsp_qs WHERE id = %s",
array("integer"),
array($this->id)
);
$data = $ilDB->fetchAssoc($result);
if($data != null)
{
$this->setContainerObjId($data["questionsetpool_fi"]);
$this->setDescription($data['description']);
$this->setTitle($data['title']);
$this->setOriginalId($data["original_id"]);
}
}
/**
* @return bool
*/
public function remove()
{
global $DIC;
$ilDB = $DIC->database();
$this->removePaths();
$this->removeQuestions();
return $ilDB->manipulateF(
"DELETE FROM rep_robj_xqsp_qs WHERE id = %s",
array("integer"),
array($this->getId())
);
}
public function isTitleUnique()
{
global $DIC;
$ilDB = $DIC->database();
$result = $ilDB->queryF(
"SELECT COUNT(id) num FROM rep_robj_xqsp_qs WHERE title = %s AND id != %s AND questionsetpool_fi = %s",
array("text", "integer", "integer"),
array($this->getTitle(), $this->getId(), $this->getContainerObjId())
);
$row = $ilDB->fetchAssoc($result);
return $row["num"] == 0;
}
/**
* @return array
*/
public function getPathTitles()
{
global $DIC;
$ilDB = $DIC->database();
$titles = array();
$result = $ilDB->queryF(
"SELECT DISTINCT(title) FROM rep_robj_xqsp_path WHERE questionset_fi = %s",
array("integer"),
array($this->getId())
);
while($row = $ilDB->fetchAssoc($result))
{
$titles[] = $row['title'];
}
return $titles;
}
/**
* @param string$original_title
* @param integer $container_obj_id
*/
protected function getUniqueTitleForContainer($original_title, $container_obj_id)
{
global $DIC;
$ilDB = $DIC->database();
$title = $original_title;
$i = 1;
if($this->getContainerObjId() == $container_obj_id)
{
++$i;
$title .= ' (' . $i . ')';
}
do
{
$result = $ilDB->queryF(
"SELECT id FROM rep_robj_xqsp_qs WHERE title = %s AND questionsetpool_fi = %s",
array("text", "integer"),
array($title, $container_obj_id)
);
if(!$ilDB->numRows($result))
{
return $title;
}
$title = $original_title . ' (' . ++$i . ')';
}
while(true);
}
/**
* @param int $container_obj_id
*
* @return self
*/
public function duplicate($container_obj_id)
{
$clone = $this->duplicateSet($container_obj_id);
$question_ids = $this->duplicateQuestions($container_obj_id, $clone);
$this->duplicatePaths($clone, $question_ids);
return $clone;
}
public function synchronize($container_obj_id, $old_questions)
{
$clone = $this->duplicateSet($container_obj_id);
$question_ids = $this->synchronizeQuestions($container_obj_id, $clone, $old_questions);
$this->duplicatePaths($clone, $question_ids);
return $clone;
}
/**
* @param ilPropertyFormGUI $form
*/
public function bindForm(ilPropertyFormGUI $form)
{
$this->setTitle($form->getInput('title'));
$this->setDescription($form->getInput('description'));
}
/**
* @param int $old_id
* @param int $new_id
*/
public static function updateOriginalId($old_id, $new_id)
{
global $DIC;
$ilDB = $DIC->database();
$ilDB->update(
"rep_robj_xqsp_qs",
array("original_id" => array("integer", $new_id)),
array("original_id" => array("integer", $old_id))
);
}
/**
* @return array
*/
private function removeQuestions()
{
$data = $this->getQuestionList()->getData();
$question_ids = array();
foreach ($data as $element)
{
$question_ids[] = $element["question_id"];
}
return $this->getQuestionList()->remove($question_ids);
}
private function removePaths()
{
require_once "class.ilQuestionSetPoolPath.php";
$data = $this->getPathList()->getData();
foreach ($data as $element)
{
$path = new ilQuestionSetPoolPath($element["id"]);
$path->read();
$path->remove();
}
}
/**
* @param $container_obj_id
*
* @return ilQuestionSetPoolSet
*/
private function duplicateSet($container_obj_id)
{
$clone = new ilQuestionSetPoolSet();
$clone->setTitle($this->getUniqueTitleForContainer($this->getTitle(), $container_obj_id));
$clone->setDescription($this->getDescription());
//$clone->setOriginalId($this->getOriginalId());
$clone->setOriginalId($this->getId());
$clone->setContainerObjId($container_obj_id);
$clone->update();
return $clone;
}
/**
* @param $clone
* @param $question_ids
*/
private function duplicatePaths($clone, $question_ids)
{
require_once "class.ilQuestionSetPoolPath.php";
$data = $this->getPathList()->getData();
foreach($data as $element)
{
$path = new ilQuestionSetPoolPath($element["id"]);
$path->read();
$path->setSet($clone);
$path->duplicate($question_ids);
}
}
/**
* @param int $container_obj_id
* @param ilQuestionSetPoolSet $clone
*
* @return array
*/
private function duplicateQuestions($container_obj_id, $clone)
{
$data = $this->getQuestionList()->getData();
$question_ids = array();
foreach($data as $element)
{
$question_ids[] = $element["question_id"];
}
$question_ids = $clone->getQuestionList()->duplicate($question_ids, $this, $container_obj_id);
$this->xqsp_qst_mapping = $question_ids;
return $question_ids;
}
public function getQuestionMapping()
{
return $this->xqsp_qst_mapping;
}
/**
* @param int $container_obj_id
* @param ilQuestionSetPoolSet $clone
* @param array $old_questions
*
* @return array
*/
private function synchronizeQuestions($container_obj_id, $clone, $old_questions)
{
$data = $this->getQuestionList()->getData();
$question_ids = array();
foreach($data as $element)
{
$question_ids[] = $element["question_id"];
}
$question_ids = $clone->getQuestionList()->synchronize($question_ids, $this, $container_obj_id, $old_questions);
return $question_ids;
}
*/
class ilQuestionSetPoolSet extends ilPluginModel
{
/**
* @var integer
*/
protected $id;
/**
* @var string
*/
protected $title;
/**
* @var string
*/
protected $description;
/**
* @var ilQuestionSetPoolSetQuestionList
*/
protected $question_list;
/**
* @var ilQuestionSetPoolPathList
*/
protected $path_list;
/**
* @var int|null
*/
protected $original_id;
/**
* @var int
*/
protected $container_obj_id;
/**
* needed for formatest-importer
* @var array
*/
public $xqsp_qst_mapping = array();
/**
* ilQuestionSetPoolSet constructor.
* @param int $id question_set_id
*/
public function __construct($id = 0)
{
require_once 'class.ilQuestionSetPoolSetQuestionList.php';
require_once 'class.ilQuestionSetPoolPathList.php';
$this->question_list = new ilQuestionSetPoolSetQuestionList($this);
$this->path_list = new ilQuestionSetPoolPathList($this);
parent::__construct($id);
}
/**
* @param integer $id
* @return bool
*/
public static function exists($id)
{
global $DIC;
$ilDB = $DIC->database();
$result = $ilDB->queryF(
"SELECT COUNT(*) cnt FROM rep_robj_xqsp_qs WHERE id = %s",
array("integer"),
array($id)
);
$data = $ilDB->fetchAssoc($result);
return (int) $data['cnt'] == 1 ? true : false;
}
/**
* @param string $description
*/
public function setDescription($description)
{
$this->description = $description;
}
/**
* @return string
*/
public function getDescription()
{
return $this->description;
}
/**
* @param int $id
*/
public function setId($id)
{
$this->id = $id;
}
/**
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* @param string $title
*/
public function setTitle($title)
{
$this->title = $title;
}
/**
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* @return ilQuestionSetPoolSetQuestionList
*/
public function getQuestionList()
{
return $this->question_list;
}
/**
* @return ilQuestionSetPoolPathList
*/
public function getPathList()
{
return $this->path_list;
}
/**
* @param int|null $original_id
*/
public function setOriginalId($original_id)
{
$this->original_id = $original_id;
}
/**
* @return int|null
*/
public function getOriginalId()
{
return $this->original_id;
}
/**
* @param int $container_obj_id
*/
public function setContainerObjId($container_obj_id)
{
$this->container_obj_id = $container_obj_id;
}
/**
* @return int
*/
public function getContainerObjId()
{
return $this->container_obj_id;
}
public function update()
{
global $DIC;
$ilDB = $DIC->database();
if ($this->id > 0) {
return (bool) $ilDB->update(
"rep_robj_xqsp_qs",
array(
"title" => array("text", $this->getTitle()),
"description" => array("text", $this->getDescription()),
"original_id" => array("integer", $this->getOriginalId())
),
array(
"id" => array("integer", $this->getId())
)
);
} else {
$this->setId($ilDB->nextId("rep_robj_xqsp_qs"));
return $ilDB->insert(
"rep_robj_xqsp_qs",
array(
"id" => array("integer", $this->getId()),
"title" => array("text", $this->getTitle()),
"description" => array("text", $this->getDescription()),
"questionsetpool_fi" => array("integer", $this->getContainerObjId()),
"original_id" => array("integer", $this->getOriginalId())
)
);
}
}
public function read()
{
global $DIC;
$ilDB = $DIC->database();
$result = $ilDB->queryF(
"SELECT * FROM rep_robj_xqsp_qs WHERE id = %s",
array("integer"),
array($this->id)
);
$data = $ilDB->fetchAssoc($result);
if ($data != null) {
$this->setContainerObjId($data["questionsetpool_fi"]);
$this->setDescription($data['description']);
$this->setTitle($data['title']);
$this->setOriginalId($data["original_id"]);
}
}
/**
* @return bool
*/
public function remove()
{
global $DIC;
$ilDB = $DIC->database();
$this->removePaths();
$this->removeQuestions();
return $ilDB->manipulateF(
"DELETE FROM rep_robj_xqsp_qs WHERE id = %s",
array("integer"),
array($this->getId())
);
}
public function isTitleUnique()
{
global $DIC;
$ilDB = $DIC->database();
$result = $ilDB->queryF(
"SELECT COUNT(id) num FROM rep_robj_xqsp_qs WHERE title = %s AND id != %s AND questionsetpool_fi = %s",
array("text", "integer", "integer"),
array($this->getTitle(), $this->getId(), $this->getContainerObjId())
);
$row = $ilDB->fetchAssoc($result);
return $row["num"] == 0;
}
/**
* @return array
*/
public function getPathTitles()
{
global $DIC;
$ilDB = $DIC->database();
$titles = array();
$result = $ilDB->queryF(
"SELECT DISTINCT(title) FROM rep_robj_xqsp_path WHERE questionset_fi = %s",
array("integer"),
array($this->getId())
);
while ($row = $ilDB->fetchAssoc($result)) {
$titles[] = $row['title'];
}
return $titles;
}
/**
* @param string$original_title
* @param integer $container_obj_id
*/
protected function getUniqueTitleForContainer($original_title, $container_obj_id)
{
global $DIC;
$ilDB = $DIC->database();
$title = $original_title;
$i = 1;
if ($this->getContainerObjId() == $container_obj_id) {
++$i;
$title .= ' (' . $i . ')';
}
do {
$result = $ilDB->queryF(
"SELECT id FROM rep_robj_xqsp_qs WHERE title = %s AND questionsetpool_fi = %s",
array("text", "integer"),
array($title, $container_obj_id)
);
if (!$ilDB->numRows($result)) {
return $title;
}
$title = $original_title . ' (' . ++$i . ')';
} while (true);
}
/**
* @param int $container_obj_id
*
* @return self
*/
public function duplicate($container_obj_id)
{
$clone = $this->duplicateSet($container_obj_id);
$question_ids = $this->duplicateQuestions($container_obj_id, $clone);
$this->duplicatePaths($clone, $question_ids);
return $clone;
}
public function synchronize($container_obj_id, $old_questions)
{
$clone = $this->duplicateSet($container_obj_id);
$question_ids = $this->synchronizeQuestions($container_obj_id, $clone, $old_questions);
$this->duplicatePaths($clone, $question_ids);
return $clone;
}
/**
* @param ilPropertyFormGUI $form
*/
public function bindForm(ilPropertyFormGUI $form)
{
$this->setTitle($form->getInput('title'));
$this->setDescription($form->getInput('description'));
}
/**
* @param int $old_id
* @param int $new_id
*/
public static function updateOriginalId($old_id, $new_id)
{
global $DIC;
$ilDB = $DIC->database();
$ilDB->update(
"rep_robj_xqsp_qs",
array("original_id" => array("integer", $new_id)),
array("original_id" => array("integer", $old_id))
);
}
/**
* @return array
*/
private function removeQuestions()
{
$data = $this->getQuestionList()->getData();
$question_ids = array();
foreach ($data as $element) {
$question_ids[] = $element["question_id"];
}
return $this->getQuestionList()->remove($question_ids);
}
private function removePaths()
{
require_once "class.ilQuestionSetPoolPath.php";
$data = $this->getPathList()->getData();
foreach ($data as $element) {
$path = new ilQuestionSetPoolPath($element["id"]);
$path->read();
$path->remove();
}
}
/**
* @param $container_obj_id
*
* @return ilQuestionSetPoolSet
*/
private function duplicateSet($container_obj_id)
{
$clone = new ilQuestionSetPoolSet();
$clone->setTitle($this->getUniqueTitleForContainer($this->getTitle(), $container_obj_id));
$clone->setDescription($this->getDescription());
//$clone->setOriginalId($this->getOriginalId());
$clone->setOriginalId($this->getId());
$clone->setContainerObjId($container_obj_id);
$clone->update();
return $clone;
}
/**
* @param $clone
* @param $question_ids
*/
private function duplicatePaths($clone, $question_ids)
{
require_once "class.ilQuestionSetPoolPath.php";
$data = $this->getPathList()->getData();
foreach ($data as $element) {
$path = new ilQuestionSetPoolPath($element["id"]);
$path->read();
$path->setSet($clone);
$path->duplicate($question_ids);
}
}
/**
* @param int $container_obj_id
* @param ilQuestionSetPoolSet $clone
*
* @return array
*/
private function duplicateQuestions($container_obj_id, $clone)
{
$data = $this->getQuestionList()->getData();
$question_ids = array();
foreach ($data as $element) {
$question_ids[] = $element["question_id"];
}
$question_ids = $clone->getQuestionList()->duplicate($question_ids, $this, $container_obj_id);
$this->xqsp_qst_mapping = $question_ids;
return $question_ids;
}
public function getQuestionMapping()
{
return $this->xqsp_qst_mapping;
}
/**
* @param int $container_obj_id
* @param ilQuestionSetPoolSet $clone
* @param array $old_questions
*
* @return array
*/
private function synchronizeQuestions($container_obj_id, $clone, $old_questions)
{
$data = $this->getQuestionList()->getData();
$question_ids = array();
foreach ($data as $element) {
$question_ids[] = $element["question_id"];
}
$question_ids = $clone->getQuestionList()->synchronize($question_ids, $this, $container_obj_id, $old_questions);
return $question_ids;
}
}
......@@ -8,152 +8,143 @@ require_once "abstract.ilPluginModelList.php";
* Date: 10.10.13
* Time: 10:49
* @author Thomas Joußen <tjoussen@databay.de>
*/
*/
class ilQuestionSetPoolSetList extends ilPluginModelList
{
/**
* @var ilObjQuestionSetPool
*/
protected $question_set_pool;
/**
* needed for formatest-importer
* @var array
*/
public $xqsp_qst_mapping = array();
/**
* needed for formatest-importer
* @var array
*/
public $set_mapping = array();
/**
* @var ilObjQuestionSetPool
*/
protected $question_set_pool;
/**
* needed for formatest-importer
* @var array
*/
public $xqsp_qst_mapping = array();
/**
* needed for formatest-importer
* @var array
*/
public $set_mapping = array();
public function __construct($question_set_pool)
{
$this->question_set_pool = $question_set_pool;
public function __construct($question_set_pool)
{
$this->question_set_pool = $question_set_pool;
parent::__construct();
}
parent::__construct();
}
/**
* @param array $params
* @param array $filter
*
* @return array
*/
public function loadData($params = array(), $filter = array())
{
require_once "./Customizing/global/plugins/Services/Repository/RepositoryObject/QuestionSetPool/classes/providers/class.ilQuestionSetPoolSetsProvider.php";
/**
* @param array $params
* @param array $filter
*
* @return array
*/
public function loadData($params = array(), $filter = array())
{
require_once "./Customizing/global/plugins/Services/Repository/RepositoryObject/QuestionSetPool/classes/providers/class.ilQuestionSetPoolSetsProvider.php";
$provider = new ilQuestionSetPoolSetsProvider();
$filter["questionsetpool_fi"] = $this->question_set_pool->getId();
return $provider->loadData($filter, $params);
}
$provider = new ilQuestionSetPoolSetsProvider();
$filter["questionsetpool_fi"] = $this->question_set_pool->getId();
return $provider->loadData($filter, $params);
}
public function getSet($id)
{
$data = $this->getData();
public function getSet($id)
{
$data = $this->getData();
foreach($data as $item)
{
if($item->getId() == $id)
{
return $item;
}
}
foreach ($data as $item) {
if ($item->getId() == $id) {
return $item;
}
}
return null;
}
/**
* @param $set_ids
* @param bool $do_clone
* @return bool
*/
public function insert($set_ids, $do_clone = true)
{
require_once "./Customizing/global/plugins/Services/Repository/RepositoryObject/QuestionSetPool/classes/class.ilObjQuestionSetPool.php";
foreach($set_ids as $set_id)
{
$set = new ilQuestionSetPoolSet($set_id);
$set->read();
if($set != null )
{
if($do_clone)
{
$clone = $set->duplicate($this->question_set_pool->getId());
$container_id = $clone->getId();
$this->set_mapping[$set_id] = $clone->getId();
$this->xqsp_qst_mapping = $set->getQuestionMapping();
}
else
{
$container_id = $set->getId();
$this->xqsp_qst_mapping = $set->getQuestionMapping();
}
$success = $this->db->queryF(
"INSERT INTO rep_robj_xtsf_qs (obj_fi, questionset_fi, sorting)
return null;
}
/**
* @param $set_ids
* @param bool $do_clone
* @return bool
*/
public function insert($set_ids, $do_clone = true)
{
require_once "./Customizing/global/plugins/Services/Repository/RepositoryObject/QuestionSetPool/classes/class.ilObjQuestionSetPool.php";
foreach ($set_ids as $set_id) {
$set = new ilQuestionSetPoolSet($set_id);
$set->read();
if ($set != null) {
if ($do_clone) {
$clone = $set->duplicate($this->question_set_pool->getId());
$container_id = $clone->getId();
$this->set_mapping[$set_id] = $clone->getId();
$this->xqsp_qst_mapping = $set->getQuestionMapping();
} else {
$container_id = $set->getId();
$this->xqsp_qst_mapping = $set->getQuestionMapping();
}
$success = $this->db->queryF(
"INSERT INTO rep_robj_xtsf_qs (obj_fi, questionset_fi, sorting)
(SELECT %s,%s,
CASE WHEN MAX(sorting) IS NULL
THEN 10
ELSE MAX(sorting) + 10
END
FROM rep_robj_xtsf_qs WHERE obj_fi = %s)",
array("integer", "integer", "integer"),
array($this->question_set_pool->getId(), $container_id, $this->question_set_pool->getId())
);
if(!$success)
{
return false;
}
}
}
return true;
}
array("integer", "integer", "integer"),
array($this->question_set_pool->getId(), $container_id, $this->question_set_pool->getId())
);
if (!$success) {
return false;
}
}
}
return true;
}
public function remove($question_ids)
{
return true;
}
public function remove($question_ids)
{
return true;
}
/**
* @param array $data
*
* @return array
*/
public function createObjectsFromData($data)
{
$objects = array();
foreach($data as $item)
{
require_once 'class.ilQuestionSetPoolSet.php';
$set = new ilQuestionSetPoolSet($this->question_set_pool);
$set->setId($item['id']);
$set->setTitle($item['title']);
$set->setDescription($item['description']);
/**
* @param array $data
*
* @return array
*/
public function createObjectsFromData($data)
{
$objects = array();
foreach ($data as $item) {
require_once 'class.ilQuestionSetPoolSet.php';
$set = new ilQuestionSetPoolSet($this->question_set_pool);
$set->setId($item['id']);
$set->setTitle($item['title']);
$set->setDescription($item['description']);
$objects[] = $set;
}
$objects[] = $set;
}
return $objects;
}
/**
* @return array
*/
public function getQuestionMapping()
{
return $this->xqsp_qst_mapping;
}
/**
* @return array
*/
public function getSetMapping()
{
return $this->set_mapping;
}
return $objects;
}
/**
* @return array
*/
public function getQuestionMapping()
{
return $this->xqsp_qst_mapping;
}
/**
* @return array
*/
public function getSetMapping()
{
return $this->set_mapping;
}
}
......@@ -8,376 +8,344 @@ require_once "./Customizing/global/plugins/Services/Repository/RepositoryObject/
* Date: 26.09.13
* Time: 12:21
* @author Thomas Joußen <tjoussen@databay.de>
*/
*/
class ilQuestionSetPoolSetQuestionList extends ilPluginModelList
{
/**
* @var ilQuestionSetPoolSet
*/
protected $set;
public function __construct($set)
{
$this->set = $set;
parent::__construct();
}
/**
* @param array $params
* @param array $filter
*
* @return array
*/
public function loadData($params = array(), $filter = array())
{
require_once "./Customizing/global/plugins/Services/Repository/RepositoryObject/QuestionSetPool/classes/providers/class.ilQuestionSetPoolSetQuestionsProvider.php";
$provider = new ilQuestionSetPoolSetQuestionsProvider();
$filter["questionset_fi"] = $this->set->getId();
return $provider->loadData($filter, $params);
}
/**
* @param array $question_ids
* @param ilObjQuestionSetPool $question_set_pool
*
* @return bool
*/
public function insert($question_ids, $question_set_pool)
{
require_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
$question_titles = $this->getQuestionTitles();
foreach($question_ids as $question_id)
{
$question = assQuestion::_instantiateQuestion($question_id);
$obj_id = $question->getObjId();
$title = $question->getTitle();
if(in_array($title, $question_titles))
{
$i = 2;
while(in_array($title . ' (' . $i . ')', $question_titles))
{
$i++;
}
$title .= ' (' . $i . ')';
}
$question_titles[] = $title;
//$copy_id = $question->copyObject($this->question_set_pool->getId());
$copy_id = $question->duplicate(true, $title,"","",$question_set_pool->getId());
if($question->getObjId() == $obj_id)
{
$this->db->update(
"qpl_questions",
array(
"original_id" => array("integer", null)
),
array(
"question_id" => array("integer", $copy_id)
)
);
}
$success = $this->db->queryF(
"INSERT INTO rep_robj_xqsp_qs_qst (questionset_fi, question_fi, question_index)
/**
* @var ilQuestionSetPoolSet
*/
protected $set;
public function __construct($set)
{
$this->set = $set;
parent::__construct();
}
/**
* @param array $params
* @param array $filter
*
* @return array
*/
public function loadData($params = array(), $filter = array())
{
require_once "./Customizing/global/plugins/Services/Repository/RepositoryObject/QuestionSetPool/classes/providers/class.ilQuestionSetPoolSetQuestionsProvider.php";
$provider = new ilQuestionSetPoolSetQuestionsProvider();
$filter["questionset_fi"] = $this->set->getId();
return $provider->loadData($filter, $params);
}
/**
* @param array $question_ids
* @param ilObjQuestionSetPool $question_set_pool
*
* @return bool
*/
public function insert($question_ids, $question_set_pool)
{
$question_titles = $this->getQuestionTitles();
foreach ($question_ids as $question_id) {
$question = assQuestion::_instantiateQuestion($question_id);
$obj_id = $question->getObjId();
$title = $question->getTitle();
if (in_array($title, $question_titles)) {
$i = 2;
while (in_array($title . ' (' . $i . ')', $question_titles)) {
$i++;
}
$title .= ' (' . $i . ')';
}
$question_titles[] = $title;
//$copy_id = $question->copyObject($this->question_set_pool->getId());
$copy_id = $question->duplicate(true, $title, "", "", $question_set_pool->getId());
if ($question->getObjId() == $obj_id) {
$this->db->update(
"qpl_questions",
array(
"original_id" => array("integer", null)
),
array(
"question_id" => array("integer", $copy_id)
)
);
}
$success = $this->db->queryF(
"INSERT INTO rep_robj_xqsp_qs_qst (questionset_fi, question_fi, question_index)
(SELECT %s,%s,
CASE WHEN MAX(question_index) IS NULL
THEN 1
ELSE MAX(question_index) + 1
END
FROM rep_robj_xqsp_qs_qst WHERE questionset_fi = %s)",
array("integer", "integer", "integer"),
array($this->set->getId(), $copy_id, $this->set->getId())
);
if(!$success)
{
return false;
}
}
return true;
}
/**
* @return array
*/
public function getQuestionTitles()
{
global $DIC;
$ilDB = $DIC->database();
$titles = array();
$result = $ilDB->queryF("SELECT DISTINCT(qpl_questions.title) FROM rep_robj_xqsp_qs_qst, qpl_questions WHERE rep_robj_xqsp_qs_qst.questionset_fi = %s AND rep_robj_xqsp_qs_qst.question_fi = qpl_questions.question_id ORDER BY rep_robj_xqsp_qs_qst.question_index",
array('integer'),
array($this->set->getId())
);
while ($row = $ilDB->fetchAssoc($result))
{
$titles[] = $row['title'];
}
return $titles;
}
/**
* @param array $question_ids
* @param ilQuestionSetPoolSet $old_set
* @param integer $container_obj_id Container id (e.g. question set pool obj_id or forma test obj_id)
*
* @return array
*/
public function duplicate($question_ids, $old_set, $container_obj_id)
{
require_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
$new_question_ids = array();
foreach($question_ids as $question_id)
{
$question = assQuestion::_instantiateQuestion($question_id);
$original_obj_fi = $question->getObjId();
$copy_id = $question->duplicate(true, "","","", $container_obj_id);
$new_question_ids[$question_id] = $copy_id;
if($original_obj_fi != $container_obj_id)
{
$this->db->manipulateF(
'UPDATE qpl_questions SET original_id = %s WHERE question_id = %s',
array('integer', 'integer'),
array($question_id, $copy_id)
);
}
$success = $this->db->queryF(
"INSERT INTO rep_robj_xqsp_qs_qst (questionset_fi, question_fi, question_index)
array("integer", "integer", "integer"),
array($this->set->getId(), $copy_id, $this->set->getId())
);
if (!$success) {
return false;
}
}
return true;
}
/**
* @return array
*/
public function getQuestionTitles()
{
global $DIC;
$ilDB = $DIC->database();
$titles = array();
$result = $ilDB->queryF(
"SELECT DISTINCT(qpl_questions.title) FROM rep_robj_xqsp_qs_qst, qpl_questions WHERE rep_robj_xqsp_qs_qst.questionset_fi = %s AND rep_robj_xqsp_qs_qst.question_fi = qpl_questions.question_id ORDER BY rep_robj_xqsp_qs_qst.question_index",
array('integer'),
array($this->set->getId())
);
while ($row = $ilDB->fetchAssoc($result)) {
$titles[] = $row['title'];
}
return $titles;
}
/**
* @param array $question_ids
* @param ilQuestionSetPoolSet $old_set
* @param integer $container_obj_id Container id (e.g. question set pool obj_id or forma test obj_id)
*
* @return array
*/
public function duplicate($question_ids, $old_set, $container_obj_id)
{
$new_question_ids = array();
foreach ($question_ids as $question_id) {
$question = assQuestion::_instantiateQuestion($question_id);
$original_obj_fi = $question->getObjId();
$copy_id = $question->duplicate(true, "", "", "", $container_obj_id);
$new_question_ids[$question_id] = $copy_id;
if ($original_obj_fi != $container_obj_id) {
$this->db->manipulateF(
'UPDATE qpl_questions SET original_id = %s WHERE question_id = %s',
array('integer', 'integer'),
array($question_id, $copy_id)
);
}
$success = $this->db->queryF(
"INSERT INTO rep_robj_xqsp_qs_qst (questionset_fi, question_fi, question_index)
(SELECT %s, %s, question_index
FROM rep_robj_xqsp_qs_qst WHERE questionset_fi = %s AND question_fi = %s
)",
array("integer", "integer", "integer", "integer"),
array($this->set->getId(), $copy_id, $old_set->getId(), $question_id)
);
if(!$success)
{
return array();
}
}
return $new_question_ids;
}
/**
* @param array $question_ids
* @param ilQuestionSetPoolSet $old_set
* @param int $container_obj_id
* @param array $old_questions
*/
public function synchronize($question_ids, $old_set, $container_obj_id, $old_questions)
{
require_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
$new_question_ids = array();
foreach($question_ids as $question_id)
{
$question = assQuestion::_instantiateQuestion($question_id);
$old_original_id = $question->getOriginalId();
$copy_id = $question->duplicate(true, "","","", $container_obj_id);
$new_question_ids[$question_id] = $copy_id;
// Change original id of base question (Testquestion)
$this->db->manipulateF(
"UPDATE qpl_questions SET original_id = %s WHERE original_id = %s",
array("integer", "integer"),
array($copy_id, $old_original_id)
);
foreach($old_questions as $old_question)
{
if($old_question["question_id"] == $old_original_id)
{
$old_original_id = $old_question["original_id"];
}
}
$this->db->manipulateF(
"UPDATE qpl_questions SET original_id = %s WHERE question_id = %s",
array("integer", "integer"),
array($old_original_id, $copy_id)
);
$success = $this->db->queryF(
"INSERT INTO rep_robj_xqsp_qs_qst (questionset_fi, question_fi, question_index)
array("integer", "integer", "integer", "integer"),
array($this->set->getId(), $copy_id, $old_set->getId(), $question_id)
);
if (!$success) {
return array();
}
}
return $new_question_ids;
}
/**
* @param array $question_ids
* @param ilQuestionSetPoolSet $old_set
* @param int $container_obj_id
* @param array $old_questions
*/
public function synchronize($question_ids, $old_set, $container_obj_id, $old_questions)
{
$new_question_ids = array();
foreach ($question_ids as $question_id) {
$question = assQuestion::_instantiateQuestion($question_id);
$old_original_id = $question->getOriginalId();
$copy_id = $question->duplicate(true, "", "", "", $container_obj_id);
$new_question_ids[$question_id] = $copy_id;
// Change original id of base question (Testquestion)
$this->db->manipulateF(
"UPDATE qpl_questions SET original_id = %s WHERE original_id = %s",
array("integer", "integer"),
array($copy_id, $old_original_id)
);
foreach ($old_questions as $old_question) {
if ($old_question["question_id"] == $old_original_id) {
$old_original_id = $old_question["original_id"];
}
}
$this->db->manipulateF(
"UPDATE qpl_questions SET original_id = %s WHERE question_id = %s",
array("integer", "integer"),
array($old_original_id, $copy_id)
);
$success = $this->db->queryF(
"INSERT INTO rep_robj_xqsp_qs_qst (questionset_fi, question_fi, question_index)
(SELECT %s, %s, question_index
FROM rep_robj_xqsp_qs_qst WHERE questionset_fi = %s AND question_fi = %s
)",
array("integer", "integer", "integer", "integer"),
array($this->set->getId(), $copy_id, $old_set->getId(), $question_id)
);
if(!$success)
{
return array();
}
}
return $new_question_ids;
}
/**
* @param array $question_ids
*
* @return bool
*/
public function remove($question_ids)
{
foreach($question_ids as $question_id)
{
$success = $this->db->manipulateF(
"DELETE FROM rep_robj_xqsp_qs_qst WHERE question_fi = %s",
array("integer"),
array($question_id)
);
require_once 'Modules/TestQuestionPool/classes/class.assQuestion.php';
/**
* @var $gui assQuestionGUI
*/
$question = assQuestion::_instantiateQuestion($question_id);
if($question instanceof assQuestion)
{
/**
* @var $object assQuestion
*/
$question->delete($question_id);
//@todo überprüfen ob Löschen von Verzeichnissen bei Fragen mit Dateiupload (zB: Imagemap + vertikale Anordnungsfrage) funktioniert
}
if(!$success)
{
return false;
}
}
return true;
}
/**
* @param array $data
*
* @return array
*/
public function createObjectsFromData($data)
{
return $data;
}
/**
* @param nt $question_id
* @param null $original_question_id
* @return bool||int $copy_id
*/
public function import($question_id, $original_question_id = NULL)
{
require_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
$question_titles = $this->getQuestionTitles();
$question = assQuestion::_instantiateQuestion($question_id);
$obj_id = $question->getObjId();
$title = $question->getTitle();
if(in_array($title, $question_titles))
{
$i = 2;
while(in_array($title . ' (' . $i . ')', $question_titles))
{
$i++;
}
$title .= ' (' . $i . ')';
}
$question_titles[] = $title;
if($question->getObjId() == $obj_id)
{
if($original_question_id == 0)
{
$original_question_id = NULL;
}
$this->db->update(
"qpl_questions",
array(
"original_id" => array("integer", $original_question_id)
),
array(
"question_id" => array("integer", $question_id)
)
);
}
$success = $this->db->queryF(
"INSERT INTO rep_robj_xqsp_qs_qst (questionset_fi, question_fi, question_index)
array("integer", "integer", "integer", "integer"),
array($this->set->getId(), $copy_id, $old_set->getId(), $question_id)
);
if (!$success) {
return array();
}
}
return $new_question_ids;
}
/**
* @param array $question_ids
*
* @return bool
*/
public function remove($question_ids)
{
foreach ($question_ids as $question_id) {
$success = $this->db->manipulateF(
"DELETE FROM rep_robj_xqsp_qs_qst WHERE question_fi = %s",
array("integer"),
array($question_id)
);
/**
* @var $gui assQuestionGUI
*/
$question = assQuestion::_instantiateQuestion($question_id);
if ($question instanceof assQuestion) {
/**
* @var $object assQuestion
*/
$question->delete($question_id);
//@todo überprüfen ob Löschen von Verzeichnissen bei Fragen mit Dateiupload (zB: Imagemap + vertikale Anordnungsfrage) funktioniert
}
if (!$success) {
return false;
}
}
return true;
}
/**
* @param array $data
*
* @return array
*/
public function createObjectsFromData($data)
{
return $data;
}
/**
* @param nt $question_id
* @param null $original_question_id
* @return bool||int $copy_id
*/
public function import($question_id, $original_question_id = null)
{
$question_titles = $this->getQuestionTitles();
$question = assQuestion::_instantiateQuestion($question_id);
$obj_id = $question->getObjId();
$title = $question->getTitle();
if (in_array($title, $question_titles)) {
$i = 2;
while (in_array($title . ' (' . $i . ')', $question_titles)) {
$i++;
}
$title .= ' (' . $i . ')';
}
$question_titles[] = $title;
if ($question->getObjId() == $obj_id) {
if ($original_question_id == 0) {
$original_question_id = null;
}
$this->db->update(
"qpl_questions",
array(
"original_id" => array("integer", $original_question_id)
),
array(
"question_id" => array("integer", $question_id)
)
);
}
$success = $this->db->queryF(
"INSERT INTO rep_robj_xqsp_qs_qst (questionset_fi, question_fi, question_index)
(SELECT %s,%s,
CASE WHEN MAX(question_index) IS NULL
THEN 1
ELSE MAX(question_index) + 1
END
FROM rep_robj_xqsp_qs_qst WHERE questionset_fi = %s)",
array("integer", "integer", "integer"),
array($this->set->getId(), $question_id, $this->set->getId())
);
if(!$success)
{
return false;
}
return $question_id;
}
/**
* @param array $question_ids
* @param ilQuestionSetPoolSet $source_set
* @param ilQuestionSetPoolSet $target_set
* @return array
*/
public function cloneQuestionList($question_ids, ilQuestionSetPoolSet $source_set, ilQuestionSetPoolSet $target_set)
{
require_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
$new_question_ids = array();
foreach($question_ids as $question_id)
{
$question = assQuestion::_instantiateQuestion($question_id);
$copy_id = $question->duplicate(true, "","","", $target_set->getContainerObjId());
$original_obj_fi = $question->getObjId();
$new_question_ids[$question_id] = $copy_id;
if($original_obj_fi != $target_set->getContainerObjId())
{
$this->db->manipulateF(
'UPDATE qpl_questions SET original_id = %s WHERE question_id = %s',
array('integer', 'integer'),
array($question_id, $copy_id)
);
}
$this->db->queryF(
"INSERT INTO rep_robj_xqsp_qs_qst (questionset_fi, question_fi, question_index)
array("integer", "integer", "integer"),
array($this->set->getId(), $question_id, $this->set->getId())
);
if (!$success) {
return false;
}
return $question_id;
}
/**
* @param array $question_ids
* @param ilQuestionSetPoolSet $source_set
* @param ilQuestionSetPoolSet $target_set
* @return array
*/
public function cloneQuestionList($question_ids, ilQuestionSetPoolSet $source_set, ilQuestionSetPoolSet $target_set)
{
$new_question_ids = array();
foreach ($question_ids as $question_id) {
$question = assQuestion::_instantiateQuestion($question_id);
$copy_id = $question->duplicate(true, "", "", "", $target_set->getContainerObjId());
$original_obj_fi = $question->getObjId();
$new_question_ids[$question_id] = $copy_id;
if ($original_obj_fi != $target_set->getContainerObjId()) {
$this->db->manipulateF(
'UPDATE qpl_questions SET original_id = %s WHERE question_id = %s',
array('integer', 'integer'),
array($question_id, $copy_id)
);
}
$this->db->queryF(
"INSERT INTO rep_robj_xqsp_qs_qst (questionset_fi, question_fi, question_index)
(SELECT %s, %s, question_index
FROM rep_robj_xqsp_qs_qst WHERE questionset_fi = %s AND question_fi = %s
)",
array("integer", "integer", "integer", "integer"),
array($target_set->getId(), $copy_id, $source_set->getId(), $question_id)
);
}
return $new_question_ids;
}
array("integer", "integer", "integer", "integer"),
array($target_set->getId(), $copy_id, $source_set->getId(), $question_id)
);
}
return $new_question_ids;
}
}
......@@ -7,19 +7,19 @@
* @author Thomas Joußen <tjoussen@databay.de>
*/
interface ilPluginModelInterface {
interface ilPluginModelInterface
{
public function update();
public function update();
public function read();
public function read();
/**
* @return array
*/
public function toArray();
/**
* @return array
*/
public function toArray();
/**
* @param ilPropertyFormGUI $form
*/
public function bindForm(ilPropertyFormGUI $form);
}
\ No newline at end of file
/**
* @param ilPropertyFormGUI $form
*/
public function bindForm(ilPropertyFormGUI $form);
}
......@@ -8,186 +8,181 @@ require_once "interface.ilPluginTableDataProvider.php";
* Date: 24.09.13
* Time: 09:00
* @author Thomas Joußen <tjoussen@databay.de>
*/
abstract class ilPluginTableDatabaseDataProvider implements ilPluginTableDataProvider{
/**
* @var ilDB
*/
protected $db;
/**
* @var int
*/
protected $limit = 0;
/**
* @var int
*/
protected $offset = 0;
/**
* @var string
*/
protected $query = "";
/**
*
*/
public function __construct()
{
global $DIC;
$this->db = $DIC->database();
}
/**
* @param $limit
*
* @throws InvalidArgumentException
*/
public function setLimit($limit)
{
if (!is_numeric($limit))
{
throw new InvalidArgumentException('Please provide a valid numerical limit.');
}
$this->limit = $limit;
}
/**
* @return int
*/
public function getLimit()
{
return $this->limit;
}
/**
* @param $offset
*
* @throws InvalidArgumentException
*/
public function setOffset($offset)
{
if (!is_numeric($offset))
{
throw new InvalidArgumentException('Please provide a valid numerical offset.');
}
$this->offset = $offset;
}
/**
* @return int
*/
public function getOffset()
{
return $this->offset;
}
/**
* @param array $filter
* @param array $orderBy
*
* @return array
*/
public function loadData(array $filter, array $orderBy = array())
{
$data = array();
// $this->db->setLimit($this->limit, $this->offset);
$this->buildQuery($filter, $orderBy);
$res = $this->db->query($this->query);
while ($row = $this->db->fetchAssoc($res))
{
$data[] = $row;
}
return $data;
}
/**
* @param array $filter
* @param array $orderBy
*
* @return string
*/
protected function buildQuery(array $filter, array $orderBy)
{
$select = $this->getSelectPart();
$where = $this->getWherePart($filter);
$from = $this->getFromPart();
$join = $this->getJoinPart();
$order = $this->getOrderByPart($orderBy);
$group = $this->getGroupByPart();
$having = $this->getHavingPart($filter);
$where = strlen($where)? 'WHERE ' . $where : '';
$query = "SELECT {$select} FROM {$from} {$join} {$where}";
if (strlen($group))
{
$query .= " GROUP BY {$group}";
}
if (strlen($having))
{
$query .= " HAVING {$having}";
}
if (strlen($order))
{
$query .= " ORDER BY {$order}";
}
$this->query = $query;
}
/**
* @return string
* @abstract
*/
abstract protected function getSelectPart();
/**
* @return string
* @abstract
*/
abstract protected function getFromPart();
/**
* @return string
* @abstract
*/
abstract protected function getJoinPart();
/**
* @param array $filter
* @return string
* @abstract
*/
abstract protected function getWherePart(array $filter);
/**
* @return string
* @abstract
*/
abstract protected function getGroupByPart();
/**
* @param array $filter
* @return string
* @abstract
*/
abstract protected function getHavingPart(array $filter);
/**
* @param array $params
* @return string
* @abstract
*/
abstract protected function getOrderByPart(array $params);
*/
abstract class ilPluginTableDatabaseDataProvider implements ilPluginTableDataProvider
{
/**
* @var ilDB
*/
protected $db;
/**
* @var int
*/
protected $limit = 0;
/**
* @var int
*/
protected $offset = 0;
/**
* @var string
*/
protected $query = "";
/**
*
*/
public function __construct()
{
global $DIC;
$this->db = $DIC->database();
}
/**
* @param $limit
*
* @throws InvalidArgumentException
*/
public function setLimit($limit)
{
if (!is_numeric($limit)) {
throw new InvalidArgumentException('Please provide a valid numerical limit.');
}
$this->limit = $limit;
}
/**
* @return int
*/
public function getLimit()
{
return $this->limit;
}
/**
* @param $offset
*
* @throws InvalidArgumentException
*/
public function setOffset($offset)
{
if (!is_numeric($offset)) {
throw new InvalidArgumentException('Please provide a valid numerical offset.');
}
$this->offset = $offset;
}
/**
* @return int
*/
public function getOffset()
{
return $this->offset;
}
/**
* @param array $filter
* @param array $orderBy
*
* @return array
*/
public function loadData(array $filter, array $orderBy = array())
{
$data = array();
// $this->db->setLimit($this->limit, $this->offset);
$this->buildQuery($filter, $orderBy);
$res = $this->db->query($this->query);
while ($row = $this->db->fetchAssoc($res)) {
$data[] = $row;
}
return $data;
}
/**
* @param array $filter
* @param array $orderBy
*
* @return string
*/
protected function buildQuery(array $filter, array $orderBy)
{
$select = $this->getSelectPart();
$where = $this->getWherePart($filter);
$from = $this->getFromPart();
$join = $this->getJoinPart();
$order = $this->getOrderByPart($orderBy);
$group = $this->getGroupByPart();
$having = $this->getHavingPart($filter);
$where = strlen($where)? 'WHERE ' . $where : '';
$query = "SELECT {$select} FROM {$from} {$join} {$where}";
if (strlen($group)) {
$query .= " GROUP BY {$group}";
}
if (strlen($having)) {
$query .= " HAVING {$having}";
}
if (strlen($order)) {
$query .= " ORDER BY {$order}";
}
$this->query = $query;
}
/**
* @return string
* @abstract
*/
abstract protected function getSelectPart();
/**
* @return string
* @abstract
*/
abstract protected function getFromPart();
/**
* @return string
* @abstract
*/
abstract protected function getJoinPart();
/**
* @param array $filter
* @return string
* @abstract
*/
abstract protected function getWherePart(array $filter);
/**
* @return string
* @abstract
*/
abstract protected function getGroupByPart();
/**
* @param array $filter
* @return string
* @abstract
*/
abstract protected function getHavingPart(array $filter);
/**
* @param array $params
* @return string
* @abstract
*/
abstract protected function getOrderByPart(array $params);
}
......@@ -8,37 +8,34 @@
* @author Thomas Joußen <tjoussen@databay.de>
*
* @todo MAYBE CHANGE THE LOCATION OF THIS CLASS
*/
class ilParserQuestionProvider {
protected $set_id;
public function __construct($set_id)
{
$this->set_id = $set_id;
}
/**
* @param int $index
*
* @return iQuestionCondition
*/
public function getQuestion($index)
{
global $DIC;
$ilDB = $DIC->database();
$result = $ilDB->queryF(
"SELECT question_fi FROM rep_robj_xqsp_qs_qst WHERE question_index = %s AND questionset_fi = %s",
array("integer", "integer"),
array($index, $this->set_id)
);
$data = $ilDB->fetchAssoc($result);
require_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
return assQuestion::_instanciateQuestion($data['question_fi']);
}
*/
class ilParserQuestionProvider
{
protected $set_id;
public function __construct($set_id)
{
$this->set_id = $set_id;
}
/**
* @param int $index
*
* @return iQuestionCondition
*/
public function getQuestion($index)
{
global $DIC;
$ilDB = $DIC->database();
$result = $ilDB->queryF(
"SELECT question_fi FROM rep_robj_xqsp_qs_qst WHERE question_index = %s AND questionset_fi = %s",
array("integer", "integer"),
array($index, $this->set_id)
);
$data = $ilDB->fetchAssoc($result);
return assQuestion::_instanciateQuestion($data['question_fi']);
}
}
\ No newline at end of file
......@@ -8,74 +8,73 @@ require_once "abstract.ilPluginTableDatabaseDataProvider.php";
* Date: 05.12.13
* Time: 12:30
* @author Thomas Joußen <tjoussen@databay.de>
*/
*/
class ilQuestionSetPoolJumpConditionsProvider extends ilPluginTableDatabaseDataProvider
{
/**
* @return string
*/
protected function getSelectPart()
{
return "con.*, qst.question_index";
}
/**
* @return string
*/
protected function getSelectPart()
{
return "con.*, qst.question_index";
}
/**
* @return string
*/
protected function getFromPart()
{
return "rep_robj_xqsp_jmp_con con";
}
/**
* @return string
*/
protected function getFromPart()
{
return "rep_robj_xqsp_jmp_con con";
}
/**
* @return string
*/
protected function getJoinPart()
{
return join(" ", array(
"INNER JOIN rep_robj_xqsp_node n ON n.id = con.node_fi",
"INNER JOIN rep_robj_xqsp_path p ON p.id = n.path_fi",
"LEFT JOIN rep_robj_xqsp_qs_qst qst ON qst.questionset_fi = p.questionset_fi AND qst.question_fi = con.question_fi"
));
}
/**
* @return string
*/
protected function getJoinPart()
{
return join(" ", array(
"INNER JOIN rep_robj_xqsp_node n ON n.id = con.node_fi",
"INNER JOIN rep_robj_xqsp_path p ON p.id = n.path_fi",
"LEFT JOIN rep_robj_xqsp_qs_qst qst ON qst.questionset_fi = p.questionset_fi AND qst.question_fi = con.question_fi"
));
}
/**
* @param array $filter
*
* @return string
*/
protected function getWherePart(array $filter)
{
return "con.node_fi = " . $this->db->quote($filter['node_fi']);
}
/**
* @param array $filter
*
* @return string
*/
protected function getWherePart(array $filter)
{
return "con.node_fi = " . $this->db->quote($filter['node_fi']);
}
/**
* @return string
*/
protected function getGroupByPart()
{
return "";
}
/**
* @return string
*/
protected function getGroupByPart()
{
return "";
}
/**
* @param array $filter
*
* @return string
*/
protected function getHavingPart(array $filter)
{
return "";
}
/**
* @param array $filter
*
* @return string
*/
protected function getHavingPart(array $filter)
{
return "";
}
/**
* @param array $params
*
* @return string
*/
protected function getOrderByPart(array $params)
{
return "con.sorting ASC";
}
/**
* @param array $params
*
* @return string
*/
protected function getOrderByPart(array $params)
{
return "con.sorting ASC";
}
}
\ No newline at end of file
......@@ -8,85 +8,84 @@ require_once "abstract.ilPluginTableDatabaseDataProvider.php";
* Date: 21.11.13
* Time: 12:23
* @author Thomas Joußen <tjoussen@databay.de>
*/
*/
class ilQuestionSetPoolNodeProvider extends ilPluginTableDatabaseDataProvider
{
/**
* @return string
*/
protected function getSelectPart()
{
$select = array(
"rep_robj_xqsp_node.*",
"rep_robj_xqsp_qs.id as set_fi",
"qpl_questions.title as question_title",
"rep_robj_xqsp_qs_qst.question_index",
// "rep_robj_xqsp_jmp_con.*"
);
/**
* @return string
*/
protected function getSelectPart()
{
$select = array(
"rep_robj_xqsp_node.*",
"rep_robj_xqsp_qs.id as set_fi",
"qpl_questions.title as question_title",
"rep_robj_xqsp_qs_qst.question_index",
// "rep_robj_xqsp_jmp_con.*"
);
return join(", ", $select);
}
return join(", ", $select);
}
/**
* @return string
*/
protected function getFromPart()
{
return "rep_robj_xqsp_node";
}
/**
* @return string
*/
protected function getFromPart()
{
return "rep_robj_xqsp_node";
}
/**
* @return string
*/
protected function getJoinPart()
{
$join = array(
"INNER JOIN qpl_questions ON qpl_questions.question_id = rep_robj_xqsp_node.question_fi",
"INNER JOIN rep_robj_xqsp_path ON rep_robj_xqsp_path.id = rep_robj_xqsp_node.path_fi",
"INNER JOIN rep_robj_xqsp_qs ON rep_robj_xqsp_qs.id = rep_robj_xqsp_path.questionset_fi",
"INNER JOIN rep_robj_xqsp_qs_qst ON rep_robj_xqsp_qs_qst.question_fi = qpl_questions.question_id",
// "INNER JOIN rep_robj_xqsp_jmp_con ON rep_robj_xqsp_jmp_con.node_fi = rep_robj_xqsp_node.id"
);
return implode(" ", $join);
}
/**
* @return string
*/
protected function getJoinPart()
{
$join = array(
"INNER JOIN qpl_questions ON qpl_questions.question_id = rep_robj_xqsp_node.question_fi",
"INNER JOIN rep_robj_xqsp_path ON rep_robj_xqsp_path.id = rep_robj_xqsp_node.path_fi",
"INNER JOIN rep_robj_xqsp_qs ON rep_robj_xqsp_qs.id = rep_robj_xqsp_path.questionset_fi",
"INNER JOIN rep_robj_xqsp_qs_qst ON rep_robj_xqsp_qs_qst.question_fi = qpl_questions.question_id",
// "INNER JOIN rep_robj_xqsp_jmp_con ON rep_robj_xqsp_jmp_con.node_fi = rep_robj_xqsp_node.id"
);
return implode(" ", $join);
}
/**
* @param array $filter
*
* @return string
*/
protected function getWherePart(array $filter)
{
return "rep_robj_xqsp_node.path_fi =" . $this->db->quote($filter['path_fi']);
}
/**
* @param array $filter
*
* @return string
*/
protected function getWherePart(array $filter)
{
return "rep_robj_xqsp_node.path_fi =" . $this->db->quote($filter['path_fi']);
}
/**
* @return string
*/
protected function getGroupByPart()
{
return "";
}
/**
* @return string
*/
protected function getGroupByPart()
{
return "";
}
/**
* @param array $filter
*
* @return string
*/
protected function getHavingPart(array $filter)
{
return "";
}
/**
* @param array $filter
*
* @return string
*/
protected function getHavingPart(array $filter)
{
return "";
}
/**
* @param array $params
*
* @return string
*/
protected function getOrderByPart(array $params)
{
return "rep_robj_xqsp_node.node_index ASC";
}
/**
* @param array $params
*
* @return string
*/
protected function getOrderByPart(array $params)
{
return "rep_robj_xqsp_node.node_index ASC";
}
}
\ No newline at end of file
......@@ -8,70 +8,69 @@ require_once "abstract.ilPluginTableDatabaseDataProvider.php";
* Date: 19.11.13
* Time: 12:15
* @author Thomas Joußen <tjoussen@databay.de>
*/
*/
class ilQuestionSetPoolPathProvider extends ilPluginTableDatabaseDataProvider
{
/**
* @return string
*/
protected function getSelectPart()
{
return "*";
}
/**
* @return string
*/
protected function getSelectPart()
{
return "*";
}
/**
* @return string
*/
protected function getFromPart()
{
return "rep_robj_xqsp_path";
}
/**
* @return string
*/
protected function getFromPart()
{
return "rep_robj_xqsp_path";
}
/**
* @return string
*/
protected function getJoinPart()
{
return "";
}
/**
* @return string
*/
protected function getJoinPart()
{
return "";
}
/**
* @param array $filter
*
* @return string
*/
protected function getWherePart(array $filter)
{
return "rep_robj_xqsp_path.questionset_fi = " . $this->db->quote($filter['questionset_fi']);
}
/**
* @param array $filter
*
* @return string
*/
protected function getWherePart(array $filter)
{
return "rep_robj_xqsp_path.questionset_fi = " . $this->db->quote($filter['questionset_fi']);
}
/**
* @return string
*/
protected function getGroupByPart()
{
return "";
}
/**
* @return string
*/
protected function getGroupByPart()
{
return "";
}
/**
* @param array $filter
*
* @return string
*/
protected function getHavingPart(array $filter)
{
return "";
}
/**
* @param array $filter
*
* @return string
*/
protected function getHavingPart(array $filter)
{
return "";
}
/**
* @param array $params
*
* @return string
*/
protected function getOrderByPart(array $params)
{
return "rep_robj_xqsp_path.path_index ASC";
}
/**
* @param array $params
*
* @return string
*/
protected function getOrderByPart(array $params)
{
return "rep_robj_xqsp_path.path_index ASC";
}
}
\ No newline at end of file
......@@ -8,138 +8,133 @@ require_once "abstract.ilPluginTableDatabaseDataProvider.php";
* Date: 16.04.13
* Time: 16:12
* @author Thomas Joußen <tjoussen@databay.de>
*/
*/
class ilQuestionSetPoolQuestionsBrowserProvider extends ilPluginTableDatabaseDataProvider
{
/**
* @return string
*/
protected function getSelectPart()
{
$fields = array(
"qpl_questions.*",
"qpl_qst_type.type_tag",
"qpl_qst_type.plugin",
"object_data.title pool_title",
"object_reference.ref_id pool_ref_id"
);
return implode(", ", $fields);
}
/**
* @return string
*/
protected function getFromPart()
{
$from = array(
"qpl_questions",
);
return implode(", ", $from);
}
/**
* @return string
*/
protected function getJoinPart()
{
$joins = array(
"INNER JOIN qpl_qst_type ON qpl_questions.question_type_fi = qpl_qst_type.question_type_id",
"INNER JOIN object_data ON object_data.obj_id = qpl_questions.obj_fi",
"INNER JOIN object_reference ON object_reference.obj_id = qpl_questions.obj_fi",
//"LEFT JOIN rep_robj_xqsp_question ON qpl_questions.question_id = rep_robj_xqsp_question.question_fi"
);
return implode(" ", $joins);
}
/**
* @param array $filter
*
* @return string
*/
protected function getWherePart(array $filter)
{
$excludes = array(
14,
8
);
$types = array_merge($excludes, ilObjAssessmentFolder::_getManualScoring());
$where = array(
"qpl_questions.original_id IS NULL",
"qpl_questions.tstamp > 0",
/**
* @return string
*/
protected function getSelectPart()
{
$fields = array(
"qpl_questions.*",
"qpl_qst_type.type_tag",
"qpl_qst_type.plugin",
"object_data.title pool_title",
"object_reference.ref_id pool_ref_id"
);
return implode(", ", $fields);
}
/**
* @return string
*/
protected function getFromPart()
{
$from = array(
"qpl_questions",
);
return implode(", ", $from);
}
/**
* @return string
*/
protected function getJoinPart()
{
$joins = array(
"INNER JOIN qpl_qst_type ON qpl_questions.question_type_fi = qpl_qst_type.question_type_id",
"INNER JOIN object_data ON object_data.obj_id = qpl_questions.obj_fi",
"INNER JOIN object_reference ON object_reference.obj_id = qpl_questions.obj_fi",
//"LEFT JOIN rep_robj_xqsp_question ON qpl_questions.question_id = rep_robj_xqsp_question.question_fi"
);
return implode(" ", $joins);
}
/**
* @param array $filter
*
* @return string
*/
protected function getWherePart(array $filter)
{
$excludes = array(
14,
8
);
$types = array_merge($excludes, ilObjAssessmentFolder::_getManualScoring());
$where = array(
"qpl_questions.original_id IS NULL",
"qpl_questions.tstamp > 0",
// "(rep_robj_xqsp_question.questionsetpool_fi IS NULL OR rep_robj_xqsp_question.questionsetpool_fi != " . $this->db->quote($filter['xqsp_id'], 'integer') . ")",
// "rep_robj_xqsp_question.questionsetpool_fi != " . $this->db->quote($filter['xqsp_id'], 'integer'),
$this->db->in("qpl_qst_type.question_type_id", $types, true, "integer"),
$this->db->in('qpl_questions.obj_fi', $filter["question_pools"], false, 'integer'),
"qpl_questions.complete = " . $this->db->quote("1", "text")
);
$where = $this->addOptionalFilterElements($filter, $where);
return implode(" AND ", $where);
}
/**
* @return string
*/
protected function getGroupByPart()
{
return "";
}
/**
* @param array $filter
* @return string
*/
protected function getHavingPart(array $filter)
{
return "";
}
/**
* @param array $params
* @return string
*/
protected function getOrderByPart(array $params)
{
return "";
}
/**
* @param array $filter
* @param $where
*
* @return array
*/
protected function addOptionalFilterElements(array $filter, $where)
{
if ($filter["question_type"])
{
$where[] = "qpl_qst_type.type_tag = " . $this->db->quote($filter["question_type"], "text");
}
if ($filter["title"])
{
$where[] = $this->db->like("qpl_questions.title", "text", "%".$filter["title"]."%");
}
if ($filter["description"])
{
$where[] = $this->db->like("qpl_questions.description", "text", "%".$filter["description"]."%");
}
if ($filter["author"])
{
$where[] = $this->db->like("qpl_questions.author", "text", "%".$filter["author"]."%");
}
if ($filter["qpl"])
{
$where[] = $this->db->like("object_data.title", "text", "%".$filter["qpl"]."%");
}
return $where;
}
$this->db->in("qpl_qst_type.question_type_id", $types, true, "integer"),
$this->db->in('qpl_questions.obj_fi', $filter["question_pools"], false, 'integer'),
"qpl_questions.complete = " . $this->db->quote("1", "text")
);
$where = $this->addOptionalFilterElements($filter, $where);
return implode(" AND ", $where);
}
/**
* @return string
*/
protected function getGroupByPart()
{
return "";
}
/**
* @param array $filter
* @return string
*/
protected function getHavingPart(array $filter)
{
return "";
}
/**
* @param array $params
* @return string
*/
protected function getOrderByPart(array $params)
{
return "";
}
/**
* @param array $filter
* @param $where
*
* @return array
*/
protected function addOptionalFilterElements(array $filter, $where)
{
if ($filter["question_type"]) {
$where[] = "qpl_qst_type.type_tag = " . $this->db->quote($filter["question_type"], "text");
}
if ($filter["title"]) {
$where[] = $this->db->like("qpl_questions.title", "text", "%" . $filter["title"] . "%");
}
if ($filter["description"]) {
$where[] = $this->db->like("qpl_questions.description", "text", "%" . $filter["description"] . "%");
}
if ($filter["author"]) {
$where[] = $this->db->like("qpl_questions.author", "text", "%" . $filter["author"] . "%");
}
if ($filter["qpl"]) {
$where[] = $this->db->like("object_data.title", "text", "%" . $filter["qpl"] . "%");
}
return $where;
}
}
......@@ -8,93 +8,92 @@ require_once "abstract.ilPluginTableDatabaseDataProvider.php";
* Date: 15.11.13
* Time: 10:01
* @author Thomas Joußen <tjoussen@databay.de>
*/
*/
class ilQuestionSetPoolSetQuestionsProvider extends ilPluginTableDatabaseDataProvider
{
/**
* @return string
*/
protected function getSelectPart()
{
$fields = array(
"qpl_questions.*",
"qpl_qst_type.type_tag",
"qpl_qst_type.plugin",
"object_data.title as pool_title",
"rep_robj_xqsp_qs_qst.question_index"
);
/**
* @return string
*/
protected function getSelectPart()
{
$fields = array(
"qpl_questions.*",
"qpl_qst_type.type_tag",
"qpl_qst_type.plugin",
"object_data.title as pool_title",
"rep_robj_xqsp_qs_qst.question_index"
);
return implode(", ", $fields);
}
return implode(", ", $fields);
}
/**
* @return string
*/
protected function getFromPart()
{
$from = array(
"qpl_questions",
);
/**
* @return string
*/
protected function getFromPart()
{
$from = array(
"qpl_questions",
);
return implode(", ", $from);
}
return implode(", ", $from);
}
/**
* @return string
*/
protected function getJoinPart()
{
$joins = array(
"INNER JOIN qpl_qst_type ON qpl_questions.question_type_fi = qpl_qst_type.question_type_id",
"INNER JOIN object_data ON object_data.obj_id = qpl_questions.obj_fi",
"LEFT JOIN rep_robj_xqsp_qs_qst ON rep_robj_xqsp_qs_qst.question_fi = qpl_questions.question_id"
);
/**
* @return string
*/
protected function getJoinPart()
{
$joins = array(
"INNER JOIN qpl_qst_type ON qpl_questions.question_type_fi = qpl_qst_type.question_type_id",
"INNER JOIN object_data ON object_data.obj_id = qpl_questions.obj_fi",
"LEFT JOIN rep_robj_xqsp_qs_qst ON rep_robj_xqsp_qs_qst.question_fi = qpl_questions.question_id"
);
return implode(" ", $joins);
}
return implode(" ", $joins);
}
/**
* @param array $filter
*
* @return string
*/
protected function getWherePart(array $filter)
{
$where = array(
"qpl_questions.tstamp > 0",
"rep_robj_xqsp_qs_qst.questionset_fi = " . $this->db->quote($filter["questionset_fi"], 'integer')
);
/**
* @param array $filter
*
* @return string
*/
protected function getWherePart(array $filter)
{
$where = array(
"qpl_questions.tstamp > 0",
"rep_robj_xqsp_qs_qst.questionset_fi = " . $this->db->quote($filter["questionset_fi"], 'integer')
);
// ADD FILTER ELEMENTS
// ADD FILTER ELEMENTS
return implode(" AND ", $where);
}
return implode(" AND ", $where);
}
/**
* @return string
*/
protected function getGroupByPart()
{
return "";
}
/**
* @return string
*/
protected function getGroupByPart()
{
return "";
}
/**
* @param array $filter
* @return string
*/
protected function getHavingPart(array $filter)
{
return "";
}
/**
* @param array $filter
* @return string
*/
protected function getHavingPart(array $filter)
{
return "";
}
/**
* @param array $params
* @return string
*/
protected function getOrderByPart(array $params)
{
return "";
}
/**
* @param array $params
* @return string
*/
protected function getOrderByPart(array $params)
{
return "";
}
}
\ No newline at end of file
......@@ -8,74 +8,74 @@ require_once "abstract.ilPluginTableDatabaseDataProvider.php";
* Date: 07.10.13
* Time: 14:34
* @author Thomas Joußen <tjoussen@databay.de>
*/
*/
class ilQuestionSetPoolSetsProvider extends ilPluginTableDatabaseDataProvider
{
/**
* @return string
*/
protected function getSelectPart()
{
$select = array(
"id",
"title",
"description"
);
/**
* @return string
*/
protected function getSelectPart()
{
$select = array(
"id",
"title",
"description"
);
$select[] = "(SELECT COUNT(qst.question_fi) FROM rep_robj_xqsp_qs_qst qst WHERE qst.questionset_fi = qs.id) has_questions";
$select[] = "(SELECT COUNT(qst.question_fi) FROM rep_robj_xqsp_qs_qst qst WHERE qst.questionset_fi = qs.id) has_questions";
return implode(", ", $select);
}
return implode(", ", $select);
}
/**
* @return string
*/
protected function getFromPart()
{
return "rep_robj_xqsp_qs qs";
}
/**
* @return string
*/
protected function getFromPart()
{
return "rep_robj_xqsp_qs qs";
}
/**
* @return string
*/
protected function getJoinPart()
{
return "";
}
/**
* @return string
*/
protected function getJoinPart()
{
return "";
}
/**
* @param array $filter
*
* @return string
*/
protected function getWherePart(array $filter)
{
return "questionsetpool_fi = " . $this->db->quote($filter["questionsetpool_fi"], "integer");
}
/**
* @param array $filter
*
* @return string
*/
protected function getWherePart(array $filter)
{
return "questionsetpool_fi = " . $this->db->quote($filter["questionsetpool_fi"], "integer");
}
/**
* @return string
*/
protected function getGroupByPart()
{
return "";
}
/**
* @return string
*/
protected function getGroupByPart()
{
return "";
}
/**
* @param array $filter
* @return string
*/
protected function getHavingPart(array $filter)
{
return "";
}
/**
* @param array $filter
* @return string
*/
protected function getHavingPart(array $filter)
{
return "";
}
/**
* @param array $params
* @return string
*/
protected function getOrderByPart(array $params)
{
return "";
}
/**
* @param array $params
* @return string
*/
protected function getOrderByPart(array $params)
{
return "";
}
}