| 1 |
www |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
declare(strict_types=1);
|
|
|
4 |
|
|
|
5 |
namespace LeadersLinked\Form;
|
|
|
6 |
|
|
|
7 |
use Laminas\Form\Form;
|
|
|
8 |
use LeadersLinked\Model\CompanyMicrolearningSlide;
|
|
|
9 |
use LeadersLinked\Mapper\QueryMapper;
|
|
|
10 |
use LeadersLinked\Mapper\CompanyMicrolearningQuizMapper;
|
|
|
11 |
use LeadersLinked\Model\CompanyMicrolearningQuiz;
|
|
|
12 |
|
|
|
13 |
class SlideQuizzEditForm extends Form
|
|
|
14 |
{
|
|
|
15 |
|
|
|
16 |
public function __construct($adapter, $company_id)
|
|
|
17 |
{
|
|
|
18 |
parent::__construct();
|
|
|
19 |
$this->setInputFilter(new SlideQuizzEditFilter($adapter, $company_id));
|
|
|
20 |
|
|
|
21 |
$this->add([
|
|
|
22 |
'name' => 'type',
|
|
|
23 |
'type' => \Laminas\Form\Element\Hidden::class,
|
|
|
24 |
'attributes' => [
|
|
|
25 |
'id' => 'type',
|
|
|
26 |
'value' => CompanyMicrolearningSlide::TYPE_QUIZ
|
|
|
27 |
]
|
|
|
28 |
]);
|
|
|
29 |
|
|
|
30 |
$this->add([
|
|
|
31 |
'name' => 'name',
|
|
|
32 |
'type' => \Laminas\Form\Element\Textarea::class,
|
|
|
33 |
'attributes' => [
|
|
|
34 |
'id' => 'name',
|
|
|
35 |
]
|
|
|
36 |
]);
|
|
|
37 |
|
|
|
38 |
$this->add([
|
|
|
39 |
'name' => 'order',
|
|
|
40 |
'type' => \Laminas\Form\Element\Text::class,
|
|
|
41 |
'attributes' => [
|
|
|
42 |
'id' => 'order',
|
|
|
43 |
],
|
|
|
44 |
]);
|
|
|
45 |
|
|
|
46 |
$this->add([
|
|
|
47 |
'name' => 'background',
|
|
|
48 |
'type' => \Laminas\Form\Element\File::class,
|
|
|
49 |
'attributes' => [
|
|
|
50 |
'id' => 'background',
|
|
|
51 |
]
|
|
|
52 |
]);
|
|
|
53 |
|
|
|
54 |
$this->add([
|
|
|
55 |
'name' => 'quiz_id',
|
|
|
56 |
'type' => \Laminas\Form\Element\Select::class,
|
|
|
57 |
'options' => [
|
|
|
58 |
'value_options' => $this->getQuizOptions($adapter, $company_id)
|
|
|
59 |
],
|
|
|
60 |
'attributes' => [
|
|
|
61 |
'id' => 'quiz_id',
|
|
|
62 |
]
|
|
|
63 |
]);
|
|
|
64 |
|
|
|
65 |
}
|
|
|
66 |
|
|
|
67 |
|
|
|
68 |
private function getQuizOptions($adapter, $company_id)
|
|
|
69 |
{
|
|
|
70 |
$queryMapper = QueryMapper::getInstance($adapter);
|
|
|
71 |
$select = $queryMapper->getSql()->select(CompanyMicrolearningQuizMapper::_TABLE);
|
|
|
72 |
$select->columns(['id', 'name']);
|
|
|
73 |
$select->where->equalTo('company_id', $company_id);
|
|
|
74 |
$select->where->equalTo('status', CompanyMicrolearningQuiz::STATUS_ACTIVE);
|
|
|
75 |
$select->where->equalTo('check', CompanyMicrolearningQuiz::CHECK_OK);
|
|
|
76 |
|
|
|
77 |
$options = [];
|
|
|
78 |
$records = $queryMapper->fetchAll($select);
|
|
|
79 |
foreach($records as $record)
|
|
|
80 |
{
|
|
|
81 |
$options[ $record['id'] ] = $record['name'];
|
|
|
82 |
}
|
|
|
83 |
|
|
|
84 |
return $options;
|
|
|
85 |
|
|
|
86 |
|
|
|
87 |
}
|
|
|
88 |
}
|