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;
101 $ilDB = $DIC[
'ilDB'];
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'];
125 $ilDB = $DIC[
'ilDB'];
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');
189 $tree = $DIC[
'tree'];
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;
215 $ilDB = $DIC[
'ilDB'];
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') .
" " .
265 $ilDB = $DIC[
'ilDB'];
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]);
298 $ilDB = $DIC[
'ilDB'];
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');
312 $ilDB = $DIC[
'ilDB'];
314 $query =
"UPDATE crs_objective_tst " .
317 "WHERE test_objective_id = " .
$ilDB->quote($a_objective_id,
'integer') .
"";
327 $ilDB = $DIC[
'ilDB'];
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)
387 $ilDB = $DIC[
'ilDB'];
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) {
482 return $question[
'test_type'] == self::TYPE_FINAL_TEST;
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();
645 $ilDB = $DIC[
'ilDB'];
647 foreach ($this->tests as $ref_id => $test_data) {
648 switch ($test_data[
'status']) {
653 case self::TYPE_FINAL_TEST:
657 if ($test_data[
'limit'] == -1
or $test_data[
'limit'] > $points) {
658 switch ($test_data[
'status']) {
663 case self::TYPE_FINAL_TEST:
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') .
" ";
680 $ilDB = $DIC[
'ilDB'];
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)
708 $ilDB = $DIC[
'ilDB'];
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()) {
746 $ilDB = $DIC[
'ilDB'];
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');
762 $ilDB = $DIC[
'ilDB'];
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');
793 $ilDB = $DIC[
'ilDB'];
795 $query =
"DELETE FROM crs_objective_qst " .
799 $query =
"DELETE FROM crs_objective_tst " .
812 $ilDB = $DIC[
'ilDB'];
813 $tree = $DIC[
'tree'];
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 " .
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;
877 $ilDB = $DIC[
'ilDB'];
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)
891 $ilDB = $DIC[
'ilDB'];
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') .
" ";
912 $ilDB = $DIC[
'ilDB'];
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');
930 $ilDB = $DIC[
'ilDB'];
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));
static loookupTestLimit($a_test_id, $a_objective_id)
getFinalTests()
get final tests
xmlStartTag($tag, $attrs=null, $empty=false, $encode=true, $escape=true)
Writes a starttag.
static _lookupMaximumPointsOfQuestion($a_question_id)
lookup maximimum point
getQuestionsOfTest($a_test_id)
Get questions of test.
const TYPE_SELF_ASSESSMENT
static _lookupContainerIdByObjectiveId($a_objective_id)
Get container of object.
getSelfAssessmentPoints()
get self assessment points
cloneDependencies($a_new_objective, $a_copy_id)
clone objective questions
static _isAssigned($a_objective_id, $a_tst_ref_id, $a_question_id)
toXml(ilXmlWriter $writer)
To xml.
static _isTestAssignedToObjective($a_test_id, $a_objective_id)
Check if test is assigned to objective.
isSelfAssessmentQuestion($a_question_id)
check if question is self assessment question
updateLimits()
update limits
getNumberOfQuestionsByTest($a_test_ref_id)
static _getMaximumPoints($question_id)
Returns the maximum points, a learner can reach answering the question.
isFinalTestQuestion($a_question_id)
is final test question
static _getAllReferences($a_id)
get all reference ids of object
xmlEndTag($tag)
Writes an endtag.
static _hasTests($a_course_id)
public
getFinalTestQuestions()
get final test questions
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
static _getInstance($a_copy_id)
Get instance of copy wizard options.
foreach($_POST as $key=> $value) $res
getFinalTestPoints()
get final test points
deleteByTestType($a_type)
getMaxPointsByTest($a_test_ref_id)
static _getTest($a_test_objective_id)
getSelfAssessmentQuestions()
get self assessment questions
setTestSuggestedLimit($a_limit)
getQuestion($question_id)
xmlElement($tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
getQuestionsByTest($a_test_ref_id)
__construct($a_objective_id)
Constructor type $ilDB.
setQuestionId($a_question_id)
updateTest($a_objective_id)
static _updateTestLimits($a_objective_id, $a_status, $a_limit)
update test limits
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
static getLogger($a_component_id)
Get component logger.
__deleteTest($a_test_ref_id)
static lookupObjectivesOfQuestion($a_qid)
Lookup objective for test question type $ilDB.
getSelfAssessmentTests()
get self assessment tests
static lookupQuestionsByObjective($a_test_id, $a_objective)
class ilcourseobjectiveQuestion
static deleteTest($a_tst_ref_id)
const TYPE_SELF_ASSESSMENT
static _getAssignableTests($a_container_ref_id)
Get assignable tests.
getMaxPointsByObjective()