| Línea 104... |
Línea 104... |
| 104 |
// Link to overview.
|
104 |
// Link to overview.
|
| 105 |
if (has_capability('block/point_view:access_overview', $this->context)) {
|
105 |
if (has_capability('block/point_view:access_overview', $this->context)) {
|
| 106 |
$parameters = [
|
106 |
$parameters = [
|
| 107 |
'instanceid' => $this->instance->id,
|
107 |
'instanceid' => $this->instance->id,
|
| 108 |
'contextid' => $this->context->id,
|
108 |
'contextid' => $this->context->id,
|
| 109 |
'courseid' => $COURSE->id
|
109 |
'courseid' => $COURSE->id,
|
| 110 |
];
|
110 |
];
|
| Línea 111... |
Línea 111... |
| 111 |
|
111 |
|
| 112 |
$url = new moodle_url('/blocks/point_view/overview.php', $parameters);
|
112 |
$url = new moodle_url('/blocks/point_view/overview.php', $parameters);
|
| 113 |
$title = get_string('reactionsdetails', 'block_point_view');
|
113 |
$title = get_string('reactionsdetails', 'block_point_view');
|
| Línea 122... |
Línea 122... |
| 122 |
]),
|
122 |
]),
|
| 123 |
[ 'title' => $title ]
|
123 |
[ 'title' => $title ]
|
| 124 |
);
|
124 |
);
|
| 125 |
}
|
125 |
}
|
| Línea -... |
Línea 126... |
| - |
|
126 |
|
| - |
|
127 |
if ($this->page->cm !== null
|
| - |
|
128 |
&& (!empty($this->config->enable_point_views) || !empty($this->config->enable_difficultytracks))
|
| - |
|
129 |
&& has_capability('moodle/block:edit', $this->context)) {
|
| - |
|
130 |
$this->content->text .= html_writer::div(
|
| - |
|
131 |
get_string('forthismodule', 'block_point_view', $this->page->cm->get_formatted_name()), 'mt-3 mb-2');
|
| - |
|
132 |
$moduleform = new block_point_view\module_form(new moodle_url('/blocks/point_view/action/updatemodule.php'),
|
| - |
|
133 |
[
|
| - |
|
134 |
'cmid' => $this->page->cm->id,
|
| - |
|
135 |
'blockconfig' => $this->config,
|
| - |
|
136 |
'blockinstanceid' => $this->instance->id,
|
| - |
|
137 |
'returnurl' => $this->page->url,
|
| - |
|
138 |
]);
|
| - |
|
139 |
$moduleform->set_data([
|
| - |
|
140 |
'enablereactions' => ($this->config->{'moduleselectm' . $this->page->cm->id} ?? 0) > 0 ? 1 : 0,
|
| - |
|
141 |
'difficultytrack' => $this->config->{'difficulty_' . $this->page->cm->id} ?? 0,
|
| - |
|
142 |
]);
|
| - |
|
143 |
$this->content->text .= $moduleform->render();
|
| - |
|
144 |
}
|
| - |
|
145 |
|
| - |
|
146 |
if ((!$this->instance->showinsubcontexts || !preg_match('/^(?:mod-)?\\*$/', $this->instance->pagetypepattern))
|
| - |
|
147 |
&& has_capability('moodle/block:edit', $this->context)) {
|
| - |
|
148 |
$this->content->text .=
|
| - |
|
149 |
'<div>
|
| - |
|
150 |
<i class="fa fa-info-circle text-info mr-1"></i>' .
|
| - |
|
151 |
get_string('blockonlyonmainpage', 'block_point_view') .
|
| - |
|
152 |
'</div>
|
| - |
|
153 |
<form method="post" action="' . $CFG->wwwroot . '/blocks/point_view/action/showinsubcontexts.php">
|
| - |
|
154 |
<input name="sesskey" type="hidden" value="' . sesskey() . '">
|
| - |
|
155 |
<input name="blockinstanceid" type="hidden" value="' . $this->instance->id . '">
|
| - |
|
156 |
<input name="returnurl" type="hidden" value="' . $this->page->url . '">
|
| - |
|
157 |
<input id="block_point_view_showinsubcontexts" type="submit"
|
| - |
|
158 |
value="' . get_string('showinsubcontexts', 'block_point_view') . '" class="btn btn-link p-0">
|
| - |
|
159 |
</form>';
|
| - |
|
160 |
$this->page->requires->event_handler('#block_point_view_showinsubcontexts', 'click', 'M.util.show_confirm_dialog',
|
| - |
|
161 |
[ 'message' => get_string('confirmshowinsubcontexts', 'block_point_view') ]);
|
| - |
|
162 |
}
|
| 126 |
|
163 |
|
| Línea 127... |
Línea 164... |
| 127 |
} else if (has_capability('block/point_view:addinstance', $this->context)) {
|
164 |
} else if (has_capability('block/point_view:addinstance', $this->context)) {
|
| Línea 128... |
Línea 165... |
| 128 |
|
165 |
|
| Línea 160... |
Línea 197... |
| 160 |
* @see block_base::get_required_javascript()
|
197 |
* @see block_base::get_required_javascript()
|
| 161 |
*/
|
198 |
*/
|
| 162 |
public function get_required_javascript() {
|
199 |
public function get_required_javascript() {
|
| 163 |
parent::get_required_javascript();
|
200 |
parent::get_required_javascript();
|
| Línea -... |
Línea 201... |
| - |
|
201 |
|
| - |
|
202 |
require_once(__DIR__ . '/locallib.php');
|
| 164 |
|
203 |
|
| 165 |
global $USER, $COURSE;
|
204 |
global $USER, $COURSE;
|
| 166 |
if (get_config('block_point_view', 'enable_point_views_admin')
|
205 |
if (get_config('block_point_view', 'enable_point_views_admin')
|
| 167 |
&& (!empty($this->config->enable_point_views) || !empty($this->config->enable_difficultytracks))
|
206 |
&& (!empty($this->config->enable_point_views) || !empty($this->config->enable_difficultytracks))
|
| 168 |
&& !$this->page->user_is_editing()) {
|
- |
|
| 169 |
|
- |
|
| Línea 170... |
Línea 207... |
| 170 |
require_once(__DIR__ . '/locallib.php');
|
207 |
&& (!$this->page->user_is_editing() || $this->page->cm !== null)) {
|
| 171 |
|
208 |
|
| 172 |
// Build data for javascript.
|
209 |
// Build data for javascript.
|
| 173 |
$blockdata = new stdClass();
|
210 |
$blockdata = new stdClass();
|
| Línea 204... |
Línea 241... |
| 204 |
</style>';
|
241 |
</style>';
|
| 205 |
} else {
|
242 |
} else {
|
| 206 |
$cssnode = '';
|
243 |
$cssnode = '';
|
| 207 |
}
|
244 |
}
|
| Línea 208... |
Línea 245... |
| 208 |
|
245 |
|
| 209 |
$this->page->requires->js_init_code('document.getElementsByClassName("course-content")[0]
|
246 |
$this->page->requires->js_init_code('document.querySelectorAll(".course-content, #page")[0]
|
| Línea 210... |
Línea 247... |
| 210 |
.insertAdjacentHTML("beforeend", "' . addslashes_js($datanode . $cssnode) . '");');
|
247 |
.insertAdjacentHTML("beforeend", "' . addslashes_js($datanode . $cssnode) . '");');
|
| 211 |
|
248 |
|
| 212 |
$strings = [ 'totalreactions', 'greentrack', 'bluetrack', 'redtrack', 'blacktrack' ];
|
249 |
$strings = [ 'totalreactions', 'greentrack', 'bluetrack', 'redtrack', 'blacktrack' ];
|
| 213 |
$this->page->requires->strings_for_js($strings, 'block_point_view');
|
250 |
$this->page->requires->strings_for_js($strings, 'block_point_view');
|
| - |
|
251 |
$this->page->requires->js_call_amd('block_point_view/script_point_view', 'init', [ $COURSE->id ]);
|
| - |
|
252 |
}
|
| - |
|
253 |
|
| - |
|
254 |
if (get_config('block_point_view', 'enable_point_views_admin') && $this->page->cm !== null) {
|
| - |
|
255 |
$this->page->requires->js_call_amd('block_point_view/script_config_point_view',
|
| 214 |
$this->page->requires->js_call_amd('block_point_view/script_point_view', 'init', [ $COURSE->id ]);
|
256 |
'setupDifficultyTrackChange', [ block_point_view_get_track_colors() ]);
|
| Línea 215... |
Línea 257... |
| 215 |
}
|
257 |
}
|
| 216 |
}
|
258 |
}
|
| 217 |
|
259 |
|
| Línea 263... |
Línea 305... |
| 263 |
// Do not touch any files if this is a commit from somewhere else.
|
305 |
// Do not touch any files if this is a commit from somewhere else.
|
| 264 |
parent::instance_config_save($this->config);
|
306 |
parent::instance_config_save($this->config);
|
| 265 |
}
|
307 |
}
|
| Línea 266... |
Línea 308... |
| 266 |
|
308 |
|
| - |
|
309 |
/**
|
| - |
|
310 |
* {@inheritDoc}
|
| - |
|
311 |
* @see block_base::instance_create()
|
| - |
|
312 |
*/
|
| - |
|
313 |
public function instance_create() {
|
| - |
|
314 |
require_once(__DIR__ . '/locallib.php');
|
| - |
|
315 |
// Show the block in subcontexts (we need it to be present on activities pages).
|
| - |
|
316 |
block_point_view_show_in_subcontexts($this->instance->id);
|
| - |
|
317 |
return true;
|
| - |
|
318 |
}
|
| - |
|
319 |
|
| 267 |
/**
|
320 |
/**
|
| 268 |
* Delete file storage.
|
321 |
* Delete file storage.
|
| 269 |
*
|
322 |
*
|
| 270 |
* @return bool
|
323 |
* @return bool
|
| 271 |
*/
|
324 |
*/
|