From e4708df764e3e87d621fa0a244e7ba89ff99229e Mon Sep 17 00:00:00 2001 From: fneumann Date: Sat, 23 Mar 2024 00:48:01 +0100 Subject: [PATCH] fixed 0040804: Minimal margin size is not set to minimum (5mm) but to 4 --- CHANGELOG.md | 9 +++-- .../Data/Constraints/class.MinimumInteger.php | 30 +++++++++++++++ classes/Data/class.DataConstraints.php | 37 +++++++++++++++++++ classes/Task/class.EditorSettingsGUI.php | 12 +++--- classes/class.LongEssayAssessmentDI.php | 23 ++++++++++-- lang/ilias_de.lang | 3 +- 6 files changed, 100 insertions(+), 14 deletions(-) create mode 100644 classes/Data/Constraints/class.MinimumInteger.php create mode 100644 classes/Data/class.DataConstraints.php diff --git a/CHANGELOG.md b/CHANGELOG.md index d33f1a68..19974ec1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,12 @@ # Change Log ## Version 1.5 (upcoming) -- function to add all course tutors as correctors -- optimized file delivery of instructions, material, solution -- don't block writer startup by loading instructions and material +- plugin: function to add all course tutors as correctors +- plugin: fixed 0040804: Minimal margin size is not set to minimum (5mm) but to 4 +- plugin: optimized file delivery of instructions, material, solution +- service: fixed error sending new steps after partially successful sending +- writer: don't block writer startup by loading instructions and material +- writer: fixed scrolling area of preview for autorisation ## Version 1.4.1 (2024-03-01) - fixed pseudonym creation for writers diff --git a/classes/Data/Constraints/class.MinimumInteger.php b/classes/Data/Constraints/class.MinimumInteger.php new file mode 100644 index 00000000..52b731e5 --- /dev/null +++ b/classes/Data/Constraints/class.MinimumInteger.php @@ -0,0 +1,30 @@ +min = $min; + parent::__construct( + function ($value) { + return $value >= $this->min; + }, + function ($txt, $value) { + return $txt("rep_robj_xlas_constraint_error_not_minimum", $value, $this->min); + }, + $data_factory, + $lng + ); + } +} \ No newline at end of file diff --git a/classes/Data/class.DataConstraints.php b/classes/Data/class.DataConstraints.php new file mode 100644 index 00000000..3e6cead7 --- /dev/null +++ b/classes/Data/class.DataConstraints.php @@ -0,0 +1,37 @@ +dataFactory = $dataFactory; + $this->language = $language; + } + + /** + * Creates a constraint that can be used to check if an integer value is + * greater or equal than the defined lower limit. + * + * @param int $minimum - lower limit for the new constraint + * @return MinimumInteger + */ + public function minimumInteger(int $minimum) : MinimumInteger + { + return new MinimumInteger($minimum, $this->dataFactory, $this->language); + } +} diff --git a/classes/Task/class.EditorSettingsGUI.php b/classes/Task/class.EditorSettingsGUI.php index 5cd698e4..301d71ee 100644 --- a/classes/Task/class.EditorSettingsGUI.php +++ b/classes/Task/class.EditorSettingsGUI.php @@ -126,12 +126,12 @@ protected function editSettings() $fields['add_correction_margin'] = $factory->optionalGroup( [ 'left_correction_margin' => $factory->numeric($this->plugin->txt('left_correction_margin')) - ->withAdditionalTransformation($this->refinery->to()->int()) + ->withAdditionalTransformation($this->refinery->kindlyTo()->int()) ->withRequired(true) ->withDisabled($hasComments) ->withValue($editorSettings->getLeftCorrectionMargin()), 'right_correction_margin' => $factory->numeric($this->plugin->txt('right_correction_margin')) - ->withAdditionalTransformation($this->refinery->to()->int()) + ->withAdditionalTransformation($this->refinery->kindlyTo()->int()) ->withRequired(true) ->withDisabled($hasComments) ->withValue($editorSettings->getRightCorrectionMargin()), @@ -162,25 +162,25 @@ protected function editSettings() $fields['top_margin'] = $factory->numeric($this->plugin->txt('pdf_top_margin'), $this->plugin->txt('pdf_top_margin_info')) ->withAdditionalTransformation($this->refinery->to()->int()) - ->withAdditionalTransformation($this->refinery->int()->isGreaterThan(4)) + ->withAdditionalTransformation($this->localDI->constraints()->minimumInteger(5)) ->withRequired(true) ->withValue($pdfSettings->getTopMargin()); $fields['bottom_margin'] = $factory->numeric($this->plugin->txt('pdf_bottom_margin'), $this->plugin->txt('pdf_bottom_margin_info')) ->withAdditionalTransformation($this->refinery->to()->int()) - ->withAdditionalTransformation($this->refinery->int()->isGreaterThan(4)) + ->withAdditionalTransformation($this->localDI->constraints()->minimumInteger(5)) ->withRequired(true) ->withValue($pdfSettings->getBottomMargin()); $fields['left_margin'] = $factory->numeric($this->plugin->txt('pdf_left_margin'), $this->plugin->txt('pdf_left_margin_info')) ->withAdditionalTransformation($this->refinery->to()->int()) - ->withAdditionalTransformation($this->refinery->int()->isGreaterThan(4)) + ->withAdditionalTransformation($this->localDI->constraints()->minimumInteger(5)) ->withRequired(true) ->withValue($pdfSettings->getLeftMargin()); $fields['right_margin'] = $factory->numeric($this->plugin->txt('pdf_right_margin'), $this->plugin->txt('pdf_right_margin_info')) ->withAdditionalTransformation($this->refinery->to()->int()) - ->withAdditionalTransformation($this->refinery->int()->isGreaterThan(4)) + ->withAdditionalTransformation($this->localDI->constraints()->minimumInteger(5)) ->withRequired(true) ->withValue($pdfSettings->getRightMargin()); diff --git a/classes/class.LongEssayAssessmentDI.php b/classes/class.LongEssayAssessmentDI.php index d4ee68ad..235e334f 100644 --- a/classes/class.LongEssayAssessmentDI.php +++ b/classes/class.LongEssayAssessmentDI.php @@ -20,6 +20,7 @@ use ILIAS\Plugin\LongEssayAssessment\Task\LoggingService; use ILIAS\Plugin\LongEssayAssessment\CorrectorAdmin\CorrectorAssignmentsService; use ILIAS\Plugin\LongEssayAssessment\ServiceLayer\ServicesFactory; +use ILIAS\Plugin\LongEssayAssessment\Data\DataConstraints; /** * @author Fabian Wolf @@ -52,6 +53,13 @@ public function init(\ilLongEssayAssessmentPlugin $plugin) $dic["xlas.plugin"] = $plugin; + $dic["xlas.data_constraints"] = function() use ($dic) { + return new DataConstraints( + new \ILIAS\Data\Factory(), + $dic->language() + ); + }; + $dic["xlas.custom_template_factory"] = function () use ($dic) { return new PluginTemplateFactory($dic["ui.template_factory"], $dic["xlas.plugin"], $dic["tpl"]); }; @@ -153,6 +161,17 @@ public static function getInstance(): LongEssayAssessmentDI return self::$instance; } + public function constraints() : DataConstraints + { + return $this->container["xlas.data_constraints"]; + } + + public function services() : ServicesFactory + { + return $this->container["xlas.services_factory"]; + } + + public function getSystemRepo(): SystemRepository { return $this->container["xlas.system_repository"]; @@ -183,10 +202,6 @@ public function getCorrectorRepo(): CorrectorRepository return $this->container["xlas.corrector_repository"]; } - public function services() : ServicesFactory - { - return $this->container["xlas.services_factory"]; - } // /** // * @return ComponentRenderer diff --git a/lang/ilias_de.lang b/lang/ilias_de.lang index ecd7bba9..71cf1b2f 100644 --- a/lang/ilias_de.lang +++ b/lang/ilias_de.lang @@ -534,4 +534,5 @@ import_line_corrector_repeated#:#Zeile %s: das Konto '%s' ist mehrfach zur Korre assignment_excel_import_info#:#Die Zuweisungen werden vom ersten Blatt einer Excel-Datei importiert, dessen erste Zeile die Spaltenbezeichnungen enthält. Sie muss die Bezeichnungen "Login" für den Teilnehmer, "Corrector 1" für den Korrektor und evtl. "Corrector 2" für einen Zweitkorrektor enthalten. In diesen Spalten werden Login-Namen von Benutzerkonten eingetragen, die im System existieren müssen. Falls sie noch nicht als Teilnehmer oder Korrektoren eingetragen sind, wird das automatisch gemacht. add_all_course_tutors#:#Alle Tutoren hinzufügen confirm_add_all_course_tutors#:#Möchten Sie alle Kurstutoren als Korrektoren hinzufügen? -tutors_added#:#Die Tutoren wurden hinzugefügt \ No newline at end of file +tutors_added#:#Die Tutoren wurden hinzugefügt +constraint_error_not_minimum#:#%s ist kleiner als das Minimum %s. \ No newline at end of file