Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 76... Línea 76...
76
     */
76
     */
77
    public function export_for_template(\renderer_base $output): ?stdClass {
77
    public function export_for_template(\renderer_base $output): ?stdClass {
78
        if (!$this->show_visibility()) {
78
        if (!$this->show_visibility()) {
79
            return null;
79
            return null;
80
        }
80
        }
-
 
81
        if (!$this->format->show_activity_editor_options($this->mod)) {
-
 
82
            return null;
-
 
83
        }
81
        $format = $this->format;
84
        $format = $this->format;
82
        // In rare legacy cases, the section could be stealth (orphaned) but they are not editable.
85
        // In rare legacy cases, the section could be stealth (orphaned) but they are not editable.
83
        if (!$format->show_editor()
86
        if (!$format->show_editor()
84
            || !has_capability('moodle/course:activityvisibility', $this->mod->context)) {
87
            || !has_capability('moodle/course:activityvisibility', $this->mod->context)) {
85
            return $this->build_static_data($output);
88
            return $this->build_static_data($output);
Línea 129... Línea 132...
129
     */
132
     */
130
    protected function get_dropdown_data(
133
    protected function get_dropdown_data(
131
        \renderer_base $output,
134
        \renderer_base $output,
132
        choicelist $choice,
135
        choicelist $choice,
133
    ): stdClass {
136
    ): stdClass {
134
        $badgetext = $output->sr_text(get_string('availability'));
137
        $badgetext = $output->visually_hidden_text(get_string('availability'));
Línea 135... Línea 138...
135
 
138
 
136
        if (!$this->mod->visible) {
139
        if (!$this->mod->visible) {
137
            $badgetext .= get_string('hiddenfromstudents');
140
            $badgetext .= get_string('hiddenfromstudents');
138
            $icon = $this->get_icon('hide');
141
            $icon = $this->get_icon('hide');
Línea 231... Línea 234...
231
        if ($this->section->visible || $this->mod->has_view()) {
234
        if ($this->section->visible || $this->mod->has_view()) {
232
            $label = $this->section->visible ? 'show' : 'stealth';
235
            $label = $this->section->visible ? 'show' : 'stealth';
233
            $choice->add_option(
236
            $choice->add_option(
234
                'show',
237
                'show',
235
                get_string("availability_{$label}", 'core_courseformat'),
238
                get_string("availability_{$label}", 'core_courseformat'),
236
                $this->get_option_data($label, 'cmShow')
239
                $this->get_option_data($label, 'cmShow', 'cm_show')
237
            );
240
            );
238
        }
241
        }
239
        $choice->add_option(
242
        $choice->add_option(
240
            'hide',
243
            'hide',
241
            get_string('availability_hide', 'core_courseformat'),
244
            get_string('availability_hide', 'core_courseformat'),
242
            $this->get_option_data('hide', 'cmHide')
245
            $this->get_option_data('hide', 'cmHide', 'cm_hide')
243
        );
246
        );
Línea 244... Línea 247...
244
 
247
 
245
        if ($CFG->allowstealth && $this->format->allow_stealth_module_visibility($this->mod, $this->section)) {
248
        if ($CFG->allowstealth && $this->format->allow_stealth_module_visibility($this->mod, $this->section)) {
246
            $choice->add_option(
249
            $choice->add_option(
247
                'stealth',
250
                'stealth',
248
                get_string('availability_stealth', 'core_courseformat'),
251
                get_string('availability_stealth', 'core_courseformat'),
249
                $this->get_option_data('stealth', 'cmStealth')
252
                $this->get_option_data('stealth', 'cmStealth', 'cm_stealth')
250
            );
253
            );
251
        }
254
        }
252
        return $choice;
255
        return $choice;
Línea 253... Línea 256...
253
    }
256
    }
254
 
257
 
255
    /**
258
    /**
-
 
259
     * Get the data for the option.
256
     * Get the data for the option.
260
     * @param string $name the name of the option
257
     * @param string $name the name of the option
261
     * @param string $mutation the mutation name
258
     * @param string $action the state action of the option
262
     * @param string $stateaction the state action name
259
     * @return array
263
     * @return array
-
 
264
     */
-
 
265
    private function get_option_data(string $name, string $mutation, string $stateaction): array {
-
 
266
        $format = $this->format;
-
 
267
        $nonajaxurl = $format->get_update_url(
-
 
268
            action: $stateaction,
-
 
269
            ids: [$this->mod->id],
-
 
270
            returnurl: $format->get_view_url($format->get_sectionnum(), ['navigation' => true]),
260
     */
271
        );
261
    private function get_option_data(string $name, string $action): array {
272
 
262
        return [
273
        return [
263
            'description' => get_string("availability_{$name}_help", 'core_courseformat'),
-
 
264
            'icon' => $this->get_icon($name),
274
            'description' => get_string("availability_{$name}_help", 'core_courseformat'),
265
            // Non-ajax behat is not smart enough to discrimante hidden links
-
 
266
            // so we need to keep providing the non-ajax links.
275
            'icon' => $this->get_icon($name),
267
            'url' => $this->format->get_non_ajax_cm_action_url($action, $this->mod),
276
            'url' => $nonajaxurl,
268
            'extras' => [
277
            'extras' => [
269
                'data-id' => $this->mod->id,
278
                'data-id' => $this->mod->id,
270
                'data-action' => $action,
279
                'data-action' => $mutation,
271
            ]
280
            ]
Línea 272... Línea 281...
272
        ];
281
        ];