/** * Returns an array containing all variables and values which can be exchanged in the certificate * The values should be calculated from real data. The $params parameter array should contain all * necessary information to calculate the values. * * @param array $params An array of parameters to calculate the certificate parameter values * @return array The certificate variables */ public function getCertificateVariablesForPresentation($params = array()) { global $lng, $ilUser; $lng->loadLanguageModule('certificate'); $points = $this->object->getPointsInPercent(); $txtPoints = ""; if (is_null($points)) { $txtPoints = $lng->txt("certificate_points_notavailable"); } else { $txtPoints = number_format($points, 1, $lng->txt("lang_sep_decimal"), $lng->txt("lang_sep_thousand")) . " %"; } $max_points = $this->object->getMaxPoints(); $txtMaxPoints = ''; if (is_null($max_points)) { $txtMaxPoints = $lng->txt("certificate_points_notavailable"); } else { if ($max_points != floor($max_points)) { $txtMaxPoints = number_format($max_points, 1, $lng->txt("lang_sep_decimal"), $lng->txt("lang_sep_thousand")); } else { $txtMaxPoints = $max_points; } } $user_data = $params["user_data"]; $completion_date = $this->getUserCompletionDate($user_data["usr_id"]); $vars = $this->getBaseVariablesForPresentation($user_data, $params["last_access"], $completion_date); $vars["SCORM_TITLE"] = ilUtil::prepareFormOutput($this->object->getTitle()); $vars["SCORM_POINTS"] = $txtPoints; $vars["SCORM_POINTS_MAX"] = $txtMaxPoints; foreach ($vars as $id => $caption) { $insert_tags["[" . $id . "]"] = $caption; } include_once 'Services/Tracking/classes/class.ilLPCollections.php'; $lp_collections = new ilLPCollections($this->object->getId()); $counter = 0; foreach (ilLPCollections::_getPossibleSAHSItems($this->object->getId()) as $item_id => $sahs_item) { if ($lp_collections->isAssigned($item_id)) { $insert_tags['[SCO_T_' . $counter . ']'] = $sahs_item['title']; //." getId=".$this->object->getId()." item_id=".$item_id." user_id=".$ilUser->getId() $a_scores = ilLPCollections::_getScoresForUserAndCP_Node_Id($this->object->getId(), $item_id, $ilUser->getId()); if ($a_scores["raw"] == null) { $insert_tags['[SCO_P_' . $counter . ']'] = $lng->txt("certificate_points_notavailable"); } else { $insert_tags['[SCO_P_' . $counter . ']'] = number_format($a_scores["raw"], 1, $lng->txt("lang_sep_decimal"), $lng->txt("lang_sep_thousand")); } if ($a_scores["max"] == null) { $insert_tags['[SCO_PM_' . $counter . ']'] = $lng->txt("certificate_points_notavailable"); } else { $insert_tags['[SCO_PM_' . $counter . ']'] = number_format($a_scores["max"], 1, $lng->txt("lang_sep_decimal"), $lng->txt("lang_sep_thousand")); } if ($a_scores["scaled"] == null) { $insert_tags['[SCO_PP_' . $counter . ']'] = $lng->txt("certificate_points_notavailable"); } else { $insert_tags['[SCO_PP_' . $counter . ']'] = number_format($a_scores["scaled"] * 100, 1, $lng->txt("lang_sep_decimal"), $lng->txt("lang_sep_thousand")) . " %"; } $counter++; } } return $insert_tags; }