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();
79 $objectiveIds[] =
$row->objective_id;
98 $query =
"SELECT qst_ass_id FROM crs_objective_qst ".
99 "WHERE ref_id = ".$ilDB->quote($a_test_id ,
'integer').
" ".
100 "AND objective_id = ".$ilDB->quote($a_objective_id ,
'integer');
102 return $res->numRows() ? true :
false;
118 include_once(
'Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
120 $mappings = $cwo->getMappings();
123 $mapping_key = $question[
'ref_id'].
'_question_'.$question[
'question_id'];
124 if(!isset($mappings[$mapping_key])
or !$mappings[$mapping_key])
128 $question_ref_id = $question[
'ref_id'];
129 $question_obj_id = $question[
'obj_id'];
130 $question_qst_id = $question[
'question_id'];
131 $new_ref_id = $mappings[$question_ref_id];
132 $new_obj_id = $ilObjDataCache->lookupObjId($new_ref_id);
134 if($new_obj_id == $question_obj_id)
138 $new_question_id = $question_qst_id;
142 $new_question_info = $mappings[$question_ref_id.
'_question_'.$question_qst_id];
143 $new_question_arr = explode(
'_',$new_question_info);
144 if(!isset($new_question_arr[2])
or !$new_question_arr[2])
149 $new_question_id = $new_question_arr[2];
155 $new_question->setTestRefId($new_ref_id);
156 $new_question->setTestObjId($new_obj_id);
157 $new_question->setQuestionId($new_question_id);
158 $new_question->add();
164 $new_test_id = $mappings[
"$test[ref_id]"];
166 $query =
"UPDATE crs_objective_tst ".
167 "SET tst_status = ".$this->db->quote($test[
'tst_status'] ,
'integer').
", ".
168 "tst_limit_p = ".$this->db->quote($test[
'tst_limit'] ,
'integer').
" ".
169 "WHERE objective_id = ".$this->db->quote($a_new_objective ,
'integer').
" ".
170 "AND ref_id = ".$this->db->quote($new_test_id ,
'integer');
187 return $tree->getSubTree($tree->getNodeData($a_container_ref_id),
true,
'tst');
193 $this->tst_status = $a_status;
197 return (
int) $this->tst_status;
201 $this->tst_limit = $a_limit;
205 return (
int) $this->tst_limit;
211 $query =
"UPDATE crs_objective_tst ".
212 "SET tst_status = ".$this->db->quote($this->
getTestStatus() ,
'integer').
" ".
213 "WHERE objective_id = ".$this->db->quote($this->
getObjectiveId() ,
'integer').
" ".
214 "AND ref_id = ".$this->db->quote($this->
getTestRefId() ,
'integer').
" ";
219 $query =
"SELECT * FROM crs_objective_tst ".
220 "WHERE objective_id = ".$ilDB->quote($this->
getObjectiveId() ,
'integer').
" ".
221 "AND ref_id = ".$ilDB->quote($this->
getTestRefId() ,
'integer').
"";
230 $query =
"SELECT tst_limit_p FROM crs_objective_tst ".
231 "WHERE objective_id = ".$this->db->quote($this->
getObjectiveId() ,
'integer').
" ".
232 "AND tst_status = ".$this->db->quote($this->
getTestStatus() ,
'integer').
" ";
239 $limit =
$row->tst_limit_p;
242 $next_id = $ilDB->nextId(
'crs_objective_tst');
243 $query =
"INSERT INTO crs_objective_tst (test_objective_id,objective_id,ref_id,obj_id,tst_status,tst_limit_p) ".
245 $ilDB->quote($next_id,
'integer').
", ".
250 $this->db->quote($limit ,
'integer').
" ".
262 $query =
"DELETE FROM crs_objective_qst ".
263 "WHERE objective_id = ".$ilDB->quote($this->
getObjectiveId() ,
'integer').
" ".
264 "AND ref_id = ".$ilDB->quote($a_test_ref_id ,
'integer').
" ";
268 $query =
"DELETE FROM crs_objective_tst ".
269 "WHERE objective_id = ".$ilDB->quote($this->
getObjectiveId() ,
'integer').
" ".
270 "AND ref_id = ".$ilDB->quote($a_test_ref_id ,
'integer').
" ";
273 unset($this->tests[$a_test_ref_id]);
292 $query =
"UPDATE crs_objective_tst ".
293 "SET tst_limit_p = ".$ilDB->quote($a_limit ,
'integer').
" ".
294 "WHERE tst_status = ".$ilDB->quote($a_status ,
'integer').
" ".
295 "AND objective_id = ".$ilDB->quote($a_objective_id ,
'integer');
304 $query =
"UPDATE crs_objective_tst ".
305 "SET tst_status = ".$ilDB->quote($this->
getTestStatus() ,
'integer').
", ".
307 "WHERE test_objective_id = ".$ilDB->quote($a_objective_id ,
'integer').
"";
317 $query =
"SELECT * FROM crs_objective_tst cot ".
318 "JOIN object_data obd ON cot.obj_id = obd.obj_id ".
319 "WHERE objective_id = ".$ilDB->quote($this->
getObjectiveId() ,
'integer').
" ".
325 $test[
'test_objective_id'] =
$row->test_objective_id;
326 $test[
'objective_id'] =
$row->objective_id;
348 foreach($this->tests as
$test)
355 return $self ? $self :
array();
366 foreach($this->tests as
$test)
368 if($test[
'status'] == self::TYPE_FINAL_TEST)
373 return $final ? $final :
array();
376 public static function _getTest($a_test_objective_id)
380 $query =
"SELECT * FROM crs_objective_tst ".
381 "WHERE test_objective_id = ".$ilDB->quote($a_test_objective_id ,
'integer').
" ";
386 $test[
'test_objective_id'] =
$row->test_objective_id;
387 $test[
'objective_id'] =
$row->objective_id;
400 return $this->questions ? $this->questions :
array();
411 foreach($this->questions as $question)
418 return $self ? $self :
array();
431 $points += $question[
'points'];
433 return $points ? $points : 0;
446 $points += $question[
'points'];
448 return $points ? $points : 0;
459 foreach($this->questions as $question)
461 if($question[
'question_id'] == $a_question_id)
478 foreach($this->questions as $question)
480 if($question[
'question_id'] == $a_question_id)
482 return $question[
'test_type'] == self::TYPE_FINAL_TEST;
497 foreach($this->questions as $question)
499 if($question[
'test_type'] == self::TYPE_FINAL_TEST)
501 $final[] = $question;
504 return $final ? $final :
array();
520 if($a_test_id == $qst[
'obj_id'])
530 return $this->questions[$question_id] ? $this->questions[$question_id] :
array();
540 $this->tst_ref_id = $a_ref_id;
544 return $this->tst_ref_id ? $this->tst_ref_id : 0;
548 $this->tst_obj_id = $a_obj_id;
552 return $this->tst_obj_id ? $this->tst_obj_id : 0;
556 $this->question_id = $a_question_id;
560 return $this->question_id;
566 include_once
'./Modules/Test/classes/class.ilObjTest.php';
575 $points += $tmp_question->getMaximumPoints();
577 unset($tmp_question);
591 if($question[
'ref_id'] == $a_test_ref_id)
595 $points += $tmp_question->getMaximumPoints();
597 unset($tmp_question);
615 include_once(
'Modules/TestQuestionPool/classes/class.assQuestion.php');
626 if($question[
'ref_id'] == $a_test_ref_id)
638 if($question[
'ref_id'] == $a_test_ref_id)
640 $qst[] = $question[
'question_id'];
643 return $qst ? $qst :
array();
657 foreach($this->tests as
$ref_id => $test_data)
659 switch($test_data[
'status'])
665 case self::TYPE_FINAL_TEST:
669 if($test_data[
'limit'] == -1
or $test_data[
'limit'] > $points)
671 switch($test_data[
'status'])
677 case self::TYPE_FINAL_TEST:
681 $query =
"UPDATE crs_objective_tst ".
682 "SET tst_limit = ".$this->db->quote($points ,
'integer').
" ".
683 "WHERE test_objective_id = ".$this->db->quote($test_data[
'test_objective_id'] ,
'integer').
" ";
694 $query =
"DELETE FROM crs_objective_qst ".
695 "WHERE objective_id = ".$this->db->quote($this->
getObjectiveId() ,
'integer').
" ".
696 "AND question_id = ".$this->db->quote($this->
getQuestionId() ,
'integer').
" ";
699 $next_id = $ilDB->nextId(
'crs_objective_qst');
700 $query =
"INSERT INTO crs_objective_qst (qst_ass_id, objective_id,ref_id,obj_id,question_id) ".
702 $ilDB->quote($next_id,
'integer').
", ".
716 function delete($qst_id)
725 $query =
"SELECT * FROM crs_objective_qst ".
726 "WHERE qst_ass_id = ".$ilDB->quote($qst_id ,
'integer').
" ";
731 $test_rid =
$row->ref_id;
732 $test_oid =
$row->obj_id;
735 $query =
"DELETE FROM crs_objective_qst ".
736 "WHERE qst_ass_id = ".$ilDB->quote($qst_id ,
'integer').
" ";
740 $query =
"SELECT * FROM crs_objective_qst ".
741 "WHERE ref_id = ".$ilDB->quote($test_rid ,
'integer').
" ".
742 "AND obj_id = ".$ilDB->quote($test_oid ,
'integer').
" ".
743 "AND objective_id = ".$ilDB->quote($this->
getObjectiveId() ,
'integer').
" ";
759 $query =
'DELETE FROM crs_objective_tst '.
760 'WHERE ref_id = '.$ilDB->quote($a_tst_ref_id,
'integer');
761 $ilDB->manipulate(
$query);
763 $query =
'DELETE FROM crs_objective_qst '.
764 'WHERE ref_id = '.$ilDB->quote($a_tst_ref_id,
'integer');
765 $ilDB->manipulate(
$query);
775 $deletable_refs =
array();
776 foreach((
array) $this->tests as $tst_data)
778 if($tst_data[
'status'] ==
$a_type)
780 $deletable_refs[] = $tst_data[
'ref_id'];
784 $query =
'DELETE from crs_objective_tst '.
785 'WHERE objective_id = '.$ilDB->quote($this->
getObjectiveId(),
'integer').
' '.
786 'AND tst_status = '.$ilDB->quote(
$a_type,
'integer');
787 $ilDB->manipulate(
$query);
790 $query =
'DELETE from crs_objective_tst '.
791 'WHERE objective_id = '.$ilDB->quote($this->
getObjectiveId(),
'integer').
' '.
792 'AND '.$ilDB->in(
'ref_id',$deletable_refs,
false,
'integer');
793 $ilDB->manipulate(
$query);
804 $query =
"DELETE FROM crs_objective_qst ".
805 "WHERE objective_id = ".$ilDB->quote($this->
getObjectiveId() ,
'integer').
" ";
808 $query =
"DELETE FROM crs_objective_tst ".
809 "WHERE objective_id = ".$ilDB->quote($this->
getObjectiveId() ,
'integer').
" ";
821 include_once
'./Modules/Test/classes/class.ilObjTest.php';
822 include_once(
'Modules/Course/classes/class.ilCourseObjective.php');
825 $container_ref_id = current($container_ref_ids);
828 $query =
"SELECT * FROM crs_objective_tst ".
829 "WHERE objective_id = ".$ilDB->quote($this->
getObjectiveId() ,
'integer').
" ";
833 $this->tests[
$row->ref_id][
'test_objective_id'] =
$row->test_objective_id;
834 $this->tests[
$row->ref_id][
'ref_id'] =
$row->ref_id;
835 $this->tests[
$row->ref_id][
'obj_id'] =
$row->obj_id;
836 $this->tests[
$row->ref_id][
'status'] =
$row->tst_status;
837 $this->tests[
$row->ref_id][
'limit'] =
$row->tst_limit_p;
840 $this->questions =
array();
841 $query =
"SELECT * FROM crs_objective_qst coq ".
842 "JOIN qpl_questions qq ON coq.question_id = qq.question_id ".
843 "WHERE objective_id = ".$ilDB->quote($this->
getObjectiveId() ,
'integer').
" ".
849 if(!$tree->isInTree(
$row->ref_id)
or !$tree->isGrandChild($container_ref_id,
$row->ref_id))
856 $this->
delete(
$row->question_id);
860 $qst[
'ref_id'] =
$row->ref_id;
861 $qst[
'obj_id'] =
$row->obj_id;
862 $qst[
'question_id'] =
$row->question_id;
863 $qst[
'qst_ass_id'] =
$row->qst_ass_id;
864 $qst[
'title'] = $question->getTitle();
865 $qst[
'description'] = $question->getComment();
866 $qst[
'test_type'] = $this->tests[
$row->ref_id][
'status'];
867 $qst[
'points'] = $question->getPoints();
869 $this->questions[
$row->qst_ass_id] = $qst;
887 $query =
"SELECT co.objective_id FROM crs_objectives co JOIN ".
888 "crs_objective_tst cot ON co.objective_id = cot.objective_id ".
889 "WHERE crs_id = ".$ilDB->quote($a_course_id ,
'integer').
" ";
891 return $res->numRows() ? true :
false;
895 static function _isAssigned($a_objective_id,$a_tst_ref_id,$a_question_id)
899 $query =
"SELECT crs_qst.objective_id objective_id FROM crs_objective_qst crs_qst, crs_objectives crs_obj ".
900 "WHERE crs_qst.objective_id = crs_obj.objective_id ".
901 "AND crs_qst.objective_id = ".$ilDB->quote($a_objective_id ,
'integer') .
" ".
902 "AND ref_id = ".$ilDB->quote($a_tst_ref_id ,
'integer').
" ".
903 "AND question_id = ".$ilDB->quote($a_question_id ,
'integer').
" ";
919 $query =
'SELECT question_id FROM crs_objective_qst '.
920 'WHERE objective_id = '.$ilDB->quote($a_objective,
'integer').
' '.
921 'AND obj_id = '.$ilDB->quote($a_test_id,
'integer');
936 $query =
'SELECT tst_limit_p FROM crs_objective_tst '.
937 'WHERE objective_id = '.$ilDB->quote($a_objective_id,
'integer').
' '.
938 'AND obj_id = '.$ilDB->quote($a_test_id,
'integer');
942 return (
int)
$row->tst_limit_p;
955 include_once
'./Modules/Course/classes/Objectives/class.ilLOXmlWriter.php';
960 'refId' => $test[
'ref_id'],
961 'testType' => $test[
'tst_status'],
962 'limit' => $test[
'tst_limit']
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.
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.
static _isAssigned($a_objective_id, $a_tst_ref_id, $a_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)
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.
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)
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()