Skip to content

Commit 1093183

Browse files
authored
Create AnswerTable.php
1 parent bfc100b commit 1093183

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

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+
}

0 commit comments

Comments
 (0)