Skip to content

Commit

Permalink
fixed 0040804: Minimal margin size is not set to minimum (5mm) but to 4
Browse files Browse the repository at this point in the history
  • Loading branch information
fneumann committed Mar 22, 2024
1 parent af919fc commit e4708df
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 14 deletions.
9 changes: 6 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
30 changes: 30 additions & 0 deletions classes/Data/Constraints/class.MinimumInteger.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace ILIAS\Plugin\LongEssayAssessment\Data\Constraints;

use ILIAS\Refinery\Constraint;
use ILIAS\Data;
use ILIAS\Refinery\Custom\Constraint as CustomConstraint;

class MinimumInteger extends CustomConstraint implements Constraint
{
/**
* @var int
*/
protected $min;

public function __construct(int $min, Data\Factory $data_factory, \ilLanguage $lng)
{
$this->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
);
}
}
37 changes: 37 additions & 0 deletions classes/Data/class.DataConstraints.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace ILIAS\Plugin\LongEssayAssessment\Data;

use ILIAS\Data\Factory;
use ILIAS\Plugin\LongEssayAssessment\Data\Constraints\MinimumInteger;

class DataConstraints
{
/**
* @var Factory
*/
private $dataFactory;

/**
* @var \ilLanguage
*/
private $language;

public function __construct(Factory $dataFactory, \ilLanguage $language)
{
$this->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);
}
}
12 changes: 6 additions & 6 deletions classes/Task/class.EditorSettingsGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down Expand Up @@ -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());

Expand Down
23 changes: 19 additions & 4 deletions classes/class.LongEssayAssessmentDI.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
Expand Down Expand Up @@ -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"]);
};
Expand Down Expand Up @@ -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"];
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion lang/ilias_de.lang
Original file line number Diff line number Diff line change
Expand Up @@ -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
tutors_added#:#Die Tutoren wurden hinzugefügt
constraint_error_not_minimum#:#%s ist kleiner als das Minimum %s.

0 comments on commit e4708df

Please sign in to comment.