public function perform()
 {
     $this->processLockerFactory->setUserId($this->getUserId());
     foreach ($this->getQuestionIds() as $questionId) {
         $this->processLockerFactory->setQuestionId($questionId);
         $processLocker = $this->processLockerFactory->getLocker();
         $processLocker->requestUserSolutionAdoptLock();
         $this->adoptQuestionAnswer($questionId);
         $processLocker->releaseUserSolutionAdoptLock();
     }
 }
Esempio n. 2
0
 /**
 * Creates a question GUI instance of a given question type
 *
 * @param integer $question_type The question type of the question
 * @param integer $question_id The question id of the question, if available
 * @return assQuestionGUI $questionGUI The question GUI instance
 * @access	public
 */
 function &createQuestionGUI($question_type, $question_id = -1)
 {
     if (!$question_type and $question_id > 0) {
         $question_type = $this->getQuestionType($question_id);
     }
     if (!strlen($question_type)) {
         return null;
     }
     include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
     assQuestion::_includeClass($question_type, 1);
     $question_type_gui = assQuestion::getGuiClassNameByQuestionType($question_type);
     $question = new $question_type_gui();
     if ($question_id > 0) {
         $question->object->loadFromDb($question_id);
         global $ilCtrl, $ilDB, $ilUser, $lng;
         $feedbackObjectClassname = assQuestion::getFeedbackClassNameByQuestionType($question_type);
         $question->object->feedbackOBJ = new $feedbackObjectClassname($question->object, $ilCtrl, $ilDB, $lng);
         $assSettings = new ilSetting('assessment');
         require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionProcessLockerFactory.php';
         $processLockerFactory = new ilAssQuestionProcessLockerFactory($assSettings, $ilDB);
         $processLockerFactory->setQuestionId($question->object->getId());
         $processLockerFactory->setUserId($ilUser->getId());
         include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
         $processLockerFactory->setAssessmentLogEnabled(ilObjAssessmentFolder::_enabledAssessmentLogging());
         $question->object->setProcessLocker($processLockerFactory->getLocker());
     }
     return $question;
 }
 function saveQuestion($sid, $active_id, $question_id, $pass, $solution)
 {
     $this->initAuth($sid);
     $this->initIlias();
     if (!$this->__checkSession($sid)) {
         return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
     }
     if (!$this->isAllowedCall($sid, $active_id)) {
         return $this->__raiseError("The required user information is only available for active users.", "");
     }
     if (is_array($solution) && array_key_exists("item", $solution)) {
         $solution = $solution["item"];
     }
     global $ilDB, $ilUser;
     require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionProcessLockerFactory.php';
     $processLockerFactory = new ilAssQuestionProcessLockerFactory(new ilSetting('assessment'), $ilDB);
     $processLockerFactory->setQuestionId($question_id);
     $processLockerFactory->setUserId($ilUser->getId());
     include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
     $processLockerFactory->setAssessmentLogEnabled(ilObjAssessmentFolder::_enabledAssessmentLogging());
     $processLocker = $processLockerFactory->getLocker();
     $processLocker->requestPersistWorkingStateLock();
     $processLocker->requestUserSolutionUpdateLock();
     $ilDB = $GLOBALS['ilDB'];
     if ($active_id > 0 && $question_id > 0 && strlen($pass) > 0) {
         $affectedRows = $ilDB->manipulateF("DELETE FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s", array('integer', 'integer', 'integer'), array($active_id, $question_id, $pass));
     }
     $totalrows = 0;
     for ($i = 0; $i < count($solution); $i += 3) {
         $next_id = $ilDB->nextId('tst_solutions');
         $affectedRows = $ilDB->insert("tst_solutions", array("solution_id" => array("integer", $next_id), "active_fi" => array("integer", $active_id), "question_fi" => array("integer", $question_id), "value1" => array("clob", $solution[$i]), "value2" => array("clob", $solution[$i + 1]), "points" => array("float", $solution[$i + 2]), "pass" => array("integer", $pass), "tstamp" => array("integer", time())));
         $totalrows += $affectedRows;
     }
     $processLocker->releaseUserSolutionUpdateLock();
     if ($totalrows == 0) {
         $processLocker->releasePersistWorkingStateLock();
         return $this->__raiseError("Wrong solution data. ILIAS did not execute any database queries: Solution data: " . print_r($solution, true), 'No result');
     } else {
         include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
         $question = assQuestion::_instanciateQuestion($question_id);
         $question->setProcessLocker($processLocker);
         $question->calculateResultsFromSolution($active_id, $pass);
         $processLocker->releasePersistWorkingStateLock();
     }
     return true;
 }
Esempio n. 4
0
 /**
  * Creates an instance of a question gui with a given question id
  *
  * @param 	integer	$a_question_id
  *
  * @return 	\assQuestionGUI	The question gui instance
  */
 public static function instantiateQuestionGUI($a_question_id)
 {
     global $ilCtrl, $ilDB, $lng, $ilUser;
     if (strcmp($a_question_id, "") != 0) {
         $question_type = assQuestion::_getQuestionType($a_question_id);
         assQuestion::_includeClass($question_type, 1);
         $question_type_gui = self::getGuiClassNameByQuestionType($question_type);
         $question_gui = new $question_type_gui();
         $question_gui->object->loadFromDb($a_question_id);
         $feedbackObjectClassname = self::getFeedbackClassNameByQuestionType($question_type);
         $question_gui->object->feedbackOBJ = new $feedbackObjectClassname($question_gui->object, $ilCtrl, $ilDB, $lng);
         $assSettings = new ilSetting('assessment');
         require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionProcessLockerFactory.php';
         $processLockerFactory = new ilAssQuestionProcessLockerFactory($assSettings, $ilDB);
         $processLockerFactory->setQuestionId($question_gui->object->getId());
         $processLockerFactory->setUserId($ilUser->getId());
         include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
         $processLockerFactory->setAssessmentLogEnabled(ilObjAssessmentFolder::_enabledAssessmentLogging());
         $question_gui->object->setProcessLocker($processLockerFactory->getLocker());
     } else {
         global $ilLog;
         $ilLog->write('Instantiate question called without question id. (instantiateQuestionGUI@assQuestion)', $ilLog->WARNING);
         return null;
     }
     return $question_gui;
 }