51 $this->objective_id = $a_objective_id;
68 $query =
'SELECT objective_id FROM crs_objective_qst '.
69 'WHERE question_id = '.$ilDB->quote($a_qid,
'integer');
71 $objectiveIds = array();
74 $objectiveIds[] =
$row->objective_id;
93 $query =
"SELECT qst_ass_id FROM crs_objective_qst ".
94 "WHERE ref_id = ".$ilDB->quote($a_test_id ,
'integer').
" ".
95 "AND objective_id = ".$ilDB->quote($a_objective_id ,
'integer');
97 return $res->numRows() ? true :
false;
113 include_once(
'Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
115 $mappings = $cwo->getMappings();
118 $mapping_key = $question[
'ref_id'].
'_question_'.$question[
'question_id'];
119 if(!isset($mappings[$mapping_key]) or !$mappings[$mapping_key])
123 $question_ref_id = $question[
'ref_id'];
124 $question_obj_id = $question[
'obj_id'];
125 $question_qst_id = $question[
'question_id'];
126 $new_ref_id = $mappings[$question_ref_id];
127 $new_obj_id = $ilObjDataCache->lookupObjId($new_ref_id);
129 if($new_obj_id == $question_obj_id)
133 $new_question_id = $question_qst_id;
137 $new_question_info = $mappings[$question_ref_id.
'_question_'.$question_qst_id];
138 $new_question_arr = explode(
'_',$new_question_info);
139 if(!isset($new_question_arr[2]) or !$new_question_arr[2])
144 $new_question_id = $new_question_arr[2];
150 $new_question->setTestRefId($new_ref_id);
151 $new_question->setTestObjId($new_obj_id);
152 $new_question->setQuestionId($new_question_id);
153 $new_question->add();
159 $new_test_id = $mappings[
"$test[ref_id]"];
161 $query =
"UPDATE crs_objective_tst ".
162 "SET tst_status = ".$this->db->quote($test[
'tst_status'] ,
'integer').
", ".
163 "tst_limit_p = ".$this->db->quote($test[
'tst_limit'] ,
'integer').
" ".
164 "WHERE objective_id = ".$this->db->quote($a_new_objective ,
'integer').
" ".
165 "AND ref_id = ".$this->db->quote($new_test_id ,
'integer');
182 return $tree->getSubTree($tree->getNodeData($a_container_ref_id),
true,
'tst');
188 $this->tst_status = $a_status;
192 return (
int) $this->tst_status;
196 $this->tst_limit = $a_limit;
200 return (
int) $this->tst_limit;
206 $query =
"UPDATE crs_objective_tst ".
207 "SET tst_status = ".$this->db->quote($this->
getTestStatus() ,
'integer').
" ".
208 "WHERE objective_id = ".$this->db->quote($this->
getObjectiveId() ,
'integer').
" ".
209 "AND ref_id = ".$this->db->quote($this->
getTestRefId() ,
'integer').
" ";
214 $query =
"SELECT * FROM crs_objective_tst ".
215 "WHERE objective_id = ".$ilDB->quote($this->
getObjectiveId() ,
'integer').
" ".
216 "AND ref_id = ".$ilDB->quote($this->
getTestRefId() ,
'integer').
"";
225 $query =
"SELECT tst_limit_p FROM crs_objective_tst ".
226 "WHERE objective_id = ".$this->db->quote($this->
getObjectiveId() ,
'integer').
" ".
227 "AND tst_status = ".$this->db->quote($this->
getTestStatus() ,
'integer').
" ";
234 $limit =
$row->tst_limit_p;
237 $next_id = $ilDB->nextId(
'crs_objective_tst');
238 $query =
"INSERT INTO crs_objective_tst (test_objective_id,objective_id,ref_id,obj_id,tst_status,tst_limit_p) ".
240 $ilDB->quote($next_id,
'integer').
", ".
245 $this->db->quote($limit ,
'integer').
" ".
257 $query =
"DELETE FROM crs_objective_qst ".
258 "WHERE objective_id = ".$ilDB->quote($this->
getObjectiveId() ,
'integer').
" ".
259 "AND ref_id = ".$ilDB->quote($a_test_ref_id ,
'integer').
" ";
263 $query =
"DELETE FROM crs_objective_tst ".
264 "WHERE objective_id = ".$ilDB->quote($this->
getObjectiveId() ,
'integer').
" ".
265 "AND ref_id = ".$ilDB->quote($a_test_ref_id ,
'integer').
" ";
268 unset($this->tests[$a_test_ref_id]);
287 $query =
"UPDATE crs_objective_tst ".
288 "SET tst_limit_p = ".$ilDB->quote($a_limit ,
'integer').
" ".
289 "WHERE tst_status = ".$ilDB->quote($a_status ,
'integer').
" ".
290 "AND objective_id = ".$ilDB->quote($a_objective_id ,
'integer');
299 $query =
"UPDATE crs_objective_tst ".
300 "SET tst_status = ".$ilDB->quote($this->
getTestStatus() ,
'integer').
", ".
302 "WHERE test_objective_id = ".$ilDB->quote($a_objective_id ,
'integer').
"";
312 $query =
"SELECT * FROM crs_objective_tst cot ".
313 "JOIN object_data obd ON cot.obj_id = obd.obj_id ".
314 "WHERE objective_id = ".$ilDB->quote($this->
getObjectiveId() ,
'integer').
" ".
320 $test[
'test_objective_id'] =
$row->test_objective_id;
321 $test[
'objective_id'] =
$row->objective_id;
343 foreach($this->tests as
$test)
350 return $self ? $self : array();
361 foreach($this->tests as
$test)
363 if($test[
'status'] == self::TYPE_FINAL_TEST)
368 return $final ? $final : array();
375 $query =
"SELECT * FROM crs_objective_tst ".
376 "WHERE test_objective_id = ".$ilDB->quote($a_test_objective_id ,
'integer').
" ";
381 $test[
'test_objective_id'] =
$row->test_objective_id;
382 $test[
'objective_id'] =
$row->objective_id;
395 return $this->questions ? $this->questions : array();
406 foreach($this->questions as $question)
413 return $self ? $self : array();
426 $points += $question[
'points'];
428 return $points ? $points : 0;
441 $points += $question[
'points'];
443 return $points ? $points : 0;
454 foreach($this->questions as $question)
456 if($question[
'question_id'] == $a_question_id)
473 foreach($this->questions as $question)
475 if($question[
'question_id'] == $a_question_id)
477 return $question[
'test_type'] == self::TYPE_FINAL_TEST;
492 foreach($this->questions as $question)
494 if($question[
'test_type'] == self::TYPE_FINAL_TEST)
496 $final[] = $question;
499 return $final ? $final : array();
515 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';
570 $points += $tmp_question->getMaximumPoints();
572 unset($tmp_question);
586 if($question[
'ref_id'] == $a_test_ref_id)
590 $points += $tmp_question->getMaximumPoints();
592 unset($tmp_question);
610 include_once(
'Modules/TestQuestionPool/classes/class.assQuestion.php');
621 if($question[
'ref_id'] == $a_test_ref_id)
633 if($question[
'ref_id'] == $a_test_ref_id)
635 $qst[] = $question[
'question_id'];
638 return $qst ? $qst : array();
652 foreach($this->tests as
$ref_id => $test_data)
654 switch($test_data[
'status'])
660 case self::TYPE_FINAL_TEST:
664 if($test_data[
'limit'] == -1 or $test_data[
'limit'] > $points)
666 switch($test_data[
'status'])
672 case self::TYPE_FINAL_TEST:
676 $query =
"UPDATE crs_objective_tst ".
677 "SET tst_limit = ".$this->db->quote($points ,
'integer').
" ".
678 "WHERE test_objective_id = ".$this->db->quote($test_data[
'test_objective_id'] ,
'integer').
" ";
689 $query =
"DELETE FROM crs_objective_qst ".
690 "WHERE objective_id = ".$this->db->quote($this->
getObjectiveId() ,
'integer').
" ".
691 "AND question_id = ".$this->db->quote($this->
getQuestionId() ,
'integer').
" ";
694 $next_id = $ilDB->nextId(
'crs_objective_qst');
695 $query =
"INSERT INTO crs_objective_qst (qst_ass_id, objective_id,ref_id,obj_id,question_id) ".
697 $ilDB->quote($next_id,
'integer').
", ".
711 function delete($qst_id)
720 $query =
"SELECT * FROM crs_objective_qst ".
721 "WHERE qst_ass_id = ".$ilDB->quote($qst_id ,
'integer').
" ";
726 $test_rid =
$row->ref_id;
727 $test_oid =
$row->obj_id;
730 $query =
"DELETE FROM crs_objective_qst ".
731 "WHERE qst_ass_id = ".$ilDB->quote($qst_id ,
'integer').
" ";
735 $query =
"SELECT * FROM crs_objective_qst ".
736 "WHERE ref_id = ".$ilDB->quote($test_rid ,
'integer').
" ".
737 "AND obj_id = ".$ilDB->quote($test_oid ,
'integer').
" ".
738 "AND objective_id = ".$ilDB->quote($this->
getObjectiveId() ,
'integer').
" ";
754 $query =
'DELETE FROM crs_objective_tst '.
755 'WHERE ref_id = '.$ilDB->quote($a_tst_ref_id,
'integer');
756 $ilDB->manipulate(
$query);
758 $query =
'DELETE FROM crs_objective_qst '.
759 'WHERE ref_id = '.$ilDB->quote($a_tst_ref_id,
'integer');
760 $ilDB->manipulate(
$query);
770 $deletable_refs = array();
771 foreach((array) $this->tests as $tst_data)
773 if($tst_data[
'status'] == $a_type)
775 $deletable_refs[] = $tst_data[
'ref_id'];
779 $query =
'DELETE from crs_objective_tst '.
780 'WHERE objective_id = '.$ilDB->quote($this->
getObjectiveId(),
'integer').
' '.
781 'AND tst_status = '.$ilDB->quote($a_type,
'integer');
782 $ilDB->manipulate(
$query);
785 $query =
'DELETE from crs_objective_tst '.
786 'WHERE objective_id = '.$ilDB->quote($this->
getObjectiveId(),
'integer').
' '.
787 'AND '.$ilDB->in(
'ref_id',$deletable_refs,
false,
'integer');
788 $ilDB->manipulate(
$query);
799 $query =
"DELETE FROM crs_objective_qst ".
800 "WHERE objective_id = ".$ilDB->quote($this->
getObjectiveId() ,
'integer').
" ";
803 $query =
"DELETE FROM crs_objective_tst ".
804 "WHERE objective_id = ".$ilDB->quote($this->
getObjectiveId() ,
'integer').
" ";
816 include_once
'./Modules/Test/classes/class.ilObjTest.php';
817 include_once(
'Modules/Course/classes/class.ilCourseObjective.php');
820 $container_ref_id = current($container_ref_ids);
823 $query =
"SELECT * FROM crs_objective_tst ".
824 "WHERE objective_id = ".$ilDB->quote($this->
getObjectiveId() ,
'integer').
" ";
828 $this->tests[
$row->ref_id][
'test_objective_id'] =
$row->test_objective_id;
829 $this->tests[
$row->ref_id][
'ref_id'] =
$row->ref_id;
830 $this->tests[
$row->ref_id][
'obj_id'] =
$row->obj_id;
831 $this->tests[
$row->ref_id][
'status'] =
$row->tst_status;
832 $this->tests[
$row->ref_id][
'limit'] =
$row->tst_limit_p;
835 $this->questions = array();
836 $query =
"SELECT * FROM crs_objective_qst coq ".
837 "JOIN qpl_questions qq ON coq.question_id = qq.question_id ".
838 "WHERE objective_id = ".$ilDB->quote($this->
getObjectiveId() ,
'integer').
" ".
844 if(!$tree->isInTree(
$row->ref_id) or !$tree->isGrandChild($container_ref_id,
$row->ref_id))
851 $this->
delete(
$row->question_id);
855 $qst[
'ref_id'] =
$row->ref_id;
856 $qst[
'obj_id'] =
$row->obj_id;
857 $qst[
'question_id'] =
$row->question_id;
858 $qst[
'qst_ass_id'] =
$row->qst_ass_id;
859 $qst[
'title'] = $question->getTitle();
860 $qst[
'description'] = $question->getComment();
861 $qst[
'test_type'] = $this->tests[
$row->ref_id][
'status'];
862 $qst[
'points'] = $question->getPoints();
864 $this->questions[
$row->qst_ass_id] = $qst;
882 $query =
"SELECT co.objective_id FROM crs_objectives co JOIN ".
883 "crs_objective_tst cot ON co.objective_id = cot.objective_id ".
884 "WHERE crs_id = ".$ilDB->quote($a_course_id ,
'integer').
" ";
886 return $res->numRows() ? true :
false;
890 function _isAssigned($a_objective_id,$a_tst_ref_id,$a_question_id)
894 $query =
"SELECT crs_qst.objective_id objective_id FROM crs_objective_qst crs_qst, crs_objectives crs_obj ".
895 "WHERE crs_qst.objective_id = crs_obj.objective_id ".
896 "AND crs_qst.objective_id = ".$ilDB->quote($a_objective_id ,
'integer') .
" ".
897 "AND ref_id = ".$ilDB->quote($a_tst_ref_id ,
'integer').
" ".
898 "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');
931 $query =
'SELECT tst_limit_p FROM crs_objective_tst '.
932 'WHERE objective_id = '.$ilDB->quote($a_objective_id,
'integer').
' '.
933 'AND obj_id = '.$ilDB->quote($a_test_id,
'integer');
937 return (
int)
$row->tst_limit_p;
950 include_once
'./Modules/Course/classes/Objectives/class.ilLOXmlWriter.php';
955 'refId' => $test[
'ref_id'],
956 'testType' => $test[
'tst_status'],
957 'limit' => $test[
'tst_limit']
964 $writer->
xmlElement(
'Question', array(
'id' => $question_id));
ilCourseObjectiveQuestion($a_objective_id)
static loookupTestLimit($a_test_id, $a_objective_id)
getFinalTests()
get final tests
static _lookupMaximumPointsOfQuestion($a_question_id)
lookup maximimum point
getQuestionsOfTest($a_test_id)
Get questions of test.
getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
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
xmlStartTag($tag, $attrs=NULL, $empty=FALSE, $encode=TRUE, $escape=TRUE)
Writes a starttag.
& _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
xmlElement($tag, $attrs=NULL, $data=Null, $encode=TRUE, $escape=TRUE)
Writes a basic element (no children, just textual content)
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)
isFinalTestQuestion($a_question_id)
is final test question
static _getAllReferences($a_id)
get all reference ids of object
xmlEndTag($tag)
Writes an endtag.
const DB_FETCHMODE_OBJECT
getFinalTestQuestions()
get final test questions
static _getInstance($a_copy_id)
Get instance of copy wizard options.
getFinalTestPoints()
get final test points
deleteByTestType($a_type)
getMaxPointsByTest($a_test_ref_id)
_getMaximumPoints($question_id)
Returns the maximum points, a learner can reach answering the question.
getSelfAssessmentQuestions()
get self assessment questions
_hasTests($a_course_id)
public
setTestSuggestedLimit($a_limit)
getQuestion($question_id)
_isAssigned($a_objective_id, $a_tst_ref_id, $a_question_id)
getQuestionsByTest($a_test_ref_id)
setQuestionId($a_question_id)
updateTest($a_objective_id)
static _updateTestLimits($a_objective_id, $a_status, $a_limit)
update test limits
static getLogger($a_component_id)
Get component logger.
__deleteTest($a_test_ref_id)
static lookupObjectivesOfQuestion($a_qid)
Lookup objective for test question type $ilDB.
_getTest($a_test_objective_id)
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()