Skip to content

Commit

Permalink
2.0.7 - dic::user errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jcopado committed Sep 19, 2023
1 parent f9e981b commit fbf35fd
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 20 deletions.
2 changes: 1 addition & 1 deletion classes/Participant/class.xdhtParticipant.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public function update()

if ($this->hasStatusChanged()) {
ilLPStatusWrapper::_updateStatus($this->training_obj_id, $this->usr_id);
ilChangeEvent::_recordReadEvent(ilDhbwTrainingPlugin::PLUGIN_PREFIX, intval(filter_input(INPUT_GET, 'ref_id')), $this->training_obj_id, self::dic()->user()->getId());
ilChangeEvent::_recordReadEvent(ilDhbwTrainingPlugin::PLUGIN_PREFIX, intval(filter_input(INPUT_GET, 'ref_id')), $this->training_obj_id, $ilUser->getId());
}
}

Expand Down
3 changes: 2 additions & 1 deletion classes/Recommender/RecommenderCurl.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,12 @@ public function start()/*:void*/
*/
protected function getAnonymizedUserHash() : string
{
global $ilUser;
$alg = 'sha256'; // put new desired hashing algo here
if (array_search($alg,hash_algos()) === false) {
$alg = 'md5'; // Fallback to md5 if $alg not included in php
}
return hash($alg,Config::getField(Config::KEY_SALT) . self::dic()->user()->getId());
return hash($alg,Config::getField(Config::KEY_SALT) . $ilUser->getId());
}


Expand Down
30 changes: 18 additions & 12 deletions classes/Start/class.xdhtStartGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,12 @@ public function start()
*/
public function proceedWithReturnOfRecommender()
{
global $ilUser;
$output = "";

if ($this->facade->settings()->getLearningProgress() && $this->response->getLearningProgressStatus() !== null) {
$this->facade->xdhtParticipantFactory()->updateStatus($this->facade->xdhtParticipantFactory()
->findOrCreateParticipantByUsrAndTrainingObjectId(self::dic()->user()
->findOrCreateParticipantByUsrAndTrainingObjectId($ilUser
->getId(), $this->facade->objectId()), $this->response->getLearningProgressStatus());
}

Expand All @@ -127,10 +128,10 @@ public function proceedWithReturnOfRecommender()
$set = $ilDB->query($sql);
$row = $ilDB->fetchAssoc($set);

ilPersonalSkill::addPersonalSkill(self::dic()->user()->getId(), $competence_id);
ilPersonalSkill::addPersonalSkill($ilUser->getId(), $competence_id);
ilBasicSkill::writeUserSkillLevelStatus(
$row['id'],
self::dic()->user()->getId(),
$ilUser->getId(),
$this->facade->refId(),
$competence_id,
ilBasicSkill::ACHIEVED,
Expand Down Expand Up @@ -208,6 +209,8 @@ public function proceedWithReturnOfRecommender()
*/
protected function initAnsweredQuestionForm($question) : ilTemplate
{
global $ilUser;

$tpl = new ilTemplate('tpl.questions_answered_form.html', true, true, 'Customizing/global/plugins/Services/Repository/RepositoryObject/DhbwTraining');
$tpl->setVariable("ACTION", self::dic()->ctrl()->getLinkTarget($this, self::CMD_SENDRATING));
$q_gui = assQuestionGUI::_getQuestionGUI("", $question['question_id']);
Expand All @@ -217,14 +220,14 @@ protected function initAnsweredQuestionForm($question) : ilTemplate

return $tpl;
}
$previewSession = new ilAssQuestionPreviewSession(self::dic()->user()->getId(), $question['question_id']);
$previewSession = new ilAssQuestionPreviewSession($ilUser->getId(), $question['question_id']);
$q_gui->setPreviewSession($previewSession);

/**
* shuffle like before
*/
$shuffler = new ilArrayElementShuffler();
$shuffler->setSeed($q_gui->object->getId() + self::dic()->user()->getId());
$shuffler->setSeed($q_gui->object->getId() + $ilUser->getId());
$q_gui->object->setShuffle(1);
$q_gui->object->setShuffler($shuffler);

Expand Down Expand Up @@ -260,6 +263,8 @@ protected function initAnsweredQuestionForm($question) : ilTemplate
*/
protected function initQuestionForm($question) : ilTemplate
{
global $ilUser;

$tpl = new ilTemplate('tpl.questions_form.html', true, true, 'Customizing/global/plugins/Services/Repository/RepositoryObject/DhbwTraining');
$tpl->setVariable("ACTION", self::dic()->ctrl()->getLinkTarget($this, self::CMD_ANSWER));

Expand All @@ -271,7 +276,7 @@ protected function initQuestionForm($question) : ilTemplate
return $tpl;
}

$previewSession = new ilAssQuestionPreviewSession(self::dic()->user()->getId(), $question['question_id']);
$previewSession = new ilAssQuestionPreviewSession($ilUser->getId(), $question['question_id']);

$previewSession->init();
$q_gui->setPreviewSession($previewSession);
Expand All @@ -280,7 +285,7 @@ protected function initQuestionForm($question) : ilTemplate
* Shuffle!
*/
$shuffler = new ilArrayElementShuffler();
$shuffler->setSeed($q_gui->object->getId() + self::dic()->user()->getId());
$shuffler->setSeed($q_gui->object->getId() + $ilUser->getId());
$q_gui->object->setShuffle(1);
$q_gui->object->setShuffler($shuffler);

Expand Down Expand Up @@ -406,8 +411,8 @@ public function answer()
*/
public function setAnsweredForPreviewSession($question) : bool
{

$previewSession = new ilAssQuestionPreviewSession(self::dic()->user()->getId(), $question['question_id']);
global $ilUser;
$previewSession = new ilAssQuestionPreviewSession($ilUser->getId(), $question['question_id']);

$q_gui = assQuestionGUI::_getQuestionGUI("", $question['question_id']);
if(is_object($q_gui )) {
Expand Down Expand Up @@ -448,11 +453,12 @@ public function proceed()
*/
protected function renderCompetences()/*:void*/
{

self::dic()->ui()->mainTemplate()->setRightContent(self::output()->getHTML(self::dic()->ui()->factory()->listing()->descriptive(array_reduce(ilPersonalSkill::getSelectedUserSkills(self::dic()
->user()
->getId()), function (array $items, array $competence) : array {

$level_id = ilPersonalSkill::getSelfEvaluation(self::dic()->user()->getId(), $competence["skill_node_id"], 0, $competence["skill_node_id"]);
global $ilUser;
$level_id = ilPersonalSkill::getSelfEvaluation($ilUser->getId(), $competence["skill_node_id"], 0, $competence["skill_node_id"]);

if ($level_id === null) {
return [];
Expand All @@ -464,7 +470,7 @@ protected function renderCompetences()/*:void*/
return [];
}

$items[$competence["title"]] = (new ilBasicSkill($competence["skill_node_id"]))->getLevelData(ilPersonalSkill::getSelfEvaluation(self::dic()->user()->getId(), $competence["skill_node_id"],
$items[$competence["title"]] = (new ilBasicSkill($competence["skill_node_id"]))->getLevelData(ilPersonalSkill::getSelfEvaluation($ilUser->getId(), $competence["skill_node_id"],
0, $competence["skill_node_id"]))["title"];

return $items;
Expand Down
2 changes: 1 addition & 1 deletion plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require_once __DIR__ . "/vendor/srag/dic/src/PHPVersionChecker.php";

$id = "xdht";
$version = "2.0.6";
$version = "2.0.7";
$ilias_min_version = "6.0";
$ilias_max_version = "7.999";
$responsible = "fluxlabs ag";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,10 +399,11 @@ public function initCSSandJS()/*: void*/
*/
public function insert(ilTemplate $tpl)/*: void*/
{
global $ilUser;
$options = [
// Services/Calendar/classes/class.ilCalendarUtil.php::addDateTimePicker
"date_config" => [
'locale' => self::dic()->user()->getLanguage(),
'locale' => $ilUser->getLanguage(),
'stepping' => 5,
'useCurrent' => false,
'calendarWeeks' => true,
Expand All @@ -413,8 +414,8 @@ public function insert(ilTemplate $tpl)/*: void*/
'keepInvalid' => true,
'sideBySide' => true,
//'collapse' => false,
'format' => !empty(self::dic()->user()->getId())
&& intval(self::dic()->user()->getId()) !== ANONYMOUS_USER_ID ? ilCalendarUtil::getUserDateFormat(false) : "DD.MM.YYYY"
'format' => !empty($ilUser->getId())
&& intval($ilUser->getId()) !== ANONYMOUS_USER_ID ? ilCalendarUtil::getUserDateFormat(false) : "DD.MM.YYYY"
]
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ class MultiSelectSearchInputGUI extends ilMultiSelectInputGUI implements ilTable
*/
public function __construct(string $title = "", string $post_var = "")
{
global $ilUser;

if (substr($post_var, -2) != "[]") {
$post_var = $post_var . "[]";
}
Expand All @@ -79,7 +81,7 @@ public function __construct(string $title = "", string $post_var = "")
$dir = "./" . substr($dir, strpos($dir, "/Customizing/") + 1);

self::dic()->ui()->mainTemplate()->addJavaScript($dir . "/../../node_modules/select2/dist/js/select2.full.min.js");
self::dic()->ui()->mainTemplate()->addJavaScript($dir . "/../../node_modules/select2/dist/js/i18n/" . self::dic()->user()->getCurrentLanguage()
self::dic()->ui()->mainTemplate()->addJavaScript($dir . "/../../node_modules/select2/dist/js/i18n/" . $ilUser->getCurrentLanguage()
. ".js");
self::dic()->ui()->mainTemplate()->addCss($dir . "/../../node_modules/select2/dist/css/select2.min.css");
self::dic()->ui()->mainTemplate()->addCss($dir . "/css/multiselectsearchinputgui.css");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,15 @@ public static function init(/*?*/ PluginInterface $plugin = null)/*: void*/
$dir = __DIR__;
$dir = "./" . substr($dir, strpos($dir, "/Customizing/") + 1);

global $ilUser;

self::dic()->ui()->mainTemplate()->addCss($version_parameter->appendToUrl($dir . "/../../node_modules/select2/dist/css/select2.min.css"));

self::dic()->ui()->mainTemplate()->addCss($version_parameter->appendToUrl($dir . "/css/multi_select_search_new_input_gui.css"));

self::dic()->ui()->mainTemplate()->addJavaScript($version_parameter->appendToUrl($dir . "/../../node_modules/select2/dist/js/select2.full.min.js"));

self::dic()->ui()->mainTemplate()->addJavaScript($version_parameter->appendToUrl($dir . "/../../node_modules/select2/dist/js/i18n/" . self::dic()->user()->getCurrentLanguage()
self::dic()->ui()->mainTemplate()->addJavaScript($version_parameter->appendToUrl($dir . "/../../node_modules/select2/dist/js/i18n/" . $ilUser->getCurrentLanguage()
. ".js"));
}
}
Expand Down

0 comments on commit fbf35fd

Please sign in to comment.