58        $this->objective_id = $a_objective_id;
 
   77        $query = 
'SELECT objective_id FROM crs_objective_qst ' .
 
   78                'WHERE question_id = ' . 
$ilDB->quote($a_qid, 
'integer');
 
   80        $objectiveIds = array();
 
   82            $objectiveIds[] = 
$row->objective_id;
 
  103        $query = 
"SELECT qst_ass_id FROM crs_objective_qst " .
 
  104            "WHERE ref_id = " . 
$ilDB->quote($a_test_id, 
'integer') . 
" " .
 
  105            "AND objective_id = " . 
$ilDB->quote($a_objective_id, 
'integer');
 
  107        return $res->numRows() ? true : 
false;
 
  123        $ilObjDataCache = 
$DIC[
'ilObjDataCache'];
 
  127        include_once(
'Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
 
  129        $mappings = $cwo->getMappings();
 
  131            $mapping_key = $question[
'ref_id'] . 
'_question_' . $question[
'question_id'];
 
  132            if (!isset($mappings[$mapping_key]) or !$mappings[$mapping_key]) {
 
  135            $question_ref_id = $question[
'ref_id'];
 
  136            $question_obj_id = $question[
'obj_id'];
 
  137            $question_qst_id = $question[
'question_id'];
 
  138            $new_ref_id = $mappings[$question_ref_id];
 
  139            $new_obj_id = $ilObjDataCache->lookupObjId($new_ref_id);
 
  141            if ($new_obj_id == $question_obj_id) {
 
  144                $new_question_id = $question_qst_id;
 
  146                $new_question_info = $mappings[$question_ref_id . 
'_question_' . $question_qst_id];
 
  147                $new_question_arr = explode(
'_', $new_question_info);
 
  148                if (!isset($new_question_arr[2]) or !$new_question_arr[2]) {
 
  152                $new_question_id = $new_question_arr[2];
 
  158            $new_question->setTestRefId($new_ref_id);
 
  159            $new_question->setTestObjId($new_obj_id);
 
  160            $new_question->setQuestionId($new_question_id);
 
  161            $new_question->add();
 
  166            $new_test_id = $mappings[
"$test[ref_id]"];
 
  168            $query = 
"UPDATE crs_objective_tst " .
 
  169                "SET tst_status = " . $this->db->quote(
$test[
'tst_status'], 
'integer') . 
", " .
 
  170                "tst_limit_p = " . $this->db->quote(
$test[
'tst_limit'], 
'integer') . 
" " .
 
  171                "WHERE objective_id = " . $this->db->quote($a_new_objective, 
'integer') . 
" " .
 
  172                "AND ref_id = " . $this->db->quote($new_test_id, 
'integer');
 
  191        return $tree->getSubTree(
$tree->getNodeData($a_container_ref_id), 
true, 
'tst');
 
  197        $this->tst_status = $a_status;
 
  201        return (
int) $this->tst_status;
 
  205        $this->tst_limit = $a_limit;
 
  209        return (
int) $this->tst_limit;
 
  217        $query = 
"UPDATE crs_objective_tst " .
 
  218            "SET tst_status = " . $this->db->quote($this->
getTestStatus(), 
'integer') . 
" " .
 
  219            "WHERE objective_id = " . $this->db->quote($this->
getObjectiveId(), 
'integer') . 
" " .
 
  220            "AND ref_id = " . $this->db->quote($this->
getTestRefId(), 
'integer') . 
" ";
 
  225        $query = 
"SELECT * FROM crs_objective_tst " .
 
  230        if (
$res->numRows()) {
 
  235        $query = 
"SELECT tst_limit_p FROM crs_objective_tst " .
 
  236            "WHERE objective_id = " . $this->db->quote($this->
getObjectiveId(), 
'integer') . 
" " .
 
  237            "AND tst_status = " . $this->db->quote($this->
getTestStatus(), 
'integer') . 
" ";
 
  243            $limit = 
$row->tst_limit_p;
 
  246        $next_id = 
$ilDB->nextId(
'crs_objective_tst');
 
  247        $query = 
"INSERT INTO crs_objective_tst (test_objective_id,objective_id,ref_id,obj_id,tst_status,tst_limit_p) " .
 
  249            $ilDB->quote($next_id, 
'integer') . 
", " .
 
  254            $this->db->quote($limit, 
'integer') . 
" " .
 
  268        $query = 
"DELETE FROM crs_objective_qst " .
 
  270            "AND ref_id = " . 
$ilDB->quote($a_test_ref_id, 
'integer') . 
" ";
 
  274        $query = 
"DELETE FROM crs_objective_tst " .
 
  276            "AND ref_id = " . 
$ilDB->quote($a_test_ref_id, 
'integer') . 
" ";
 
  279        unset($this->tests[$a_test_ref_id]);
 
  300        $query = 
"UPDATE crs_objective_tst " .
 
  301            "SET tst_limit_p = " . 
$ilDB->quote($a_limit, 
'integer') . 
" " .
 
  302            "WHERE tst_status = " . 
$ilDB->quote($a_status, 
'integer') . 
" " .
 
  303            "AND objective_id = " . 
$ilDB->quote($a_objective_id, 
'integer');
 
  314        $query = 
"UPDATE crs_objective_tst " .
 
  317            "WHERE test_objective_id = " . 
$ilDB->quote($a_objective_id, 
'integer') . 
"";
 
  329        $query = 
"SELECT * FROM crs_objective_tst cot " .
 
  330            "JOIN object_data obd ON cot.obj_id = obd.obj_id " .
 
  336            $test[
'test_objective_id'] = 
$row->test_objective_id;
 
  337            $test[
'objective_id'] = 
$row->objective_id;
 
  359        foreach ($this->tests as 
$test) {
 
  364        return $self ? $self : array();
 
  375        foreach ($this->tests as 
$test) {
 
  376            if (
$test[
'status'] == self::TYPE_FINAL_TEST) {
 
  380        return $final ? $final : array();
 
  383    public static function _getTest($a_test_objective_id)
 
  389        $query = 
"SELECT * FROM crs_objective_tst " .
 
  390            "WHERE test_objective_id = " . 
$ilDB->quote($a_test_objective_id, 
'integer') . 
" ";
 
  394            $test[
'test_objective_id'] = 
$row->test_objective_id;
 
  395            $test[
'objective_id'] = 
$row->objective_id;
 
  408        return $this->questions ? $this->questions : array();
 
  419        foreach ($this->questions as $question) {
 
  424        return $self ? $self : array();
 
  436            $points += $question[
'points'];
 
  438        return $points ? $points : 0;
 
  450            $points += $question[
'points'];
 
  452        return $points ? $points : 0;
 
  463        foreach ($this->questions as $question) {
 
  464            if ($question[
'question_id'] == $a_question_id) {
 
  480        foreach ($this->questions as $question) {
 
  481            if ($question[
'question_id'] == $a_question_id) {
 
  496        foreach ($this->questions as $question) {
 
  497            if ($question[
'test_type'] == self::TYPE_FINAL_TEST) {
 
  498                $final[] = $question;
 
  501        return $final ? $final : array();
 
  516            if ($a_test_id == $qst[
'obj_id']) {
 
  525        return $this->questions[$question_id] ? $this->questions[$question_id] : array();
 
  535        $this->tst_ref_id = $a_ref_id;
 
  539        return $this->tst_ref_id ? $this->tst_ref_id : 0;
 
  543        $this->tst_obj_id = $a_obj_id;
 
  547        return $this->tst_obj_id ? $this->tst_obj_id : 0;
 
  551        $this->question_id = $a_question_id;
 
  555        return $this->question_id;
 
  561        include_once 
'./Modules/Test/classes/class.ilObjTest.php';
 
  569            $points += $tmp_question->getMaximumPoints();
 
  571            unset($tmp_question);
 
  584            if ($question[
'ref_id'] == $a_test_ref_id) {
 
  587                $points += $tmp_question->getMaximumPoints();
 
  589                unset($tmp_question);
 
  607        include_once(
'Modules/TestQuestionPool/classes/class.assQuestion.php');
 
  617            if ($question[
'ref_id'] == $a_test_ref_id) {
 
  627            if ($question[
'ref_id'] == $a_test_ref_id) {
 
  628                $qst[] = $question[
'question_id'];
 
  631        return $qst ? $qst : array();
 
  647        foreach ($this->tests as $ref_id => $test_data) {
 
  648            switch ($test_data[
'status']) {
 
  657            if ($test_data[
'limit'] == -1 or $test_data[
'limit'] > $points) {
 
  658                switch ($test_data[
'status']) {
 
  667                $query = 
"UPDATE crs_objective_tst " .
 
  668                    "SET tst_limit = " . $this->db->quote($points, 
'integer') . 
" " .
 
  669                    "WHERE test_objective_id = " . $this->db->quote($test_data[
'test_objective_id'], 
'integer') . 
" ";
 
  682        $query = 
"DELETE FROM crs_objective_qst " .
 
  683            "WHERE objective_id = " . $this->db->quote($this->
getObjectiveId(), 
'integer') . 
" " .
 
  684            "AND question_id = " . $this->db->quote($this->
getQuestionId(), 
'integer') . 
" ";
 
  687        $next_id = 
$ilDB->nextId(
'crs_objective_qst');
 
  688        $query = 
"INSERT INTO crs_objective_qst (qst_ass_id, objective_id,ref_id,obj_id,question_id) " .
 
  690            $ilDB->quote($next_id, 
'integer') . 
", " .
 
  704    public function delete($qst_id)
 
  714        $query = 
"SELECT * FROM crs_objective_qst " .
 
  715            "WHERE qst_ass_id = " . 
$ilDB->quote($qst_id, 
'integer') . 
" ";
 
  719            $test_rid = 
$row->ref_id;
 
  720            $test_oid = 
$row->obj_id;
 
  723        $query = 
"DELETE FROM crs_objective_qst " .
 
  724            "WHERE qst_ass_id = " . 
$ilDB->quote($qst_id, 
'integer') . 
" ";
 
  728        $query = 
"SELECT * FROM crs_objective_qst " .
 
  729            "WHERE ref_id = " . 
$ilDB->quote($test_rid, 
'integer') . 
" " .
 
  730            "AND obj_id = " . 
$ilDB->quote($test_oid, 
'integer') . 
" " .
 
  734        if (!
$res->numRows()) {
 
  748        $query = 
'DELETE FROM crs_objective_tst ' .
 
  749                'WHERE ref_id = ' . 
$ilDB->quote($a_tst_ref_id, 
'integer');
 
  752        $query = 
'DELETE FROM crs_objective_qst ' .
 
  753                'WHERE ref_id = ' . 
$ilDB->quote($a_tst_ref_id, 
'integer');
 
  766        $deletable_refs = array();
 
  767        foreach ((array) $this->tests as $tst_data) {
 
  768            if ($tst_data[
'status'] == 
$a_type) {
 
  769                $deletable_refs[] = $tst_data[
'ref_id'];
 
  773        $query = 
'DELETE from crs_objective_tst ' .
 
  779        $query = 
'DELETE from crs_objective_tst ' .
 
  781                'AND ' . 
$ilDB->in(
'ref_id', $deletable_refs, 
false, 
'integer');
 
  795        $query = 
"DELETE FROM crs_objective_qst " .
 
  799        $query = 
"DELETE FROM crs_objective_tst " .
 
  815        include_once 
'./Modules/Test/classes/class.ilObjTest.php';
 
  816        include_once(
'Modules/Course/classes/class.ilCourseObjective.php');
 
  819        $container_ref_id = current($container_ref_ids);
 
  822        $query = 
"SELECT * FROM crs_objective_tst " .
 
  826            $this->tests[
$row->ref_id][
'test_objective_id'] = 
$row->test_objective_id;
 
  827            $this->tests[
$row->ref_id][
'ref_id'] = 
$row->ref_id;
 
  828            $this->tests[
$row->ref_id][
'obj_id'] = 
$row->obj_id;
 
  829            $this->tests[
$row->ref_id][
'status'] = 
$row->tst_status;
 
  830            $this->tests[
$row->ref_id][
'limit'] = 
$row->tst_limit_p;
 
  833        $this->questions = array();
 
  834        $query = 
"SELECT * FROM crs_objective_qst coq " .
 
  835            "JOIN qpl_questions qq ON coq.question_id = qq.question_id " .
 
  841            if (!
$tree->isInTree(
$row->ref_id) or !
$tree->isGrandChild($container_ref_id, 
$row->ref_id)) {
 
  846                $this->
delete(
$row->question_id);
 
  850            $qst[
'ref_id'] = 
$row->ref_id;
 
  851            $qst[
'obj_id'] = 
$row->obj_id;
 
  852            $qst[
'question_id'] = 
$row->question_id;
 
  853            $qst[
'qst_ass_id'] = 
$row->qst_ass_id;
 
  854            $qst[
'title'] = $question->getTitle();
 
  855            $qst[
'description'] = $question->getComment();
 
  856            $qst[
'test_type'] = $this->tests[
$row->ref_id][
'status'];
 
  857            $qst[
'points'] = $question->getPoints();
 
  859            $this->questions[
$row->qst_ass_id] = $qst;
 
  879        $query = 
"SELECT co.objective_id FROM crs_objectives co JOIN " .
 
  880            "crs_objective_tst cot ON co.objective_id = cot.objective_id " .
 
  881            "WHERE crs_id = " . 
$ilDB->quote($a_course_id, 
'integer') . 
" ";
 
  883        return $res->numRows() ? true : 
false;
 
  887    public static function _isAssigned($a_objective_id, $a_tst_ref_id, $a_question_id)
 
  893        $query = 
"SELECT crs_qst.objective_id objective_id FROM crs_objective_qst crs_qst, crs_objectives crs_obj " .
 
  894            "WHERE crs_qst.objective_id = crs_obj.objective_id " .
 
  895            "AND crs_qst.objective_id = " . 
$ilDB->quote($a_objective_id, 
'integer') . 
" " .
 
  896            "AND ref_id = " . 
$ilDB->quote($a_tst_ref_id, 
'integer') . 
" " .
 
  897            "AND question_id = " . 
$ilDB->quote($a_question_id, 
'integer') . 
" ";
 
  914        $query = 
'SELECT question_id FROM crs_objective_qst ' .
 
  915                'WHERE objective_id = ' . 
$ilDB->quote($a_objective, 
'integer') . 
' ' .
 
  916                'AND obj_id = ' . 
$ilDB->quote($a_test_id, 
'integer');
 
  932        $query = 
'SELECT tst_limit_p FROM crs_objective_tst ' .
 
  933                'WHERE objective_id = ' . 
$ilDB->quote($a_objective_id, 
'integer') . 
' ' .
 
  934                'AND obj_id = ' . 
$ilDB->quote($a_test_id, 
'integer');
 
  937            return (
int) 
$row->tst_limit_p;
 
  949            include_once 
'./Modules/Course/classes/Objectives/class.ilLOXmlWriter.php';
 
  954                    'refId' => 
$test[
'ref_id'],
 
  955                    'testType' => 
$test[
'tst_status'],
 
  956                    'limit' => 
$test[
'tst_limit']
 
  962                $writer->
xmlElement(
'Question', array(
'id' => $question_id));
 
An exception for terminatinating execution or to throw for unit testing.
static _getMaximumPoints($question_id)
Returns the maximum points, a learner can reach answering the question.
static _getInstance($a_copy_id)
Get instance of copy wizard options.
class ilcourseobjectiveQuestion
cloneDependencies($a_new_objective, $a_copy_id)
clone objective questions
isFinalTestQuestion($a_question_id)
is final test question
getQuestionsOfTest($a_test_id)
Get questions of test.
deleteByTestType($a_type)
getQuestionsByTest($a_test_ref_id)
getFinalTestQuestions()
get final test questions
static _getTest($a_test_objective_id)
getMaxPointsByTest($a_test_ref_id)
getSelfAssessmentTests()
get self assessment tests
__construct($a_objective_id)
Constructor @global type $ilDB.
static lookupObjectivesOfQuestion($a_qid)
Lookup objective for test question @global type $ilDB.
getMaxPointsByObjective()
getNumberOfQuestionsByTest($a_test_ref_id)
static lookupQuestionsByObjective($a_test_id, $a_objective)
static deleteTest($a_tst_ref_id)
getQuestion($question_id)
static _updateTestLimits($a_objective_id, $a_status, $a_limit)
update test limits
static _isAssigned($a_objective_id, $a_tst_ref_id, $a_question_id)
getSelfAssessmentPoints()
get self assessment points
setQuestionId($a_question_id)
getSelfAssessmentQuestions()
get self assessment questions
static _lookupMaximumPointsOfQuestion($a_question_id)
lookup maximimum point
static _hasTests($a_course_id)
@access public
static loookupTestLimit($a_test_id, $a_objective_id)
getFinalTests()
get final tests
static _getAssignableTests($a_container_ref_id)
Get assignable tests.
toXml(ilXmlWriter $writer)
To xml.
getFinalTestPoints()
get final test points
isSelfAssessmentQuestion($a_question_id)
check if question is self assessment question
updateTest($a_objective_id)
updateLimits()
update limits
__deleteTest($a_test_ref_id)
setTestSuggestedLimit($a_limit)
const TYPE_SELF_ASSESSMENT
static _isTestAssignedToObjective($a_test_id, $a_objective_id)
Check if test is assigned to objective.
static _lookupContainerIdByObjectiveId($a_objective_id)
Get container of object.
static getLogger($a_component_id)
Get component logger.
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
static _getAllReferences($a_id)
get all reference ids of object
xmlEndTag($tag)
Writes an endtag.
xmlElement($tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
xmlStartTag($tag, $attrs=null, $empty=false, $encode=true, $escape=true)
Writes a starttag.
const TYPE_SELF_ASSESSMENT
foreach($_POST as $key=> $value) $res