Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 1441
Línea 149... Línea 149...
149
                    'type' => 'submit',
149
                    'type' => 'submit',
150
                    'name' => 'award',
150
                    'name' => 'award',
151
                    'value' => $this->output->larrow() . ' ' . get_string('award', 'badges'),
151
                    'value' => $this->output->larrow() . ' ' . get_string('award', 'badges'),
152
                    'class' => 'actionbutton btn btn-secondary')
152
                    'class' => 'actionbutton btn btn-secondary')
153
                );
153
                );
-
 
154
        if (has_capability('moodle/badges:revokebadge', $this->page->context)) {
154
        $actioncell->text .= html_writer::empty_tag('input', array(
155
            $actioncell->text .= html_writer::empty_tag(
-
 
156
                'input',
-
 
157
                [
155
                    'type' => 'submit',
158
                    'type' => 'submit',
156
                    'name' => 'revoke',
159
                    'name' => 'revoke',
157
                    'value' => get_string('revoke', 'badges') . ' ' . $this->output->rarrow(),
160
                    'value' => get_string('revoke', 'badges') . ' ' . $this->output->rarrow(),
158
                    'class' => 'actionbutton btn btn-secondary')
161
                    'class' => 'actionbutton btn btn-secondary',
159
                );
162
                ]
-
 
163
            );
-
 
164
        }
160
        $actioncell->text .= html_writer::end_tag('div', array());
165
        $actioncell->text .= html_writer::end_tag('div', array());
161
        $actioncell->attributes['class'] = 'actions';
166
        $actioncell->attributes['class'] = 'actions';
162
        $potentialcell = new html_table_cell();
167
        $potentialcell = new html_table_cell();
163
        $potentialcell->text = $potentialuc->display(true);
168
        $potentialcell->text = $potentialuc->display(true);
164
        $potentialcell->attributes['class'] = 'potential';
169
        $potentialcell->attributes['class'] = 'potential';
Línea 184... Línea 189...
184
        $dl[get_string('version', 'badges')] = $badge->version;
189
        $dl[get_string('version', 'badges')] = $badge->version;
185
        $dl[get_string('language')] = $languages[$badge->language];
190
        $dl[get_string('language')] = $languages[$badge->language];
186
        $dl[get_string('description', 'badges')] = $badge->description;
191
        $dl[get_string('description', 'badges')] = $badge->description;
187
        $dl[get_string('createdon', 'search')] = userdate($badge->timecreated);
192
        $dl[get_string('createdon', 'search')] = userdate($badge->timecreated);
188
        $dl[get_string('badgeimage', 'badges')] = print_badge_image($badge, $context, 'large');
193
        $dl[get_string('badgeimage', 'badges')] = print_badge_image($badge, $context, 'large');
189
        $dl[get_string('imageauthorname', 'badges')] = $badge->imageauthorname;
-
 
190
        $dl[get_string('imageauthoremail', 'badges')] =
-
 
191
            html_writer::tag('a', $badge->imageauthoremail, array('href' => 'mailto:' . $badge->imageauthoremail));
-
 
192
        $dl[get_string('imageauthorurl', 'badges')] =
-
 
193
            html_writer::link($badge->imageauthorurl, $badge->imageauthorurl, array('target' => '_blank'));
-
 
194
        $dl[get_string('imagecaption', 'badges')] = $badge->imagecaption;
194
        $dl[get_string('imagecaption', 'badges')] = $badge->imagecaption;
195
        $tags = \core_tag_tag::get_item_tags('core_badges', 'badge', $badge->id);
195
        $tags = \core_tag_tag::get_item_tags('core_badges', 'badge', $badge->id);
196
        $dl[get_string('tags', 'badges')] = $this->output->tag_list($tags, '');
196
        $dl[get_string('tags', 'badges')] = $this->output->tag_list($tags, '');
197
        $display .= $this->definition_list($dl);
197
        $display .= $this->definition_list($dl);
Línea 198... Línea 198...
198
 
198
 
199
        // Issuer details.
199
        // Issuer details.
200
        $display .= $this->heading(get_string('issuerdetails', 'badges'), 3);
200
        $display .= $this->heading(get_string('issuerdetails', 'badges'), 3);
201
        $dl = array();
201
        $dl = array();
-
 
202
        $dl[get_string('issuername', 'badges')] = $badge->issuername;
-
 
203
        $dl[get_string('contact', 'badges')] = '';
202
        $dl[get_string('issuername', 'badges')] = $badge->issuername;
204
        if (trim($badge->issuercontact)) {
-
 
205
            $dl[get_string('contact', 'badges')] = html_writer::tag(
-
 
206
                'a',
-
 
207
                $badge->issuercontact,
-
 
208
                ['href' => 'mailto:' . $badge->issuercontact],
-
 
209
            );
-
 
210
        }
-
 
211
        $dl[get_string('issuerurl', 'badges')] = '';
-
 
212
        if (trim($badge->issuerurl)) {
-
 
213
            $dl[get_string('issuerurl', 'badges')] = html_writer::tag(
-
 
214
                'a',
-
 
215
                $badge->issuerurl,
-
 
216
                ['href' => $badge->issuerurl, 'target' => '_blank'],
-
 
217
            );
203
        $dl[get_string('contact', 'badges')] = html_writer::tag('a', $badge->issuercontact, array('href' => 'mailto:' . $badge->issuercontact));
218
        }
Línea 204... Línea 219...
204
        $display .= $this->definition_list($dl);
219
        $display .= $this->definition_list($dl);
205
 
220
 
206
        // Issuance details if any.
221
        // Issuance details if any.
Línea 240... Línea 255...
240
        if (has_capability('moodle/badges:viewawarded', $context)) {
255
        if (has_capability('moodle/badges:viewawarded', $context)) {
241
            $display .= $this->heading(get_string('awards', 'badges'), 3);
256
            $display .= $this->heading(get_string('awards', 'badges'), 3);
242
            if ($badge->has_awards()) {
257
            if ($badge->has_awards()) {
243
                $url = new moodle_url('/badges/recipients.php', array('id' => $badge->id));
258
                $url = new moodle_url('/badges/recipients.php', array('id' => $badge->id));
244
                $a = new stdClass();
259
                $a = new stdClass();
-
 
260
                $a->badgename = $badge->name;
245
                $a->link = $url->out();
261
                $a->link = $url->out();
246
                $a->count = count($badge->get_awards());
262
                $a->count = count($badge->get_awards());
247
                $display .= get_string('numawards', 'badges', $a);
263
                $display .= get_string('numawards', 'badges', $a);
248
            } else {
264
            } else {
249
                $display .= get_string('noawards', 'badges');
265
                $display .= get_string('noawards', 'badges');
Línea 264... Línea 280...
264
 
280
 
265
        return html_writer::div($display, null, array('id' => 'badge-overview'));
281
        return html_writer::div($display, null, array('id' => 'badge-overview'));
Línea 266... Línea 282...
266
    }
282
    }
267
 
-
 
268
    /**
-
 
269
     * Prints action icons for the badge.
283
 
270
     *
-
 
271
     * @deprecated sinde Moodle 4.3
-
 
272
     * @param \core_badges\badge $badge
-
 
273
     * @param \context $context
284
    /**
274
     * @return string
-
 
275
     */
-
 
276
    public function print_badge_table_actions($badge, $context) {
-
 
277
        debugging("print_badge_table_actions() is deprecated.", DEBUG_DEVELOPER);
-
 
278
        $actions = "";
-
 
279
 
-
 
280
        if (has_capability('moodle/badges:configuredetails', $context) && $badge->has_criteria()) {
-
 
281
            // Activate/deactivate badge.
-
 
282
            if ($badge->status == BADGE_STATUS_INACTIVE || $badge->status == BADGE_STATUS_INACTIVE_LOCKED) {
-
 
283
                // "Activate" will go to another page and ask for confirmation.
-
 
284
                $url = new moodle_url('/badges/action.php');
-
 
285
                $url->param('id', $badge->id);
-
 
286
                $url->param('activate', true);
-
 
287
                $url->param('sesskey', sesskey());
-
 
288
                $return = new moodle_url(qualified_me());
285
     * @deprecated sinde Moodle 4.3
289
                $url->param('return', $return->out_as_local_url(false));
-
 
290
                $actions .= $this->output->action_icon($url, new pix_icon('t/show', get_string('activate', 'badges'))) . " ";
-
 
291
            } else {
-
 
292
                $url = new moodle_url(qualified_me());
-
 
293
                $url->param('lock', $badge->id);
-
 
294
                $url->param('sesskey', sesskey());
-
 
295
                $actions .= $this->output->action_icon($url, new pix_icon('t/hide', get_string('deactivate', 'badges'))) . " ";
-
 
296
            }
-
 
297
        }
-
 
298
 
-
 
299
        // Award badge manually.
-
 
300
        if ($badge->has_manual_award_criteria() &&
286
     */
301
                has_capability('moodle/badges:awardbadge', $context) &&
-
 
302
                $badge->is_active()) {
-
 
303
            $url = new moodle_url('/badges/award.php', array('id' => $badge->id));
-
 
304
            $actions .= $this->output->action_icon($url, new pix_icon('t/award', get_string('award', 'badges'))) . " ";
-
 
305
        }
-
 
306
 
287
    #[\core\attribute\deprecated(null, reason: 'It is no longer used', since: '4.3', mdl: 'MDL-77061', final: true)]
307
        // Edit badge.
-
 
308
        if (has_capability('moodle/badges:configuredetails', $context)) {
-
 
309
            $url = new moodle_url('/badges/edit.php', array('id' => $badge->id, 'action' => 'badge'));
-
 
310
            $actions .= $this->output->action_icon($url, new pix_icon('t/edit', get_string('edit'))) . " ";
-
 
311
        }
-
 
312
 
-
 
313
        // Duplicate badge.
-
 
314
        if (has_capability('moodle/badges:createbadge', $context)) {
-
 
315
            $url = new moodle_url('/badges/action.php', array('copy' => '1', 'id' => $badge->id, 'sesskey' => sesskey()));
-
 
316
            $actions .= $this->output->action_icon($url, new pix_icon('t/copy', get_string('copy'))) . " ";
-
 
317
        }
-
 
318
 
-
 
319
        // Delete badge.
-
 
320
        if (has_capability('moodle/badges:deletebadge', $context)) {
-
 
321
            $url = new moodle_url(qualified_me());
-
 
322
            $url->param('delete', $badge->id);
-
 
323
            $actions .= $this->output->action_icon($url, new pix_icon('t/delete', get_string('delete'))) . " ";
-
 
324
        }
-
 
325
 
288
    public function print_badge_table_actions() {
Línea 326... Línea 289...
326
        return $actions;
289
        \core\deprecation::emit_deprecation([self::class, __FUNCTION__]);
327
    }
290
    }
328
 
291
 
Línea 385... Línea 348...
385
        $actionhtml = $this->output->single_button(
348
        $actionhtml = $this->output->single_button(
386
                    new moodle_url('/badges/mybadges.php', array('downloadall' => true, 'sesskey' => sesskey())),
349
                    new moodle_url('/badges/mybadges.php', array('downloadall' => true, 'sesskey' => sesskey())),
387
                    get_string('downloadall'), 'POST', array('class' => 'activatebadge'));
350
                    get_string('downloadall'), 'POST', array('class' => 'activatebadge'));
388
        $downloadall = $this->output->box('', 'col-md-3');
351
        $downloadall = $this->output->box('', 'col-md-3');
389
        $downloadall .= $this->output->box($actionhtml, 'col-md-9');
352
        $downloadall .= $this->output->box($actionhtml, 'col-md-9');
390
        $downloadall = $this->output->box($downloadall, 'row ml-5');
353
        $downloadall = $this->output->box($downloadall, 'row ms-5');
Línea 391... Línea 354...
391
 
354
 
392
        // Local badges.
355
        // Local badges.
393
        $localhtml = html_writer::start_tag('div', array('id' => 'issued-badge-table', 'class' => 'generalbox'));
356
        $localhtml = html_writer::start_tag('div', array('id' => 'issued-badge-table', 'class' => 'generalbox'));
394
        $sitename = format_string($SITE->fullname, true, array('context' => context_system::instance()));
357
        $sitename = format_string($SITE->fullname, true, array('context' => context_system::instance()));
Línea 429... Línea 392...
429
            $attr = ['class' => 'btn btn-secondary'];
392
            $attr = ['class' => 'btn btn-secondary'];
430
            $label = get_string('backpackbadgessettings', 'badges');
393
            $label = get_string('backpackbadgessettings', 'badges');
431
            $backpacksettings = html_writer::link(new moodle_url('/badges/mybackpack.php'), $label, $attr);
394
            $backpacksettings = html_writer::link(new moodle_url('/badges/mybackpack.php'), $label, $attr);
432
            $actionshtml = $this->output->box('', 'col-md-3');
395
            $actionshtml = $this->output->box('', 'col-md-3');
433
            $actionshtml .= $this->output->box($backpacksettings, 'col-md-9');
396
            $actionshtml .= $this->output->box($backpacksettings, 'col-md-9');
434
            $actionshtml = $this->output->box($actionshtml, 'row ml-5');
397
            $actionshtml = $this->output->box($actionshtml, 'row ms-5');
435
            $externalhtml .= $actionshtml;
398
            $externalhtml .= $actionshtml;
436
        }
399
        }
Línea 437... Línea 400...
437
 
400
 
438
        return $localhtml . $externalhtml;
401
        return $localhtml . $externalhtml;
Línea 489... Línea 452...
489
 
452
 
490
        return $htmlpagingbar . $htmltable . $htmlpagingbar;
453
        return $htmlpagingbar . $htmltable . $htmlpagingbar;
Línea 491... Línea 454...
491
    }
454
    }
492
 
-
 
493
    /**
-
 
494
     * Render a table of badges.
455
 
495
     *
-
 
496
     * @deprecated since Moodle 4.3
-
 
497
     * @param \core_badges\output\badge_management $badges
-
 
498
     * @return string
-
 
499
     */
-
 
500
    protected function render_badge_management(\core_badges\output\badge_management $badges) {
-
 
501
        debugging("render_badge_management() is deprecated.", DEBUG_DEVELOPER);
-
 
502
        $paging = new paging_bar($badges->totalcount, $badges->page, $badges->perpage, $this->page->url, 'page');
-
 
503
 
-
 
504
        // New badge button.
-
 
505
        $htmlnew = '';
-
 
506
        $htmlpagingbar = $this->render($paging);
-
 
507
        $table = new html_table();
-
 
508
        $table->attributes['class'] = 'table table-bordered table-striped';
-
 
509
 
-
 
510
        $sortbyname = $this->helper_sortable_heading(get_string('name'),
-
 
511
                'name', $badges->sort, $badges->dir);
-
 
512
        $sortbystatus = $this->helper_sortable_heading(get_string('status', 'badges'),
-
 
513
                'status', $badges->sort, $badges->dir);
-
 
514
        $table->head = array(
-
 
515
                $sortbyname,
-
 
516
                $sortbystatus,
-
 
517
                get_string('bcriteria', 'badges'),
-
 
518
                get_string('awards', 'badges'),
-
 
519
                get_string('actions')
-
 
520
            );
-
 
521
        $table->colclasses = array('name', 'status', 'criteria', 'awards', 'actions');
-
 
522
 
-
 
523
        foreach ($badges->badges as $b) {
-
 
524
            $style = !$b->is_active() ? array('class' => 'dimmed') : array();
-
 
525
            $forlink =  print_badge_image($b, $this->page->context) . ' ' .
-
 
526
                        html_writer::start_tag('span') . $b->name . html_writer::end_tag('span');
-
 
527
            $name = html_writer::link(new moodle_url('/badges/overview.php', array('id' => $b->id)), $forlink, $style);
-
 
528
            $status = $b->statstring;
-
 
529
            $criteria = self::print_badge_criteria($b, 'short');
-
 
530
 
-
 
531
            if (has_capability('moodle/badges:viewawarded', $this->page->context)) {
-
 
532
                $awards = html_writer::link(new moodle_url('/badges/recipients.php', array('id' => $b->id)), $b->awards);
-
 
533
            } else {
-
 
534
                $awards = $b->awards;
-
 
535
            }
-
 
536
 
-
 
537
            $actions = self::print_badge_table_actions($b, $this->page->context);
-
 
538
 
-
 
539
            $row = array($name, $status, $criteria, $awards, $actions);
-
 
540
            $table->data[] = $row;
-
 
541
        }
-
 
542
        $htmltable = html_writer::table($table);
-
 
543
 
-
 
544
        return $htmlnew . $htmlpagingbar . $htmltable . $htmlpagingbar;
-
 
545
    }
-
 
546
 
-
 
547
    /**
456
    /**
-
 
457
     * @deprecated since Moodle 4.3
548
     * @deprecated since Moodle 4.0 - Use the manage_badge_action_bar tertiary navigation instead.
458
     */
549
     */
459
    #[\core\attribute\deprecated(null, reason: 'It is no longer used', since: '4.3', mdl: 'MDL-77061', final: true)]
550
    public function print_badge_tabs() {
460
    protected function render_badge_management() {
Línea 551... Línea 461...
551
        throw new coding_exception(__FUNCTION__ . '() has been removed.');
461
        \core\deprecation::emit_deprecation([self::class, __FUNCTION__]);
552
    }
462
    }
553
 
463
 
Línea 571... Línea 481...
571
                    $action = '';
481
                    $action = '';
572
                }
482
                }
Línea 573... Línea 483...
573
 
483
 
574
                $message = $status . $action;
484
                $message = $status . $action;
-
 
485
            } else {
-
 
486
                $this->page->requires->js_call_amd('core_badges/actions', 'init');
575
            } else {
487
 
576
                $status = get_string('statusmessage_' . $badge->status, 'badges');
488
                $status = get_string('statusmessage_' . $badge->status, 'badges');
577
                if ($badge->is_active()) {
489
                if ($badge->is_active()) {
-
 
490
                    $action = $this->output->single_button(
-
 
491
                        new moodle_url('#'),
-
 
492
                        get_string('deactivate', 'badges'),
-
 
493
                        'POST',
-
 
494
                        [
-
 
495
                            'class' => 'activatebadge',
578
                    $action = $this->output->single_button(new moodle_url('/badges/action.php',
496
                            'data-action' => 'disablebadge',
579
                                array('id' => $badge->id, 'lock' => 1, 'sesskey' => sesskey(),
497
                            'data-badgeid' => $badge->id,
580
                                      'return' => $this->page->url->out_as_local_url(false))),
498
                            'data-badgename' => $badge->name,
-
 
499
                            'data-courseid' => $badge->courseid,
-
 
500
                        ],
581
                            get_string('deactivate', 'badges'), 'POST', array('class' => 'activatebadge'));
501
                    );
582
                } else {
502
                } else {
-
 
503
                    $action = $this->output->single_button(
-
 
504
                        new moodle_url('#'),
-
 
505
                        get_string('activate', 'badges'),
-
 
506
                        'POST',
-
 
507
                        [
-
 
508
                            'class' => 'activatebadge',
583
                    $action = $this->output->single_button(new moodle_url('/badges/action.php',
509
                            'data-action' => 'enablebadge',
584
                                array('id' => $badge->id, 'activate' => 1, 'sesskey' => sesskey(),
510
                            'data-badgeid' => $badge->id,
585
                                      'return' => $this->page->url->out_as_local_url(false))),
511
                            'data-badgename' => $badge->name,
-
 
512
                            'data-courseid' => $badge->courseid,
586
                            get_string('activate', 'badges'), 'POST', array('class' => 'activatebadge'));
513
                        ]);
Línea 587... Línea 514...
587
                }
514
                }
Línea 588... Línea 515...
588
 
515
 
Línea 665... Línea 592...
665
                            $criteriadescr;
592
                            $criteriadescr;
666
                }
593
                }
667
            }
594
            }
668
        }
595
        }
Línea -... Línea 596...
-
 
596
 
-
 
597
        $criteriadesc = count($items) > 1 ? html_writer::alist($items, [], 'ul') : reset($items);
669
 
598
 
670
        return $overalldescr . $condition . html_writer::alist($items, array(), 'ul');;
599
        return $overalldescr . $condition . $criteriadesc;
Línea 671... Línea 600...
671
    }
600
    }
672
 
601
 
673
    /**
602
    /**
Línea 781... Línea 710...
781
        if (!is_null($sortid)) {
710
        if (!is_null($sortid)) {
782
            if ($sortby !== $sortid || $sorthow !== 'ASC') {
711
            if ($sortby !== $sortid || $sorthow !== 'ASC') {
783
                $url = new moodle_url($this->page->url);
712
                $url = new moodle_url($this->page->url);
784
                $url->params(array('sort' => $sortid, 'dir' => 'ASC'));
713
                $url->params(array('sort' => $sortid, 'dir' => 'ASC'));
785
                $out .= $this->output->action_icon($url,
714
                $out .= $this->output->action_icon($url,
786
                        new pix_icon('t/sort_asc', get_string('sortbyx', 'core', s($text)), null, array('class' => 'iconsort')));
715
                        new pix_icon('t/sort_asc', get_string('sortbyx', 'core', s($text)), null));
787
            }
716
            }
788
            if ($sortby !== $sortid || $sorthow !== 'DESC') {
717
            if ($sortby !== $sortid || $sorthow !== 'DESC') {
789
                $url = new moodle_url($this->page->url);
718
                $url = new moodle_url($this->page->url);
790
                $url->params(array('sort' => $sortid, 'dir' => 'DESC'));
719
                $url->params(array('sort' => $sortid, 'dir' => 'DESC'));
791
                $out .= $this->output->action_icon($url,
720
                $out .= $this->output->action_icon($url,
792
                        new pix_icon('t/sort_desc', get_string('sortbyxreverse', 'core', s($text)), null, array('class' => 'iconsort')));
721
                        new pix_icon('t/sort_desc', get_string('sortbyxreverse', 'core', s($text)), null));
793
            }
722
            }
794
        }
723
        }
795
        return $out;
724
        return $out;
796
    }
725
    }
797
    /**
726
    /**