Proyectos de Subversion Moodle

Rev

Rev 4 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 4 Rev 5
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 126... Línea -...
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
            }
-
 
163
 
126
 
Línea 164... Línea 127...
164
        } else if (has_capability('block/point_view:addinstance', $this->context)) {
127
        } else if (has_capability('block/point_view:addinstance', $this->context)) {
Línea 165... Línea 128...
165
 
128
 
Línea 197... Línea 160...
197
     * @see block_base::get_required_javascript()
160
     * @see block_base::get_required_javascript()
198
     */
161
     */
199
    public function get_required_javascript() {
162
    public function get_required_javascript() {
200
        parent::get_required_javascript();
163
        parent::get_required_javascript();
Línea 201... Línea -...
201
 
-
 
202
        require_once(__DIR__ . '/locallib.php');
-
 
203
 
164
 
204
        global $USER, $COURSE;
165
        global $USER, $COURSE;
205
        if (get_config('block_point_view', 'enable_point_views_admin')
166
        if (get_config('block_point_view', 'enable_point_views_admin')
206
                && (!empty($this->config->enable_point_views) || !empty($this->config->enable_difficultytracks))
167
                && (!empty($this->config->enable_point_views) || !empty($this->config->enable_difficultytracks))
-
 
168
                && !$this->page->user_is_editing()) {
-
 
169
 
Línea 207... Línea 170...
207
                && (!$this->page->user_is_editing() || $this->page->cm !== null)) {
170
            require_once(__DIR__ . '/locallib.php');
208
 
171
 
209
            // Build data for javascript.
172
            // Build data for javascript.
210
            $blockdata = new stdClass();
173
            $blockdata = new stdClass();
Línea 241... Línea 204...
241
                            </style>';
204
                            </style>';
242
            } else {
205
            } else {
243
                $cssnode = '';
206
                $cssnode = '';
244
            }
207
            }
Línea 245... Línea 208...
245
 
208
 
246
            $this->page->requires->js_init_code('document.querySelectorAll(".course-content, #page")[0]
209
            $this->page->requires->js_init_code('document.getElementsByClassName("course-content")[0]
Línea 247... Línea 210...
247
                                                 .insertAdjacentHTML("beforeend", "' . addslashes_js($datanode . $cssnode) . '");');
210
                                                 .insertAdjacentHTML("beforeend", "' . addslashes_js($datanode . $cssnode) . '");');
248
 
211
 
249
            $strings = [ 'totalreactions', 'greentrack', 'bluetrack', 'redtrack', 'blacktrack' ];
212
            $strings = [ 'totalreactions', 'greentrack', 'bluetrack', 'redtrack', 'blacktrack' ];
250
            $this->page->requires->strings_for_js($strings, 'block_point_view');
213
            $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',
-
 
256
                    'setupDifficultyTrackChange', [ block_point_view_get_track_colors() ]);
214
            $this->page->requires->js_call_amd('block_point_view/script_point_view', 'init', [ $COURSE->id ]);
Línea 257... Línea 215...
257
        }
215
        }
258
    }
216
    }
259
 
217
 
Línea 305... Línea 263...
305
        // Do not touch any files if this is a commit from somewhere else.
263
        // Do not touch any files if this is a commit from somewhere else.
306
        parent::instance_config_save($this->config);
264
        parent::instance_config_save($this->config);
307
    }
265
    }
Línea 308... Línea 266...
308
 
266
 
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
 
-
 
320
    /**
267
    /**
321
     * Delete file storage.
268
     * Delete file storage.
322
     *
269
     *
323
     * @return bool
270
     * @return bool
324
     */
271
     */