From 09fc02951144d46950a083445193c7b041966588 Mon Sep 17 00:00:00 2001 From: Nithy1anand Date: Fri, 24 Nov 2023 15:17:03 +0530 Subject: [PATCH] Fixed the kickstart issues and supported for the Moodle-4.3. --- .github/workflows/moodle-ci.yml | 12 ++++++++++++ classes/course_importer.php | 4 ++++ classes/observer.php | 2 +- classes/output/course_template_list.php | 3 ++- classes/template_table.php | 20 ++++++++++++++++++++ styles.css | 5 +++++ template.php | 6 +++--- templates/import_course_list.mustache | 2 +- version.php | 4 ++-- 9 files changed, 50 insertions(+), 8 deletions(-) diff --git a/.github/workflows/moodle-ci.yml b/.github/workflows/moodle-ci.yml index e023fb2..f8ccf6c 100644 --- a/.github/workflows/moodle-ci.yml +++ b/.github/workflows/moodle-ci.yml @@ -28,6 +28,18 @@ jobs: fail-fast: false matrix: include: + - php: '8.2' + moodle-branch: 'MOODLE_403_STABLE' + database: 'mariadb' + - php: '8.2' + moodle-branch: 'MOODLE_403_STABLE' + database: 'pgsql' + - php: '8.1' + moodle-branch: 'MOODLE_403_STABLE' + database: 'mariadb' + - php: '8.1' + moodle-branch: 'MOODLE_403_STABLE' + database: 'pgsql' - php: '8.0' moodle-branch: 'MOODLE_402_STABLE' database: 'mariadb' diff --git a/classes/course_importer.php b/classes/course_importer.php index 2d50eff..05deb23 100644 --- a/classes/course_importer.php +++ b/classes/course_importer.php @@ -166,12 +166,16 @@ public static function import($backuptempdir, $courseid) { throw $e; } finally { // Reset some settings. + $fullname = $course->fullname; + $shortname = $course->shortname; $summary = $course->summary; $summaryformat = $course->summaryformat; $enddate = $course->enddate; $timecreated = $course->timecreated; // Reload course. $course = $DB->get_record('course', ['id' => $courseid]); + $course->fullname = $fullname; + $course->shortname = $shortname; $course->summary = $summary; $course->summaryformat = $summaryformat; $course->enddate = $enddate; diff --git a/classes/observer.php b/classes/observer.php index e5aa4de..b2e2734 100644 --- a/classes/observer.php +++ b/classes/observer.php @@ -39,7 +39,7 @@ public static function format_kickstart_changeconfig($event) { $data = $event->get_data(); $plugin = $data['other']['plugin']; $name = isset($data['other']['name']) ? $data['other']['name'] : ''; - if (preg_match("/^format_/", $plugin) && $name == 'disabled') { + if (preg_match("/^format_/", $plugin ?? '') && $name == 'disabled') { $templates = isset($CFG->kickstart_templates) ? explode(",", $CFG->kickstart_templates) : []; $disable = ($data['other']['value'] == 1) ? true : false; $format = substr($plugin, 7); diff --git a/classes/output/course_template_list.php b/classes/output/course_template_list.php index edfa27e..dd8a5d1 100644 --- a/classes/output/course_template_list.php +++ b/classes/output/course_template_list.php @@ -140,6 +140,7 @@ public function get_templates() { 'format_kickstart', 'description', $template->id), $template->descriptionformat); + $template->title = format_string($template->title); $tags = []; foreach (\core_tag_tag::get_item_tags('format_kickstart', 'format_kickstart_template', $template->id) as $tag) { $tags[] = '#' . $tag->get_display_name(false); @@ -152,7 +153,7 @@ public function get_templates() { if (!$template->courseformat) { $templatecount++; } - if ($limit > 0 && $templatecount >= $limit) { + if ($limit > 0 && $templatecount > $limit) { break; } if (format_kickstart_has_pro()) { diff --git a/classes/template_table.php b/classes/template_table.php index 98211a8..b2d51cd 100644 --- a/classes/template_table.php +++ b/classes/template_table.php @@ -37,6 +37,16 @@ */ class template_table extends \table_sql { + /** + * @var int + */ + public $totaltemplates; + + /** + * @var int + */ + public $cnt; + /** * Setup table. * @@ -77,6 +87,16 @@ public function __construct() { $this->define_headers($headers); } + /** + * Generate title. + * + * @param \stdClass $data + * @return mixed + */ + public function col_title($data) { + return format_string($data->title); + } + /** * Generate tag list. * diff --git a/styles.css b/styles.css index 49f6af4..7a79c21 100644 --- a/styles.css +++ b/styles.css @@ -130,6 +130,11 @@ body.format-kickstart .form-control .fa-search { .format-kickstart .course-content > .card .card-body { text-align: right; } +.format-kickstart .course-content > .card .card-body > .img-responsive + .card-title { + text-align: center; + float: none; + margin: 1rem 0; +} .format-kickstart .course-content > .card .card-body .card-title { text-align: left; margin-top: 5px; diff --git a/template.php b/template.php index 7c34dff..852e189 100644 --- a/template.php +++ b/template.php @@ -173,9 +173,9 @@ 'templatebackimg', $id, $templatebgoptions); $template->templatebackimg = $drafteditor; } - $template->cohortids = json_decode($template->cohortids, true); - $template->categoryids = json_decode($template->categoryids, true); - $template->roleids = json_decode($template->roleids, true); + $template->cohortids = isset($template->cohortids) ? json_decode($template->cohortids, true) : []; + $template->categoryids = isset($template->categoryids) ? json_decode($template->categoryids, true) : []; + $template->roleids = isset($template->roleids) ? json_decode($template->roleids, true) : []; } // Check the template is normal or course format. if (!$template->courseformat) { diff --git a/templates/import_course_list.mustache b/templates/import_course_list.mustache index a70c8e4..1465741 100644 --- a/templates/import_course_list.mustache +++ b/templates/import_course_list.mustache @@ -59,7 +59,7 @@ {{#courses}}
diff --git a/version.php b/version.php index 9927744..ae651cc 100644 --- a/version.php +++ b/version.php @@ -24,9 +24,9 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2023071201; // The current plugin version (Date: YYYYMMDDXX). +$plugin->version = 2023112300; // The current plugin version (Date: YYYYMMDDXX). $plugin->requires = 2022041900; // Requires this Moodle version. $plugin->release = 'Version 1.3'; $plugin->component = 'format_kickstart'; // Full name of the plugin (used for diagnostics). -$plugin->supported = [400, 402]; +$plugin->supported = [40, 403]; $plugin->maturity = MATURITY_STABLE;