|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* For licensing terms, see /license.txt */ |
|
4
|
|
|
|
|
5
|
|
|
use Chamilo\CoreBundle\Enums\ActionIcon; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* Class SurveyExportTxtPlugin. |
|
9
|
|
|
*/ |
|
10
|
|
|
class SurveyExportTxtPlugin extends Plugin |
|
11
|
|
|
{ |
|
12
|
|
|
/** |
|
13
|
|
|
* SurveyExportTxtPlugin constructor. |
|
14
|
|
|
*/ |
|
15
|
|
|
protected function __construct() |
|
16
|
|
|
{ |
|
17
|
|
|
$settings = [ |
|
18
|
|
|
'enabled' => 'boolean', |
|
19
|
|
|
'export_incomplete' => 'boolean', |
|
20
|
|
|
]; |
|
21
|
|
|
|
|
22
|
|
|
parent::__construct('0.1', 'Angel Fernando Quiroz Campos', $settings); |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @return SurveyExportTxtPlugin|null |
|
27
|
|
|
*/ |
|
28
|
|
|
public static function create() |
|
29
|
|
|
{ |
|
30
|
|
|
static $result = null; |
|
31
|
|
|
|
|
32
|
|
|
return $result ?: $result = new self(); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Installation process. |
|
37
|
|
|
*/ |
|
38
|
|
|
public function install() |
|
39
|
|
|
{ |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Uninstallation process. |
|
44
|
|
|
*/ |
|
45
|
|
|
public function uninstall() |
|
46
|
|
|
{ |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @param array $params |
|
51
|
|
|
* |
|
52
|
|
|
* @return string |
|
53
|
|
|
*/ |
|
54
|
|
|
public static function filterModify($params) |
|
55
|
|
|
{ |
|
56
|
|
|
$enabled = api_get_plugin_setting('surveyexporttxt', 'enabled'); |
|
57
|
|
|
|
|
58
|
|
|
if ('true' !== $enabled) { |
|
59
|
|
|
return ''; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
$surveyId = isset($params['survey_id']) ? (int) $params['survey_id'] : 0; |
|
63
|
|
|
$iconSize = isset($params['icon_size']) ? $params['icon_size'] : ICON_SIZE_SMALL; |
|
64
|
|
|
|
|
65
|
|
|
if (empty($surveyId)) { |
|
66
|
|
|
return ''; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
return Display::url( |
|
70
|
|
|
Display::getMdiIcon(ActionIcon::EXPORT_ARCHIVE, 'ch-tool-icon', null, $iconSize, get_lang('Export')), |
|
71
|
|
|
api_get_path(WEB_PLUGIN_PATH).'SurveyExportTxt/export.php?survey='.$surveyId.'&'.api_get_cidreq() |
|
72
|
|
|
); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* Create tools for all courses. |
|
77
|
|
|
*/ |
|
78
|
|
|
private function createLinkToCourseTools() |
|
|
|
|
|
|
79
|
|
|
{ |
|
80
|
|
|
$result = Database::getManager() |
|
81
|
|
|
->createQuery('SELECT c.id FROM ChamiloCoreBundle:Course c') |
|
82
|
|
|
->getResult(); |
|
83
|
|
|
|
|
84
|
|
|
foreach ($result as $item) { |
|
85
|
|
|
$this->createLinkToCourseTool($this->get_name().':teacher', $item['id']); |
|
86
|
|
|
} |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* Remove all course tools created by plugin. |
|
91
|
|
|
*/ |
|
92
|
|
|
private function removeLinkToCourseTools() |
|
|
|
|
|
|
93
|
|
|
{ |
|
94
|
|
|
Database::getManager() |
|
95
|
|
|
->createQuery('DELETE FROM ChamiloCourseBundle:CTool t WHERE t.link LIKE :link AND t.category = :category') |
|
96
|
|
|
->execute(['link' => 'SurveyExportTxt/start.php%', 'category' => 'plugin']); |
|
97
|
|
|
} |
|
98
|
|
|
} |
|
99
|
|
|
|
This check looks for private methods that have been defined, but are not used inside the class.