ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilTestEvaluationDataTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
26 {
28 
29  protected function setUp(): void
30  {
31  parent::setUp();
32  $user_data = [
35  ];
36  $this->testObj = new ilTestEvaluationData($user_data);
37  }
38 
39 
41  {
42  $this->assertInstanceOf(ilTestEvaluationData::class, $this->testObj);
43  }
44 
45  public function test__sleep(): void
46  {
47  $expected = ['question_titles', 'participants', 'statistics', 'arr_filter', 'datasets', 'test'];
48 
49  $this->assertEquals($expected, $this->testObj->__sleep());
50  }
51 
52  public function testDatasets(): void
53  {
54  $this->testObj->setDatasets(20);
55 
56  $this->assertEquals(20, $this->testObj->getDatasets());
57  }
58 
59  public function testQuestionTitle(): void
60  {
61  $expected = [
62  120 => "abcd",
63  121 => "Hello",
64  2150 => "World",
65  ];
66 
67  foreach ($expected as $questionId => $questionTitle) {
68  $this->testObj->addQuestionTitle($questionId, $questionTitle);
69  }
70 
71  $this->assertEquals($expected, $this->testObj->getQuestionTitles());
72 
73  $this->assertEquals($expected[2150], $this->testObj->getQuestionTitle(2150));
74  }
75 
76  public function testEvaluationFactory(): void
77  {
78  $records = [];
79  $records[7] = [
80  "active_id" => 7 ,
81  "question_fi" => 9,
82  "result_points" => 1.2,
83  "answered" => true,
84  "manual" => 1,
85  "original_id" => null,
86  "questiontitle" => "some title",
87  "qpl_maxpoints" => 2.4,
88  "submitted" => true,
89  "last_finished_pass" => 1,
90  "active_fi" => 7 ,
91  "pass" => 1,
92  "points" => 10.3,
93  "maxpoints" => 32,
94  "questioncount" => 32,
95  "answeredquestions" => 1,
96  "workingtime" => 28,
97  "tstamp" => 1731941437,
98  "hint_count" => 0,
99  "hint_points" => 0,
100  "obligations_answered" => true,
101  "exam_id" => "I0_T355_A7_P1",
102  "usr_id" => 6,
103  "firstname" => "root",
104  "lastname" => "user",
105  "title" => "",
106  "login" => "root"
107  ];
108 
109  $test_obj = $this->createMock(ilObjTest::class);
110  $test_obj
111  ->expects($this->once())
112  ->method('getPassScoring');
113  $test_obj
114  ->expects($this->once())
115  ->method('getAccessFilteredParticipantList');
116  $test_obj
117  ->expects($this->once())
118  ->method('getTestParticipants');
119 
120  $factory = new class ($test_obj, $records) extends ilTestEvaluationFactory {
121  public function __construct(
122  protected ilObjTest $test_obj,
123  protected array $records
124  ) {
125  }
126  protected function queryEvaluationData(array $active_ids): array
127  {
128  return $this->records;
129  }
130  protected function getVisitTimeOfParticipant(int $active_id): array
131  {
132  return [
133  'firstvisit' => 1731941437,
134  'lastvisit' => 1731941537
135  ];
136  }
137  protected function addQuestionsToParticipantPasses(ilTestEvaluationData $evaluation_data): ilTestEvaluationData
138  {
139  return $evaluation_data;
140  }
141  };
142 
143  $data = $factory->getEvaluationData();
144  $this->assertInstanceOf(ilTestEvaluationData::class, $data);
145  $this->assertEquals(
146  [7],
147  $data->getParticipantIds()
148  );
149  $this->assertInstanceOf(ilTestEvaluationUserData::class, $data->getParticipant(7));
150  }
151 }
Class ilTestEvaluationDataTest.
__construct(VocabulariesInterface $vocabularies)
Class ilTestBaseClass.