function isObjectAnonymized()
 {
     switch ($this->obj_type) {
         case 'tst':
             include_once './Modules/Test/classes/class.ilObjTest.php';
             if (ilObjTest::_lookupAnonymity($this->obj_id)) {
                 return true;
             }
         default:
             return false;
     }
     return false;
 }
Esempio n. 2
0
 public function isAnonymized()
 {
     include_once './Modules/Test/classes/class.ilObjTest.php';
     return (bool) ilObjTest::_lookupAnonymity($this->obj_id);
 }
 function getTestOutput($active_id, $pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE)
 {
     $userdata = $this->object->getActiveUserData($active_id);
     // generate the question output
     include_once "./Services/UICore/classes/class.ilTemplate.php";
     $template = new ilTemplate("tpl.il_as_qpl_javaapplet_question_output.html", TRUE, TRUE, "Modules/TestQuestionPool");
     $template->setCurrentBlock("appletparam");
     $template->setVariable("PARAM_NAME", "test_type");
     include_once "./Modules/Test/classes/class.ilObjTest.php";
     if (ilObjTest::_lookupAnonymity(ilObjTest::_getObjectIDFromTestID($userdata["test_id"]))) {
         $template->setVariable("PARAM_VALUE", "0");
     } else {
         $template->setVariable("PARAM_VALUE", "1");
     }
     $template->parseCurrentBlock();
     $template->setCurrentBlock("appletparam");
     $template->setVariable("PARAM_NAME", "active_id");
     $template->setVariable("PARAM_VALUE", $active_id);
     $template->parseCurrentBlock();
     $template->setCurrentBlock("appletparam");
     $template->setVariable("PARAM_NAME", "test_id");
     $template->setVariable("PARAM_VALUE", $userdata["test_id"]);
     $template->parseCurrentBlock();
     $template->setCurrentBlock("appletparam");
     $template->setVariable("PARAM_NAME", "question_id");
     $template->setVariable("PARAM_VALUE", $this->object->getId());
     $template->parseCurrentBlock();
     $template->setCurrentBlock("appletparam");
     $template->setVariable("PARAM_NAME", "user_id");
     $template->setVariable("PARAM_VALUE", $userdata["user_id"]);
     $template->parseCurrentBlock();
     $template->setCurrentBlock("appletparam");
     $template->setVariable("PARAM_NAME", "points_max");
     $template->setVariable("PARAM_VALUE", $this->object->getPoints());
     $template->parseCurrentBlock();
     $template->setCurrentBlock("appletparam");
     $template->setVariable("PARAM_NAME", "session_id");
     $template->setVariable("PARAM_VALUE", $_COOKIE["PHPSESSID"]);
     $template->parseCurrentBlock();
     $template->setCurrentBlock("appletparam");
     $template->setVariable("PARAM_NAME", "client");
     $template->setVariable("PARAM_VALUE", CLIENT_ID);
     $template->parseCurrentBlock();
     $template->setCurrentBlock("appletparam");
     $template->setVariable("PARAM_NAME", "pass");
     $actualpass = ilObjTest::_getPass($active_id);
     $template->setVariable("PARAM_VALUE", $actualpass);
     $template->parseCurrentBlock();
     $template->setCurrentBlock("appletparam");
     $template->setVariable("PARAM_NAME", "post_url");
     $template->setVariable("PARAM_VALUE", ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH) . "/Modules/TestQuestionPool/save_question_post_data.php");
     $template->parseCurrentBlock();
     // additional parameters
     for ($i = 0; $i < $this->object->getParameterCount(); $i++) {
         $parameter = $this->object->getParameter($i);
         $template->setCurrentBlock("appletparam");
         $template->setVariable("PARAM_NAME", $parameter["name"]);
         $template->setVariable("PARAM_VALUE", $parameter["value"]);
         $template->parseCurrentBlock();
     }
     if ($active_id) {
         $solutions = NULL;
         include_once "./Modules/Test/classes/class.ilObjTest.php";
         if (!ilObjTest::_getUsePreviousAnswers($active_id, true)) {
             if (is_null($pass)) {
                 $pass = ilObjTest::_getPass($active_id);
             }
         }
         $info = $this->object->getReachedInformation($active_id, $pass);
         foreach ($info as $kk => $infodata) {
             $template->setCurrentBlock("appletparam");
             $template->setVariable("PARAM_NAME", "value_" . $infodata["order"] . "_1");
             $template->setVariable("PARAM_VALUE", $infodata["value1"]);
             $template->parseCurrentBlock();
             $template->setCurrentBlock("appletparam");
             $template->setVariable("PARAM_NAME", "value_" . $infodata["order"] . "_2");
             $template->setVariable("PARAM_VALUE", $infodata["value2"]);
             $template->parseCurrentBlock();
         }
         include_once './Services/Administration/classes/class.ilSetting.php';
         $soapSetting = new ilSetting();
         if ($soapSetting->get("soap_user_administration") == 1) {
             $template->setCurrentBlock("appletparam");
             $template->setVariable("PARAM_NAME", "server");
             $template->setVariable("PARAM_VALUE", ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH) . "/webservice/soap/server.php");
         }
     }
     $questiontext = $this->object->getQuestion();
     $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
     $template->setVariable("APPLET_WIDTH", $this->object->getJavaWidth());
     $template->setVariable("APPLET_HEIGHT", $this->object->getJavaHeight());
     $template->setVariable("APPLET_CODE", $this->object->getJavaCode());
     if (strlen($this->object->getJavaArchive()) > 0) {
         $template->setVariable("APPLET_ARCHIVE", " archive=\"" . $this->object->getJavaArchive() . "\"");
     } else {
         if (strpos($this->object->getJavaAppletFilename(), ".jar") !== FALSE) {
             $template->setVariable("APPLET_ARCHIVE", " archive=\"" . $this->object->getJavaPathWeb() . $this->object->getJavaAppletFilename() . "\"");
         }
     }
     if (strlen($this->object->getJavaCodebase()) > 0) {
         $template->setVariable("APPLET_CODEBASE", " codebase=\"" . $this->object->getJavaCodebase() . "\"");
     } else {
         if (strpos($this->object->getJavaAppletFilename(), ".class") !== FALSE) {
             $template->setVariable("APPLET_CODEBASE", " codebase=\"" . $this->object->getJavaPathWeb() . "\"");
         }
     }
     $questionoutput = $template->get();
     $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id, $questionoutput);
     return $pageoutput;
 }
 function __read()
 {
     global $ilObjDataCache, $ilDB;
     $this->items = array();
     if ($ilObjDataCache->lookupType($this->getObjId()) != 'sahs') {
         $course_ref_ids = ilObject::_getAllReferences($this->getObjId());
         $course_ref_id = end($course_ref_ids);
         $query = "SELECT * FROM ut_lp_collections utc " . "JOIN object_reference obr ON item_id = ref_id " . "JOIN object_data obd ON obr.obj_id = obd.obj_id " . "WHERE utc.obj_id = " . $this->db->quote($this->obj_id, 'integer') . " " . "AND active = " . $ilDB->quote(1, 'integer') . " " . "ORDER BY title";
     } else {
         $query = "SELECT * FROM ut_lp_collections WHERE obj_id = " . $ilDB->quote($this->getObjId(), 'integer') . " " . "AND active = " . $ilDB->quote(1, 'integer');
     }
     $res = $this->db->query($query);
     while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
         if ($ilObjDataCache->lookupType($this->getObjId()) != 'sahs') {
             if (!in_array($row->item_id, ilLPCollections::_getPossibleItems($course_ref_id))) {
                 $this->__deleteEntry($this->getObjId(), $row->item_id);
                 continue;
             }
         }
         // Check anonymized
         if ($ilObjDataCache->lookupType($item_obj_id = $ilObjDataCache->lookupObjId($row->item_id)) == 'tst') {
             include_once './Modules/Test/classes/class.ilObjTest.php';
             if (ilObjTest::_lookupAnonymity($item_obj_id)) {
                 $this->__deleteEntry($this->getObjId(), $row->item_id);
                 continue;
             }
         }
         $this->items[] = $row->item_id;
     }
 }
 /**
  * Get selectable columns
  *
  * @param
  * @return
  */
 function getSelectableColumns()
 {
     global $lng, $ilSetting;
     if ($this->selectable_columns) {
         return $this->selectable_columns;
     }
     $anonymized_object = false;
     include_once './Modules/Test/classes/class.ilObjTest.php';
     if (ilObjTest::_lookupAnonymity($this->obj_id)) {
         $anonymized_object = true;
     }
     include_once "./Services/User/classes/class.ilUserProfile.php";
     $up = new ilUserProfile();
     $up->skipGroup("preferences");
     $up->skipGroup("settings");
     $ufs = $up->getStandardFields();
     // default fields
     $cols = array();
     $cols["login"] = array("txt" => $lng->txt("login"), "default" => true);
     if (!$anonymized_object) {
         $cols["firstname"] = array("txt" => $lng->txt("firstname"), "default" => true);
         $cols["lastname"] = array("txt" => $lng->txt("lastname"), "default" => true);
     }
     // show only if extended data was activated in lp settings
     include_once 'Services/Tracking/classes/class.ilObjUserTracking.php';
     $tracking = new ilObjUserTracking();
     if ($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_LAST_ACCESS)) {
         $cols["first_access"] = array("txt" => $lng->txt("trac_first_access"), "default" => true);
         $cols["last_access"] = array("txt" => $lng->txt("trac_last_access"), "default" => true);
     }
     if ($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_READ_COUNT)) {
         $cols["read_count"] = array("txt" => $lng->txt("trac_read_count"), "default" => true);
     }
     if ($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_SPENT_SECONDS)) {
         $cols["spent_seconds"] = array("txt" => $lng->txt("trac_spent_seconds"), "default" => true);
     }
     if ($this->isPercentageAvailable($this->obj_id)) {
         $cols["percentage"] = array("txt" => $lng->txt("trac_percentage"), "default" => true);
     }
     // do not show status if learning progress is deactivated
     $mode = ilLPObjSettings::_lookupMode($this->obj_id);
     if ($mode != LP_MODE_DEACTIVATED && $mode != LP_MODE_LP_MODE_UNDEFINED) {
         $cols["status"] = array("txt" => $lng->txt("trac_status"), "default" => true);
         $cols['status_changed'] = array('txt' => $lng->txt('trac_status_changed'), 'default' => false);
     }
     if ($this->type != "lm") {
         $cols["mark"] = array("txt" => $lng->txt("trac_mark"), "default" => true);
     }
     $cols["u_comment"] = array("txt" => $lng->txt("trac_comment"), "default" => false);
     $cols["create_date"] = array("txt" => $lng->txt("create_date"), "default" => false);
     $cols["language"] = array("txt" => $lng->txt("language"), "default" => false);
     // add user data only if object is [part of] course
     if (!$anonymized_object && ($this->in_course || $this->in_group)) {
         // only show if export permission is granted
         include_once 'Services/PrivacySecurity/classes/class.ilPrivacySettings.php';
         if (ilPrivacySettings::_getInstance()->checkExportAccess($this->ref_id)) {
             $this->user_fields = array();
             // other user profile fields
             foreach ($ufs as $f => $fd) {
                 if (!isset($cols[$f]) && $f != "username" && !$fd["lists_hide"]) {
                     if ($this->in_course && !($fd["course_export_fix_value"] || $ilSetting->get("usr_settings_course_export_" . $f))) {
                         continue;
                     }
                     if ($this->in_group && !($fd["group_export_fix_value"] || $ilSetting->get("usr_settings_group_export_" . $f))) {
                         continue;
                     }
                     $cols[$f] = array("txt" => $lng->txt($f), "default" => false);
                     $this->user_fields[] = $f;
                 }
             }
             // additional defined user data fields
             include_once './Services/User/classes/class.ilUserDefinedFields.php';
             $user_defined_fields = ilUserDefinedFields::_getInstance();
             if ($this->in_course) {
                 $user_defined_fields = $user_defined_fields->getCourseExportableFields();
             } else {
                 $user_defined_fields = $user_defined_fields->getGroupExportableFields();
             }
             foreach ($user_defined_fields as $definition) {
                 if ($definition["field_type"] != UDF_TYPE_WYSIWYG) {
                     $f = "udf_" . $definition["field_id"];
                     $cols[$f] = array("txt" => $definition["field_name"], "default" => false);
                     $this->user_fields[] = $f;
                 }
             }
         }
     }
     $this->selectable_columns = $cols;
     return $cols;
 }
 /**
  * Check if item is anonymized
  * @param array item
  * @return <type>
  */
 protected function isAnonymized($a_item)
 {
     switch ($a_item['type']) {
         case 'tst':
             include_once './Modules/Test/classes/class.ilObjTest.php';
             if (ilObjTest::_lookupAnonymity($a_item['obj_id'])) {
                 return true;
             }
             return false;
         default:
             return false;
     }
 }
 /**
  * Retrieves a participant name from active id
  *
  * @param integer $active_id Active ID of the participant
  * @return string The output name of the user
  * @access public
  */
 function _getParticipantData($active_id)
 {
     global $lng, $ilDB;
     $result = $ilDB->queryF("SELECT * FROM tst_active WHERE active_id = %s", array("integer"), array($active_id));
     $row = $ilDB->fetchAssoc($result);
     $user_id = $row["user_fi"];
     $test_id = $row["test_fi"];
     $importname = $row['importname'];
     $result = $ilDB->queryF("SELECT obj_fi FROM tst_tests WHERE test_id = %s", array("integer"), array($test_id));
     $row = $ilDB->fetchAssoc($result);
     $obj_id = $row["obj_fi"];
     include_once "./Modules/Test/classes/class.ilObjTest.php";
     $is_anonymous = ilObjTest::_lookupAnonymity($obj_id);
     include_once './Services/User/classes/class.ilObjUser.php';
     $uname = ilObjUser::_lookupName($user_id);
     $name = "";
     if (strlen($importname)) {
         $name = $importname . ' (' . $lng->txt('imported') . ')';
     } else {
         if (strlen($uname["firstname"] . $uname["lastname"]) == 0) {
             $name = $lng->txt("deleted_user");
         } else {
             if ($user_id == ANONYMOUS_USER_ID) {
                 $name = $lastname;
             } else {
                 $name = trim($uname["lastname"] . ", " . $uname["firstname"] . " " . $uname["title"]);
             }
             if ($is_anonymous) {
                 $name = $lng->txt("anonymous");
             }
         }
     }
     return $name;
 }