Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/release_9' into merge/9/9-5-2024…
Browse files Browse the repository at this point in the history
…1108
  • Loading branch information
mjansenDatabay committed Nov 8, 2024
2 parents 8b084e8 + a91105a commit f045665
Show file tree
Hide file tree
Showing 78 changed files with 583 additions and 1,044 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,11 @@ public static function handleEvent(
): void {
global $DIC;

$user_event = $DIC->bookingManager()->internal()->domain()->userEvent();

switch ($a_component) {
case "Services/User":
switch ($a_event) {
case "deleteUser":
$user_event->handleDeletion((int) $a_parameter["usr_id"]);
$DIC->bookingManager()->internal()->domain()->userEvent()->handleDeletion((int) $a_parameter["usr_id"]);
break;
}
break;
Expand Down
1 change: 1 addition & 0 deletions Modules/Course/classes/class.ilObjCourseGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,7 @@ public function updateObject(): void
$GLOBALS['DIC']->language()->txt('crs_tile_and_objective_view_not_supported')
);
$this->editObject($form);
return;
}

// Additional checks: both tile and session limitation activated (not supported)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,9 @@ public function getAssignmentMembersIds(): array
" WHERE ass_id = " . $ilDB->quote($this->assignment->getId(), "integer"));

while ($rec = $ilDB->fetchAssoc($set)) {
if (!\ilObjUser::userExists([(int) $rec['usr_id']])) {
continue;
}
$members[] = $rec['usr_id'];
}

Expand Down
37 changes: 25 additions & 12 deletions Modules/File/classes/Info/class.ilObjFileInfoRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@
*
*********************************************************************/

use ILIAS\DI\Container;
use ILIAS\Filesystem\Stream\FileStream;
use ILIAS\FileUpload\DTO\UploadResult;
use ILIAS\FileUpload\FileUpload;
use ILIAS\ResourceStorage\Manager\Manager;
use ILIAS\ResourceStorage\Revision\Revision;
use ILIAS\ResourceStorage\Policy\FileNamePolicyException;
use ILIAS\Data\DataSize;
use ILIAS\FileUpload\MimeType;

Expand Down Expand Up @@ -63,15 +56,30 @@ private function initInlineSuffixes(): array
return array_map('strtolower', explode(' ', $settings->get('inline_file_extensions', '')));
}

public function preloadData(array $object_ids): void
public function preloadData(array $ids, bool $are_ref_ids = false): void
{
$res = $this->db->query(
"SELECT title, rid, file_id, page_count FROM file_data JOIN object_data ON object_data.obj_id = file_data.file_id WHERE rid IS NOT NULL AND " . $this->db->in(
if ($are_ref_ids) {
$query = "SELECT title, rid, file_id, page_count
FROM file_data
JOIN object_data ON object_data.obj_id = file_data.file_id
JOIN object_reference ON object_reference.obj_id = object_data.obj_id
WHERE rid IS NOT NULL AND " . $this->db->in(
'ref_id',
$ids,
false,
'integer'
);
} else {
$query = "SELECT title, rid, file_id, page_count FROM file_data JOIN object_data ON object_data.obj_id = file_data.file_id WHERE rid IS NOT NULL AND " . $this->db->in(
'file_id',
$object_ids,
$ids,
false,
'integer'
)
);
}

$res = $this->db->query(
$query
);
$rids = [];
$page_counts = [];
Expand Down Expand Up @@ -113,7 +121,12 @@ public function preloadData(array $object_ids): void

public function getByObjectId(int $object_id): ilObjFileInfo
{
if (isset(self::$cache[$object_id])) {
return self::$cache[$object_id];
}

$this->preloadData([$object_id]);

return self::$cache[$object_id] ?? new ilObjFileInfo(
'Unknown',
null,
Expand Down
14 changes: 9 additions & 5 deletions Modules/File/classes/PreProcessors/class.ilCountPDFPages.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*
*********************************************************************/

use ILIAS\ResourceStorage\Services;
use ILIAS\FileUpload\MimeType;
use ILIAS\ResourceStorage\Identification\ResourceIdentification;

Expand All @@ -27,7 +28,10 @@
*/
class ilCountPDFPages
{
private \ILIAS\ResourceStorage\Services $irss;
/**
* @readonly
*/
private Services $irss;
private bool $postscript_available = false;
private bool $imagick_available = false;

Expand Down Expand Up @@ -69,11 +73,11 @@ public function extractAmountOfPagesByPath(string $path_to_pdf): ?int
if ($this->imagick_available) {
$pages = null;
try {
$imagick = new Imagick($path_to_pdf);
$pages = $imagick->getNumberImages();
$imagick = new Imagick();
$imagick->pingImage($path_to_pdf);

return $pages;
} catch (Throwable $e) {
return $imagick->getNumberImages();
} catch (Throwable) {
// Imagick is not available or another error occured
}
}
Expand Down
4 changes: 2 additions & 2 deletions Modules/File/classes/class.ilObjFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ public function __construct(int $a_id = 0, bool $a_call_by_reference = true)

protected function initFileInfo(int $id, bool $is_ref_id): void
{
$repository = new ilObjFileInfoRepository(true);
$repository = new ilObjFileInfoRepository();
if ($is_ref_id) {
$this->file_info = $repository->getByRefId($id);
} else {
$this->file_info = ($repository)->getByObjectId($id);
$this->file_info = $repository->getByObjectId($id);
}
}

Expand Down
6 changes: 3 additions & 3 deletions Modules/Glossary/Export/class.ilGlossaryDataSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,9 @@ public function importRecord(
$newObj->setDescription($a_rec["Description"]);
$newObj->setVirtualMode($a_rec["Virtual"]);
$newObj->setPresentationMode($a_rec["PresMode"]);
$newObj->setSnippetLength($a_rec["SnippetLength"]);
$newObj->setActiveGlossaryMenu($a_rec["GloMenuActive"]);
$newObj->setShowTaxonomy($a_rec["ShowTax"]);
$newObj->setSnippetLength((int) ($a_rec["SnippetLength"] ?? 0));
$newObj->setActiveGlossaryMenu((bool) ($a_rec["GloMenuActive"] ?? false));
$newObj->setShowTaxonomy((bool) ($a_rec["ShowTax"] ?? false));
$newObj->setActiveFlashcards((bool) ($a_rec["FlashActive"] ?? false));
$newObj->setFlashcardsMode($a_rec["FlashMode"] ?? "");
if ($this->getCurrentInstallationId() > 0) {
Expand Down
6 changes: 4 additions & 2 deletions Modules/Glossary/Term/class.ilGlossaryTerm.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ public function read(): void
$this->setImportId((string) $term_rec["import_id"]);
$this->setLanguage((string) $term_rec["language"]);
$this->setGlossaryId((int) $term_rec["glo_id"]);
$this->setShortText((string) $term_rec["short_text"]);
$this->setShortTextDirty((int) $term_rec["short_text_dirty"]);

$this->page_object = new ilGlossaryDefPage($this->getId());
}
Expand Down Expand Up @@ -232,8 +234,8 @@ public function create(bool $a_omit_page_creation = false): void
$ilDB->quote($this->getImportId(), "text") . ", " .
$ilDB->now() . ", " .
$ilDB->now() . ", " .
$ilDB->quote($this->getShortText()) . ", " .
$ilDB->quote($this->getShortTextDirty()) . ")");
$ilDB->quote($this->getShortText(), "text") . ", " .
$ilDB->quote($this->getShortTextDirty(), "integer") . ")");

if (!$a_omit_page_creation) {
$this->page_object = new ilGlossaryDefPage();
Expand Down
4 changes: 2 additions & 2 deletions Modules/Glossary/classes/class.ilObjGlossary.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,11 @@ public function setSnippetLength(int $a_val): void
$this->snippet_length = $a_val;
}

public function getSnippetLength(): ?int
public function getSnippetLength(): int
{
return ($this->snippet_length > 0)
? $this->snippet_length
: null;
: 200;
}

public function setOnline(bool $a_online): void
Expand Down
13 changes: 1 addition & 12 deletions Modules/Poll/classes/BlockGUI/class.ilPollBlockGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
* https://www.ilias.de
* https://github.com/ILIAS-eLearning
*
********************************************************************
*/
*********************************************************************/

declare(strict_types=1);

Expand All @@ -33,7 +32,6 @@ class ilPollBlockGUI extends ilBlockGUI
public static string $block_type = "poll";
protected ilPollBlock $poll_block;
public static bool $js_init = false;
protected bool $new_rendering = true;
protected UIFactory $ui_factory;
protected UIRenderer $ui_renderer;
protected ilPollStateInfo $state;
Expand Down Expand Up @@ -244,15 +242,6 @@ public function getNumberOfCommentsForRedraw(): void
$this->comments->getNumberOfCommentsForRedraw();
}

public function fillDataSection(): void
{
$this->setDataSection($this->getLegacyContent());
}

//
// New rendering
//

protected function getLegacyContent(): string
{
$this->tpl = new ilTemplate(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php

declare(strict_types=1);

/**
* This file is part of ILIAS, a powerful learning management system
* published by ILIAS open source e-Learning e.V.
Expand All @@ -18,6 +16,8 @@
*
*********************************************************************/

declare(strict_types=1);

use ILIAS\HTTP\Wrapper\RequestWrapper;
use ILIAS\Refinery\Factory;

Expand Down Expand Up @@ -135,13 +135,6 @@ protected function isRepositoryObject(): bool
{
return false;
}

public function fillDataSection(): void
{
assert($this->userHasReadableStudyProgrammes()); // We should not get here.
$this->tpl->setVariable("BLOCK_ROW", $this->getDataSectionContent());
}

protected function userHasVisibleStudyProgrammes(): bool
{
if (count($this->users_assignments) === 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ public function checkInput(): bool

// check neutral column scale
if ($neutral_scale != "") {
if (is_array($foundvalues['scale'])) {
if (isset($foundvalues['scale'])) {
if (in_array($neutral_scale, $foundvalues['scale'])) {
$this->setAlert($lng->txt("msg_duplicate_scale"));
return false;
Expand Down
17 changes: 10 additions & 7 deletions Modules/Test/classes/Results/class.ilTestPassResultsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,6 @@ protected function getMapping(): \Closure
$stats_fields[$lng->txt('tst_question_hints_requested_hint_count_header')] = (string)$question->getNumberOfRequestedHints();
$stats = $ui_factory->listing()->characteristicValue()->text($stats_fields);

$user_answer = $question->getUserAnswer();
$best_solution = $env->getShowBestSolution() ? $question->getBestSolution() : '';


$feedback = $ui_factory->listing()->descriptive([
$lng->txt('tst_feedback') => $question->getFeedback()
Expand All @@ -219,11 +216,17 @@ protected function getMapping(): \Closure
]);
}

$user_answer = $question->getUserAnswer();
$answer_contents = [
$ui_factory->listing()->descriptive([$lng->txt('tst_header_participant') => $user_answer])
];
if ($env->getShowBestSolution()) {
$answer_contents[] = $ui_factory->listing()->descriptive([
$lng->txt('tst_header_solution') => $question->getBestSolution()
]);
}

$answers = $ui_factory->layout()->alignment()->horizontal()->evenlyDistributed(
$ui_factory->listing()->descriptive([$lng->txt('tst_header_participant') => $user_answer]),
$ui_factory->listing()->descriptive([$lng->txt('tst_header_solution') => $best_solution])
);
$answers = $ui_factory->layout()->alignment()->horizontal()->evenlyDistributed(...$answer_contents);
$contents[] = $answers;

$content = $ui_factory->layout()->alignment()->vertical(...$contents);
Expand Down
52 changes: 21 additions & 31 deletions Modules/Test/classes/class.ilObjTestGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -1431,43 +1431,33 @@ public function importVerifiedFileObject()
$questionParentObjId = $_POST["qpl"];
}

$imp = new ilImport($this->testrequest->getRefId());
$map = $imp->getMapping();
$map->addMapping('Modules/Test', 'tst', 'new_id', (string) $newObj->getId());

$fileName = ilSession::get('tst_import_subdir') . '.zip';
$fullPath = ilSession::get('tst_import_dir') . '/' . $fileName;

if (is_file(ilSession::get("tst_import_dir") . '/' . ilSession::get("tst_import_subdir") . "/manifest.xml")) {
$newObj->saveToDb();

ilSession::set('tst_import_idents', $_POST['ident'] ?? '');
ilSession::set('tst_import_qst_parent', $questionParentObjId);

$fileName = ilSession::get('tst_import_subdir') . '.zip';
$fullPath = ilSession::get('tst_import_dir') . '/' . $fileName;
$imp = new ilImport($this->testrequest->getRefId());
$map = $imp->getMapping();
$map->addMapping('Modules/Test', 'tst', 'new_id', (string) $newObj->getId());
$imp->importObject($newObj, $fullPath, $fileName, 'tst', 'Modules/Test', true);
} else {
$qtiParser = new ilQTIParser(ilSession::get("tst_import_qti_file"), ilQTIParser::IL_MO_PARSE_QTI, $questionParentObjId, $_POST["ident"] ?? '');
if (!file_exists(ilSession::get("tst_import_results_file"))
&& (!isset($_POST["ident"]) || !is_array($_POST["ident"]) || !count($_POST["ident"]))) {
$qtiParser->setIgnoreItemsEnabled(true);
}
$qtiParser->setTestObject($newObj);
$qtiParser->startParsing();
$newObj->saveToDb();
$questionPageParser = new ilQuestionPageParser($newObj, ilSession::get("tst_import_xml_file"), ilSession::get("tst_import_subdir"));
$questionPageParser->setQuestionMapping($qtiParser->getImportMapping());
$questionPageParser->startParsing();

if (file_exists(ilSession::get("tst_import_results_file"))) {
$results = new ilTestResultsImportParser(
ilSession::get("tst_import_results_file"),
$newObj,
$this->db,
$this->logging_services->root()
);
$results->setQuestionIdMapping($qtiParser->getQuestionIdMapping());
$results->startParsing();
}

$newObj->update();
$test_importer = new ilTestImporter();
$test_importer->setImport($imp);
$test_importer->setInstallId(IL_INST_ID);
$test_importer->setImportDirectory(ilSession::get('tst_import_dir') . '/' . ilSession::get('tst_import_subdir'));
$test_importer->init();

$test_importer->importXmlRepresentation(
'',
'',
'',
$map,
);
}


Expand Down Expand Up @@ -2480,7 +2470,7 @@ public function confirmedApplyDefaultsObject()
*/
public function applyDefaultsObject($confirmed = false)
{
if(!$confirmed) {
if (!$confirmed) {
if (!isset($_POST['chb_defaults']) || !is_array($_POST["chb_defaults"]) || 1 !== count($_POST["chb_defaults"])) {
$this->tpl->setOnScreenMessage('info', $this->lng->txt("tst_defaults_apply_select_one"));

Expand All @@ -2498,7 +2488,7 @@ public function applyDefaultsObject($confirmed = false)
return;
}

if(!$confirmed) {
if (!$confirmed) {
$defaults = $this->object->getTestDefaults($_POST["chb_defaults"][0]);
} else {
$defaults = $this->object->getTestDefaults($_POST["confirmed_defaults_id"][0]);
Expand Down
Loading

0 comments on commit f045665

Please sign in to comment.