/**
  * Select skill for question
  */
 function selectSkillForQuestion()
 {
     global $ilCtrl, $lng;
     include_once "./Modules/Survey/classes/class.ilSurveySkill.php";
     $skill_survey = new ilSurveySkill($this->survey);
     $skill_id_parts = explode(":", $_GET["selected_skill"]);
     $skill_survey->addQuestionSkillAssignment((int) $_GET["q_id"], (int) $skill_id_parts[0], (int) $skill_id_parts[1]);
     ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
     $ilCtrl->redirect($this, "listQuestionAssignment");
 }
Example #2
0
 /**
  * Clone object
  *
  * @access public
  * @param int ref_id of target container
  * @param int copy id
  * @return object new svy object
  */
 public function cloneObject($a_target_id, $a_copy_id = 0)
 {
     global $ilDB;
     $this->loadFromDb();
     // Copy settings
     $newObj = parent::cloneObject($a_target_id, $a_copy_id);
     $this->cloneMetaData($newObj);
     $newObj->updateMetaData();
     $newObj->setAuthor($this->getAuthor());
     $newObj->setIntroduction($this->getIntroduction());
     $newObj->setOutro($this->getOutro());
     $newObj->setStatus($this->getStatus());
     $newObj->setEvaluationAccess($this->getEvaluationAccess());
     $newObj->setStartDate($this->getStartDate());
     $newObj->setEndDate($this->getEndDate());
     $newObj->setInvitation($this->getInvitation());
     $newObj->setInvitationMode($this->getInvitationMode());
     $newObj->setAnonymize($this->getAnonymize());
     $newObj->setShowQuestionTitles($this->getShowQuestionTitles());
     $newObj->setTemplate($this->getTemplate());
     $newObj->setPoolUsage($this->getPoolUsage());
     $newObj->setViewOwnResults($this->hasViewOwnResults());
     $newObj->setMailOwnResults($this->hasMailOwnResults());
     // #12661
     if ($this->get360Mode()) {
         $newObj->set360Mode(true);
         $newObj->set360SelfEvaluation($this->get360SelfEvaluation());
         $newObj->set360SelfAppraisee($this->get360SelfAppraisee());
         $newObj->set360SelfRaters($this->get360SelfRaters());
         $newObj->set360Results($this->get360Results());
         $newObj->set360SkillService($this->get360SkillService());
     }
     // reminder/notification
     $newObj->setReminderStatus($this->getReminderStatus());
     $newObj->setReminderStart($this->getReminderStart());
     $newObj->setReminderEnd($this->getReminderEnd());
     $newObj->setReminderFrequency($this->getReminderFrequency());
     $newObj->setReminderTarget($this->getReminderTarget());
     // reminder_last_sent must not be copied!
     $newObj->setTutorNotificationStatus($this->getTutorNotificationStatus());
     $newObj->setTutorNotificationRecipients($this->getTutorNotificationRecipients());
     $newObj->setTutorNotificationTarget($this->getTutorNotificationTarget());
     $question_pointer = array();
     // clone the questions
     $mapping = array();
     include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
     foreach ($this->questions as $key => $question_id) {
         $question = ilObjSurvey::_instanciateQuestion($question_id);
         if ($question) {
             $question->id = -1;
             $original_id = SurveyQuestion::_getOriginalId($question_id, false);
             $question->saveToDb($original_id);
             $newObj->questions[$key] = $question->getId();
             $question_pointer[$question_id] = $question->getId();
             $mapping[$question_id] = $question->getId();
         }
     }
     $newObj->saveToDb();
     $newObj->cloneTextblocks($mapping);
     // #14929
     if ($this->get360Mode() && $this->get360SkillService()) {
         include_once "./Modules/Survey/classes/class.ilSurveySkill.php";
         $src_skills = new ilSurveySkill($this);
         $tgt_skills = new ilSurveySkill($newObj);
         foreach ($mapping as $src_qst_id => $tgt_qst_id) {
             $qst_skill = $src_skills->getSkillForQuestion($src_qst_id);
             if ($qst_skill) {
                 $tgt_skills->addQuestionSkillAssignment($tgt_qst_id, $qst_skill["base_skill_id"], $qst_skill["tref_id"]);
             }
         }
     }
     // clone the questionblocks
     $questionblocks = array();
     $questionblock_questions = array();
     $result = $ilDB->queryF("SELECT * FROM svy_qblk_qst WHERE survey_fi = %s", array('integer'), array($this->getSurveyId()));
     if ($result->numRows() > 0) {
         while ($row = $ilDB->fetchAssoc($result)) {
             array_push($questionblock_questions, $row);
             $questionblocks[$row["questionblock_fi"]] = $row["questionblock_fi"];
         }
     }
     // create new questionblocks
     foreach ($questionblocks as $key => $value) {
         $questionblock = ilObjSurvey::_getQuestionblock($key);
         $questionblock_id = ilObjSurvey::_addQuestionblock($questionblock["title"], $questionblock["owner_fi"], $questionblock["show_questiontext"], $questionblock["show_blocktitle"]);
         $questionblocks[$key] = $questionblock_id;
     }
     // create new questionblock questions
     foreach ($questionblock_questions as $key => $value) {
         if ($questionblocks[$value["questionblock_fi"]] && $question_pointer[$value["question_fi"]]) {
             $next_id = $ilDB->nextId('svy_qblk_qst');
             $affectedRows = $ilDB->manipulateF("INSERT INTO svy_qblk_qst (qblk_qst_id, survey_fi, questionblock_fi, question_fi) " . "VALUES (%s, %s, %s, %s)", array('integer', 'integer', 'integer', 'integer'), array($next_id, $newObj->getSurveyId(), $questionblocks[$value["questionblock_fi"]], $question_pointer[$value["question_fi"]]));
         }
     }
     // clone the constraints
     $constraints = ilObjSurvey::_getConstraints($this->getSurveyId());
     $newConstraints = array();
     foreach ($constraints as $key => $constraint) {
         if ($question_pointer[$constraint["for_question"]] && $question_pointer[$constraint["question"]]) {
             if (!array_key_exists($constraint['id'], $newConstraints)) {
                 $constraint_id = $newObj->addConstraint($question_pointer[$constraint["question"]], $constraint["relation_id"], $constraint["value"], $constraint['conjunction']);
                 $newConstraints[$constraint['id']] = $constraint_id;
             }
             $newObj->addConstraintToQuestion($question_pointer[$constraint["for_question"]], $newConstraints[$constraint['id']]);
         }
     }
     // clone the obligatory states
     $result = $ilDB->queryF("SELECT * FROM svy_qst_oblig WHERE survey_fi = %s", array('integer'), array($this->getSurveyId()));
     if ($result->numRows() > 0) {
         while ($row = $ilDB->fetchAssoc($result)) {
             if ($question_pointer[$row["question_fi"]]) {
                 $next_id = $ilDB->nextId('svy_qst_oblig');
                 $affectedRows = $ilDB->manipulateF("INSERT INTO svy_qst_oblig (question_obligatory_id, survey_fi, question_fi, " . "obligatory, tstamp) VALUES (%s, %s, %s, %s, %s)", array('integer', 'integer', 'integer', 'text', 'integer'), array($next_id, $newObj->getSurveyId(), $question_pointer[$row["question_fi"]], $row["obligatory"], time()));
             }
         }
     }
     return $newObj;
 }