Skip to content

Commit 40398d5

Browse files
authored
Merge pull request #1 from elenasimchenko/v-0.2
v 0.2
2 parents b4ea537 + 1093183 commit 40398d5

File tree

4 files changed

+247
-0
lines changed

4 files changed

+247
-0
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Change log
2+
3+
## 0.2 - 2019-09-02
4+
5+
* Добавлены классы AnswerTable, QuestionTable, TestResultTable

lib/AnswerTable.php

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
namespace Learning;
3+
use Bitrix\Main\Entity;
4+
5+
class AnswerTable 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_answer';
15+
}
16+
17+
/**
18+
* Returns entity map definition.
19+
*
20+
* @return array
21+
* @throws \Bitrix\Main\ArgumentException
22+
*/
23+
public static function getMap()
24+
{
25+
return array(
26+
new Entity\IntegerField('ID', array(
27+
'primary' => true,
28+
'autocomplete' => true
29+
)),
30+
new Entity\IntegerField('QUESTION_ID', array(
31+
'required' => true
32+
)),
33+
new Entity\ReferenceField(
34+
'QUESTION',
35+
'\Learning\QuestionTable',
36+
array('=this.QUESTION_ID' => 'ref.ID'),
37+
array('join_type' => 'LEFT')
38+
),
39+
new Entity\IntegerField('SORT'),
40+
new Entity\TextField('ANSWER', array(
41+
'required' => true
42+
)),
43+
new Entity\StringField('CORRECT', array(
44+
'required' => true,
45+
'validation' => array(__CLASS__, 'validateCorrect'),
46+
)),
47+
new Entity\TextField('FEEDBACK'),
48+
new Entity\TextField('MATCH_ANSWER')
49+
);
50+
}
51+
/**
52+
* Returns validators for CORRECT field.
53+
*
54+
* @return array
55+
*/
56+
public static function validateCorrect()
57+
{
58+
return array(
59+
new Main\Entity\Validator\Length(null, 1),
60+
);
61+
}
62+
}

lib/QuestionTable.php

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
<?php
2+
namespace Learning;
3+
use Bitrix\Main\Entity;
4+
5+
class QuestionTable 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_question';
15+
}
16+
17+
/**
18+
* Returns User Fields ID.
19+
*
20+
* @return array
21+
*/
22+
public static function getUfId()
23+
{
24+
return 'LEARNING_QUESTIONS';
25+
}
26+
27+
/**
28+
* Returns entity map definition.
29+
*
30+
* @return array
31+
* @throws \Bitrix\Main\ArgumentException
32+
* @throws \Bitrix\Main\ObjectException
33+
*/
34+
public static function getMap()
35+
{
36+
return array(
37+
new Entity\IntegerField('ID', array(
38+
'primary' => true,
39+
'autocomplete' => true
40+
)),
41+
new Entity\BooleanField('ACTIVE', array(
42+
'values' => array('N', 'Y')
43+
)),
44+
new Entity\DatetimeField('TIMESTAMP_X', array(
45+
'default_value' => new \Bitrix\Main\Type\DateTime(),
46+
'title' => 'timestamp',
47+
)),
48+
new Entity\IntegerField('LESSON_ID'),
49+
new Entity\ReferenceField(
50+
'LESSON',
51+
'\Learning\LessonTable',
52+
array('=this.LESSON_ID' => 'ref.ID'),
53+
array('join_type' => 'LEFT')
54+
),
55+
new Entity\StringField('QUESTION_TYPE', array(
56+
'required' => true,
57+
'validation' => array(__CLASS__, 'validateQuestionType'),
58+
)),
59+
new Entity\StringField('NAME', array(
60+
'required' => true,
61+
'validation' => array(__CLASS__, 'validateName'),
62+
)),
63+
new Entity\IntegerField('SORT'),
64+
new Entity\IntegerField('DESCRIPTION'),
65+
new Entity\TextField('DESCRIPTION_TYPE'),
66+
new Entity\BooleanField('SELF', array(
67+
'values' => array('text', 'html')
68+
)),
69+
new Entity\TextField('COMMENT_TEXT'),
70+
new Entity\IntegerField('FILE_ID'),
71+
new Entity\BooleanField('SELF', array(
72+
'values' => array('N', 'Y')
73+
)),
74+
new Entity\IntegerField('POINT'),
75+
new Entity\StringField('DIRECTION', array(
76+
'required' => true,
77+
'validation' => array(__CLASS__, 'validateDirection'),
78+
)),
79+
new Entity\BooleanField('CORRECT_REQUIRED', array(
80+
'values' => array('N', 'Y')
81+
)),
82+
new Entity\BooleanField('EMAIL_ANSWER', array(
83+
'values' => array('N', 'Y')
84+
)),
85+
new Entity\TextField('INCORRECT_MESSAGE'),
86+
);
87+
}
88+
89+
/**
90+
* Returns validators for QUESTION_TYPE field.
91+
*
92+
* @return array
93+
*/
94+
public static function validateQuestionType()
95+
{
96+
return array(
97+
new Main\Entity\Validator\Length(null, 1),
98+
);
99+
}
100+
101+
/**
102+
* Returns validators for NAME field.
103+
*
104+
* @return array
105+
*/
106+
public static function validateName()
107+
{
108+
return array(
109+
new Main\Entity\Validator\Length(null, 255),
110+
);
111+
}
112+
113+
/**
114+
* Returns validators for DIRECTION field.
115+
*
116+
* @return array
117+
*/
118+
public static function validateDirection()
119+
{
120+
return array(
121+
new Main\Entity\Validator\Length(null, 1),
122+
);
123+
}
124+
}

lib/TestResultTable.php

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
namespace Learning;
3+
use Bitrix\Main\Entity;
4+
5+
class TestResultTable 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_result';
15+
}
16+
17+
/**
18+
* Returns entity map definition.
19+
*
20+
* @return array
21+
*/
22+
public static function getMap()
23+
{
24+
return array(
25+
'ID' => array(
26+
'data_type' => 'integer',
27+
'primary' => true,
28+
'autocomplete' => true,
29+
),
30+
'ATTEMPT_ID' => array(
31+
'data_type' => 'integer',
32+
'required' => true,
33+
),
34+
'QUESTION_ID' => array(
35+
'data_type' => 'integer',
36+
'required' => true,
37+
),
38+
'RESPONSE' => array(
39+
'data_type' => 'text',
40+
),
41+
'POINT' => array(
42+
'data_type' => 'integer',
43+
'required' => true,
44+
),
45+
'CORRECT' => array(
46+
'data_type' => 'boolean',
47+
'values' => array('N', 'Y'),
48+
),
49+
'ANSWERED' => array(
50+
'data_type' => 'boolean',
51+
'values' => array('N', 'Y'),
52+
),
53+
);
54+
}
55+
}
56+

0 commit comments

Comments
 (0)