diff --git a/Modules/IndividualAssessment/classes/class.ilIndividualAssessmentDataSet.php b/Modules/IndividualAssessment/classes/class.ilIndividualAssessmentDataSet.php
index d1b3aa13c1e7..9592b42f5c1f 100644
--- a/Modules/IndividualAssessment/classes/class.ilIndividualAssessmentDataSet.php
+++ b/Modules/IndividualAssessment/classes/class.ilIndividualAssessmentDataSet.php
@@ -111,10 +111,10 @@ protected function _readData($entity, $ids)
'id' => $iass_id,
'title' => $obj->getTitle(),
'description' => $obj->getDescription(),
- 'content' => $settings->content(),
- 'recordTemplate' => $settings->recordTemplate(),
- 'eventTimePlaceRequired' => (int) $settings->eventTimePlaceRequired(),
- 'file_required' => (int) $settings->fileRequired(),
+ 'content' => $settings->getContent(),
+ 'recordTemplate' => $settings->getRecordTemplate(),
+ 'eventTimePlaceRequired' => (int) $settings->isEventTimePlaceRequired(),
+ 'file_required' => (int) $settings->isFileRequired(),
"contact" => $info->getContact(),
"responsibility" => $info->getResponsibility(),
"phone" => $info->getPhone(),
@@ -170,7 +170,7 @@ public function importRecord($entity, $types, array $rec, ilImportMapping $mappi
$rec['phone'],
$rec['mails'],
$rec['consultation_hours']
- );
+ );
$newObj->setTitle($rec["title"]);
$newObj->setDescription($rec["description"]);
diff --git a/Modules/LearningModule/Presentation/classes/class.ilLMPresentationGUI.php b/Modules/LearningModule/Presentation/classes/class.ilLMPresentationGUI.php
index dc0565c116b3..d8efc2c807d2 100755
--- a/Modules/LearningModule/Presentation/classes/class.ilLMPresentationGUI.php
+++ b/Modules/LearningModule/Presentation/classes/class.ilLMPresentationGUI.php
@@ -292,6 +292,7 @@ public function executeCommand()
$lng = $this->lng;
$ilCtrl = $this->ctrl;
$ilUser = $this->user;
+ $ilErr = $this->error;
// check read permission and parent conditions
// todo: replace all this by ilAccess call
diff --git a/Modules/LearningModule/classes/class.ilEditClipboard.php b/Modules/LearningModule/classes/class.ilEditClipboard.php
index 7646afc757cb..defaa67aa204 100755
--- a/Modules/LearningModule/classes/class.ilEditClipboard.php
+++ b/Modules/LearningModule/classes/class.ilEditClipboard.php
@@ -37,8 +37,11 @@ class ilEditClipboard
{
public static function getContentObjectType()
{
- if (isset($_SESSION["ilEditClipboard"])) {
- return $_SESSION["ilEditClipboard"]["type"];
+ global $DIC;
+ $user = $DIC->user();
+ $lm_type = $user->getPref("lm_clipboard_type");
+ if ($lm_type != "") {
+ return $lm_type;
} else {
return false;
}
@@ -46,13 +49,18 @@ public static function getContentObjectType()
public static function setAction($a_action)
{
- $_SESSION["ilEditClipboard"] = array("action" => $a_action);
+ global $DIC;
+ $user = $DIC->user();
+ $user->writePref("lm_clipboard_action", $a_action);
}
public static function getAction()
{
- if (isset($_SESSION["ilEditClipboard"])) {
- return $_SESSION["ilEditClipboard"]["action"];
+ global $DIC;
+ $user = $DIC->user();
+ $lm_action = $user->getPref("lm_clipboard_action");
+ if ($lm_action != "") {
+ return $lm_action;
} else {
return false;
}
@@ -60,19 +68,32 @@ public static function getAction()
public static function getContentObjectId()
{
- if (isset($_SESSION["ilEditClipboard"])) {
- return $_SESSION["ilEditClipboard"]["id"];
+ global $DIC;
+ $user = $DIC->user();
+ $lm_id = $user->getPref("lm_clipboard_id");
+ if ($lm_id != "") {
+ return $lm_id;
}
+ return "";
}
public static function storeContentObject($a_type, $a_id, $a_action = "cut")
{
- $_SESSION["ilEditClipboard"] = array("type" => $a_type,
- "id" => $a_id, "action" => $a_action);
+ global $DIC;
+ $user = $DIC->user();
+ $user->writePref("lm_clipboard_id", $a_id);
+ $user->writePref("lm_clipboard_type", $a_type);
+ self::setAction($a_action);
}
public static function clear()
{
- unset($_SESSION["ilEditClipboard"]);
+ global $DIC;
+ $user = $DIC->user();
+ $user->clipboardDeleteObjectsOfType("pg");
+ $user->clipboardDeleteObjectsOfType("st");
+ $user->writePref("lm_clipboard_id", "");
+ $user->writePref("lm_clipboard_type", "");
+ $user->writePref("lm_clipboard_action", "");
}
}
diff --git a/Modules/LearningModule/classes/class.ilLMTracker.php b/Modules/LearningModule/classes/class.ilLMTracker.php
index e8c5caa39f34..f197973b35b7 100644
--- a/Modules/LearningModule/classes/class.ilLMTracker.php
+++ b/Modules/LearningModule/classes/class.ilLMTracker.php
@@ -179,25 +179,17 @@ public function trackAccess($a_page_id, $user_id)
*/
public function trackLastPageAccess($usr_id, $lm_id, $obj_id)
{
- $ilDB = $this->db;
-
- // first check if an entry for this user and this lm already exist, when so, delete
- $q = "DELETE FROM lo_access " .
- "WHERE usr_id = " . $ilDB->quote((int) $usr_id, "integer") . " " .
- "AND lm_id = " . $ilDB->quote((int) $lm_id, "integer");
- $ilDB->manipulate($q);
-
$title = "";
-
- $q = "INSERT INTO lo_access " .
- "(timestamp,usr_id,lm_id,obj_id,lm_title) " .
- "VALUES " .
- "(" . $ilDB->now() . "," .
- $ilDB->quote((int) $usr_id, "integer") . "," .
- $ilDB->quote((int) $lm_id, "integer") . "," .
- $ilDB->quote((int) $obj_id, "integer") . "," .
- $ilDB->quote($title, "text") . ")";
- $ilDB->manipulate($q);
+ $db = $this->db;
+ $db->replace("lo_access", [
+ "usr_id" => ["integer", $usr_id],
+ "lm_id" => ["integer", $lm_id]
+ ], [
+ "timestamp" => ["timestamp", ilUtil::now()],
+ "obj_id" => ["integer", $obj_id],
+ "lm_title" => ["text", $title]
+ ]
+ );
}
diff --git a/Modules/LearningModule/classes/class.ilLearningModuleNotification.php b/Modules/LearningModule/classes/class.ilLearningModuleNotification.php
index f9d19b7d0014..40f3c87bc7a7 100644
--- a/Modules/LearningModule/classes/class.ilLearningModuleNotification.php
+++ b/Modules/LearningModule/classes/class.ilLearningModuleNotification.php
@@ -140,14 +140,13 @@ public function send()
$mail_obj = new ilMail(ANONYMOUS_USER_ID);
$mail_obj->appendInstallationSignature(true);
- $mail_obj->sendMail(
+ $mail_obj->enqueue(
ilObjUser::_lookupLogin($user_id),
"",
"",
$subject,
$message,
- [],
- false
+ []
);
}
}
diff --git a/Modules/LearningModule/templates/default/tpl.glossary_term_output.html b/Modules/LearningModule/templates/default/tpl.glossary_term_output.html
index b8283d9b85a7..9317a3796487 100755
--- a/Modules/LearningModule/templates/default/tpl.glossary_term_output.html
+++ b/Modules/LearningModule/templates/default/tpl.glossary_term_output.html
@@ -23,7 +23,7 @@
-
{TXT_TERM}
+
{TXT_TERM}
{TXT_DEFINITION}
diff --git a/Modules/LearningSequence/classes/GlobalSettings/LSGlobalSettings.php b/Modules/LearningSequence/classes/GlobalSettings/LSGlobalSettings.php
new file mode 100644
index 000000000000..02ead10a6b33
--- /dev/null
+++ b/Modules/LearningSequence/classes/GlobalSettings/LSGlobalSettings.php
@@ -0,0 +1,35 @@
+polling_interval_seconds = $polling_interval_seconds;
+ }
+
+ public function getPollingIntervalSeconds() : float
+ {
+ return $this->polling_interval_seconds;
+ }
+
+ public function getPollingIntervalMilliseconds() : int
+ {
+ $interval = $this->getPollingIntervalSeconds() * 1000;
+ return (int) $interval;
+ }
+
+ public function withPollingIntervalSeconds(float $seconds) : LSGlobalSettings
+ {
+ $clone = clone $this;
+ $clone->polling_interval_seconds = $seconds;
+ return $clone;
+ }
+}
diff --git a/Modules/LearningSequence/classes/GlobalSettings/LSGlobalSettingsDB.php b/Modules/LearningSequence/classes/GlobalSettings/LSGlobalSettingsDB.php
new file mode 100644
index 000000000000..bf75005d36aa
--- /dev/null
+++ b/Modules/LearningSequence/classes/GlobalSettings/LSGlobalSettingsDB.php
@@ -0,0 +1,11 @@
+il_settings = $il_settings;
+ }
+
+ public function getSettings() : LSGlobalSettings
+ {
+ $interval_seconds = (float) $this->il_settings->get(
+ self::SETTING_POLL_INTERVAL,
+ self::POLL_INTERVAL_DEFAULT
+ );
+
+ return new LSGlobalSettings($interval_seconds);
+ }
+
+ public function storeSettings(LSGlobalSettings $settings)
+ {
+ $this->il_settings->set(
+ self::SETTING_POLL_INTERVAL,
+ $settings->getPollingIntervalSeconds()
+ );
+ }
+}
diff --git a/Modules/LearningSequence/classes/Player/LSControlBuilder.php b/Modules/LearningSequence/classes/Player/LSControlBuilder.php
index d593efde8858..5a830bbb5cb3 100644
--- a/Modules/LearningSequence/classes/Player/LSControlBuilder.php
+++ b/Modules/LearningSequence/classes/Player/LSControlBuilder.php
@@ -16,8 +16,6 @@ class LSControlBuilder implements ControlBuilder
{
const CMD_START_OBJECT = 'start_legacy_obj';
const CMD_CHECK_CURRENT_ITEM_LP = 'ccilp';
- const UPDATE_LEGACY_OBJECT_LP_INTERVAL = 2000;
-
/**
* @var Component|null
@@ -84,14 +82,21 @@ class LSControlBuilder implements ControlBuilder
*/
protected $additional_js;
+ /**
+ * @var LSGlobalSettings
+ */
+ protected $global_settings;
+
public function __construct(
Factory $ui_factory,
LSURLBuilder $url_builder,
- ilLanguage $language
+ ilLanguage $language,
+ LSGlobalSettings $global_settings
) {
$this->ui_factory = $ui_factory;
$this->url_builder = $url_builder;
$this->lng = $language;
+ $this->global_settings = $global_settings;
}
public function getExitControl()
@@ -302,7 +307,7 @@ public function start(string $label, string $url, int $parameter = null) : Contr
$this->start = $this->ui_factory->button()
->primary($label, '')
->withOnLoadCode(function ($id) use ($url) {
- $interval = self::UPDATE_LEGACY_OBJECT_LP_INTERVAL;
+ $interval = $this->global_settings->getPollingIntervalMilliseconds();
return "$('#{$id}').on('click', function(ev) {
var il_ls_win = window.open('$url');
window._lso_current_item_lp = -1;
@@ -329,7 +334,12 @@ protected function setListenerJS(
) {
$this->additional_js =
<<keys() as $key) {
- $this[$key] = $dic[$key];
- }
-
$this["db.filesystem"] = function ($c) : ilLearningSequenceFilesystem {
return new ilLearningSequenceFilesystem();
};
diff --git a/Modules/LearningSequence/classes/class.ilLSLocalDI.php b/Modules/LearningSequence/classes/class.ilLSLocalDI.php
index 2fb7640be1b0..5ca00f049e4f 100644
--- a/Modules/LearningSequence/classes/class.ilLSLocalDI.php
+++ b/Modules/LearningSequence/classes/class.ilLSLocalDI.php
@@ -9,14 +9,11 @@
class ilLSLocalDI extends Container
{
public function init(
- ilLSDI $dic,
+ ArrayAccess $dic,
+ ilLSDI $lsdic,
DataFactory $data_factory,
ilObjLearningSequence $object
) {
- foreach ($dic->keys() as $key) {
- $this[$key] = $dic[$key];
- }
-
$ref_id = (int) $object->getRefId();
$obj_id = (int) $object->getId();
$obj_title = $object->getTitle();
@@ -36,12 +33,12 @@ public function init(
return ilContainerSorting::_getInstance($c["obj.obj_id"]);
};
- $this["db.lsitems"] = function ($c) use ($dic) : ilLSItemsDB {
+ $this["db.lsitems"] = function ($c) use ($dic, $lsdic) : ilLSItemsDB {
$online_status = new LSItemOnlineStatus();
return new ilLSItemsDB(
$dic["tree"],
$c["obj.sorting"],
- $dic["db.postconditions"],
+ $lsdic["db.postconditions"],
$online_status
);
};
@@ -53,16 +50,16 @@ public function init(
);
};
- $this["learneritems"] = function ($c) : ilLSLearnerItemsQueries {
+ $this["learneritems"] = function ($c) use ($dic, $lsdic) : ilLSLearnerItemsQueries {
return new ilLSLearnerItemsQueries(
$c["db.progress"],
- $c["db.states"],
+ $lsdic["db.states"],
$c["obj.ref_id"],
$c["usr.id"]
);
};
- $this["gui.learner"] = function ($c) use ($dic, $object) : ilObjLearningSequenceLearnerGUI {
+ $this["gui.learner"] = function ($c) use ($dic, $lsdic, $object) : ilObjLearningSequenceLearnerGUI {
$has_items = count($c["learneritems"]->getItems()) > 0;
$first_access = $c["learneritems"]->getFirstAccess();
@@ -79,7 +76,7 @@ public function init(
$dic["ui.factory"],
$dic["ui.renderer"],
$c["roles"],
- $dic["db.settings"]->getSettingsFor($c["obj.obj_id"]),
+ $lsdic["db.settings"]->getSettingsFor($c["obj.obj_id"]),
$c["player.curriculumbuilder"],
$c["player"]
);
@@ -120,11 +117,17 @@ public function init(
return new LSUrlBuilder($player_base_url);
};
+ $this["globalsetttings"] = function ($c) use ($dic) {
+ $db = new ilLSGlobalSettingsDB($dic['ilSetting']);
+ return $db->getSettings();
+ };
+
$this["player.controlbuilder"] = function ($c) use ($dic) : LSControlBuilder {
return new LSControlBuilder(
$dic["ui.factory"],
$c["player.urlbuilder"],
- $dic["lng"]
+ $dic["lng"],
+ $c["globalsetttings"]
);
};
@@ -158,7 +161,7 @@ public function init(
);
};
- $this["player"] = function ($c) use ($dic) : ilLSPlayer {
+ $this["player"] = function ($c) use ($dic, $lsdic) : ilLSPlayer {
return new ilLSPlayer(
$c["obj.title"],
$c["learneritems"],
@@ -168,7 +171,7 @@ public function init(
$c["player.viewfactory"],
$c["player.kioskrenderer"],
$dic["ui.factory"],
- $dic["gs.current_context"]
+ $lsdic["gs.current_context"]
);
};
diff --git a/Modules/LearningSequence/classes/class.ilObjLearningSequence.php b/Modules/LearningSequence/classes/class.ilObjLearningSequence.php
index ef8bde988ff6..810b40f41881 100644
--- a/Modules/LearningSequence/classes/class.ilObjLearningSequence.php
+++ b/Modules/LearningSequence/classes/class.ilObjLearningSequence.php
@@ -240,6 +240,7 @@ public function getLocalDI() : \ArrayAccess
if (is_null($this->local_di)) {
$di = new ilLSLocalDI();
$di->init(
+ $this->getDIC(),
$this->getDI(),
new \ILIAS\Data\Factory(),
$this
diff --git a/Modules/LearningSequence/classes/Settings/ilObjLearningSequenceAdmin.php b/Modules/LearningSequence/classes/class.ilObjLearningSequenceAdmin.php
similarity index 62%
rename from Modules/LearningSequence/classes/Settings/ilObjLearningSequenceAdmin.php
rename to Modules/LearningSequence/classes/class.ilObjLearningSequenceAdmin.php
index 3d62e80e30bb..1259a9aac6e3 100644
--- a/Modules/LearningSequence/classes/Settings/ilObjLearningSequenceAdmin.php
+++ b/Modules/LearningSequence/classes/class.ilObjLearningSequenceAdmin.php
@@ -1,11 +1,11 @@
-type = 'lsos';
+
+ global $DIC;
+ $this->ctrl = $DIC['ilCtrl'];
+ $this->rbacsystem = $DIC['rbacsystem'];
+ parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
+
+ $this->settings_db = new ilLSGlobalSettingsDB($DIC['ilSetting']);
+ $this->ui_factory = $DIC['ui.factory'];
+ $this->ui_renderer = $DIC['ui.renderer'];
+ $this->refinery = $DIC['refinery'];
+ $this->request = $DIC->http()->request();
+ }
+
+ public function getAdminTabs()
+ {
+ $this->tabs_gui->addTarget('settings', $this->ctrl->getLinkTargetByClass(self::class, self::CMD_EDIT));
+ if ($this->rbacsystem->checkAccess('edit_permission', $this->object->getRefId())) {
+ $this->tabs_gui->addTarget('perm_settings', $this->ctrl->getLinkTargetByClass('ilpermissiongui', 'perm'), array(), 'ilpermissiongui');
+ }
+ }
+
+ public function executeCommand()
+ {
+ $this->checkPermission('read');
+ $next_class = $this->ctrl->getNextClass($this);
+ $cmd = $this->ctrl->getCmd();
+ $this->prepareOutput();
+
+ switch ($next_class) {
+ case 'ilpermissiongui':
+ $this->tabs_gui->setTabActive('perm_settings');
+ $perm_gui = new ilPermissionGUI($this);
+ $this->ctrl->forwardCommand($perm_gui);
+ break;
+
+ default:
+ switch ($cmd) {
+ case self::CMD_VIEW:
+ case self::CMD_EDIT:
+ $this->edit();
+ break;
+ case self::CMD_SAVE:
+ $this->save();
+ break;
+ default:
+ throw new Exception(__METHOD__ . " :: Unknown command " . $cmd);
+ }
+ }
+ }
+
+ protected function getForm(array $values = []) : Input\Container\Form\Form
+ {
+ $target = $this->ctrl->getLinkTargetByClass(self::class, self::CMD_SAVE);
+ $poll_interval = $this->ui_factory->input()->field()->numeric(
+ $this->lng->txt("lso_admin_interval_label"),
+ $this->lng->txt("lso_admin_interval_byline")
+ )
+ ->withAdditionalTransformation(
+ $this->refinery->int()->isGreaterThan(0)
+ )
+ ->withAdditionalTransformation(
+ $this->refinery->custom()->transformation(
+ function ($v) {
+ return (float) $v;
+ }
+ )
+ );
+
+ if (isset($values[self::F_POLL_INTERVAL])) {
+ $poll_interval = $poll_interval->withValue($values[self::F_POLL_INTERVAL]);
+ }
+
+ $section = $this->ui_factory->input()->field()->section(
+ [self::F_POLL_INTERVAL => $poll_interval],
+ $this->lng->txt("lso_admin_form_title"),
+ $this->lng->txt("lso_admin_form_byline")
+ );
+ $form = $this->ui_factory->input()->container()->form()
+ ->standard($target, [$section])
+ ->withAdditionalTransformation(
+ $this->refinery->custom()->transformation(
+ function ($data) {
+ return array_shift($data);
+ }
+ )
+ );
+
+ return $form;
+ }
+
+ protected function show(Input\Container\Form\Form $form) : void
+ {
+ $this->tpl->setContent(
+ $this->ui_renderer->render($form)
+ );
+ }
+
+ protected function edit() : void
+ {
+ $values = [
+ self::F_POLL_INTERVAL => $this->settings_db->getSettings()->getPollingIntervalSeconds()
+ ];
+ $form = $this->getForm($values);
+ $this->show($form);
+ }
+
+ protected function save() : void
+ {
+ $form = $this->getForm()->withRequest($this->request);
+ $data = $form->getData();
+ if ($data) {
+ $settings = $this->settings_db->getSettings()
+ ->withPollingIntervalSeconds($data[self::F_POLL_INTERVAL]);
+ $this->settings_db->storeSettings($settings);
+ }
+ $this->show($form);
+ }
+}
diff --git a/Modules/LearningSequence/test/GlobalSettings/GlobalSettingsTest.php b/Modules/LearningSequence/test/GlobalSettings/GlobalSettingsTest.php
new file mode 100644
index 000000000000..021172dac823
--- /dev/null
+++ b/Modules/LearningSequence/test/GlobalSettings/GlobalSettingsTest.php
@@ -0,0 +1,35 @@
+assertEquals(
+ $interval,
+ $settings->getPollingIntervalSeconds()
+ );
+
+ return $settings;
+ }
+
+ /**
+ * @depends testConstruction
+ */
+ public function testIntervalAttribute(LSGlobalSettings $settings)
+ {
+ $interval = 2.0;
+ $settings = $settings->withPollingIntervalSeconds($interval);
+ $this->assertEquals(
+ $interval,
+ $settings->getPollingIntervalSeconds()
+ );
+ $this->assertEquals(
+ $interval * 1000,
+ $settings->getPollingIntervalMilliseconds()
+ );
+ }
+}
diff --git a/Modules/LearningSequence/test/LSControlBuilderTest.php b/Modules/LearningSequence/test/LSControlBuilderTest.php
index 138f725ed8b4..5e878b596154 100644
--- a/Modules/LearningSequence/test/LSControlBuilderTest.php
+++ b/Modules/LearningSequence/test/LSControlBuilderTest.php
@@ -22,8 +22,9 @@ public function setUp() : void
$data_factory = new DataFactory();
$uri = $data_factory->uri('http://ilias.de/somepath');
$url_builder = new LSUrlBuilder($uri);
+ $settings = new LSGlobalSettings(12);
- $this->control_builder = new LSControlBuilder($ui_factory, $url_builder, $lang);
+ $this->control_builder = new LSControlBuilder($ui_factory, $url_builder, $lang, $settings);
}
public function testConstruction()
diff --git a/Modules/LearningSequence/test/ilModulesLearningSequenceSuite.php b/Modules/LearningSequence/test/ilModulesLearningSequenceSuite.php
index 4ab199aabfbe..d2aca5a61f11 100644
--- a/Modules/LearningSequence/test/ilModulesLearningSequenceSuite.php
+++ b/Modules/LearningSequence/test/ilModulesLearningSequenceSuite.php
@@ -16,6 +16,7 @@ public static function suite()
require_once("./Modules/LearningSequence/test/Settings/LSSettingsTest.php");
require_once("./Modules/LearningSequence/test/LSItems/LSItemTest.php");
require_once("./Modules/LearningSequence/test/LearnerProgress/LSLearnerItemTest.php");
+ require_once("./Modules/LearningSequence/test/GlobalSettings/GlobalSettingsTest.php");
$suite->addTestSuite("LSControlBuilderTest");
$suite->addTestSuite("LSLocatorBuilderTest");
@@ -24,6 +25,7 @@ public static function suite()
$suite->addTestSuite("LSSettingsTest");
$suite->addTestSuite("LSItemTest");
$suite->addTestSuite("LSLearnerItemTest");
+ $suite->addTestSuite("LSGlobalSettingsTest");
return $suite;
}
diff --git a/Modules/OrgUnit/classes/Provider/OrgUnitToolProvider.php b/Modules/OrgUnit/classes/Provider/OrgUnitToolProvider.php
index 34d0ac65209d..7497eab63ce0 100644
--- a/Modules/OrgUnit/classes/Provider/OrgUnitToolProvider.php
+++ b/Modules/OrgUnit/classes/Provider/OrgUnitToolProvider.php
@@ -57,11 +57,13 @@ public function getToolsForContextStack(CalledContexts $called_contexts) : array
private function getTree() : Tree
{
global $DIC;
+ $lng = $DIC->language();
$tree = $this->getTreeRecursion();
$parent_node_id = $DIC->repositoryTree()->getParentId(ilObjOrgUnit::getRootOrgRefId());
- return $this->dic->ui()->factory()->tree()->expandable($tree)->withData($tree->getChildsOfNode($parent_node_id));
+ return $this->dic->ui()->factory()->tree()->expandable($lng->txt("org_units"), $tree)
+ ->withData($tree->getChildsOfNode($parent_node_id));
}
private function getTreeRecursion() : TreeRecursion
diff --git a/Modules/Portfolio/classes/class.ilObjPortfolioAdministrationGUI.php b/Modules/Portfolio/classes/class.ilObjPortfolioAdministrationGUI.php
index 4907be5e8567..41096d3a12a7 100644
--- a/Modules/Portfolio/classes/class.ilObjPortfolioAdministrationGUI.php
+++ b/Modules/Portfolio/classes/class.ilObjPortfolioAdministrationGUI.php
@@ -161,7 +161,6 @@ public function saveSettings()
$banner = (bool) $form->getInput("banner");
$prfa_set = new ilSetting("prfa");
- $prfa_set->set("pd_block", (bool) $form->getInput("pd_block"));
$prfa_set->set("banner", $banner);
$prfa_set->set("banner_width", (int) $form->getInput("width"));
$prfa_set->set("banner_height", (int) $form->getInput("height"));
@@ -217,11 +216,6 @@ protected function initFormSettings()
$prfa_set = new ilSetting("prfa");
- $pdblock = new ilCheckboxInputGUI($lng->txt("prtf_pd_block"), "pd_block");
- $pdblock->setInfo($lng->txt("prtf_pd_block_info"));
- $pdblock->setChecked($prfa_set->get("pd_block", false));
- $form->addItem($pdblock);
-
$banner = new ilCheckboxInputGUI($lng->txt("prtf_preview_banner"), "banner");
$banner->setInfo($lng->txt("prtf_preview_banner_info"));
$form->addItem($banner);
diff --git a/Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModuleGUI.php b/Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModuleGUI.php
index 11f466153ba7..f522c1cf8890 100755
--- a/Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModuleGUI.php
+++ b/Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModuleGUI.php
@@ -2010,7 +2010,7 @@ public function insertChapter($a_redirect = true)
$chap_ids[] = $chap->getId();
}
$chap_ids = array_reverse($chap_ids);
- $chap_ids = implode($chap_ids, ":");
+ $chap_ids = implode(":", $chap_ids);
if ($a_redirect) {
$ilCtrl->setParameter($this, "highlight", $chap_ids);
@@ -2057,7 +2057,7 @@ public function insertSco($a_redirect = true)
$sco_ids[] = $sco->getId();
}
$sco_ids = array_reverse($sco_ids);
- $sco_ids = implode($sco_ids, ":");
+ $sco_ids = implode(":", $sco_ids);
if ($a_redirect) {
$ilCtrl->setParameter($this, "highlight", $sco_ids);
@@ -2104,7 +2104,7 @@ public function insertAsset($a_redirect = true)
$ass_ids[] = $ass->getId();
}
$ass_ids = array_reverse($ass_ids);
- $ass_ids = implode($ass_ids, ":");
+ $ass_ids = implode(":", $ass_ids);
if ($a_redirect) {
$ilCtrl->setParameter($this, "highlight", $ass_ids);
@@ -2150,7 +2150,7 @@ public function insertPage($a_redirect = true)
$page_ids[] = $page->getId();
}
$page_ids = array_reverse($page_ids);
- $page_ids = implode($page_ids, ":");
+ $page_ids = implode(":", $page_ids);
if ($a_redirect) {
$ilCtrl->setParameter($this, "highlight", $page_ids);
@@ -2403,7 +2403,7 @@ public function insertTemplate($a_redirect = true)
$page_ids[] = $page->getId();
}
$page_ids = array_reverse($page_ids);
- $page_ids = implode($page_ids, ":");
+ $page_ids = implode(":", $page_ids);
if ($a_redirect) {
if ($_GET["obj_id"] != "") {
diff --git a/Modules/ScormAicc/classes/SCORM/class.ilObjSCORMTracking.php b/Modules/ScormAicc/classes/SCORM/class.ilObjSCORMTracking.php
index 5a34e28481b9..1993a75a6088 100755
--- a/Modules/ScormAicc/classes/SCORM/class.ilObjSCORMTracking.php
+++ b/Modules/ScormAicc/classes/SCORM/class.ilObjSCORMTracking.php
@@ -277,8 +277,6 @@ public static function syncGlobalStatus($userId, $packageId, $data, $new_global_
$saved_global_status = $data->saved_global_status;
$ilLog->write("saved_global_status=" . $saved_global_status);
- //last_visited!
-
// get attempts
if (!$data->packageAttempts) {
$val_set = $ilDB->queryF(
@@ -299,9 +297,9 @@ public static function syncGlobalStatus($userId, $packageId, $data, $new_global_
$totalTime = (int) $data->totalTimeCentisec;
$totalTime = round($totalTime / 100);
$ilDB->queryF(
- 'UPDATE sahs_user SET sco_total_time_sec=%s, status=%s, percentage_completed=%s, package_attempts=%s WHERE obj_id = %s AND user_id = %s',
- array('integer', 'integer', 'integer', 'integer', 'integer', 'integer'),
- array($totalTime, $new_global_status, $data->percentageCompleted, $attempts, $packageId, $userId)
+ 'UPDATE sahs_user SET last_visited=%s, last_access = %s, sco_total_time_sec=%s, status=%s, percentage_completed=%s, package_attempts=%s WHERE obj_id = %s AND user_id = %s',
+ array('text', 'timestamp', 'integer', 'integer', 'integer', 'integer', 'integer', 'integer'),
+ array($data->last_visited, date('Y-m-d H:i:s'), $totalTime, $new_global_status, $data->percentageCompleted, $attempts, $packageId, $userId)
);
// self::ensureObjectDataCacheExistence();
diff --git a/Modules/ScormAicc/classes/class.ilObjSAHSLearningModuleGUI.php b/Modules/ScormAicc/classes/class.ilObjSAHSLearningModuleGUI.php
index 0a96c94695ff..4ec323e9ba36 100755
--- a/Modules/ScormAicc/classes/class.ilObjSAHSLearningModuleGUI.php
+++ b/Modules/ScormAicc/classes/class.ilObjSAHSLearningModuleGUI.php
@@ -640,10 +640,10 @@ public function certificate()
public function getTabs()
{
global $DIC;
- $rbacsystem = $DIC['rbacsystem'];
$ilCtrl = $DIC['ilCtrl'];
$ilHelp = $DIC['ilHelp'];
-
+ $ilAccess = $DIC->access();
+
if ($this->ctrl->getCmd() == "delete") {
return;
}
@@ -692,7 +692,7 @@ public function getTabs()
// learning progress and offline mode
include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
- if (ilLearningProgressAccess::checkAccess($this->object->getRefId()) || $rbacsystem->checkAccess("edit_permission", "", $this->object->getRefId())) {
+ if (ilLearningProgressAccess::checkAccess($this->object->getRefId()) || $ilAccess->checkAccess("write", "", $this->object->getRefId())) {
//if scorm && offline_mode activated
if ($this->object->getSubType() == "scorm2004" || $this->object->getSubType() == "scorm") {
if ($this->object->getOfflineMode() == true) {
@@ -715,7 +715,7 @@ public function getTabs()
}
// tracking data
- if ($rbacsystem->checkAccess("read_learning_progress", $this->object->getRefId()) || $rbacsystem->checkAccess("edit_learning_progress", $this->object->getRefId())) {
+ if ($ilAccess->checkAccess("read_learning_progress", '', $this->object->getRefId()) || $ilAccess->checkAccess("edit_learning_progress", '', $this->object->getRefId())) {
if ($this->object->getSubType() == "scorm2004" || $this->object->getSubType() == "scorm") {
include_once('./Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
$privacy = ilPrivacySettings::_getInstance();
@@ -744,7 +744,7 @@ public function getTabs()
}
// export
- if ($rbacsystem->checkAccess("edit_permission", "", $this->object->getRefId())) {
+ if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
$this->tabs_gui->addTarget(
"export",
$this->ctrl->getLinkTarget($this, "export"),
@@ -754,7 +754,7 @@ public function getTabs()
}
// perm
- if ($rbacsystem->checkAccess('edit_permission', $this->object->getRefId())) {
+ if ($ilAccess->checkAccess('edit_permission', '', $this->object->getRefId())) {
$this->tabs_gui->addTarget(
"perm_settings",
$this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"),
diff --git a/Modules/ScormAicc/scripts/basisAPI.js b/Modules/ScormAicc/scripts/basisAPI.js
index e3b0928bd0d1..62a4122de377 100644
--- a/Modules/ScormAicc/scripts/basisAPI.js
+++ b/Modules/ScormAicc/scripts/basisAPI.js
@@ -77,7 +77,7 @@ function sendRequest (url, data, callback, user, password, headers) {
}
function useSendBeacon() {
- if (navigator.userAgent.indexOf("Chrome") > -1) {
+ if (navigator.userAgent.indexOf("Chrom") > -1) {
if (typeof(window.sahs_content) != "undefined" && typeof(window.sahs_content.event) != "undefined" && (window.sahs_content.event.type=="unload" || window.sahs_content.event.type=="beforeunload")) {
var raw = navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);
var version = raw ? parseInt(raw[2], 10) : false;
@@ -316,6 +316,8 @@ function IliasCommit() {
}
var s_s="",a_tmp,s_v,a_cmiTmp,i_numCompleted=0,b_statusFailed=false;
var LP_STATUS_IN_PROGRESS_NUM=1, LP_STATUS_COMPLETED_NUM=2,LP_STATUS_FAILED_NUM=3;
+ $last_visited = "";
+ if (iv.b_autoLastVisited==true) $last_visited = iv.launchId;
var o_data={
"cmi":[],
"saved_global_status":iv.status.saved_global_status,
@@ -324,7 +326,8 @@ function IliasCommit() {
"lp_mode":iv.status.lp_mode,
"hash":iv.status.hash,
"p":iv.status.p,
- "totalTimeCentisec":0
+ "totalTimeCentisec":0,
+ "last_visited":$last_visited
};
for (var i=0; iapplyToSubTreeNodes(
+ function (ilObjStudyProgramme $prg) use (&$ret) {
+ if ($prg->getId() == $this->getId()) {
+ return;
+ }
+ $ret[] = $prg;
+ },
+ false
+ );
+ return $ret;
+ }
+
/**
* Get all ilObjStudyProgrammes that are direct children of this
* object.
diff --git a/Modules/StudyProgramme/classes/class.ilObjStudyProgrammeMembersGUI.php b/Modules/StudyProgramme/classes/class.ilObjStudyProgrammeMembersGUI.php
index d17a2d86cd8d..725da4d622bf 100644
--- a/Modules/StudyProgramme/classes/class.ilObjStudyProgrammeMembersGUI.php
+++ b/Modules/StudyProgramme/classes/class.ilObjStudyProgrammeMembersGUI.php
@@ -950,18 +950,14 @@ public function mayManageMembers() : bool
);
}
- public function getLocalMembers(): array
+ public function getLocalMembers() : array
{
return $this->object->getMembers();
}
- public function isOperationAllowedForUser(int $usr_id, string $operation): bool
+ public function isOperationAllowedForUser(int $usr_id, string $operation) : bool
{
- $ret = $this->position_based_access->isUserAccessibleForOperationAtPrg(
- $usr_id,
- $this->object,
- $operation
- );
- return $ret;
+ return $this->mayManageMembers()
+ || $this->position_based_access->isUserAccessibleForOperationAtPrg($usr_id, $this->object, $operation);
}
}
diff --git a/Modules/StudyProgramme/classes/class.ilStudyProgrammeDashboardViewGUI.php b/Modules/StudyProgramme/classes/class.ilStudyProgrammeDashboardViewGUI.php
index 0c10af9b5a71..738acf530125 100644
--- a/Modules/StudyProgramme/classes/class.ilStudyProgrammeDashboardViewGUI.php
+++ b/Modules/StudyProgramme/classes/class.ilStudyProgrammeDashboardViewGUI.php
@@ -88,8 +88,10 @@ public function getHTML() : string
continue;
}
+ $current_prg = $current->getStudyProgramme();
+
/** @var ilStudyProgrammeSettings $current_prg_settings */
- $current_prg_settings = $current->getStudyProgramme()->getRawSettings();
+ $current_prg_settings = $current_prg->getRawSettings();
/** @var ilStudyProgrammeUserProgress $current_progress */
$current_progress = $current->getRootProgress();
@@ -97,9 +99,8 @@ public function getHTML() : string
list($valid, $validation_date) = $this->findValidationValues($assignments);
list($minimum_percents, $current_percents) = $this->calculatePercent(
- $current_prg_settings->getAssessmentSettings()->getPoints(),
- $current_progress->getCurrentAmountOfPoints(),
- (int) $current->getStudyProgramme()->getRefId()
+ $current_prg,
+ $current_progress->getCurrentAmountOfPoints()
);
$current_status = $current_progress->getStatus();
@@ -128,7 +129,6 @@ public function getHTML() : string
}
$items[] = $this->buildItem($current->getStudyProgramme(), $properties);
- ;
}
if (count($items) == 0) {
@@ -288,25 +288,32 @@ protected function txt(string $code) : string
return $this->lng->txt($code);
}
- protected function calculatePercent(int $points, int $current_points, int $prg_ref_id) : array
+ protected function calculatePercent(ilObjStudyProgramme $prg, int $current_points) : array
{
- $children = ilObjStudyProgramme::getAllChildren($prg_ref_id);
- $max_points = 0;
- /** @var ilObjStudyProgramme $child */
- foreach ($children as $child) {
- $max_points += $child->getRawSettings()->getAssessmentSettings()->getPoints();
- }
-
$minimum_percents = 0;
$current_percents = 0;
- if ($max_points > 0) {
- $minimum_percents = round((100 * $points / $max_points), 2);
- $current_percents = round((100 * $current_points / $max_points), 2);
- }
- if ($max_points == 0 && $points == 0) {
+ if ($prg->hasLPChildren()) {
$minimum_percents = 100;
- $current_percents = 100;
+ if ($current_points > 0) {
+ $current_percents = 100;
+ }
+ }
+
+ $children = $prg->getAllPrgChildren();
+ if (count($children) > 0) {
+ $max_points = 0;
+ foreach ($children as $child) {
+ $max_points += $child->getPoints();
+ }
+
+ if ($max_points > 0) {
+ $prg_points = $prg->getPoints();
+ $minimum_percents = round((100 * $prg_points / $max_points), 2);
+ }
+ if ($current_points > 0) {
+ $current_percents = round((100 * $current_points / $max_points), 2);
+ }
}
return [
@@ -315,6 +322,7 @@ protected function calculatePercent(int $points, int $current_points, int $prg_r
];
}
+
/**
* @throws ilException
*/
diff --git a/Modules/StudyProgramme/classes/class.ilStudyProgrammeMembersTableGUI.php b/Modules/StudyProgramme/classes/class.ilStudyProgrammeMembersTableGUI.php
index 885283877a8d..eed296b0664f 100644
--- a/Modules/StudyProgramme/classes/class.ilStudyProgrammeMembersTableGUI.php
+++ b/Modules/StudyProgramme/classes/class.ilStudyProgrammeMembersTableGUI.php
@@ -293,22 +293,20 @@ protected function buildActionDropDown(
$access_by_position = $this->isPermissionControlledByOrguPosition();
$parent = $this->getParentObject();
- $view_individual_plan =
- $access_by_position == false ||
- $parent->isOperationAllowedForUser($usr_id, ilOrgUnitOperation::OP_VIEW_INDIVIDUAL_PLAN)
- ;
+ $view_individual_plan = $parent->isOperationAllowedForUser(
+ $usr_id,
+ ilOrgUnitOperation::OP_VIEW_INDIVIDUAL_PLAN
+ );
- $edit_individual_plan =
- $access_by_position == false ||
- $parent->isOperationAllowedForUser($usr_id, ilOrgUnitOperation::OP_VIEW_INDIVIDUAL_PLAN)
- ;
+ $edit_individual_plan = $parent->isOperationAllowedForUser(
+ $usr_id,
+ ilOrgUnitOperation::OP_VIEW_INDIVIDUAL_PLAN
+ );
- $manage_members =
- ( $access_by_position == false ||
- $parent->isOperationAllowedForUser($usr_id, ilOrgUnitOperation::OP_MANAGE_MEMBERS)
- ) &&
- in_array($usr_id, $this->getParentObject()->getLocalMembers())
- ;
+ $manage_members = $parent->isOperationAllowedForUser(
+ $usr_id,
+ ilOrgUnitOperation::OP_MANAGE_MEMBERS
+ ) && in_array($usr_id, $this->getParentObject()->getLocalMembers());
foreach ($actions as $action) {
switch ($action) {
diff --git a/Modules/StudyProgramme/test/ilModulesStudyProgrammeSuite.php b/Modules/StudyProgramme/test/ilModulesStudyProgrammeSuite.php
index 3e66bab2a40b..06f35e638ce7 100644
--- a/Modules/StudyProgramme/test/ilModulesStudyProgrammeSuite.php
+++ b/Modules/StudyProgramme/test/ilModulesStudyProgrammeSuite.php
@@ -59,6 +59,7 @@ public static function suite()
require_once("./Modules/StudyProgramme/test/ilStudyProgrammeDeadlineSettingsTest.php");
require_once("./Modules/StudyProgramme/test/ilStudyProgrammeTypeSettingsTest.php");
require_once("./Modules/StudyProgramme/test/types/ilStudyProgrammeTypeInfoTest.php");
+ require_once("./Modules/StudyProgramme/test/ilStudyProgrammeDashGUITest.php");
$suite->addTestSuite("ilObjStudyProgrammeTest");
$suite->addTestSuite("ilStudyProgrammeEventsTest");
$suite->addTestSuite("ilStudyProgrammeLPTest");
@@ -83,6 +84,7 @@ public static function suite()
$suite->addTestSuite("ilStudyProgrammeDeadlineSettingsTest");
$suite->addTestSuite("ilStudyProgrammeTypeSettingsTest");
$suite->addTestSuite("ilStudyProgrammeTypeInfoTest");
+ $suite->addTestSuite("ilStudyProgrammeDashGUITest");
return $suite;
}
}
diff --git a/Modules/StudyProgramme/test/ilObjStudyProgrammeTest.php b/Modules/StudyProgramme/test/ilObjStudyProgrammeTest.php
index fd1335978c73..829e5ae269e2 100644
--- a/Modules/StudyProgramme/test/ilObjStudyProgrammeTest.php
+++ b/Modules/StudyProgramme/test/ilObjStudyProgrammeTest.php
@@ -307,6 +307,15 @@ public function testTreeGetChildren()
$this->assertEquals(0, count($children[0]->getChildren()));
}
+ public function testTreeGetAllPrgChildren()
+ {
+ $this->createSmallTree();
+ $this->assertEquals(
+ 4,
+ $this->root_object->getAllPrgChildren()
+ );
+ }
+
/**
* Test getParent on ilObjStudyProgramme
*
diff --git a/Modules/StudyProgramme/test/ilStudyProgrammeDashGUITest.php b/Modules/StudyProgramme/test/ilStudyProgrammeDashGUITest.php
new file mode 100644
index 000000000000..363e46ba8688
--- /dev/null
+++ b/Modules/StudyProgramme/test/ilStudyProgrammeDashGUITest.php
@@ -0,0 +1,122 @@
+ Extended GPL, see docs/LICENSE */
+
+use PHPUnit\Framework\TestCase;
+
+/**
+ * Encapsulation of GUI
+ */
+class mockSPRGDashGUI extends ilStudyProgrammeDashboardViewGUI
+{
+ public function __construct()
+ {
+ }
+
+ public function mockCalculatePercent($prg, int $current_points)
+ {
+ return $this->calculatePercent($prg, $current_points);
+ }
+}
+
+/**
+ * TestCase for SPRG-Section of dashboard
+ */
+class ilStudyProgrammeDashGUITest extends TestCase
+{
+ protected function setUp() : void
+ {
+ $this->gui = new mockSPRGDashGUI();
+ $this->prg = $this->getMockBuilder(ilObjStudyProgramme::class)
+ ->disableOriginalConstructor()
+ ->setMethods([
+ 'hasLPChildren',
+ 'getAllPrgChildren',
+ 'getPoints'
+ ])
+ ->getMock();
+ }
+
+ public function userPointsDataProvider()
+ {
+ return [
+ 'zero' => [0, 0],
+ 'one' => [1, 0.63],
+ 'ten' => [10, 6.25],
+ 'fiftyfive' => [55, 34.38],
+ 'hundred' => [100, 62.5],
+ 'oneOone' => [101, 63.13],
+ 'onesixty' => [160, 100]
+ ];
+ }
+
+ /**
+ * @dataProvider userPointsDataProvider
+ */
+ public function testPercentageWithoutChildren(int $current_user_points)
+ {
+ $this->prg->method('hasLPChildren')
+ ->willReturn(false);
+ $this->prg->method('getAllPrgChildren')
+ ->willReturn([]);
+
+ list($minimum_percents, $current_percents)
+ = $this->gui->mockCalculatePercent($this->prg, $current_user_points);
+
+ $this->assertEquals(0, $minimum_percents);
+ $this->assertEquals(0, $current_percents);
+ }
+
+ /**
+ * @dataProvider userPointsDataProvider
+ */
+ public function testPercentageWithCoursesAtTopLevel(int $current_user_points)
+ {
+ $this->prg->method('hasLPChildren')
+ ->willReturn(true);
+
+ list($minimum_percents, $current_percents)
+ = $this->gui->mockCalculatePercent($this->prg, $current_user_points);
+
+ $this->assertEquals(100, $minimum_percents);
+ if ($current_user_points == 0) {
+ $this->assertEquals(0, $current_percents);
+ }
+ if ($current_user_points > 0) {
+ $this->assertEquals(100, $current_percents);
+ }
+ }
+
+ /**
+ * @dataProvider userPointsDataProvider
+ */
+ public function testPercentageWithPrograms(int $current_user_points, float $expected)
+ {
+ $node = $this->getMockBuilder(ilObjStudyProgramme::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['getPoints'])
+ ->getMock();
+
+ $node1 = clone $node;
+ $node1->method('getPoints')->willReturn(100);
+ $node2 = clone $node;
+ $node2->method('getPoints')->willReturn(50);
+ $node3 = clone $node;
+ $node3->method('getPoints')->willReturn(5);
+ $node4 = clone $node;
+ $node4->method('getPoints')->willReturn(5);
+
+ $this->prg->method('hasLPChildren')
+ ->willReturn(false);
+ $this->prg->method('getAllPrgChildren')
+ ->willReturn([$node1, $node2, $node3, $node4]);
+
+ $this->prg->method('getPoints')->willReturn(60);
+
+ list($minimum_percents, $current_percents)
+ = $this->gui->mockCalculatePercent($this->prg, $current_user_points);
+
+ $this->assertEquals(37.5, $minimum_percents); //37.5 = (160 max points / 60 root-prg points) * 100
+ $this->assertEquals($expected, $current_percents);
+ }
+}
diff --git a/Modules/Survey/Evaluation/class.ilSurveyEvaluationGUI.php b/Modules/Survey/Evaluation/class.ilSurveyEvaluationGUI.php
index 124995ba5648..e3bf08ed0c4e 100644
--- a/Modules/Survey/Evaluation/class.ilSurveyEvaluationGUI.php
+++ b/Modules/Survey/Evaluation/class.ilSurveyEvaluationGUI.php
@@ -447,7 +447,7 @@ public function exportCumulatedResults($details = 0)
$separator = ";";
foreach ($csvfile as $csvrow) {
$csvrow = $this->processCSVRow($csvrow, true, $separator);
- $csv .= join($csvrow, $separator) . "\n";
+ $csv .= join($separator, $csvrow) . "\n";
}
ilUtil::deliverData($csv, $surveyname . ".csv");
exit();
@@ -724,7 +724,7 @@ protected function buildExportModal($a_id, $a_cmd)
return $modal->getHTML();
}
- public function evaluation($details = 0)
+ public function evaluation($details = 0, $pdf = false, $return_pdf = false)
{
$rbacsystem = $this->rbacsystem;
$ilToolbar = $this->toolbar;
@@ -947,6 +947,15 @@ public function evaluation($details = 0)
$this->log->debug("end");
+ if ($pdf) {
+ $html = $this->tpl->printToString();
+ if ($return_pdf) {
+ return $html;
+ } else {
+ $this->generateAndSendPDF($html);
+ }
+ }
+
// $this->tpl->addCss("./Modules/Survey/templates/default/survey_print.css", "print");
}
@@ -1370,7 +1379,7 @@ public function exportEvaluationUser()
$separator = ";";
foreach ($rows as $csvrow) {
$csvrow = str_replace("\n", " ", $this->processCSVRow($csvrow, true, $separator));
- $csv .= join($csvrow, $separator) . "\n";
+ $csv .= join($separator, $csvrow) . "\n";
}
ilUtil::deliverData($csv, "$surveyname.csv");
exit();
@@ -1665,32 +1674,14 @@ protected function hasResultsAccess()
return $this->access->checkRbacOrPositionPermissionAccess('read_results', 'access_results', $this->object->getRefId());
}
- //
- // PATCH BGHW
- //
-
public function evaluationpdf()
{
- $this->ctrl->setParameter($this, "pdf", 1);
- $this->ctrl->setParameter($this, "cp", $_GET["cp"]);
- $this->ctrl->setParameter($this, "vw", $_GET["vw"]);
- $this->callPhantom(
- $this->ctrl->getLinkTarget($this, "evaluation", "", false, false),
- "pdf",
- $this->object->getTitle() . ".pdf"
- );
+ $this->evaluation(0, true);
}
public function evaluationdetailspdf()
{
- $this->ctrl->setParameter($this, "pdf", 1);
- $this->ctrl->setParameter($this, "cp", $_GET["cp"]);
- $this->ctrl->setParameter($this, "vw", $_GET["vw"]);
- $this->callPhantom(
- $this->ctrl->getLinkTarget($this, "evaluationdetails", "", false, false),
- "pdf",
- $this->object->getTitle() . ".pdf"
- );
+ $this->evaluation(1, true);
}
public function downloadChart()
@@ -1700,14 +1691,7 @@ public function downloadChart()
return;
}
- $this->ctrl->setParameter($this, "qid", $qid);
- $url = $this->ctrl->getLinkTarget($this, "renderChartOnly", "", false, false);
- $this->ctrl->setParameter($this, "qid", "");
-
- include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
- $file = $this->object->getTitle() . " - " . SurveyQuestion::_getTitle($qid);
-
- $this->callPhantom($url, "png", $file . ".png");
+ $this->renderChartOnly();
}
public function renderChartOnly()
@@ -1729,7 +1713,6 @@ public function renderChartOnly()
}
// parse answer data in evaluation results
- include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
foreach ($this->object->getSurveyQuestions() as $qdata) {
if ($qid == $qdata["question_id"]) {
$q_eval = SurveyQuestion::_instanciateQuestionEvaluation($qdata["question_id"], $finished_ids);
@@ -1758,26 +1741,37 @@ public function renderChartOnly()
}
// "print view"
- $ptpl = new ilTemplate("tpl.main.html", true, true);
- foreach ($tpl->css_files as $css) {
- $ptpl->setCurrentBlock("css_file");
- $ptpl->setVariable("CSS_FILE", $css["file"]);
- $ptpl->setVariable("CSS_MEDIA", $css["media"]);
- $ptpl->parseCurrentBlock();
- }
- foreach ($tpl->js_files as $js) {
- $ptpl->setCurrentBlock("js_file");
- $ptpl->setVariable("JS_FILE", $js);
- $ptpl->parseCurrentBlock();
- }
- $ptpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
- $ptpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilUtil::getNewContentStyleSheetLocation());
- $ptpl->setVariable("CONTENT", $dtmpl->get());
- echo $ptpl->get();
- exit();
+ $this->tpl->setContent($dtmpl->get());
+
+ $html = $this->tpl->printToString();
+ $this->generateAndSendPDF($html, $this->object->getTitle() . " - " . SurveyQuestion::_getTitle($qid).".pdf");
+ }
+
+ /**
+ *
+ * @param $html
+ * @param $filename
+ * @throws Exception
+ */
+ public function generateAndSendPDF($html, $filename = "")
+ {
+ // :TODO: fixing css dummy parameters
+ $html = preg_replace("/\?dummy\=[0-9]+/", "", $html);
+ $html = preg_replace("/\?vers\=[0-9A-Za-z\-]+/", "", $html);
+ $html = str_replace('.css$Id$', ".css", $html);
+ $html = preg_replace("/src=\"\\.\\//ims", "src=\"" . ILIAS_HTTP_PATH . "/", $html);
+ $html = preg_replace("/href=\"\\.\\//ims", "href=\"" . ILIAS_HTTP_PATH . "/", $html);
+
+ //echo $html; exit;
+
+ if ($filename == "") {
+ $filename = $this->object->getTitle() . ".pdf";
+ }
+ $pdf_factory = new ilHtmlToPdfTransformerFactory();
+ $pdf_factory->deliverPDFFromHTMLString($html, $filename, ilHtmlToPdfTransformerFactory::PDF_OUTPUT_DOWNLOAD, "Survey", "Results");
}
- public function callPhantom($a_url, $a_suffix, $a_filename, $a_return = false)
+ public function callPdfGeneration($a_url, $a_suffix, $a_filename, $a_return = false)
{
$script = ILIAS_ABSOLUTE_PATH . "/Modules/Survey/js/phantom.js";
diff --git a/Modules/Survey/Mail/FormMailCodesGUI.php b/Modules/Survey/Mail/FormMailCodesGUI.php
index bfb8c8d9cbcc..199e9712bc9b 100644
--- a/Modules/Survey/Mail/FormMailCodesGUI.php
+++ b/Modules/Survey/Mail/FormMailCodesGUI.php
@@ -74,7 +74,7 @@ public function __construct($guiclass)
$this->mailmessage->setRequired(true);
$this->mailmessage->setCols(80);
$this->mailmessage->setRows(10);
- $this->mailmessage->setInfo(sprintf($this->lng->txt('message_content_info'), join($existingcolumns, ', ')));
+ $this->mailmessage->setInfo(sprintf($this->lng->txt('message_content_info'), join(', ', $existingcolumns)));
$this->addItem($this->mailmessage);
// save message
diff --git a/Modules/Survey/Participants/class.ilSurveyParticipantsGUI.php b/Modules/Survey/Participants/class.ilSurveyParticipantsGUI.php
index 458f21640333..91494f720123 100644
--- a/Modules/Survey/Participants/class.ilSurveyParticipantsGUI.php
+++ b/Modules/Survey/Participants/class.ilSurveyParticipantsGUI.php
@@ -1470,7 +1470,7 @@ public function initMailRatersForm($appr_id, array $rec_ids)
$mailmessage_a->setRequired(true);
$mailmessage_a->setCols(80);
$mailmessage_a->setRows(10);
- $mailmessage_a->setInfo(sprintf($this->lng->txt('message_content_info'), join($existingcolumns, ', ')));
+ $mailmessage_a->setInfo(sprintf($this->lng->txt('message_content_info'), join(', ', $existingcolumns)));
$form->addItem($mailmessage_a);
$recf = new ilHiddenInputGUI("rtr_id");
diff --git a/Modules/Survey/README.md b/Modules/Survey/README.md
index cc6185e607df..4038c4f08e19 100644
--- a/Modules/Survey/README.md
+++ b/Modules/Survey/README.md
@@ -7,6 +7,11 @@
This component does currently not offer any public services.
+# PDF Generation
+
+- If wkhtmltopdf is being used you must set the "Use print media type instead of screen" flag.
+- Both PhantomJS and wkhtmltopdf struggle with canvas rendering, see e.g. https://github.com/wkhtmltopdf/wkhtmltopdf/issues/1964
+
# Internal Documentation
This section documents the general concepts and structures of the Survey Module. These are internal implementations which SHOULD not be used outside of this module unless mentioned in the API section of this README.
diff --git a/Modules/Survey/classes/class.SurveySearch.php b/Modules/Survey/classes/class.SurveySearch.php
index 77ca07491778..1b9ce2dc3470 100755
--- a/Modules/Survey/classes/class.SurveySearch.php
+++ b/Modules/Survey/classes/class.SurveySearch.php
@@ -156,13 +156,13 @@ public function search()
}
$cumulated_fields = array();
foreach ($fields as $params) {
- array_push($cumulated_fields, "(" . join($params, " OR ") . ")");
+ array_push($cumulated_fields, "(" . join(" OR ", $params) . ")");
}
$str_where = "";
if ($this->concatenation == self::CONCAT_AND) {
- $str_where = "(" . join($cumulated_fields, " AND ") . ")";
+ $str_where = "(" . join(" AND ", $cumulated_fields) . ")";
} else {
- $str_where = "(" . join($cumulated_fields, " OR ") . ")";
+ $str_where = "(" . join(" OR ", $cumulated_fields) . ")";
}
if ($str_where) {
$str_where = " AND $str_where";
diff --git a/Modules/Survey/classes/class.ilObjSurvey.php b/Modules/Survey/classes/class.ilObjSurvey.php
index 350503ed7fb9..7e0c52bccdb7 100755
--- a/Modules/Survey/classes/class.ilObjSurvey.php
+++ b/Modules/Survey/classes/class.ilObjSurvey.php
@@ -1298,7 +1298,7 @@ public function getAuthor()
}
}
}
- return join($author, ",");
+ return join(",", $author);
}
/**
@@ -3199,7 +3199,7 @@ public function getQuestionblocksTable($arrFilter)
"questionblock_id" => $row["questionblock_id"],
"title" => $row["title"],
"svy" => $surveytitles[$row["obj_fi"]],
- "contains" => join($questions_array, ", "),
+ "contains" => join(", ", $questions_array),
"owner" => $row["owner_fi"]
);
}
@@ -6127,19 +6127,24 @@ public function sendTutorResults()
$ilCtrl->setParameterByClass("ilSurveyEvaluationGUI", "ref_id", $this->getRefId());
- include_once "./Modules/Survey/classes/class.ilSurveyEvaluationGUI.php";
$gui = new ilSurveyEvaluationGUI($this);
+
$url = $ilCtrl->getLinkTargetByClass(array("ilObjSurveyGUI", "ilSurveyEvaluationGUI"), "evaluationdetails", "", false, false);
+ $html = $gui->evaluation(1, true, true);
+
$_GET["ref_id"] = $old_ref_id;
$_GET["baseClass"] = $old_base_class;
+ $pdf_factory = new ilHtmlToPdfTransformerFactory();
+ $pdf = $pdf_factory->deliverPDFFromHTMLString($html, "survey.pdf", ilHtmlToPdfTransformerFactory::PDF_OUTPUT_FILE, "Survey", "Results");
+ /*
$log->debug("calling phantom for ref_id: " . $this->getRefId());
- $pdf = $gui->callPhantom($url, "pdf", true, true);
+ $pdf = $gui->callPdfGeneration($url, "pdf", true, true);
- $log->debug("phantom called : " . $pdf);
+ $log->debug("phantom called : " . $pdf);*/
if (!$pdf ||
!file_exists($pdf)) {
@@ -6167,14 +6172,13 @@ public function sendTutorResults()
$mail_obj = new ilMail(ANONYMOUS_USER_ID);
$mail_obj->appendInstallationSignature(true);
$log->debug("send mail to user id: " . $user_id . ",login: " . ilObjUser::_lookupLogin($user_id));
- $mail_obj->sendMail(
+ $mail_obj->enqueue(
ilObjUser::_lookupLogin($user_id),
"",
"",
$subject,
$message,
- array($att),
- array("system")
+ array($att)
);
}
diff --git a/Modules/Survey/classes/class.ilObjSurveyGUI.php b/Modules/Survey/classes/class.ilObjSurveyGUI.php
index 0378a01d27c3..fdf70b01d5ce 100755
--- a/Modules/Survey/classes/class.ilObjSurveyGUI.php
+++ b/Modules/Survey/classes/class.ilObjSurveyGUI.php
@@ -1769,12 +1769,8 @@ public function infoScreen()
// :TODO: really save in session?
$_SESSION["anonymous_id"][$this->object->getId()] = $anonymous_code;
- if (ilObjSurvey::RESULTS_SELF_EVAL_ALL) {
- $survey_started = $this->object->isSurveyStarted($ilUser->getId(), $anonymous_code, $ilUser->getId());
- } else {
- $survey_started = $this->object->isSurveyStarted($ilUser->getId(), $anonymous_code);
- }
-
+ $survey_started = $this->object->isSurveyStarted($ilUser->getId(), $anonymous_code);
+
$showButtons = $big_button = false;
// already finished?
diff --git a/Modules/Survey/module.xml b/Modules/Survey/module.xml
index 8a15eee2d9ad..02fd603c5c80 100644
--- a/Modules/Survey/module.xml
+++ b/Modules/Survey/module.xml
@@ -28,4 +28,7 @@
+
+
+
diff --git a/Modules/SurveyQuestionPool/Phrases/class.ilSurveyPhrasesGUI.php b/Modules/SurveyQuestionPool/Phrases/class.ilSurveyPhrasesGUI.php
index a4c4e0a9079a..2cd1ed6a470f 100755
--- a/Modules/SurveyQuestionPool/Phrases/class.ilSurveyPhrasesGUI.php
+++ b/Modules/SurveyQuestionPool/Phrases/class.ilSurveyPhrasesGUI.php
@@ -150,7 +150,7 @@ public function phrases()
$data = array();
foreach ($phrases as $phrase_id => $phrase_array) {
$categories = &ilSurveyPhrases::_getCategoriesForPhrase($phrase_id);
- array_push($data, array('phrase_id' => $phrase_id, 'phrase' => $phrase_array["title"], 'answers' => join($categories, ", ")));
+ array_push($data, array('phrase_id' => $phrase_id, 'phrase' => $phrase_array["title"], 'answers' => join(", ", $categories)));
}
$table_gui->setData($data);
$this->tpl->setContent($table_gui->getHTML());
@@ -225,7 +225,7 @@ public function deletePhrasesForm($checked_phrases)
foreach ($checked_phrases as $phrase_id) {
$phrase_array = $phrases[$phrase_id];
$categories = &ilSurveyPhrases::_getCategoriesForPhrase($phrase_id);
- array_push($data, array('phrase_id' => $phrase_id, 'phrase' => $phrase_array["title"], 'answers' => join($categories, ", ")));
+ array_push($data, array('phrase_id' => $phrase_id, 'phrase' => $phrase_array["title"], 'answers' => join(", ", $categories)));
}
$table_gui->setData($data);
$this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
diff --git a/Modules/SurveyQuestionPool/Questions/class.SurveyQuestionGUI.php b/Modules/SurveyQuestionPool/Questions/class.SurveyQuestionGUI.php
index bd369e4347bf..b4d4f0d38b35 100755
--- a/Modules/SurveyQuestionPool/Questions/class.SurveyQuestionGUI.php
+++ b/Modules/SurveyQuestionPool/Questions/class.SurveyQuestionGUI.php
@@ -902,7 +902,7 @@ protected function initPhrasesForm()
$categories = ilSurveyPhrases::_getCategoriesForPhrase($phrase_id);
$opt = new ilRadioOption($phrase_array["title"], $phrase_id);
- $opt->setInfo(join($categories, ","));
+ $opt->setInfo(join(",", $categories));
$group->addOption($opt);
if ($phrase_array["org_title"] == "dp_standard_numbers") {
diff --git a/Modules/SystemFolder/classes/class.ilAccessibilitySupportContactsGUI.php b/Modules/SystemFolder/classes/class.ilAccessibilitySupportContactsGUI.php
index e9bb1922d069..4c2ffc34ef63 100644
--- a/Modules/SystemFolder/classes/class.ilAccessibilitySupportContactsGUI.php
+++ b/Modules/SystemFolder/classes/class.ilAccessibilitySupportContactsGUI.php
@@ -119,6 +119,7 @@ public static function getFooterLink()
$ctrl = $DIC->ctrl();
$user = $DIC->user();
$http = $DIC->http();
+ $lng = $DIC->language();
$users = ilAccessibilitySupportContacts::getValidSupportContactIds();
@@ -132,7 +133,7 @@ public static function getFooterLink()
$url = $request_scheme . '://'
. $http->request()->getServerParams()['HTTP_HOST']
. $http->request()->getServerParams()['REQUEST_URI'];
- return "mailto:" . $mails . "?body=%0D%0A%0D%0AGemeldeter%20Link:%0D%0A" . rawurlencode($url);
+ return "mailto:" . $mails . "?body=%0D%0A%0D%0A" . $lng->txt("report_accessibility_link") . "%0D%0A" . rawurlencode($url);
} else {
return $ctrl->getLinkTargetByClass("ilaccessibilitysupportcontactsgui", "");
}
diff --git a/Modules/Test/classes/class.assMarkSchema.php b/Modules/Test/classes/class.assMarkSchema.php
index b292cc7b5e8a..e7ffd8cdd542 100755
--- a/Modules/Test/classes/class.assMarkSchema.php
+++ b/Modules/Test/classes/class.assMarkSchema.php
@@ -164,7 +164,7 @@ public function saveToDb($test_id)
}
}
if (count($difffields)) {
- $this->logAction($test_id, $lng->txtlng("assessment", "log_mark_changed", ilObjAssessmentFolder::_getLogLanguage()) . ": " . join($difffields, ", "));
+ $this->logAction($test_id, $lng->txtlng("assessment", "log_mark_changed", ilObjAssessmentFolder::_getLogLanguage()) . ": " . join(", ", $difffields));
}
} else {
$this->logAction($test_id, $lng->txtlng("assessment", "log_mark_removed", ilObjAssessmentFolder::_getLogLanguage()) . ": " .
diff --git a/Modules/Test/classes/class.ilObjAssessmentFolder.php b/Modules/Test/classes/class.ilObjAssessmentFolder.php
index 05bab1de7650..f32c08aff276 100644
--- a/Modules/Test/classes/class.ilObjAssessmentFolder.php
+++ b/Modules/Test/classes/class.ilObjAssessmentFolder.php
@@ -229,7 +229,7 @@ public function _setManualScoring($type_ids)
if ((!is_array($type_ids)) || (count($type_ids) == 0)) {
$setting->delete("assessment_manual_scoring");
} else {
- $setting->set("assessment_manual_scoring", implode($type_ids, ","));
+ $setting->set("assessment_manual_scoring", implode(",", $type_ids));
}
}
@@ -247,7 +247,7 @@ public static function setScoringAdjustableQuestions($type_ids)
if ((!is_array($type_ids)) || (count($type_ids) == 0)) {
$setting->delete("assessment_scoring_adjustment");
} else {
- $setting->set("assessment_scoring_adjustment", implode($type_ids, ","));
+ $setting->set("assessment_scoring_adjustment", implode(",", $type_ids));
}
}
diff --git a/Modules/Test/classes/class.ilObjAssessmentFolderGUI.php b/Modules/Test/classes/class.ilObjAssessmentFolderGUI.php
index f782a62f66b1..668a589ca057 100644
--- a/Modules/Test/classes/class.ilObjAssessmentFolderGUI.php
+++ b/Modules/Test/classes/class.ilObjAssessmentFolderGUI.php
@@ -384,7 +384,7 @@ public function exportLogObject()
}
$csvoutput = "";
foreach ($csv as $row) {
- $csvoutput .= join($row, $separator) . "\n";
+ $csvoutput .= join($separator, $row) . "\n";
}
ilUtil::deliverData($csvoutput, str_replace(" ", "_", "log_" . $from . "_" . $until . "_" . $available_tests[$test]) . ".csv");
}
diff --git a/Modules/Test/classes/class.ilObjTest.php b/Modules/Test/classes/class.ilObjTest.php
index 33a6551b9291..477d310196ff 100755
--- a/Modules/Test/classes/class.ilObjTest.php
+++ b/Modules/Test/classes/class.ilObjTest.php
@@ -1487,7 +1487,7 @@ public function saveToDb($properties_only = false)
array_push($changed_fields, "$key: " . $oldrow[$key] . " => " . $newrow[$key]);
}
}
- $changes = join($changed_fields, ", ");
+ $changes = join(", ", $changed_fields);
if (count($changed_fields) > 0) {
$this->logAction($this->lng->txtlng("assessment", "log_modified_test", ilObjAssessmentFolder::_getLogLanguage()) . " [" . $changes . "]");
}
@@ -7041,7 +7041,7 @@ public function getAuthor()
}
}
}
- return join($author, ",");
+ return join(",", $author);
}
/**
@@ -7070,7 +7070,7 @@ public static function _lookupAuthor($obj_id)
}
}
}
- return join($author, ",");
+ return join(",", $author);
}
/**
@@ -7086,7 +7086,14 @@ public static function _getAvailableTests($use_object_id = false)
$ilDB = $DIC['ilDB'];
$result_array = array();
- $tests = ilUtil::_getObjectsByOperations("tst", "write", $ilUser->getId(), -1);
+ $tests = array_slice(
+ array_reverse(
+ ilUtil::_getObjectsByOperations("tst", "write", $ilUser->getId(), PHP_INT_MAX)
+ ),
+ 0,
+ 10000
+ );
+
if (count($tests)) {
$titles = ilObject::_prepareCloneSelection($tests, "tst");
foreach ($tests as $ref_id) {
@@ -10598,7 +10605,7 @@ public function getEvaluationAdditionalFields()
{
include_once "./Modules/Test/classes/class.ilObjTestGUI.php";
include_once "./Modules/Test/classes/tables/class.ilEvaluationAllTableGUI.php";
- $table_gui = new ilEvaluationAllTableGUI(new ilObjTestGUI(''), 'outEvaluation', $this->getAnonymity());
+ $table_gui = new ilEvaluationAllTableGUI(new ilObjTestGUI($this->getRefId()), 'outEvaluation', $this->getAnonymity());
return $table_gui->getSelectedColumns();
}
diff --git a/Modules/Test/classes/class.ilObjTestGUI.php b/Modules/Test/classes/class.ilObjTestGUI.php
index ea86ff5947d5..a9a24d883073 100755
--- a/Modules/Test/classes/class.ilObjTestGUI.php
+++ b/Modules/Test/classes/class.ilObjTestGUI.php
@@ -88,8 +88,9 @@ class ilObjTestGUI extends ilObjectGUI
/**
* Constructor
* @access public
+ * @param mixed|null $refId
*/
- public function __construct()
+ public function __construct($refId = null)
{
global $DIC;
$lng = $DIC['lng'];
@@ -101,7 +102,10 @@ public function __construct()
$this->type = "tst";
$this->ctrl = $ilCtrl;
$this->ctrl->saveParameter($this, array("ref_id", "test_ref_id", "calling_test", "test_express_mode", "q_id"));
- parent::__construct("", $_GET["ref_id"], true, false);
+ if (isset($_GET['ref_id']) && is_numeric($_GET['ref_id'])) {
+ $refId = (int) $_GET['ref_id'];
+ }
+ parent::__construct("", (int) $refId, true, false);
if ($this->object instanceof ilObjTest) {
require_once 'Modules/Test/classes/class.ilTestQuestionSetConfigFactory.php';
diff --git a/Modules/Test/classes/class.ilParticipantsTestResultsGUI.php b/Modules/Test/classes/class.ilParticipantsTestResultsGUI.php
index 04bcd4392898..d7d812cc093c 100644
--- a/Modules/Test/classes/class.ilParticipantsTestResultsGUI.php
+++ b/Modules/Test/classes/class.ilParticipantsTestResultsGUI.php
@@ -486,10 +486,6 @@ public function createUserResults($show_pass_details, $show_answers, $show_reach
$count = 0;
foreach ($show_user_results as $key => $active_id) {
- if ($this->getTestObj()->getFixedParticipants()) {
- $active_id = $this->getTestObj()->getActiveIdOfUser($active_id);
- }
-
if (!in_array($active_id, $participantData->getActiveIds())) {
continue;
}
diff --git a/Modules/Test/classes/class.ilTestEvaluationData.php b/Modules/Test/classes/class.ilTestEvaluationData.php
index 8a9cff6de9ae..979b00da4763 100755
--- a/Modules/Test/classes/class.ilTestEvaluationData.php
+++ b/Modules/Test/classes/class.ilTestEvaluationData.php
@@ -204,7 +204,7 @@ public function generateOverview()
}
$this->getParticipant($row["active_fi"])->getPass($row["pass"])->setNrOfAnsweredQuestions($row["answeredquestions"]);
- $this->getParticipant($row["active_fi"])->getPass($row["pass"])->setWorkingTime($row["workingtime"]);
+ $this->getParticipant($row["active_fi"])->getPass($row["pass"])->setExamId((string) $row["exam_id"]);
$this->getParticipant($row['active_fi'])->getPass($row['pass'])->setRequestedHintsCount($row['hint_count']);
$this->getParticipant($row['active_fi'])->getPass($row['pass'])->setDeductedHintPoints($row['hint_points']);
diff --git a/Modules/Test/classes/class.ilTestEvaluationGUI.php b/Modules/Test/classes/class.ilTestEvaluationGUI.php
index 3948db49b3bd..7f974ef8f28c 100644
--- a/Modules/Test/classes/class.ilTestEvaluationGUI.php
+++ b/Modules/Test/classes/class.ilTestEvaluationGUI.php
@@ -274,6 +274,7 @@ public function outEvaluation()
$evaluationrow['reached'] = $userdata->getReached();
$evaluationrow['max'] = $userdata->getMaxpoints();
$evaluationrow['hint_count'] = $userdata->getRequestedHintsCountFromScoredPass();
+ $evaluationrow['exam_id'] = $userdata->getExamIdFromScoredPass();
$percentage = $userdata->getReachedPointsInPercent();
$mark = $this->object->getMarkSchema()->getMatchingMark($percentage);
if (is_object($mark)) {
diff --git a/Modules/Test/classes/class.ilTestEvaluationPassData.php b/Modules/Test/classes/class.ilTestEvaluationPassData.php
index ef0570722434..e285e91fa7c8 100755
--- a/Modules/Test/classes/class.ilTestEvaluationPassData.php
+++ b/Modules/Test/classes/class.ilTestEvaluationPassData.php
@@ -87,11 +87,14 @@ class ilTestEvaluationPassData
* @var boolean
*/
private $obligationsAnswered = null;
+
+ /** @var string */
+ private $examId = '';
public function __sleep()
{
return array('answeredQuestions', 'pass', 'nrOfAnsweredQuestions', 'reachedpoints',
- 'maxpoints', 'questioncount', 'workingtime');
+ 'maxpoints', 'questioncount', 'workingtime', 'examId');
}
/**
@@ -181,7 +184,7 @@ public function addAnsweredQuestion($question_id, $max_points, $reached_points,
);
}
- public function &getAnsweredQuestion($index)
+ public function getAnsweredQuestion($index)
{
if (array_key_exists($index, $this->answeredQuestions)) {
return $this->answeredQuestions[$index];
@@ -190,7 +193,7 @@ public function &getAnsweredQuestion($index)
}
}
- public function &getAnsweredQuestionByQuestionId($question_id)
+ public function getAnsweredQuestionByQuestionId($question_id)
{
foreach ($this->answeredQuestions as $question) {
if ($question["id"] == $question_id) {
@@ -254,7 +257,23 @@ public function setObligationsAnswered($obligationsAnswered)
{
$this->obligationsAnswered = (bool) $obligationsAnswered;
}
-
+
+ /**
+ * @return string
+ */
+ public function getExamId() : string
+ {
+ return $this->examId;
+ }
+
+ /**
+ * @param string $examId
+ */
+ public function setExamId(string $examId) : void
+ {
+ $this->examId = $examId;
+ }
+
/**
* getter for property obligationsAnswered.
* if property wasn't set yet the method is trying
diff --git a/Modules/Test/classes/class.ilTestEvaluationUserData.php b/Modules/Test/classes/class.ilTestEvaluationUserData.php
index 571c09087e66..d7780f2c98fb 100755
--- a/Modules/Test/classes/class.ilTestEvaluationUserData.php
+++ b/Modules/Test/classes/class.ilTestEvaluationUserData.php
@@ -123,7 +123,7 @@ class ilTestEvaluationUserData
/**
* Test passes
*
- * @var array
+ * @var array
*/
public $passes;
@@ -340,13 +340,21 @@ public function getPasses()
{
return $this->passes;
}
-
+
+ /**
+ * @param int $pass_nr
+ * @param ilTestEvaluationPassData $pass
+ */
public function addPass($pass_nr, $pass)
{
$this->passes[$pass_nr] = $pass;
}
-
- public function &getPass($pass_nr)
+
+ /**
+ * @param $pass_nr
+ * @return ilTestEvaluationPassData|null
+ */
+ public function getPass($pass_nr)
{
if (array_key_exists($pass_nr, $this->passes)) {
return $this->passes[$pass_nr];
@@ -409,7 +417,7 @@ public function getQuestionTitles()
return $this->questionTitles;
}
- public function &getQuestions($pass = 0)
+ public function getQuestions($pass = 0)
{
if (array_key_exists($pass, $this->questions)) {
return $this->questions[$pass];
@@ -432,7 +440,7 @@ public function addQuestion($original_id, $question_id, $max_points, $sequence =
);
}
- public function &getQuestion($index, $pass = 0)
+ public function getQuestion($index, $pass = 0)
{
if (array_key_exists($index, $this->questions[$pass])) {
return $this->questions[$pass][$index];
@@ -527,6 +535,21 @@ public function getRequestedHintsCountFromScoredPass()
{
return $this->getRequestedHintsCount($this->getScoredPass());
}
+
+ /**
+ * @return string
+ */
+ public function getExamIdFromScoredPass() : string
+ {
+ $examId = '';
+ $scoredPass = $this->getScoredPass();
+
+ if (isset($this->passes[$scoredPass]) && $this->passes[$scoredPass] instanceof ilTestEvaluationPassData) {
+ $examId = $this->passes[$scoredPass]->getExamId();
+ }
+
+ return $examId;
+ }
/**
* returns the count of hints requested by participant for given testpass
diff --git a/Modules/Test/classes/class.ilTestExport.php b/Modules/Test/classes/class.ilTestExport.php
index 7f2110c24fad..623a00e3062a 100755
--- a/Modules/Test/classes/class.ilTestExport.php
+++ b/Modules/Test/classes/class.ilTestExport.php
@@ -307,7 +307,7 @@ protected function aggregatedResultsToCSV($deliver = true)
$separator = ";";
foreach ($rows as $evalrow) {
$csvrow = &$this->test_obj->processCSVRow($evalrow, true, $separator);
- $csv .= join($csvrow, $separator) . "\n";
+ $csv .= join($separator, $csvrow) . "\n";
}
if ($deliver) {
ilUtil::deliverData($csv, ilUtil::getASCIIFilename($this->test_obj->getTitle() . "_aggregated.csv"));
@@ -354,6 +354,10 @@ public function exportToExcel($deliver = true, $filterby = "", $filtertext = "",
if (count($additionalFields)) {
foreach ($additionalFields as $fieldname) {
+ if (strcmp($fieldname, "exam_id") == 0) {
+ $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt('exam_id_label'));
+ continue;
+ }
$worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt($fieldname));
}
}
@@ -411,6 +415,8 @@ public function exportToExcel($deliver = true, $filterby = "", $filtertext = "",
foreach ($additionalFields as $fieldname) {
if (strcmp($fieldname, 'gender') == 0) {
$worksheet->setCell($row, $col++, $this->lng->txt('gender_' . $userfields[$fieldname]));
+ } elseif (strcmp($fieldname, "exam_id") == 0) {
+ $worksheet->setCell($row, $col++, $userdata->getExamIdFromScoredPass());
} else {
$worksheet->setCell($row, $col++, $userfields[$fieldname]);
}
@@ -547,6 +553,9 @@ public function exportToExcel($deliver = true, $filterby = "", $filtertext = "",
if (strcmp($fieldname, "matriculation") == 0) {
$worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt('matriculation'));
}
+ if (strcmp($fieldname, "exam_id") == 0) {
+ $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt('exam_id_label'));
+ }
}
}
$worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt('test'));
@@ -577,6 +586,13 @@ public function exportToExcel($deliver = true, $filterby = "", $filtertext = "",
$col++;
}
}
+ if (strcmp($fieldname, "exam_id") == 0) {
+ if (strlen($userfields[$fieldname])) {
+ $worksheet->setCell($row, $col++, $userdata->getExamIdFromScoredPass());
+ } else {
+ $col++;
+ }
+ }
}
}
$worksheet->setCell($row, $col++, $this->test_obj->getTitle());
@@ -618,6 +634,9 @@ public function exportToExcel($deliver = true, $filterby = "", $filtertext = "",
if (strcmp($fieldname, "matriculation") == 0) {
$worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt('matriculation'));
}
+ if (strcmp($fieldname, "exam_id") == 0) {
+ $worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt('exam_id_label'));
+ }
}
}
$worksheet->setFormattedExcelTitle($worksheet->getColumnCoord($col++) . $row, $this->lng->txt('test'));
@@ -648,6 +667,13 @@ public function exportToExcel($deliver = true, $filterby = "", $filtertext = "",
$col++;
}
}
+ if (strcmp($fieldname, "exam_id") == 0) {
+ if (strlen($userfields[$fieldname])) {
+ $worksheet->setCell($row, $col++, $userdata->getExamIdFromScoredPass());
+ } else {
+ $col++;
+ }
+ }
}
}
$worksheet->setCell($row, $col++, $this->test_obj->getTitle());
@@ -764,6 +790,11 @@ public function exportToCSV($deliver = true, $filterby = "", $filtertext = "", $
$additionalFields = $this->test_obj->getEvaluationAdditionalFields();
if (count($additionalFields)) {
foreach ($additionalFields as $fieldname) {
+ if (strcmp($fieldname, "exam_id") == 0) {
+ array_push($datarow, $this->lng->txt('exam_id_label'));
+ $col++;
+ continue;
+ }
array_push($datarow, $this->lng->txt($fieldname));
$col++;
}
@@ -833,6 +864,8 @@ public function exportToCSV($deliver = true, $filterby = "", $filtertext = "", $
foreach ($additionalFields as $fieldname) {
if (strcmp($fieldname, "gender") == 0) {
array_push($datarow2, $this->lng->txt("gender_" . $userfields[$fieldname]));
+ } elseif (strcmp($fieldname, "exam_id") == 0) {
+ array_push($datarow2, $userdata->getExamIdFromScoredPass());
} else {
array_push($datarow2, $userfields[$fieldname]);
}
@@ -923,7 +956,7 @@ public function exportToCSV($deliver = true, $filterby = "", $filtertext = "", $
$separator = ";";
foreach ($rows as $evalrow) {
$csvrow = &$this->test_obj->processCSVRow($evalrow, true, $separator);
- $csv .= join($csvrow, $separator) . "\n";
+ $csv .= join($separator, $csvrow) . "\n";
}
if ($deliver) {
ilUtil::deliverData($csv, ilUtil::getASCIIFilename($this->test_obj->getTitle() . "_results.csv"));
diff --git a/Modules/Test/classes/class.ilTestLP.php b/Modules/Test/classes/class.ilTestLP.php
index 4d1a3ed9d3e6..db1b0524744c 100644
--- a/Modules/Test/classes/class.ilTestLP.php
+++ b/Modules/Test/classes/class.ilTestLP.php
@@ -109,7 +109,7 @@ protected static function isLPMember(array &$a_res, $a_usr_id, $a_obj_ids)
$set = $ilDB->query("SELECT tt.obj_fi" .
" FROM tst_active ta" .
" JOIN tst_tests tt ON (ta.test_fi = tt.test_id)" .
- " WHERE " . $ilDB->in("tt.obj_fi", (array) $a_obj_ids, "", "integer") .
+ " WHERE " . $ilDB->in("tt.obj_fi", (array) $a_obj_ids, false, "integer") .
" AND ta.user_fi = " . $ilDB->quote($a_usr_id, "integer"));
while ($row = $ilDB->fetchAssoc($set)) {
$a_res[$row["obj_fi"]] = true;
diff --git a/Modules/Test/classes/class.ilTestOutputGUI.php b/Modules/Test/classes/class.ilTestOutputGUI.php
index c4ab7405c74f..aa71399f625f 100755
--- a/Modules/Test/classes/class.ilTestOutputGUI.php
+++ b/Modules/Test/classes/class.ilTestOutputGUI.php
@@ -655,7 +655,7 @@ public function saveQuestionSolution($authorized = true, $force = false)
}
}
- if ($this->saveResult == false) {
+ if ($this->saveResult == false || (!$questionOBJ->validateSolutionSubmit() && $questionOBJ->savePartial()) ) {
$this->ctrl->setParameter($this, "save_error", "1");
$_SESSION["previouspost"] = $_POST;
}
diff --git a/Modules/Test/classes/class.ilTestPasswordChecker.php b/Modules/Test/classes/class.ilTestPasswordChecker.php
index e714f865bd2d..7a7df12b8f81 100644
--- a/Modules/Test/classes/class.ilTestPasswordChecker.php
+++ b/Modules/Test/classes/class.ilTestPasswordChecker.php
@@ -123,12 +123,10 @@ public function logWrongEnteredPassword()
protected function getWrongEnteredPasswordLogMsg()
{
- $msg = $this->lng->txtlng(
+ return $this->lng->txtlng(
'assessment',
'log_wrong_test_password_entered',
ilObjAssessmentFolder::_getLogLanguage()
);
-
- return sprintf($msg, $this->getUserEnteredPassword());
}
}
diff --git a/Modules/Test/classes/class.ilTestPlayerAbstractGUI.php b/Modules/Test/classes/class.ilTestPlayerAbstractGUI.php
index 24a997355184..d79856e30e5c 100755
--- a/Modules/Test/classes/class.ilTestPlayerAbstractGUI.php
+++ b/Modules/Test/classes/class.ilTestPlayerAbstractGUI.php
@@ -1483,6 +1483,9 @@ public function outProcessingTime($active_id)
$this->tpl->setVariable("USER_REMAINING_TIME", sprintf($this->lng->txt("tst_time_already_spent_left"), $str_time_left));
$this->tpl->parseCurrentBlock();
+ // jQuery is required by tpl.workingtime.js
+ require_once "./Services/jQuery/classes/class.iljQueryUtil.php";
+ iljQueryUtil::initjQuery();
$template = new ilTemplate("tpl.workingtime.js", true, true, 'Modules/Test');
$template->setVariable("STRING_MINUTE", $this->lng->txt("minute"));
$template->setVariable("STRING_MINUTES", $this->lng->txt("minutes"));
@@ -1557,13 +1560,19 @@ abstract protected function isQuestionSummaryFinishTestButtonRequired();
/**
* Output of a summary of all test questions for test participants
*/
- public function outQuestionSummaryCmd($fullpage = true, $contextFinishTest = false, $obligationsNotAnswered = false, $obligationsFilter = false)
+ public function outQuestionSummaryCmd($fullpage = true, $contextFinishTest = false, $obligationsInfo = false, $obligationsFilter = false)
{
if ($fullpage) {
$this->tpl->addBlockFile($this->getContentBlockName(), "adm_content", "tpl.il_as_tst_question_summary.html", "Modules/Test");
}
-
- if ($obligationsNotAnswered) {
+
+ $obligationsFulfilled = \ilObjTest::allObligationsAnswered(
+ $this->object->getId(),
+ $this->testSession->getActiveId(),
+ $this->testSession->getPass()
+ );
+
+ if ($obligationsInfo && $this->object->areObligationsEnabled() && !$obligationsFulfilled) {
ilUtil::sendFailure($this->lng->txt('not_all_obligations_answered'));
}
@@ -1588,7 +1597,7 @@ public function outQuestionSummaryCmd($fullpage = true, $contextFinishTest = fal
$table_gui->setShowPointsEnabled(!$this->object->getTitleOutput());
$table_gui->setShowMarkerEnabled($this->object->getShowMarker());
- $table_gui->setObligationsNotAnswered($obligationsNotAnswered);
+ $table_gui->setObligationsNotAnswered(!$obligationsFulfilled);
$table_gui->setShowObligationsEnabled($this->object->areObligationsEnabled());
$table_gui->setObligationsFilterEnabled($obligationsFilter);
$table_gui->setFinishTestButtonEnabled($this->isQuestionSummaryFinishTestButtonRequired());
@@ -1602,6 +1611,17 @@ public function outQuestionSummaryCmd($fullpage = true, $contextFinishTest = fal
if ($this->object->getEnableProcessingTime()) {
$this->outProcessingTime($active_id);
}
+
+ if ($this->object->isShowExamIdInTestPassEnabled()) {
+ $this->tpl->setCurrentBlock('exam_id_footer');
+ $this->tpl->setVariable('EXAM_ID_VAL', ilObjTest::lookupExamId(
+ $this->testSession->getActiveId(),
+ $this->testSession->getPass(),
+ $this->object->getId()
+ ));
+ $this->tpl->setVariable('EXAM_ID_TXT', $this->lng->txt('exam_id'));
+ $this->tpl->parseCurrentBlock();
+ }
}
}
diff --git a/Modules/Test/classes/class.ilTestSubmissionReviewGUI.php b/Modules/Test/classes/class.ilTestSubmissionReviewGUI.php
index e07532f16b57..1286501d36fa 100644
--- a/Modules/Test/classes/class.ilTestSubmissionReviewGUI.php
+++ b/Modules/Test/classes/class.ilTestSubmissionReviewGUI.php
@@ -185,8 +185,21 @@ protected function show()
$html = $this->buildToolbar('review_nav_top')->getHTML();
$html .= $this->buildUserReviewOutput() . ' ';
$html .= $this->buildToolbar('review_nav_bottom')->getHTML();
+
+ if ($this->object->isShowExamIdInTestPassEnabled() && !$this->object->getKioskMode()) {
+ $examIdTpl = new ilTemplate("tpl.exam_id_block.html", true, true, 'Modules/Test');
+ $examIdTpl->setVariable('EXAM_ID_VAL', ilObjTest::lookupExamId(
+ $this->testSession->getActiveId(),
+ $this->testSession->getPass(),
+ $this->object->getId()
+ ));
+ $examIdTpl->setVariable('EXAM_ID_TXT', $this->lng->txt('exam_id'));
+ $html .= $examIdTpl->get();
+ }
- $this->tpl->setVariable($this->getContentBlockName(), $html);
+ $this->tpl->setVariable(
+ $this->getContentBlockName(), $html
+ );
}
protected function pdfDownload()
diff --git a/Modules/Test/classes/tables/class.ilEvaluationAllTableGUI.php b/Modules/Test/classes/tables/class.ilEvaluationAllTableGUI.php
index c791dca90308..2f8b71565d92 100644
--- a/Modules/Test/classes/tables/class.ilEvaluationAllTableGUI.php
+++ b/Modules/Test/classes/tables/class.ilEvaluationAllTableGUI.php
@@ -51,6 +51,9 @@ public function __construct($a_parent_obj, $a_parent_cmd, $anonymity = false, $o
if (strcmp($c, 'email') == 0) {
$this->addColumn($this->lng->txt("email"), 'email', '');
}
+ if (strcmp($c, 'exam_id') == 0 && $this->parent_obj->object->isShowExamIdInTestResultsEnabled()) {
+ $this->addColumn($this->lng->txt("exam_id_label"), 'exam_id', '');
+ }
if (strcmp($c, 'institution') == 0) {
$this->addColumn($this->lng->txt("institution"), 'institution', '');
}
@@ -133,6 +136,7 @@ public function numericOrdering($a_field)
break;
case 'reached':
case 'hint_count':
+ case 'exam_id':
case 'answered':
return true;
break;
@@ -191,6 +195,12 @@ public function getSelectableColumns()
"txt" => $lng->txt("matriculation"),
"default" => false
);
+ if ($this->parent_obj->object->isShowExamIdInTestResultsEnabled()) {
+ $cols["exam_id"] = array(
+ "txt" => $lng->txt("exam_id_label"),
+ "default" => false
+ );
+ }
}
if ($this->parent_obj->object->getECTSOutput()) {
$cols["ects_grade"] = array(
@@ -308,6 +318,12 @@ protected function fillRow($data)
$this->tpl->setVariable("MATRICULATION", strlen($data['matriculation']) ? $data['matriculation'] : ' ');
$this->tpl->parseCurrentBlock();
}
+ if (strcmp($c, 'exam_id') == 0 && $this->parent_obj->object->isShowExamIdInTestResultsEnabled()) {
+ $this->tpl->setCurrentBlock('exam_id');
+ $examId = is_string($data['exam_id']) && strlen($data['exam_id']) ? $data['exam_id'] : ' ';
+ $this->tpl->setVariable('EXAM_ID', $examId);
+ $this->tpl->parseCurrentBlock();
+ }
}
if ($this->parent_obj->object->getECTSOutput()) {
if (strcmp($c, 'ects_grade') == 0) {
diff --git a/Modules/Test/templates/default/tpl.exam_id_block.html b/Modules/Test/templates/default/tpl.exam_id_block.html
new file mode 100644
index 000000000000..8dd2564e5c28
--- /dev/null
+++ b/Modules/Test/templates/default/tpl.exam_id_block.html
@@ -0,0 +1 @@
+
{EXAM_ID_TXT} {EXAM_ID_VAL}
\ No newline at end of file
diff --git a/Modules/Test/templates/default/tpl.il_as_tst_correct_solution_output.html b/Modules/Test/templates/default/tpl.il_as_tst_correct_solution_output.html
index a25ae3e2da55..a2a44fefac1d 100755
--- a/Modules/Test/templates/default/tpl.il_as_tst_correct_solution_output.html
+++ b/Modules/Test/templates/default/tpl.il_as_tst_correct_solution_output.html
@@ -5,7 +5,7 @@
diff --git a/Modules/Test/templates/default/tpl.il_as_tst_question_summary.html b/Modules/Test/templates/default/tpl.il_as_tst_question_summary.html
index ffb94ac33203..e6e17b5c2cef 100644
--- a/Modules/Test/templates/default/tpl.il_as_tst_question_summary.html
+++ b/Modules/Test/templates/default/tpl.il_as_tst_question_summary.html
@@ -11,4 +11,7 @@
{TEXT_CANCELTEST}
-{TABLE_LIST_OF_QUESTIONS}
\ No newline at end of file
+{TABLE_LIST_OF_QUESTIONS}
+
+
{EXAM_ID_TXT} {EXAM_ID_VAL}
+
\ No newline at end of file
diff --git a/Modules/Test/templates/default/tpl.table_evaluation_all.html b/Modules/Test/templates/default/tpl.table_evaluation_all.html
index 61196522320b..d8eacc08bfc4 100644
--- a/Modules/Test/templates/default/tpl.table_evaluation_all.html
+++ b/Modules/Test/templates/default/tpl.table_evaluation_all.html
@@ -10,6 +10,7 @@
{COUNTRY}
{DEPARTMENT}
{MATRICULATION}
+
{EXAM_ID}
{REACHED}
{HINT_COUNT}
{MARK}
diff --git a/Modules/Test/templates/default/tpl.workingtime.js b/Modules/Test/templates/default/tpl.workingtime.js
index 5c1a714191ad..bbde116a5e41 100644
--- a/Modules/Test/templates/default/tpl.workingtime.js
+++ b/Modules/Test/templates/default/tpl.workingtime.js
@@ -1,45 +1,104 @@
- var serverdate = -1;
- var unsaved = true;
-
- function setWorkingTime()
- {
- if (serverdate == -1)
- {
- var n = new Date({YEAR}, {MONTHNOW}, {DAYNOW}, {HOURNOW}, {MINUTENOW}, {SECONDNOW});
- serverdate = n.getTime() / 1000;
+/*global il:false, jQuery:false*/
+(function(w, $) {
+
+ var test_end = -1,
+ local_timer_start = -1,
+ unsaved = true,
+ interval = 0;
+
+ if (w.performance) {
+ local_timer_start = performance.now();
+ }
+
+ var server_date = (new Date({YEAR}, {MONTHNOW}, {DAYNOW}, {HOURNOW}, {MINUTENOW}, {SECONDNOW})).getTime() / 1000,
+ // first tick happens immediately, and older browser use tick-based
+ // counter which increments as soon as jQuery fires $(document).ready
+ now = server_date - 1,
+ test_start = (new Date({YEAR}, {MONTH}, {DAY}, {HOUR}, {MINUTE}, {SECOND})).getTime() / 1000,
+ test_time_min = {PTIME_M},
+ test_time_sec = {PTIME_S},
+ minute = "{STRING_MINUTE}",
+ minutes = "{STRING_MINUTES}",
+ second = "{STRING_SECOND}",
+ seconds = "{STRING_SECONDS}",
+ timeleft = "{STRING_TIMELEFT}",
+ redirectUrl = "{REDIRECT_URL}",
+ and = "{AND}",
+ time_left_span;
+
+
+ test_end = (new Date({ENDYEAR}, {ENDMONTH}, {ENDDAY}, {ENDHOUR}, {ENDMINUTE}, {ENDSECOND})).getTime() / 1000;
+
+
+ /**
+ * invoke test player's auto-save if available
+ */
+ function autoSave() {
+ unsaved = false;
+ if (typeof il.TestPlayerQuestionEditControl !== 'undefined') {
+ il.TestPlayerQuestionEditControl.saveOnTimeReached();
}
- else
- {
- serverdate++;
+ }
+
+ /**
+ * submit form to redirectUrl
+ */
+ function redirect() {
+ $("#listofquestions").attr('action', redirectUrl).submit();
+ }
+
+ /**
+ * Format a "time left" string from parameters provided.
+ * @param {Number} avail Time available in full seconds.
+ * @param {Number} avail_m Full minutes available.
+ * @param {Number} avail_s Seconds available subtracted by full minutes (i.e. avail mod 60).
+ * @return {String} Text telling how much time is left to finish the test in user's language
+ */
+ function formatString(avail, avail_m, avail_s) {
+ var output = avail_m + " ";
+ if (avail_m === 1) {
+ output += minute;
+ } else {
+ output += minutes;
}
- var startd = new Date({YEAR}, {MONTH}, {DAY}, {HOUR}, {MINUTE}, {SECOND});
- var enddtime = -1;
-
- var endd = new Date({ENDYEAR}, {ENDMONTH}, {ENDDAY}, {ENDHOUR}, {ENDMINUTE}, {ENDSECOND});
- enddtime = endd.getTime() / 1000;
-
- var ptime_m = {PTIME_M};
- var ptime_s = {PTIME_S};
- var minute = "{STRING_MINUTE}";
- var minutes = "{STRING_MINUTES}";
- var second = "{STRING_SECOND}";
- var seconds = "{STRING_SECONDS}";
- var timeleft = "{STRING_TIMELEFT}";
- var redirectUrl = "{REDIRECT_URL}";
- var and = "{AND}";
- var now = serverdate;
- var then = startd.getTime() / 1000;
+ // show seconds if less than 5min (300s) left
+ if (avail < 300) {
+ if (avail_s < 10) {
+ output += " " + and + " 0" + avail_s + " ";
+ } else {
+ output += " " + and + " " + avail_s + " ";
+ }
+ if (avail_m == 0) {
+ if (avail_s < 10) {
+ output = "0" + avail_s + " ";
+ } else {
+ output = avail_s + " ";
+ }
+ }
+ if (avail_s == 1) {
+ output += second;
+ } else {
+ output += seconds;
+ }
+ }
+ return output;
+ }
+
+ /**
+ * Calculate remaining working time and dispatch actions based on that
+ */
+ function setWorkingTime() {
// time since start in seconds
- var diff = Math.floor(now - then);
- // available time
- var avail = ptime_m * 60 + ptime_s - diff;
- if (avail < 0)
- {
+ var diff = Math.floor(now - test_start),
+ // available time
+ avail = test_time_min * 60 + test_time_sec - diff,
+ avail_m, avail_s, output;
+
+ if (avail < 0) {
avail = 0;
}
- if (enddtime > -1)
- {
- var diffToEnd = Math.floor(enddtime - now);
+ if (test_end > -1) {
+ var diffToEnd = Math.floor(test_end - now);
if ((diffToEnd > 0) && (diffToEnd < avail))
{
avail = diffToEnd;
@@ -49,64 +108,49 @@
avail = 0;
}
}
- if ((avail <= 0) && unsaved)
- {
- unsaved = false;
-// fau: testNav - call saveOnTimeReached in the new control script
- if (typeof il.TestPlayerQuestionEditControl != 'undefined')
- {
- il.TestPlayerQuestionEditControl.saveOnTimeReached();
- }
-// fau.
+ if ((avail <= 0) && unsaved) {
+ autoSave();
}
- if((avail <= 0) && redirectUrl != "") {
- $("#listofquestions").attr('action', redirectUrl).submit();
+ if((avail <= 0) && redirectUrl !== "") {
+ redirect();
}
- var avail_m = Math.floor(avail / 60);
- var avail_s = avail - (avail_m * 60);
- var output = avail_m + " ";
- if (avail_m == 1)
- {
- output += minute;
- }
- else
- {
- output += minutes;
- }
- if (avail < 300)
- {
- if (avail_s < 10)
- {
- output += " " + and + " 0" + avail_s + " ";
- }
- else
- {
- output += " " + and + " " + avail_s + " ";
- }
- if (avail_m == 0)
- {
- if (avail_s < 10)
- {
- output = "0" + avail_s + " ";
- }
- else
- {
- output = avail_s + " ";
- }
- }
- if (avail_s == 1)
- {
- output += second;
- }
- else
- {
- output += seconds;
+ avail_m = Math.floor(avail / 60);
+ avail_s = avail - (avail_m * 60);
+ output = formatString(avail, avail_m, avail_s);
+
+ time_left_span.html( timeleft.replace(/%s/, output) );
+ }
+
+ /**
+ * MUST be invoked every 1000ms in older browsers
+ * (SHOULD for those that support window.performance)
+ */
+ function tick() {
+ if (local_timer_start >= 0) {
+ // use performance API
+ var local_timer_now = performance.now();
+ if (local_timer_now >= local_timer_start) {
+ // floor in order to ensure the test is not submitted before end
+ // in which case ILIAS would display "autosave [failed|succeeded]"
+ // and not "the test ended ..."
+ now = Math.floor(server_date + (local_timer_now - local_timer_start) / 1000);
+ } else {
+ // result by performance API does not make sense, maybe it's broken
+ // in this browser/version or blocked by a privacy plugin
+ now++;
}
+ } else {
+ // performance API unsupported by client
+ now++;
}
- var span = document.getElementById("timeleft");
- span.innerHTML = timeleft.replace(/%s/, output);
+ setWorkingTime();
}
- window.setWorkingTime = setWorkingTime;
-
- window.setInterval('setWorkingTime()',1000);
\ No newline at end of file
+
+ $(function() {
+ time_left_span = $('#timeleft');
+ tick();
+ interval = w.setInterval(tick, 1000);
+ });
+
+}(window, jQuery));
diff --git a/Modules/TestQuestionPool/classes/class.assClozeTest.php b/Modules/TestQuestionPool/classes/class.assClozeTest.php
index 5e53392ba3cc..ffd3c7afa8df 100755
--- a/Modules/TestQuestionPool/classes/class.assClozeTest.php
+++ b/Modules/TestQuestionPool/classes/class.assClozeTest.php
@@ -1257,7 +1257,7 @@ protected function isValidNumericSubmitValue($submittedValue)
public function validateSolutionSubmit()
{
- foreach ($this->getSolutionSubmit() as $gapIndex => $value) {
+ foreach ($this->getSolutionSubmitValidation() as $gapIndex => $value) {
$gap = $this->getGap($gapIndex);
if ($gap->getType() != CLOZE_NUMERIC) {
@@ -1284,7 +1284,9 @@ public function fetchSolutionSubmit($submit)
$gap = $this->getGap($matches[1]);
if (is_object($gap)) {
if (!(($gap->getType() == CLOZE_SELECT) && ($value == -1))) {
- if ($gap->getType() == CLOZE_NUMERIC) {
+ if ($gap->getType() == CLOZE_NUMERIC && !is_numeric(str_replace(",", ".", $value))) {
+ $value = null;
+ } else if ($gap->getType() == CLOZE_NUMERIC) {
$value = str_replace(",", ".", $value);
}
$solutionSubmit[trim($matches[1])] = $value;
@@ -1296,7 +1298,32 @@ public function fetchSolutionSubmit($submit)
return $solutionSubmit;
}
-
+
+ public function getSolutionSubmitValidation()
+ {
+ $submit = $_POST;
+ $solutionSubmit = array();
+
+ foreach ($submit as $key => $value) {
+ if (preg_match("/^gap_(\d+)/", $key, $matches)) {
+ $value = ilUtil::stripSlashes($value, false);
+ if (strlen($value)) {
+ $gap = $this->getGap($matches[1]);
+ if (is_object($gap)) {
+ if (!(($gap->getType() == CLOZE_SELECT) && ($value == -1))) {
+ if ($gap->getType() == CLOZE_NUMERIC) {
+ $value = str_replace(",", ".", $value);
+ }
+ $solutionSubmit[trim($matches[1])] = $value;
+ }
+ }
+ }
+ }
+ }
+
+ return $solutionSubmit;
+ }
+
public function getSolutionSubmit()
{
return $this->fetchSolutionSubmit($_POST);
@@ -1951,4 +1978,9 @@ public function addAnswerOptionValue($qIndex, $answerOptionValue, $points)
$gap->addItem($item);
}
+
+ public function savePartial()
+ {
+ return true;
+ }
}
diff --git a/Modules/TestQuestionPool/classes/class.assClozeTestGUI.php b/Modules/TestQuestionPool/classes/class.assClozeTestGUI.php
index 0abee346ff51..e1c1fd869d5f 100755
--- a/Modules/TestQuestionPool/classes/class.assClozeTestGUI.php
+++ b/Modules/TestQuestionPool/classes/class.assClozeTestGUI.php
@@ -1588,7 +1588,7 @@ protected function completeAddAnswerAction($answers, $questionIndex)
$found = false;
foreach ($gap->getItems(new ilArrayElementOrderKeeper()) as $item) {
- if ($ans['answer'] != $item->getAnswerText()) {
+ if ($ans['answer'] !== $item->getAnswerText()) {
continue;
}
diff --git a/Modules/TestQuestionPool/classes/class.assErrorText.php b/Modules/TestQuestionPool/classes/class.assErrorText.php
index 2a161f13c422..fe6efee397fa 100644
--- a/Modules/TestQuestionPool/classes/class.assErrorText.php
+++ b/Modules/TestQuestionPool/classes/class.assErrorText.php
@@ -814,9 +814,9 @@ public function createErrorTextExport($selections = null)
$items[$idx] = $word;
$counter++;
}
- $textarray[$textidx] = join($items, " ");
+ $textarray[$textidx] = join(" ", $items);
}
- return join($textarray, "\n");
+ return join("\n", $textarray);
}
public function getBestSelection($withPositivePointsOnly = true)
diff --git a/Modules/TestQuestionPool/classes/class.assFlashQuestionGUI.php b/Modules/TestQuestionPool/classes/class.assFlashQuestionGUI.php
index c0e95aa47c8f..f024179a302a 100644
--- a/Modules/TestQuestionPool/classes/class.assFlashQuestionGUI.php
+++ b/Modules/TestQuestionPool/classes/class.assFlashQuestionGUI.php
@@ -272,10 +272,10 @@ public function getSolutionOutput(
if (count($params)) {
$template->setCurrentBlock("flash_vars");
- $template->setVariable("FLASH_VARS", join($params, "&"));
+ $template->setVariable("FLASH_VARS", join("&", $params));
$template->parseCurrentBlock();
$template->setCurrentBlock("applet_parameters");
- $template->setVariable("PARAM_VALUE", join($params, "&"));
+ $template->setVariable("PARAM_VALUE", join("&", $params));
$template->parseCurrentBlock();
}
if ($show_question_text == true) {
@@ -309,10 +309,10 @@ public function getPreview($show_question_only = false, $showInlineFeedback = fa
}
if (count($params)) {
$template->setCurrentBlock("flash_vars");
- $template->setVariable("FLASH_VARS", join($params, "&"));
+ $template->setVariable("FLASH_VARS", join("&", $params));
$template->parseCurrentBlock();
$template->setCurrentBlock("applet_parameters");
- $template->setVariable("PARAM_VALUE", join($params, "&"));
+ $template->setVariable("PARAM_VALUE", join("&", $params));
$template->parseCurrentBlock();
}
$template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(), true));
@@ -359,10 +359,10 @@ public function getTestOutput($active_id, $pass, $is_postponed = false, $use_pos
if (count($params)) {
$template->setCurrentBlock("flash_vars");
- $template->setVariable("FLASH_VARS", join($params, "&"));
+ $template->setVariable("FLASH_VARS", join("&", $params));
$template->parseCurrentBlock();
$template->setCurrentBlock("applet_parameters");
- $template->setVariable("PARAM_VALUE", join($params, "&"));
+ $template->setVariable("PARAM_VALUE", join("&", $params));
$template->parseCurrentBlock();
}
$template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(), true));
diff --git a/Modules/TestQuestionPool/classes/class.assFormulaQuestion.php b/Modules/TestQuestionPool/classes/class.assFormulaQuestion.php
index 026843630547..c9b7590b70d5 100755
--- a/Modules/TestQuestionPool/classes/class.assFormulaQuestion.php
+++ b/Modules/TestQuestionPool/classes/class.assFormulaQuestion.php
@@ -1268,7 +1268,7 @@ public function getBestSolution($solutions)
$unit_factor = assFormulaQuestionUnit::lookupUnitFactor($user_solution[$result_name]['unit']);
}
- $user_solution[$result->getResult()]["value"] = round(ilMath::_div($resVal, $unit_factor), 55);
+ $user_solution[$result->getResult()]["value"] = ilMath::_div($resVal, $unit_factor, 55);
}
if ($result->getResultType() == assFormulaQuestionResult::RESULT_CO_FRAC
|| $result->getResultType() == assFormulaQuestionResult::RESULT_FRAC) {
@@ -1280,15 +1280,12 @@ public function getBestSolution($solutions)
$user_solution[$result->getResult()]["value"] = $value;
$user_solution[$result->getResult()]["frac_helper"] = null;
}
- } elseif ($result->getPrecision() > 0) {
- $user_solution[$result->getResult()]["value"] = round(
+ } else {
+ $user_solution[$result->getResult()]["value"] = ilMath::_div(
$user_solution[$result->getResult()]["value"],
+ 1,
$result->getPrecision()
);
- } else {
- $user_solution[$result->getResult()]["value"] = round(
- $user_solution[$result->getResult()]["value"]
- );
}
}
return $user_solution;
diff --git a/Modules/TestQuestionPool/classes/class.assFormulaQuestionGUI.php b/Modules/TestQuestionPool/classes/class.assFormulaQuestionGUI.php
index 5da9c530cf55..9ffa10e8457e 100755
--- a/Modules/TestQuestionPool/classes/class.assFormulaQuestionGUI.php
+++ b/Modules/TestQuestionPool/classes/class.assFormulaQuestionGUI.php
@@ -907,7 +907,7 @@ public function checkInput()
* @param boolean $show_feedback Show the question feedback
* @param boolean $show_correct_solution Show the correct solution instead of the user solution
* @param boolean $show_manual_scoring Show specific information for the manual scoring output
- * @return The solution output of the question as HTML code
+ * @return string The solution output of the question as HTML code
*/
public function getSolutionOutput(
$active_id,
@@ -932,7 +932,7 @@ public function getSolutionOutput(
}
$user_solution["active_id"] = $active_id;
$user_solution["pass"] = $pass;
- $solutions = &$this->object->getSolutionValues($active_id, $pass);
+ $solutions = $this->object->getSolutionValues($active_id, $pass);
foreach ($solutions as $idx => $solution_value) {
if (preg_match("/^(\\\$v\\d+)$/", $solution_value["value1"], $matches)) {
$user_solution[$matches[1]] = $solution_value["value2"];
diff --git a/Modules/TestQuestionPool/classes/class.assImagemapQuestionGUI.php b/Modules/TestQuestionPool/classes/class.assImagemapQuestionGUI.php
index 289c9870c223..9d6dfa8613b8 100755
--- a/Modules/TestQuestionPool/classes/class.assImagemapQuestionGUI.php
+++ b/Modules/TestQuestionPool/classes/class.assImagemapQuestionGUI.php
@@ -240,7 +240,7 @@ public function saveShape()
$coords = "";
switch ($_POST["shape"]) {
case "rect":
- $coords = join($_POST['image']['mapcoords'], ",");
+ $coords = join(",", $_POST['image']['mapcoords']);
ilUtil::sendSuccess($this->lng->txt('msg_rect_added'), true);
break;
case "circle":
@@ -250,7 +250,7 @@ public function saveShape()
ilUtil::sendSuccess($this->lng->txt('msg_circle_added'), true);
break;
case "poly":
- $coords = join($_POST['image']['mapcoords'], ",");
+ $coords = join(",", $_POST['image']['mapcoords']);
ilUtil::sendSuccess($this->lng->txt('msg_poly_added'), true);
break;
}
@@ -301,9 +301,9 @@ public function areaEditor($shape = '')
ilUtil::sendInfo($this->lng->txt("rectangle_click_tl_corner"));
} elseif (count($coords) == 1) {
ilUtil::sendInfo($this->lng->txt("rectangle_click_br_corner"));
- $preview->addPoint($preview->getAreaCount(), join($coords, ","), true, "blue");
+ $preview->addPoint($preview->getAreaCount(), join(",", $coords), true, "blue");
} elseif (count($coords) == 2) {
- $c = join($coords, ",");
+ $c = join(",", $coords);
$hidearea = true;
$disabled_save = "";
}
@@ -313,7 +313,7 @@ public function areaEditor($shape = '')
ilUtil::sendInfo($this->lng->txt("circle_click_center"));
} elseif (count($coords) == 1) {
ilUtil::sendInfo($this->lng->txt("circle_click_circle"));
- $preview->addPoint($preview->getAreaCount(), join($coords, ","), true, "blue");
+ $preview->addPoint($preview->getAreaCount(), join(",", $coords), true, "blue");
} elseif (count($coords) == 2) {
if (preg_match("/(\d+)\s*,\s*(\d+)\s+(\d+)\s*,\s*(\d+)/", $coords[0] . " " . $coords[1], $matches)) {
$c = "$matches[1],$matches[2]," . (int) sqrt((($matches[3] - $matches[1]) * ($matches[3] - $matches[1])) + (($matches[4] - $matches[2]) * ($matches[4] - $matches[2])));
@@ -327,11 +327,11 @@ public function areaEditor($shape = '')
ilUtil::sendInfo($this->lng->txt("polygon_click_starting_point"));
} elseif (count($coords) == 1) {
ilUtil::sendInfo($this->lng->txt("polygon_click_next_point"));
- $preview->addPoint($preview->getAreaCount(), join($coords, ","), true, "blue");
+ $preview->addPoint($preview->getAreaCount(), join(",", $coords), true, "blue");
} elseif (count($coords) > 1) {
ilUtil::sendInfo($this->lng->txt("polygon_click_next_or_save"));
$disabled_save = "";
- $c = join($coords, ",");
+ $c = join(",". $coords);
}
break;
}
diff --git a/Modules/TestQuestionPool/classes/class.assJavaApplet.php b/Modules/TestQuestionPool/classes/class.assJavaApplet.php
index 161938d20451..dc40d9a50210 100755
--- a/Modules/TestQuestionPool/classes/class.assJavaApplet.php
+++ b/Modules/TestQuestionPool/classes/class.assJavaApplet.php
@@ -181,7 +181,7 @@ public function buildParams()
array_push($params_array, "param_value_$key=" . $value["value"]);
}
- return join($params_array, "");
+ return join("", $params_array);
}
/**
@@ -201,7 +201,7 @@ public function buildParamsOnly()
array_push($params_array, "param_name_$key=" . $value["name"]);
array_push($params_array, "param_value_$key=" . $value["value"]);
}
- return join($params_array, "");
+ return join("", $params_array);
}
/**
diff --git a/Modules/TestQuestionPool/classes/class.assOrderingHorizontal.php b/Modules/TestQuestionPool/classes/class.assOrderingHorizontal.php
index 22be37a51eec..999539678d1e 100644
--- a/Modules/TestQuestionPool/classes/class.assOrderingHorizontal.php
+++ b/Modules/TestQuestionPool/classes/class.assOrderingHorizontal.php
@@ -785,8 +785,8 @@ public function getAvailableAnswerOptions($index = null)
protected function calculateReachedPointsForSolution($value)
{
$value = $this->splitAndTrimOrderElementText($value, $this->answer_separator);
- $value = join($value, $this->answer_separator);
- if (strcmp($value, join($this->getOrderingElements(), $this->answer_separator)) == 0) {
+ $value = join($this->answer_separator, $value);
+ if (strcmp($value, join($this->answer_separator, $this->getOrderingElements())) == 0) {
$points = $this->getPoints();
return $points;
}
diff --git a/Modules/TestQuestionPool/classes/class.assOrderingHorizontalGUI.php b/Modules/TestQuestionPool/classes/class.assOrderingHorizontalGUI.php
index 611d24a4fd10..94016bfb2389 100644
--- a/Modules/TestQuestionPool/classes/class.assOrderingHorizontalGUI.php
+++ b/Modules/TestQuestionPool/classes/class.assOrderingHorizontalGUI.php
@@ -133,7 +133,6 @@ public function getSolutionOutput(
// get the solution of the user for the active pass or from the last pass if allowed
$template = new ilTemplate("tpl.il_as_qpl_orderinghorizontal_output_solution.html", true, true, "Modules/TestQuestionPool");
- //$solutionvalue = "";
if (($active_id > 0) && (!$show_correct_solution)) {
$elements = [];
$solutions = &$this->object->getSolutionValues($active_id, $pass);
@@ -151,8 +150,6 @@ public function getSolutionOutput(
$template->setVariable("ELEMENT_VALUE", ilUtil::prepareFormOutput($element));
$template->parseCurrentBlock();
}
-
- //$solutionvalue = str_replace("{::}", " ", $solutions[0]["value1"]);
} else {
$elements = $this->object->getOrderingElements();
foreach ($elements as $id => $element) {
@@ -161,7 +158,6 @@ public function getSolutionOutput(
$template->setVariable("ELEMENT_VALUE", ilUtil::prepareFormOutput($element));
$template->parseCurrentBlock();
}
- //$solutionvalue = join($this->object->getOrderingElements(), " ");
}
if (($active_id > 0) && (!$show_correct_solution)) {
@@ -255,7 +251,7 @@ public function getPreview($show_question_only = false, $showInlineFeedback = fa
$template->parseCurrentBlock();
}
$template->setVariable("QUESTION_ID", $this->object->getId());
- $template->setVariable("VALUE_ORDERRESULT", ' value="' . join($elements, '{::}') . '"');
+ $template->setVariable("VALUE_ORDERRESULT", ' value="' . join('{::}', $elements) . '"');
if ($this->object->textsize >= 10) {
$template->setVariable("STYLE", " style=\"font-size: " . $this->object->textsize . "%;\"");
}
@@ -314,7 +310,7 @@ public function getTestOutput($active_id, $pass, $is_postponed = false, $use_pos
if ($this->object->textsize >= 10) {
$template->setVariable("STYLE", " style=\"font-size: " . $this->object->textsize . "%;\"");
}
- $template->setVariable("VALUE_ORDERRESULT", ' value="' . join($elements, '{::}') . '"');
+ $template->setVariable("VALUE_ORDERRESULT", ' value="' . join('{::}', $elements) . '"');
$template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(), true));
$questionoutput = $template->get();
if (!$show_question_only) {
diff --git a/Modules/TestQuestionPool/classes/class.assQuestion.php b/Modules/TestQuestionPool/classes/class.assQuestion.php
index 0a2a2e86de3a..1161f38bbeb5 100755
--- a/Modules/TestQuestionPool/classes/class.assQuestion.php
+++ b/Modules/TestQuestionPool/classes/class.assQuestion.php
@@ -1065,7 +1065,7 @@ public function getSuggestedSolutionOutput()
break;
}
}
- return join($output, " ");
+ return join(" ", $output);
}
/**
@@ -1320,7 +1320,7 @@ final public function calculateResultsFromSolution($active_id, $pass = null, $ob
*/
final public function persistWorkingState($active_id, $pass = null, $obligationsEnabled = false, $authorized = true)
{
- if (!$this->validateSolutionSubmit()) {
+ if (!$this->validateSolutionSubmit() && !$this->savePartial()) {
return false;
}
@@ -5479,4 +5479,9 @@ protected function buildTestPresentationConfig()
}
// hey.
// fau.
+
+ public function savePartial()
+ {
+ return false;
+ }
}
diff --git a/Modules/TestQuestionPool/classes/class.assQuestionGUI.php b/Modules/TestQuestionPool/classes/class.assQuestionGUI.php
index d7b10aef65d9..0c043abc65d1 100755
--- a/Modules/TestQuestionPool/classes/class.assQuestionGUI.php
+++ b/Modules/TestQuestionPool/classes/class.assQuestionGUI.php
@@ -1309,6 +1309,10 @@ protected function saveTaxonomyAssignments()
protected function populateTaxonomyFormSection(ilPropertyFormGUI $form)
{
if (count($this->getTaxonomyIds())) {
+ // this is needed by ilTaxSelectInputGUI in some cases
+ require_once 'Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php';
+ ilOverlayGUI::initJavaScript();
+
$sectHeader = new ilFormSectionHeaderGUI();
$sectHeader->setTitle($this->lng->txt('qpl_qst_edit_form_taxonomy_section'));
$form->addItem($sectHeader);
diff --git a/Modules/TestQuestionPool/classes/class.ilMatchingPairWizardInputGUI.php b/Modules/TestQuestionPool/classes/class.ilMatchingPairWizardInputGUI.php
index ac13674820f0..a3084f7b9850 100644
--- a/Modules/TestQuestionPool/classes/class.ilMatchingPairWizardInputGUI.php
+++ b/Modules/TestQuestionPool/classes/class.ilMatchingPairWizardInputGUI.php
@@ -248,7 +248,7 @@ public function insert($a_tpl)
array_push($ids, $term->identifier);
}
$tpl->setVariable("POST_VAR", $this->getPostVar());
- $tpl->setVariable("TERM_IDS", join($ids, ","));
+ $tpl->setVariable("TERM_IDS", join(",", $ids));
$tpl->parseCurrentBlock();
$tpl->setCurrentBlock('definition_ids');
@@ -257,7 +257,7 @@ public function insert($a_tpl)
array_push($ids, $definition->identifier);
}
$tpl->setVariable("POST_VAR", $this->getPostVar());
- $tpl->setVariable("DEFINITION_IDS", join($ids, ","));
+ $tpl->setVariable("DEFINITION_IDS", join(",", $ids));
$tpl->parseCurrentBlock();
$tpl->setVariable("ELEMENT_ID", $this->getPostVar());
diff --git a/Modules/TestQuestionPool/classes/export/qti12/class.assMatchingQuestionExport.php b/Modules/TestQuestionPool/classes/export/qti12/class.assMatchingQuestionExport.php
index adb15e2c3a39..cb46cc70b3ca 100644
--- a/Modules/TestQuestionPool/classes/export/qti12/class.assMatchingQuestionExport.php
+++ b/Modules/TestQuestionPool/classes/export/qti12/class.assMatchingQuestionExport.php
@@ -137,7 +137,7 @@ public function toXML($a_include_header = true, $a_include_binary = true, $a_shu
$attrs = array(
"ident" => $definition->identifier,
"match_max" => "1",
- "match_group" => join($termids, ",")
+ "match_group" => join(",", $termids)
);
$a_xml_writer->xmlStartTag("response_label", $attrs);
$a_xml_writer->xmlStartTag("material");
diff --git a/Modules/TestQuestionPool/classes/forms/class.ilAssMatchingPairCorrectionsInputGUI.php b/Modules/TestQuestionPool/classes/forms/class.ilAssMatchingPairCorrectionsInputGUI.php
index 57898eb9b216..a270dc08e3bb 100644
--- a/Modules/TestQuestionPool/classes/forms/class.ilAssMatchingPairCorrectionsInputGUI.php
+++ b/Modules/TestQuestionPool/classes/forms/class.ilAssMatchingPairCorrectionsInputGUI.php
@@ -101,7 +101,7 @@ public function insert($a_tpl)
array_push($ids, $term->identifier);
}
$tpl->setVariable("POST_VAR", $this->getPostVar());
- $tpl->setVariable("TERM_IDS", join($ids, ","));
+ $tpl->setVariable("TERM_IDS", join(",", $ids));
$tpl->parseCurrentBlock();
$tpl->setCurrentBlock('definition_ids');
@@ -110,7 +110,7 @@ public function insert($a_tpl)
array_push($ids, $definition->identifier);
}
$tpl->setVariable("POST_VAR", $this->getPostVar());
- $tpl->setVariable("DEFINITION_IDS", join($ids, ","));
+ $tpl->setVariable("DEFINITION_IDS", join(",", $ids));
$tpl->parseCurrentBlock();
$tpl->setVariable("ELEMENT_ID", $this->getPostVar());
diff --git a/Modules/TestQuestionPool/classes/tables/class.assFileUploadFileTableGUI.php b/Modules/TestQuestionPool/classes/tables/class.assFileUploadFileTableGUI.php
index 3afbfd74761f..13d5067ab2f2 100644
--- a/Modules/TestQuestionPool/classes/tables/class.assFileUploadFileTableGUI.php
+++ b/Modules/TestQuestionPool/classes/tables/class.assFileUploadFileTableGUI.php
@@ -135,7 +135,7 @@ protected function buildFileItemContent($a_set)
return ilUtil::prepareFormOutput($a_set['value2']);
}
- $link = "";
+ $link = "";
$link .= ilUtil::prepareFormOutput($a_set['value2']) . '';
return $link;
diff --git a/Modules/TestQuestionPool/templates/default/cloze_gap_builder.js b/Modules/TestQuestionPool/templates/default/cloze_gap_builder.js
index 48fed5e51119..0d54aa201e21 100644
--- a/Modules/TestQuestionPool/templates/default/cloze_gap_builder.js
+++ b/Modules/TestQuestionPool/templates/default/cloze_gap_builder.js
@@ -1132,6 +1132,34 @@ var ClozeGapBuilder = (function () {
}
};
+ pro.removeSelectOption = function() {
+ let getPosition, pos, value;
+ if ($(this).attr('class') !== 'clone_fields_remove combination btn btn-link') {
+ value = $(this).parent().parent().find('.text_field').val();
+ $('[data-answer="' + value + '"]').show();
+ getPosition = $(this).attr('name');
+ pos = getPosition.split('_');
+ pos = getPosition.split('_');
+ ClozeSettings.gaps_php[0][pos[2]].values.splice(pos[3], 1);
+ pro.editTextarea(pos[2]);
+ if (ClozeSettings.gaps_php[0][pos[2]].values.length === 0) {
+ ClozeSettings.gaps_php[0].splice(pos[2], 1);
+ pro.removeFromTextarea(pos[2]);
+ }
+ } else {
+ getPosition = $(this).parent().attr('name');
+ pos = getPosition.split('_');
+ ClozeSettings.gaps_combination[pos[2]][0].splice(parseInt(pos[3], 10), 1);
+ ClozeSettings.gaps_combination[pos[2]][1].forEach(function (answers) {
+ answers.splice(parseInt(pos[3], 10), 1);
+ });
+ if (ClozeSettings.gaps_combination[pos[2]][0].length < 2) {
+ ClozeSettings.gaps_combination.splice(parseInt(pos[2], 10), 1);
+ }
+ }
+ pub.paintGaps();
+ return false;
+ },
pro.appendEventListenerToBeRefactored = function(){
$('.clone_fields_add').off('click');
@@ -1198,38 +1226,8 @@ var ClozeGapBuilder = (function () {
return false;
});
- $('.clone_fields_remove').on('click', function ()
- {
- var getPosition, pos, value;
- if($(this).attr('class') != 'clone_fields_remove combination btn btn-link')
- {
- value = $(this).parent().parent().find('.text_field').val();
- $('[data-answer="'+value+'"]').show();
- getPosition = $(this).attr('name');
- pos = getPosition.split('_');
- ClozeSettings.gaps_php[0][pos[2]].values.splice(pos[3], 1);
- pro.editTextarea(pos[2]);
- if (ClozeSettings.gaps_php[0][pos[2]].values.length === 0) {
- ClozeSettings.gaps_php[0].splice(pos[2], 1);
- pro.removeFromTextarea(pos[2]);
- }
- }
- else
- {
- getPosition = $(this).parent().attr('name');
- pos = getPosition.split('_');
- ClozeSettings.gaps_combination[pos[2]][0].splice(parseInt(pos[3], 10), 1);
- ClozeSettings.gaps_combination[pos[2]][1].forEach(function (answers) {
- answers.splice(parseInt(pos[3], 10), 1);
- });
- if(ClozeSettings.gaps_combination[pos[2]][0].length < 2)
- {
- ClozeSettings.gaps_combination.splice(parseInt(pos[2], 10),1);
- }
- }
- pub.paintGaps();
- return false;
- });
+ $('.clone_fields_remove').off('click', pro.removeSelectOption);
+ $('.clone_fields_remove').on('click', pro.removeSelectOption);
$('.remove_gap_button').off('click');
$('.remove_gap_button').on('click', function () {
diff --git a/Modules/TestQuestionPool/templates/default/tpl.il_as_qpl_cloze_question_gap_numeric.html b/Modules/TestQuestionPool/templates/default/tpl.il_as_qpl_cloze_question_gap_numeric.html
index c1fb5a97168e..bb71cd14a1f8 100755
--- a/Modules/TestQuestionPool/templates/default/tpl.il_as_qpl_cloze_question_gap_numeric.html
+++ b/Modules/TestQuestionPool/templates/default/tpl.il_as_qpl_cloze_question_gap_numeric.html
@@ -1 +1 @@
- size="{TEXT_GAP_SIZE}" maxlength="{TEXT_GAP_SIZE}" />
\ No newline at end of file
+ size="{TEXT_GAP_SIZE}" maxlength="{TEXT_GAP_SIZE}" />
diff --git a/Modules/TestQuestionPool/templates/default/tpl.il_as_qpl_content.html b/Modules/TestQuestionPool/templates/default/tpl.il_as_qpl_content.html
index c8daa46f9b0c..d0070414620a 100755
--- a/Modules/TestQuestionPool/templates/default/tpl.il_as_qpl_content.html
+++ b/Modules/TestQuestionPool/templates/default/tpl.il_as_qpl_content.html
@@ -1,7 +1,7 @@
{STATUSLINE}