Skip to content

Commit

Permalink
Test: Fix Missing Questions in Export
Browse files Browse the repository at this point in the history
  • Loading branch information
kergomard committed Jan 27, 2025
1 parent 3c82db7 commit bba3563
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

declare(strict_types=1);

use ILIAS\Test\Results\Data\StatusOfAttempt;
use ILIAS\Test\Statistics\Statistics;

/**
Expand Down
2 changes: 2 additions & 0 deletions components/ILIAS/Test/src/ExportImport/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public function getExporter(
$this->lng,
$this->current_user,
$test_obj,
$this->questionrepository,
"{$test_obj->getTitle()}_{$this->lng->txt('scored_pass')}_{$this->lng->txt('results')}",
true
))->withAggregatedResultsPage()
Expand All @@ -63,6 +64,7 @@ public function getExporter(
$this->lng,
$this->current_user,
$test_obj,
$this->questionrepository,
"{$test_obj->getTitle()}_{$this->lng->txt('all')}_{$this->lng->txt('results')}",
false
))->withAggregatedResultsPage()
Expand Down
14 changes: 6 additions & 8 deletions components/ILIAS/Test/src/ExportImport/ResultsExportExcel.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

namespace ILIAS\Test\ExportImport;

use ILIAS\Data\Factory as DataFactory;
use ILIAS\TestQuestionPool\Questions\GeneralQuestionPropertiesRepository;
use ILIAS\Data\DateFormat\DateFormat;

/**
Expand All @@ -44,6 +44,7 @@ public function __construct(
private readonly \ilLanguage $lng,
private readonly \ilObjUser $current_user,
private readonly \ilObjTest $test_obj,
private readonly GeneralQuestionPropertiesRepository $question_repository,
private readonly string $filename = '',
private readonly bool $scoredonly = true,
) {
Expand Down Expand Up @@ -74,10 +75,7 @@ public function withAggregatedResultsPage(): self
public function withResultsPage(): self
{
$this->worksheet->addSheet($this->lng->txt('tst_results'));

$cols_for_question_ids = $this->addResultsHeader();
$this->addResultsContent($cols_for_question_ids);

$this->addResultsContent($this->addResultsHeader());
return $this;
}

Expand Down Expand Up @@ -263,9 +261,9 @@ private function addResultsHeader(): array
$this->worksheet->setCell(1, $col++, $this->lng->txt('pass'));

$question_cols = [];
foreach ($this->test_obj->getQuestions() as $question_id) {
$question_cols[$question_id] = $col;
$this->worksheet->setCell(1, $col++, $this->getCompleteData()->getQuestionTitle($question_id));
foreach ($this->question_repository->getForParentObjectId($this->test_obj->getId()) as $question_properties) {
$question_cols[$question_properties->getQuestionId()] = $col;
$this->worksheet->setCell(1, $col++, $question_properties->getTitle());
}

$this->worksheet->setBold('A1:' . $this->worksheet->getColumnCoord($col - 1) . '1');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
namespace ILIAS\Test\Tests\ExportImport;

use ILIAS\Test\ExportImport\ResultsExportExcel;
use ILIAS\TestQuestionPool\Questions\GeneralQuestionPropertiesRepository;

class ResultsExportExcelTest extends \ilTestBaseTestCase
{
Expand All @@ -29,7 +30,8 @@ public function testConstruct(): void
$excel_export = new ResultsExportExcel(
$this->createMock(\ilLanguage::class),
$this->createMock(\ilObjUser::class),
$this->getTestObjMock()
$this->getTestObjMock(),
$this->createMock(GeneralQuestionPropertiesRepository::class),
);
$this->assertInstanceOf(ResultsExportExcel::class, $excel_export);
}
Expand Down

0 comments on commit bba3563

Please sign in to comment.