| Línea 501... |
Línea 501... |
| 501 |
public function export_for_zero_state_template(renderer_base $output) {
|
501 |
public function export_for_zero_state_template(renderer_base $output) {
|
| 502 |
global $CFG, $DB;
|
502 |
global $CFG, $DB;
|
| Línea 503... |
Línea 503... |
| 503 |
|
503 |
|
| Línea 504... |
Línea -... |
| 504 |
$nocoursesimg = $output->image_url('courses', 'block_myoverview');
|
- |
|
| 505 |
|
504 |
$nocoursesimg = $output->image_url('courses', 'block_myoverview');
|
| 506 |
$buttons = [];
|
505 |
|
| 507 |
$coursecat = \core_course_category::user_top();
|
- |
|
| 508 |
if ($coursecat) {
|
506 |
$coursecat = \core_course_category::user_top();
|
| 509 |
// Request a course button.
|
507 |
if ($coursecat) {
|
| - |
|
508 |
$category = \core_course_category::get_nearest_editable_subcategory($coursecat, ['moodle/course:request']);
|
| 510 |
$category = \core_course_category::get_nearest_editable_subcategory($coursecat, ['moodle/course:request']);
|
509 |
if ($category && $category->can_request_course()) {
|
| 511 |
if ($category && $category->can_request_course()) {
|
510 |
// Add Request a course button.
|
| 512 |
$requestbutton = new \single_button(
|
511 |
$button = new \single_button(
|
| 513 |
new \moodle_url('/course/request.php', ['category' => $category->id]),
|
512 |
new \moodle_url('/course/request.php', ['category' => $category->id]),
|
| 514 |
get_string('requestcourse'),
|
513 |
get_string('requestcourse'),
|
| 515 |
'post',
|
514 |
'post',
|
| 516 |
\single_button::BUTTON_PRIMARY
|
- |
|
| 517 |
);
|
515 |
\single_button::BUTTON_PRIMARY
|
| 518 |
$buttons[] = $requestbutton->export_for_template($output);
|
516 |
);
|
| 519 |
return $this->generate_zero_state_data(
|
- |
|
| 520 |
$nocoursesimg,
|
- |
|
| 521 |
$buttons,
|
517 |
return $this->generate_zero_state_data(
|
| 522 |
[
|
518 |
$nocoursesimg,
|
| 523 |
'title' => 'zero_request_title',
|
- |
|
| 524 |
'intro' => ($CFG->coursecreationguide ? 'zero_request_intro' : 'zero_nocourses_intro'),
|
519 |
[$button->export_for_template($output)],
|
| 525 |
],
|
520 |
['title' => 'zero_request_title', 'intro' => 'zero_request_intro']
|
| Línea 526... |
Línea 521... |
| 526 |
);
|
521 |
);
|
| 527 |
}
|
522 |
}
|
| 528 |
|
523 |
|
| 529 |
$totalcourses = $DB->count_records_select('course', 'category > 0');
|
524 |
$totalcourses = $DB->count_records_select('course', 'category > 0');
|
| 530 |
if ($coursecat) {
|
525 |
if (!$totalcourses && ($category = \core_course_category::get_nearest_editable_subcategory($coursecat, ['create']))) {
|
| 531 |
// Manage courses or categories button.
|
526 |
// Add Quickstart guide and Create course buttons.
|
| 532 |
$managebuttonname = get_string('managecategories');
|
- |
|
| 533 |
if ($totalcourses) {
|
527 |
$quickstarturl = $CFG->coursecreationguide;
|
| 534 |
$managebuttonname = get_string('managecourses');
|
528 |
if ($quickstarturl) {
|
| 535 |
}
|
- |
|
| 536 |
if ($categorytomanage = \core_course_category::get_nearest_editable_subcategory($coursecat, ['manage'])) {
|
529 |
$quickstartbutton = new \single_button(
|
| 537 |
$managebutton = new \single_button(
|
530 |
new \moodle_url($quickstarturl, ['lang' => current_language()]),
|
| 538 |
new \moodle_url('/course/management.php', ['category' => $categorytomanage->id]),
|
531 |
get_string('viewquickstart', 'block_myoverview'),
|
| 539 |
$managebuttonname,
|
532 |
'get',
|
| 540 |
);
|
- |
|
| Línea 541... |
Línea -... |
| 541 |
$buttons[] = $managebutton->export_for_template($output);
|
- |
|
| 542 |
}
|
- |
|
| 543 |
}
|
533 |
);
|
| 544 |
|
534 |
$buttons = [$quickstartbutton->export_for_template($output)];
|
| 545 |
// Create course button.
|
535 |
}
|
| 546 |
if ($category = \core_course_category::get_nearest_editable_subcategory($coursecat, ['create'])) {
|
536 |
|
| 547 |
$createbutton = new \single_button(
|
537 |
$createbutton = new \single_button(
|
| 548 |
new \moodle_url('/course/edit.php', ['category' => $category->id]),
|
538 |
new \moodle_url('/course/edit.php', ['category' => $category->id]),
|
| 549 |
get_string('createcourse', 'block_myoverview'),
|
539 |
get_string('createcourse', 'block_myoverview'),
|
| 550 |
'post',
|
- |
|
| 551 |
\single_button::BUTTON_PRIMARY,
|
- |
|
| 552 |
);
|
- |
|
| 553 |
$buttons[] = $createbutton->export_for_template($output);
|
- |
|
| 554 |
|
540 |
'post',
|
| 555 |
$title = $totalcourses ? 'zero_default_title' : 'zero_nocourses_title';
|
541 |
\single_button::BUTTON_PRIMARY
|
| 556 |
$intro = $totalcourses ? 'zero_default_intro' :
|
542 |
);
|
| 557 |
($CFG->coursecreationguide ? 'zero_request_intro' : 'zero_nocourses_intro');
|
543 |
$buttons[] = $createbutton->export_for_template($output);
|
| 558 |
return $this->generate_zero_state_data(
|
544 |
return $this->generate_zero_state_data(
|
| 559 |
$nocoursesimg,
|
545 |
$nocoursesimg,
|
| Línea -... |
Línea 546... |
| - |
|
546 |
$buttons,
|
| - |
|
547 |
['title' => 'zero_nocourses_title', 'intro' => 'zero_nocourses_intro']
|
| - |
|
548 |
);
|
| - |
|
549 |
}
|
| - |
|
550 |
|
| - |
|
551 |
if ($categorytocreate = \core_course_category::get_nearest_editable_subcategory($coursecat, ['create'])) {
|
| - |
|
552 |
$createbutton = new \single_button(
|
| - |
|
553 |
new \moodle_url('/course/edit.php', ['category' => $categorytocreate->id]),
|
| - |
|
554 |
get_string('createcourse', 'block_myoverview'),
|
| - |
|
555 |
'post',
|
| - |
|
556 |
\single_button::BUTTON_PRIMARY
|
| - |
|
557 |
);
|
| - |
|
558 |
$buttons = [$createbutton->export_for_template($output)];
|
| - |
|
559 |
if ($categorytomanage = \core_course_category::get_nearest_editable_subcategory($coursecat, ['manage'])) {
|
| - |
|
560 |
// Add a Manage course button.
|
| - |
|
561 |
$managebutton = new \single_button(
|
| - |
|
562 |
new \moodle_url('/course/management.php', ['category' => $categorytomanage->id]),
|
| - |
|
563 |
get_string('managecourses')
|
| - |
|
564 |
);
|
| - |
|
565 |
$buttons[] = $managebutton->export_for_template($output);
|
| - |
|
566 |
return $this->generate_zero_state_data(
|
| - |
|
567 |
$nocoursesimg,
|
| - |
|
568 |
array_reverse($buttons),
|
| - |
|
569 |
['title' => 'zero_default_title', 'intro' => 'zero_default_intro']
|
| - |
|
570 |
);
|
| - |
|
571 |
}
|
| - |
|
572 |
return $this->generate_zero_state_data(
|
| 560 |
$buttons,
|
573 |
$nocoursesimg,
|
| Línea 561... |
Línea 574... |
| 561 |
['title' => $title, 'intro' => $intro],
|
574 |
$buttons,
|
| 562 |
);
|
575 |
['title' => 'zero_default_title', 'intro' => 'zero_default_intro']
|
| 563 |
}
|
576 |
);
|
| 564 |
|
577 |
}
|
| 565 |
}
|
578 |
}
|
| 566 |
|
579 |
|
| Línea 567... |
Línea 580... |
| 567 |
return $this->generate_zero_state_data(
|
580 |
return $this->generate_zero_state_data(
|
| Línea 581... |
Línea 594... |
| 581 |
*/
|
594 |
*/
|
| 582 |
private function generate_zero_state_data(\moodle_url $imageurl, array $buttons, array $strings) {
|
595 |
private function generate_zero_state_data(\moodle_url $imageurl, array $buttons, array $strings) {
|
| 583 |
global $CFG;
|
596 |
global $CFG;
|
| 584 |
// Documentation data.
|
597 |
// Documentation data.
|
| 585 |
$dochref = new \moodle_url($CFG->docroot, ['lang' => current_language()]);
|
598 |
$dochref = new \moodle_url($CFG->docroot, ['lang' => current_language()]);
|
| - |
|
599 |
$quickstart = new \moodle_url($CFG->coursecreationguide, ['lang' => current_language()]);
|
| 586 |
$docparams = [
|
600 |
$docparams = [
|
| - |
|
601 |
'quickhref' => $quickstart->out(),
|
| - |
|
602 |
'quicktitle' => get_string('viewquickstart', 'block_myoverview'),
|
| - |
|
603 |
'quicktarget' => '_blank',
|
| 587 |
'dochref' => $dochref->out(),
|
604 |
'dochref' => $dochref->out(),
|
| 588 |
'doctitle' => get_string('documentation'),
|
605 |
'doctitle' => get_string('documentation'),
|
| 589 |
'doctarget' => $CFG->doctonewwindow ? '_blank' : '_self',
|
606 |
'doctarget' => $CFG->doctonewwindow ? '_blank' : '_self',
|
| 590 |
];
|
607 |
];
|
| 591 |
if ($CFG->coursecreationguide) {
|
- |
|
| 592 |
// Add quickstart guide link.
|
- |
|
| 593 |
$quickstart = new \moodle_url($CFG->coursecreationguide, ['lang' => current_language()]);
|
- |
|
| 594 |
$docparams += [
|
- |
|
| 595 |
'quickhref' => $quickstart->out(),
|
- |
|
| 596 |
'quicktitle' => get_string('viewquickstart', 'block_myoverview'),
|
- |
|
| 597 |
'quicktarget' => '_blank',
|
- |
|
| 598 |
];
|
- |
|
| 599 |
}
|
- |
|
| 600 |
return [
|
608 |
return [
|
| 601 |
'nocoursesimg' => $imageurl->out(),
|
609 |
'nocoursesimg' => $imageurl->out(),
|
| 602 |
'title' => ($strings['title']) ? get_string($strings['title'], 'block_myoverview') : '',
|
610 |
'title' => ($strings['title']) ? get_string($strings['title'], 'block_myoverview') : '',
|
| 603 |
'intro' => ($strings['intro']) ? get_string($strings['intro'], 'block_myoverview', $docparams) : '',
|
611 |
'intro' => ($strings['intro']) ? get_string($strings['intro'], 'block_myoverview', $docparams) : '',
|
| 604 |
'buttons' => $buttons,
|
612 |
'buttons' => $buttons,
|