blob: e68a1e6fb751c89204b362baab693ab4e7cf83c7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
<?php
class QuestionnaireInfo extends QuestionnaireQuestion implements QuestionType
{
public static function getIcon(bool $active = false) : Icon
{
return Icon::create(static::getIconShape(), $active ? 'clickable' : 'info');
}
/**
* Returns the shape of the icon of this QuestionType
* @return string
*/
public static function getIconShape()
{
return 'question-info';
}
public static function getName()
{
return _('Information');
}
static public function getEditingComponent()
{
return ['questionnaire-info-edit', ''];
}
public function beforeStoringQuestiondata($questiondata)
{
$questiondata['description'] = \Studip\Markup::markAsHtml(
\Studip\Markup::purifyHtml($questiondata['description'])
);
return $questiondata;
}
public function getDisplayTemplate()
{
$factory = new Flexi_TemplateFactory(realpath(__DIR__.'/../../app/views'));
$template = $factory->open('questionnaire/question_types/info/info');
$template->set_attribute('vote', $this);
return $template;
}
public function createAnswer()
{
return new QuestionnaireAnswer(); // Unused but necessary
}
public function getUserIdsOfFilteredAnswer($answer_option)
{
return [];
}
public function getResultTemplate($only_user_ids = null)
{
$factory = new Flexi_TemplateFactory(realpath(__DIR__.'/../../app/views'));
$template = $factory->open('questionnaire/question_types/info/info');
$template->set_attribute('vote', $this);
return $template;
}
public function getResultArray()
{
return [];
}
/**
* Return whether a given url is valid.
* @return bool
*/
public function hasValidURL(): bool
{
return !empty($this->questiondata['url'])
&& trim($this->questiondata['url'])
&& filter_var($this->questiondata['url'], FILTER_VALIDATE_URL);
}
}
|