56 $this->objective_id = $a_objective_id;
73 $query =
'SELECT objective_id FROM crs_objective_qst ' .
74 'WHERE question_id = ' . $ilDB->quote($a_qid,
'integer');
76 $objectiveIds =
array();
78 $objectiveIds[] =
$row->objective_id;
97 $query =
"SELECT qst_ass_id FROM crs_objective_qst " .
98 "WHERE ref_id = " . $ilDB->quote($a_test_id,
'integer') .
" " .
99 "AND objective_id = " . $ilDB->quote($a_objective_id,
'integer');
101 return $res->numRows() ? true :
false;
117 include_once(
'Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
119 $mappings = $cwo->getMappings();
121 $mapping_key = $question[
'ref_id'] .
'_question_' . $question[
'question_id'];
122 if (!isset($mappings[$mapping_key]) or !$mappings[$mapping_key]) {
125 $question_ref_id = $question[
'ref_id'];
126 $question_obj_id = $question[
'obj_id'];
127 $question_qst_id = $question[
'question_id'];
128 $new_ref_id = $mappings[$question_ref_id];
129 $new_obj_id = $ilObjDataCache->lookupObjId($new_ref_id);
131 if ($new_obj_id == $question_obj_id) {
134 $new_question_id = $question_qst_id;
136 $new_question_info = $mappings[$question_ref_id .
'_question_' . $question_qst_id];
137 $new_question_arr = explode(
'_', $new_question_info);
138 if (!isset($new_question_arr[2]) or !$new_question_arr[2]) {
142 $new_question_id = $new_question_arr[2];
148 $new_question->setTestRefId($new_ref_id);
149 $new_question->setTestObjId($new_obj_id);
150 $new_question->setQuestionId($new_question_id);
151 $new_question->add();
156 $new_test_id = $mappings[
"$test[ref_id]"];
158 $query =
"UPDATE crs_objective_tst " .
159 "SET tst_status = " . $this->db->quote($test[
'tst_status'],
'integer') .
", " .
160 "tst_limit_p = " . $this->db->quote($test[
'tst_limit'],
'integer') .
" " .
161 "WHERE objective_id = " . $this->db->quote($a_new_objective,
'integer') .
" " .
162 "AND ref_id = " . $this->db->quote($new_test_id,
'integer');
179 return $tree->getSubTree($tree->getNodeData($a_container_ref_id),
true,
'tst');
185 $this->tst_status = $a_status;
189 return (
int) $this->tst_status;
193 $this->tst_limit = $a_limit;
197 return (
int) $this->tst_limit;
203 $query =
"UPDATE crs_objective_tst " .
204 "SET tst_status = " . $this->db->quote($this->
getTestStatus(),
'integer') .
" " .
205 "WHERE objective_id = " . $this->db->quote($this->
getObjectiveId(),
'integer') .
" " .
206 "AND ref_id = " . $this->db->quote($this->
getTestRefId(),
'integer') .
" ";
211 $query =
"SELECT * FROM crs_objective_tst " .
212 "WHERE objective_id = " . $ilDB->quote($this->
getObjectiveId(),
'integer') .
" " .
213 "AND ref_id = " . $ilDB->quote($this->
getTestRefId(),
'integer') .
"";
216 if (
$res->numRows()) {
221 $query =
"SELECT tst_limit_p FROM crs_objective_tst " .
222 "WHERE objective_id = " . $this->db->quote($this->
getObjectiveId(),
'integer') .
" " .
223 "AND tst_status = " . $this->db->quote($this->
getTestStatus(),
'integer') .
" ";
229 $limit =
$row->tst_limit_p;
232 $next_id = $ilDB->nextId(
'crs_objective_tst');
233 $query =
"INSERT INTO crs_objective_tst (test_objective_id,objective_id,ref_id,obj_id,tst_status,tst_limit_p) " .
235 $ilDB->quote($next_id,
'integer') .
", " .
240 $this->db->quote($limit,
'integer') .
" " .
252 $query =
"DELETE FROM crs_objective_qst " .
253 "WHERE objective_id = " . $ilDB->quote($this->
getObjectiveId(),
'integer') .
" " .
254 "AND ref_id = " . $ilDB->quote($a_test_ref_id,
'integer') .
" ";
258 $query =
"DELETE FROM crs_objective_tst " .
259 "WHERE objective_id = " . $ilDB->quote($this->
getObjectiveId(),
'integer') .
" " .
260 "AND ref_id = " . $ilDB->quote($a_test_ref_id,
'integer') .
" ";
263 unset($this->tests[$a_test_ref_id]);
282 $query =
"UPDATE crs_objective_tst " .
283 "SET tst_limit_p = " . $ilDB->quote($a_limit,
'integer') .
" " .
284 "WHERE tst_status = " . $ilDB->quote($a_status,
'integer') .
" " .
285 "AND objective_id = " . $ilDB->quote($a_objective_id,
'integer');
294 $query =
"UPDATE crs_objective_tst " .
295 "SET tst_status = " . $ilDB->quote($this->
getTestStatus(),
'integer') .
", " .
297 "WHERE test_objective_id = " . $ilDB->quote($a_objective_id,
'integer') .
"";
307 $query =
"SELECT * FROM crs_objective_tst cot " .
308 "JOIN object_data obd ON cot.obj_id = obd.obj_id " .
309 "WHERE objective_id = " . $ilDB->quote($this->
getObjectiveId(),
'integer') .
" " .
314 $test[
'test_objective_id'] =
$row->test_objective_id;
315 $test[
'objective_id'] =
$row->objective_id;
337 foreach ($this->tests as
$test) {
342 return $self ? $self :
array();
353 foreach ($this->tests as
$test) {
354 if ($test[
'status'] == self::TYPE_FINAL_TEST) {
358 return $final ? $final :
array();
361 public static function _getTest($a_test_objective_id)
365 $query =
"SELECT * FROM crs_objective_tst " .
366 "WHERE test_objective_id = " . $ilDB->quote($a_test_objective_id,
'integer') .
" ";
370 $test[
'test_objective_id'] =
$row->test_objective_id;
371 $test[
'objective_id'] =
$row->objective_id;
384 return $this->questions ? $this->questions :
array();
395 foreach ($this->questions as $question) {
400 return $self ? $self :
array();
412 $points += $question[
'points'];
414 return $points ? $points : 0;
426 $points += $question[
'points'];
428 return $points ? $points : 0;
439 foreach ($this->questions as $question) {
440 if ($question[
'question_id'] == $a_question_id) {
456 foreach ($this->questions as $question) {
457 if ($question[
'question_id'] == $a_question_id) {
458 return $question[
'test_type'] == self::TYPE_FINAL_TEST;
472 foreach ($this->questions as $question) {
473 if ($question[
'test_type'] == self::TYPE_FINAL_TEST) {
474 $final[] = $question;
477 return $final ? $final :
array();
492 if ($a_test_id == $qst[
'obj_id']) {
501 return $this->questions[$question_id] ? $this->questions[$question_id] :
array();
511 $this->tst_ref_id = $a_ref_id;
515 return $this->tst_ref_id ? $this->tst_ref_id : 0;
519 $this->tst_obj_id = $a_obj_id;
523 return $this->tst_obj_id ? $this->tst_obj_id : 0;
527 $this->question_id = $a_question_id;
531 return $this->question_id;
537 include_once
'./Modules/Test/classes/class.ilObjTest.php';
545 $points += $tmp_question->getMaximumPoints();
547 unset($tmp_question);
560 if ($question[
'ref_id'] == $a_test_ref_id) {
563 $points += $tmp_question->getMaximumPoints();
565 unset($tmp_question);
583 include_once(
'Modules/TestQuestionPool/classes/class.assQuestion.php');
593 if ($question[
'ref_id'] == $a_test_ref_id) {
603 if ($question[
'ref_id'] == $a_test_ref_id) {
604 $qst[] = $question[
'question_id'];
607 return $qst ? $qst :
array();
621 foreach ($this->tests as $ref_id => $test_data) {
622 switch ($test_data[
'status']) {
627 case self::TYPE_FINAL_TEST:
631 if ($test_data[
'limit'] == -1 or $test_data[
'limit'] > $points) {
632 switch ($test_data[
'status']) {
637 case self::TYPE_FINAL_TEST:
641 $query =
"UPDATE crs_objective_tst " .
642 "SET tst_limit = " . $this->db->quote($points,
'integer') .
" " .
643 "WHERE test_objective_id = " . $this->db->quote($test_data[
'test_objective_id'],
'integer') .
" ";
654 $query =
"DELETE FROM crs_objective_qst " .
655 "WHERE objective_id = " . $this->db->quote($this->
getObjectiveId(),
'integer') .
" " .
656 "AND question_id = " . $this->db->quote($this->
getQuestionId(),
'integer') .
" ";
659 $next_id = $ilDB->nextId(
'crs_objective_qst');
660 $query =
"INSERT INTO crs_objective_qst (qst_ass_id, objective_id,ref_id,obj_id,question_id) " .
662 $ilDB->quote($next_id,
'integer') .
", " .
676 public function delete($qst_id)
684 $query =
"SELECT * FROM crs_objective_qst " .
685 "WHERE qst_ass_id = " . $ilDB->quote($qst_id,
'integer') .
" ";
689 $test_rid =
$row->ref_id;
690 $test_oid =
$row->obj_id;
693 $query =
"DELETE FROM crs_objective_qst " .
694 "WHERE qst_ass_id = " . $ilDB->quote($qst_id,
'integer') .
" ";
698 $query =
"SELECT * FROM crs_objective_qst " .
699 "WHERE ref_id = " . $ilDB->quote($test_rid,
'integer') .
" " .
700 "AND obj_id = " . $ilDB->quote($test_oid,
'integer') .
" " .
701 "AND objective_id = " . $ilDB->quote($this->
getObjectiveId(),
'integer') .
" ";
704 if (!
$res->numRows()) {
716 $query =
'DELETE FROM crs_objective_tst ' .
717 'WHERE ref_id = ' . $ilDB->quote($a_tst_ref_id,
'integer');
718 $ilDB->manipulate(
$query);
720 $query =
'DELETE FROM crs_objective_qst ' .
721 'WHERE ref_id = ' . $ilDB->quote($a_tst_ref_id,
'integer');
722 $ilDB->manipulate(
$query);
732 $deletable_refs =
array();
733 foreach ((
array) $this->tests as $tst_data) {
734 if ($tst_data[
'status'] ==
$a_type) {
735 $deletable_refs[] = $tst_data[
'ref_id'];
739 $query =
'DELETE from crs_objective_tst ' .
740 'WHERE objective_id = ' . $ilDB->quote($this->
getObjectiveId(),
'integer') .
' ' .
741 'AND tst_status = ' . $ilDB->quote(
$a_type,
'integer');
742 $ilDB->manipulate(
$query);
745 $query =
'DELETE from crs_objective_tst ' .
746 'WHERE objective_id = ' . $ilDB->quote($this->
getObjectiveId(),
'integer') .
' ' .
747 'AND ' . $ilDB->in(
'ref_id', $deletable_refs,
false,
'integer');
748 $ilDB->manipulate(
$query);
759 $query =
"DELETE FROM crs_objective_qst " .
760 "WHERE objective_id = " . $ilDB->quote($this->
getObjectiveId(),
'integer') .
" ";
763 $query =
"DELETE FROM crs_objective_tst " .
764 "WHERE objective_id = " . $ilDB->quote($this->
getObjectiveId(),
'integer') .
" ";
776 include_once
'./Modules/Test/classes/class.ilObjTest.php';
777 include_once(
'Modules/Course/classes/class.ilCourseObjective.php');
780 $container_ref_id = current($container_ref_ids);
783 $query =
"SELECT * FROM crs_objective_tst " .
784 "WHERE objective_id = " . $ilDB->quote($this->
getObjectiveId(),
'integer') .
" ";
787 $this->tests[
$row->ref_id][
'test_objective_id'] =
$row->test_objective_id;
788 $this->tests[
$row->ref_id][
'ref_id'] =
$row->ref_id;
789 $this->tests[
$row->ref_id][
'obj_id'] =
$row->obj_id;
790 $this->tests[
$row->ref_id][
'status'] =
$row->tst_status;
791 $this->tests[
$row->ref_id][
'limit'] =
$row->tst_limit_p;
794 $this->questions =
array();
795 $query =
"SELECT * FROM crs_objective_qst coq " .
796 "JOIN qpl_questions qq ON coq.question_id = qq.question_id " .
797 "WHERE objective_id = " . $ilDB->quote($this->
getObjectiveId(),
'integer') .
" " .
802 if (!$tree->isInTree(
$row->ref_id) or !$tree->isGrandChild($container_ref_id,
$row->ref_id)) {
807 $this->
delete(
$row->question_id);
811 $qst[
'ref_id'] =
$row->ref_id;
812 $qst[
'obj_id'] =
$row->obj_id;
813 $qst[
'question_id'] =
$row->question_id;
814 $qst[
'qst_ass_id'] =
$row->qst_ass_id;
815 $qst[
'title'] = $question->getTitle();
816 $qst[
'description'] = $question->getComment();
817 $qst[
'test_type'] = $this->tests[
$row->ref_id][
'status'];
818 $qst[
'points'] = $question->getPoints();
820 $this->questions[
$row->qst_ass_id] = $qst;
838 $query =
"SELECT co.objective_id FROM crs_objectives co JOIN " .
839 "crs_objective_tst cot ON co.objective_id = cot.objective_id " .
840 "WHERE crs_id = " . $ilDB->quote($a_course_id,
'integer') .
" ";
842 return $res->numRows() ? true :
false;
846 public static function _isAssigned($a_objective_id, $a_tst_ref_id, $a_question_id)
850 $query =
"SELECT crs_qst.objective_id objective_id FROM crs_objective_qst crs_qst, crs_objectives crs_obj " .
851 "WHERE crs_qst.objective_id = crs_obj.objective_id " .
852 "AND crs_qst.objective_id = " . $ilDB->quote($a_objective_id,
'integer') .
" " .
853 "AND ref_id = " . $ilDB->quote($a_tst_ref_id,
'integer') .
" " .
854 "AND question_id = " . $ilDB->quote($a_question_id,
'integer') .
" ";
869 $query =
'SELECT question_id FROM crs_objective_qst ' .
870 'WHERE objective_id = ' . $ilDB->quote($a_objective,
'integer') .
' ' .
871 'AND obj_id = ' . $ilDB->quote($a_test_id,
'integer');
885 $query =
'SELECT tst_limit_p FROM crs_objective_tst ' .
886 'WHERE objective_id = ' . $ilDB->quote($a_objective_id,
'integer') .
' ' .
887 'AND obj_id = ' . $ilDB->quote($a_test_id,
'integer');
890 return (
int)
$row->tst_limit_p;
902 include_once
'./Modules/Course/classes/Objectives/class.ilLOXmlWriter.php';
907 'refId' => $test[
'ref_id'],
908 'testType' => $test[
'tst_status'],
909 'limit' => $test[
'tst_limit']
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
Create styles array
The data for the language used.
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()