Skip to content

Commit

Permalink
Version 1.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
fneumann committed Mar 1, 2024
1 parent 5032bd4 commit 520bd8d
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Change Log

## Version 1.4.1 (2024-03-01)
- fixed pseudonym creation for writers

## Version 1.4 (2024-02-29)
- cleanup cross-task corrector assignments created by wrong imports
- improve corrector assignments export and import
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public function importAssignments(string $file)
/** @var Writer[] $writers */
foreach ($writers as $writer) {
if (empty($writer->getId())) {
$this->writer_repo->save($writer);
$this->writer_admin_service->saveNewWriter($writer);
}
}
/** @var Corrector[] $correctors */
Expand Down
22 changes: 18 additions & 4 deletions classes/WriterAdmin/class.WriterAdminService.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,36 @@ public function __construct(int $task_id)

/**
* Get a writer object for an ILIAS user
* A new writer object is not yet saved
* A new writer object is not yet saved, it must be saved with saveNewWriter
* @param int $user_id
* @return Writer
* @see saveNewWriter
*/
public function getWriterFromUserId(int $user_id) : Writer
{
$writer = $this->writerRepo->getWriterByUserIdAndTaskId($user_id, $this->task_id);
if (!isset($writer)) {
$writer = new Writer();
$writer->setUserId($user_id)
->setTaskId($this->task_id)
->setPseudonym($this->plugin->txt('participant') . ' ' .$writer->getId());
->setTaskId($this->task_id);
}
return $writer;
}

/**
* save a new writer object
* This sets the pseudonym which is based on the writer id
*/
public function saveNewWriter(Writer $writer) : Writer
{
$writer->setPseudonym('');
$this->writerRepo->save($writer);
// now the id is known
$writer->setPseudonym($this->plugin->txt('participant') . ' ' .$writer->getId());
$this->writerRepo->save($writer);
return $writer;
}

/**
* Get or create a writer object for an ILIAS user
* A new writer object is already saved
Expand All @@ -79,7 +93,7 @@ public function getOrCreateWriterFromUserId(int $user_id) : Writer
{
$writer = $this->getWriterFromUserId($user_id);
if (empty($writer->getId())) {
$this->writerRepo->save($writer);
$this->saveNewWriter($writer);
}
return $writer;
}
Expand Down
2 changes: 1 addition & 1 deletion plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
$id = 'xlas';

// code version; must be changed for all code changes
$version = '1.4';
$version = '1.4.1';
// ilias min and max version; must always reflect the versions that should
// run with the plugin
$ilias_min_version = '7.25';
Expand Down
9 changes: 9 additions & 0 deletions sql/dbupdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -2063,3 +2063,12 @@
LEFT JOIN xlas_corrector c ON c.id = a.corrector_id
WHERE c.id IS NULL OR w.id IS NULL OR c.task_id <> w.task_id
";
?>
<#93>
<?php
// fix wrongly created pseudonyms
$query = "
UPDATE xlas_writer
SET pseudonym = CONCAT('Teilnehmer/in ', id)
WHERE pseudonym = 'Teilnehmer/in 0'
";

0 comments on commit 520bd8d

Please sign in to comment.