Skip to content

Commit b4ea537

Browse files
authored
Create TestTable.php
1 parent b433484 commit b4ea537

File tree

1 file changed

+155
-0
lines changed

1 file changed

+155
-0
lines changed

lib/TestTable.php

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
<?php
2+
namespace Learning;
3+
use Bitrix\Main\Entity;
4+
5+
class TestTable extends Entity\DataManager
6+
{
7+
/**
8+
* Returns DB table name for entity.
9+
*
10+
* @return string
11+
*/
12+
public static function getTableName()
13+
{
14+
return 'b_learn_test';
15+
}
16+
17+
/**
18+
* Returns entity map definition.
19+
*
20+
* Reference идет со стороны вопроса на урок, отношение N:1
21+
*
22+
* @return array
23+
*/
24+
public static function getMap()
25+
{
26+
return array(
27+
new Entity\IntegerField('ID', array(
28+
'primary' => true,
29+
'autocomplete' => true
30+
)),
31+
new Entity\IntegerField('COURSE_ID', array(
32+
'required' => true
33+
)),
34+
new Entity\ReferenceField(
35+
'COURSE',
36+
'\Learning\CourseTable',
37+
array('=this.COURSE_ID' => 'ref.ID'),
38+
array('join_type' => 'LEFT')
39+
),
40+
new Entity\DateTimeField('TIMESTAMP_X', array(
41+
'required' => true
42+
)),
43+
new Entity\IntegerField('SORT'),
44+
new Entity\BooleanField('ACTIVE', array(
45+
'values' => array('N', 'Y')
46+
)),
47+
new Entity\StringField('NAME', array(
48+
'required' => true,
49+
'validation' => array(__CLASS__, 'validateName'),
50+
)),
51+
new Entity\TextField('DESCRIPTION'),
52+
new Entity\EnumField('DESCRIPTION_TYPE', array(
53+
'values' => array('text', 'html')
54+
)),
55+
new Entity\IntegerField('ATTEMPT_LIMIT', array(
56+
'required' => true
57+
)),
58+
new Entity\IntegerField('ATTEMPT_LIMIT'),
59+
new Entity\IntegerField('COMPLETED_SCORE'),
60+
new Entity\StringField('QUESTIONS_FROM', array(
61+
'required' => true,
62+
'validation' => array(__CLASS__, 'validateQuestionsFrom'),
63+
)),
64+
// @todo @ESimchenko Ref QUESTIONS_FROM
65+
new Entity\IntegerField('QUESTIONS_FROM_ID', array(
66+
'required' => true
67+
)),
68+
new Entity\IntegerField('QUESTIONS_AMOUNT', array(
69+
'required' => true
70+
)),
71+
new Entity\BooleanField('RANDOM_QUESTIONS', array(
72+
'values' => array('N', 'Y')
73+
)),
74+
new Entity\BooleanField('RANDOM_ANSWERS', array(
75+
'values' => array('N', 'Y')
76+
)),
77+
new Entity\BooleanField('APPROVED', array(
78+
'values' => array('N', 'Y')
79+
)),
80+
new Entity\BooleanField('INCLUDE_SELF_TEST', array(
81+
'values' => array('N', 'Y')
82+
)),
83+
new Entity\StringField('PASSAGE_TYPE', array(
84+
'required' => true,
85+
'validation' => array(__CLASS__, 'validatePassageType'),
86+
)),
87+
new Entity\IntegerField('PREVIOUS_TEST_ID'),
88+
// @todo @ESimchenko Ref PREVIOUS_TEST
89+
new Entity\IntegerField('PREVIOUS_TEST_SCORE'),
90+
new Entity\BooleanField('INCORRECT_CONTROL', array(
91+
'values' => array('N', 'Y')
92+
)),
93+
new Entity\IntegerField('CURRENT_INDICATION', array(
94+
'required' => true
95+
)),
96+
new Entity\IntegerField('FINAL_INDICATION', array(
97+
'required' => true
98+
)),
99+
new Entity\IntegerField('FINAL_INDICATION', array(
100+
'required' => true
101+
)),
102+
new Entity\IntegerField('MIN_TIME_BETWEEN_ATTEMPTS', array(
103+
'required' => true
104+
)),
105+
new Entity\BooleanField('SHOW_ERRORS', array(
106+
'values' => array('N', 'Y')
107+
)),
108+
new Entity\BooleanField('NEXT_QUESTION_ON_ERROR', array(
109+
'values' => array('N', 'Y')
110+
))
111+
);
112+
}
113+
114+
/**
115+
* Returns validators for NAME field.
116+
*
117+
* @return array
118+
*/
119+
public static function validateName()
120+
{
121+
return array(
122+
new Main\Entity\Validator\Length(null, 255),
123+
);
124+
}
125+
/**
126+
* Returns validators for QUESTIONS_FROM field.
127+
*
128+
* В тесте участвуют вопросы из:
129+
* A - со всего курса,
130+
* C - с каждой главы,
131+
* L - с каждого урока.
132+
* S - все вопросы урока
133+
* R -
134+
*
135+
* @return array
136+
*/
137+
public static function validateQuestionsFrom()
138+
{
139+
return array(
140+
new Main\Entity\Validator\Length(null, 1),
141+
);
142+
}
143+
/**
144+
* Returns validators for PASSAGE_TYPE field.
145+
*
146+
* @return array
147+
*/
148+
public static function validatePassageType()
149+
{
150+
return array(
151+
new Main\Entity\Validator\Length(null, 1),
152+
);
153+
}
154+
155+
}

0 commit comments

Comments
 (0)