Skip to content

Commit

Permalink
debug_competence_config
Browse files Browse the repository at this point in the history
  • Loading branch information
fluxfw authored and mstuder committed Apr 20, 2020
1 parent 7efc982 commit c4c136c
Show file tree
Hide file tree
Showing 10 changed files with 109 additions and 17 deletions.
11 changes: 11 additions & 0 deletions classes/Interface/Settings/interface.xdhtSettingsInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,17 @@ public function getRecommenderSystemServer() : int;
public function setRecommenderSystemServer(int $recommender_system_server)/*:void*/ ;


/**
* @return array
*/
public function getRecommenderSystemServerBuiltInDebugCompetences() : array;


/**
* @param array $recommender_system_server_built_in_debug_competences
*/
public function setRecommenderSystemServerBuiltInDebugCompetences(array $recommender_system_server_built_in_debug_competences)/*:void*/ ;

/**
* @return int
*/
Expand Down
16 changes: 16 additions & 0 deletions classes/Recommender/debug/api/v1/_helper/_init.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,22 @@

$random_recomander_id = $all_questions[rand(0, (count($all_questions) - 1))];

$random_competences = $facade->settings()->getRecommenderSystemServerBuiltInDebugCompetences();
if (!empty($random_competences)) {
$random_competences = array_map(function (array $skill_ids) : int {
return $skill_ids[rand(0, (count($skill_ids) - 1))];
}, array_reduce($random_competences, function (array $random_competences, array $competence) : array {
if (!isset($random_competences[$competence["competence_id"]])) {
$random_competences[$competence["competence_id"]] = [];
}
$random_competences[$competence["competence_id"]][] = $competence["skill_id"];

return $random_competences;
}, []));
} else {
$random_competences = null;
}

try {
$post = json_decode(file_get_contents("php://input"), true);
} catch (Throwable $ex) {
Expand Down
6 changes: 1 addition & 5 deletions classes/Recommender/debug/api/v1/answer.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@
"progress" => 0.5,
"progress_type" => RecommenderResponse::MESSAGE_TYPE_QUESTION,
"learning_progress_status" => RecommenderResponse::LEARNING_PROGRESS_STATUS_IN_PROGRESS,
"competences" => [
11 => 12,
12 => 15,
13 => 18
]
"competences" => $random_competences
];

require_once __DIR__ . "/_helper/_output.php";
6 changes: 1 addition & 5 deletions classes/Recommender/debug/api/v1/rating.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@
"progress" => 1,
"progress_type" => RecommenderResponse::MESSAGE_TYPE_SUCCESS,
"learning_progress_status" => RecommenderResponse::LEARNING_PROGRESS_STATUS_COMPLETED,
"competences" => [
11 => 13,
12 => 16,
13 => 19
]
"competences" => $random_competences
];

require_once __DIR__ . "/_helper/_output.php";
6 changes: 1 addition & 5 deletions classes/Recommender/debug/api/v1/start.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@
"progress" => 0,
"progress_type" => RecommenderResponse::MESSAGE_TYPE_INFO,
"learning_progress_status" => RecommenderResponse::LEARNING_PROGRESS_STATUS_NOT_ATTEMPTED,
"competences" => [
11 => 11,
12 => 14,
13 => 17
]
"competences" => $random_competences
];

require_once __DIR__ . "/_helper/_output.php";
58 changes: 58 additions & 0 deletions classes/Settings/class.xdhtSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ class xdhtSettings extends ActiveRecord implements xdhtSettingsInterface
* @db_is_notnull true
*/
protected $recommender_system_server = self::RECOMMENDER_SYSTEM_SERVER_EXTERNAL;
/**
* @var array
*
* @db_has_field true
* @db_fieldtype text
* @db_is_notnull true
*/
protected $rec_sys_ser_bui_in_deb_comp = [];
/**
* @var int
*
Expand Down Expand Up @@ -117,6 +125,38 @@ public function getConnectorContainerName()
}


/**
* @inheritDoc
*/
public function sleep(/*string*/ $field_name)
{
$field_value = $this->{$field_name};

switch ($field_name) {
case "rec_sys_ser_bui_in_deb_comp":
return json_encode($field_value);

default:
return null;
}
}


/**
* @inheritDoc
*/
public function wakeUp(/*string*/ $field_name, $field_value)
{
switch ($field_name) {
case "rec_sys_ser_bui_in_deb_comp":
return json_decode($field_value, true) ?? [];

default:
return null;
}
}


/**
* @return int
*/
Expand Down Expand Up @@ -283,6 +323,24 @@ public function setRecommenderSystemServer(int $recommender_system_server)/*:voi
}


/**
* @inheritDoc
*/
public function getRecommenderSystemServerBuiltInDebugCompetences() : array
{
return $this->rec_sys_ser_bui_in_deb_comp;
}


/**
* @inheritDoc
*/
public function setRecommenderSystemServerBuiltInDebugCompetences(array $recommender_system_server_built_in_debug_competences)/*:void*/
{
$this->rec_sys_ser_bui_in_deb_comp = $recommender_system_server_built_in_debug_competences;
}


/**
* @inheritDoc
*/
Expand Down
13 changes: 13 additions & 0 deletions classes/Settings/class.xdhtSettingsFormGUI.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

use srag\CustomInputGUIs\DhbwTraining\MultiLineNewInputGUI\MultiLineNewInputGUI;
use srag\DIC\DhbwTraining\DICTrait;
use srag\Plugins\DhbwTraining\Config\Config;

Expand Down Expand Up @@ -102,6 +103,16 @@ public function initForm()
$recommender_system_server_built_in_debug->setInfo(nl2br(str_replace("\\n", "\n", self::plugin()
->translate("recommender_system_server_built_in_debug_info", "", ["[[question_id]]", "recomander_id", self::plugin()->directory() . "/classes/Recommender/debug/api/v1"])), false));
$recommender_system_server->addOption($recommender_system_server_built_in_debug);
$recommender_system_server_built_in_debug_competences = new MultiLineNewInputGUI("competences", "recommender_system_server_built_in_debug_competences");
$recommender_system_server_built_in_debug_competences->setShowSort(false);
$recommender_system_server_built_in_debug_competences->setInfo(self::plugin()->translate("recommender_system_server_built_in_debug_competences_info", "", ["competence_id", "skill_id"]));
$recommender_system_server_built_in_debug_competences_competence_id = new ilNumberInputGUI("competence_id", "competence_id");
$recommender_system_server_built_in_debug_competences_competence_id->setRequired(true);
$recommender_system_server_built_in_debug_competences->addInput($recommender_system_server_built_in_debug_competences_competence_id);
$recommender_system_server_built_in_debug_competences_skill_id = new ilNumberInputGUI("skill_id", "skill_id");
$recommender_system_server_built_in_debug_competences_skill_id->setRequired(true);
$recommender_system_server_built_in_debug_competences->addInput($recommender_system_server_built_in_debug_competences_skill_id);
$recommender_system_server_built_in_debug->addSubItem($recommender_system_server_built_in_debug_competences);
}

$ti = new ilTextInputGUI(self::plugin()->translate("url"), 'url');
Expand Down Expand Up @@ -155,6 +166,7 @@ public function fillForm()
$values['url'] = $this->facade->settings()->getUrl();
$values['log'] = $this->facade->settings()->getLog();
$values['recommender_system'] = $this->facade->settings()->getRecommenderSystemServer();
$values['recommender_system_server_built_in_debug_competences'] = $this->facade->settings()->getRecommenderSystemServerBuiltInDebugCompetences();
if (Config::getField(Config::KEY_LEARNING_PROGRESS)) {
$values['learning_progress'] = $this->facade->settings()->getLearningProgress();
}
Expand Down Expand Up @@ -193,6 +205,7 @@ public function fillObject()
$this->facade->settings()->setUrl($this->getInput('url'));
$this->facade->settings()->setLog($this->getInput('log'));
$this->facade->settings()->setRecommenderSystemServer(intval($this->getInput('recommender_system')));
$this->facade->settings()->setRecommenderSystemServerBuiltInDebugCompetences((array) $this->getInput('recommender_system_server_built_in_debug_competences'));
if (Config::getField(Config::KEY_LEARNING_PROGRESS)) {
$this->facade->settings()->setLearningProgress(intval($this->getInput('learning_progress')));
}
Expand Down
3 changes: 2 additions & 1 deletion lang/ilias_de.lang
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,5 @@ config_configuration#:#Konfiguration
config_configuration_saved#:#Konfiguration gespeichert
config_save#:#Speichern
config_salt#:#Salt
config_salt_info#:#Wird für die Anonymisierung des Benutzers mit dem Recommender System verwendet
config_salt_info#:#Wird für die Anonymisierung des Benutzers mit dem Recommender System verwendet
recommender_system_server_built_in_debug_competences_info#:#Wenn mehrere gleiche %1$s, wird eine zufällige %2$s genommen
3 changes: 2 additions & 1 deletion lang/ilias_en.lang
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,5 @@ config_configuration#:#Configuration
config_configuration_saved#:#Configuration saved
config_save#:#Save
config_salt#:#Salt
config_salt_info#:#Used to anonymize the user with the recommender system
config_salt_info#:#Used to anonymize the user with the recommender system
recommender_system_server_built_in_debug_competences_info#:#If multiple same %1$s, a random %2$s will be taken
4 changes: 4 additions & 0 deletions sql/dbupdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,7 @@
\srag\Plugins\DhbwTraining\Config\Config::updateDB();
\srag\Plugins\DhbwTraining\Config\Config::initDefaultSalt();
?>
<#8>
<?php
\xdhtSettings::updateDB();
?>

0 comments on commit c4c136c

Please sign in to comment.