diff --git a/amd/src/block_bibleblock.js b/amd/src/block_bibleblock.js new file mode 100644 index 0000000..2b23dca --- /dev/null +++ b/amd/src/block_bibleblock.js @@ -0,0 +1,24 @@ +/*eslint no-var: "error" */ +/*eslint no-unused-vars: "off" */ +/*eslint linebreak-style: "off" */ +/*eslint no-trailing-spaces: "off" */ +/*eslint-env es6*/ +// Put this file in path/to/plugin/amd/src +// You can call it anything you like + + +import {call} from 'core/ajax'; +import notification from 'core/notification'; + + +/** + * Initialize the Page + */ +/** + * Initialize the Page + */ + export function init() { + + } + + diff --git a/amd/src/block_mytreestudyplan.js b/amd/src/block_mytreestudyplan.js deleted file mode 100644 index 1070f19..0000000 --- a/amd/src/block_mytreestudyplan.js +++ /dev/null @@ -1,107 +0,0 @@ -/*eslint no-var: "error" */ -/*eslint no-unused-vars: "off" */ -/*eslint linebreak-style: "off" */ -/*eslint no-trailing-spaces: "off" */ -/*eslint-env es6*/ -// Put this file in path/to/plugin/amd/src -// You can call it anything you like - - -import {call} from 'core/ajax'; -import notification from 'core/notification'; -import Vue from 'local_treestudyplan/vue/vue'; -import RVComponents from 'local_treestudyplan/report-viewer-components'; -import TSComponents from 'local_treestudyplan/treestudyplan-components'; -import Debugger from 'local_treestudyplan/util/debugger'; - -import {load_strings} from 'local_treestudyplan/util/string-helper'; -import {ProcessStudyplans} from 'local_treestudyplan/studyplan-processor'; - -import PortalVue from 'local_treestudyplan/portal-vue/portal-vue.esm'; -import BootstrapVue from 'local_treestudyplan/bootstrap-vue/bootstrap-vue'; -Vue.use(TSComponents); -Vue.use(RVComponents); -Vue.use(PortalVue); -Vue.use(BootstrapVue); - - -let debug = new Debugger("mytreestudyplan"); -debug.enable(); - -let strings = load_strings({ - studyplan: { - - }, -}); - -/** - * Initialize the Page - */ -/** - * Initialize the Page - * @param {string} type Type of page to show - * @param {Object} arg Arguments passed - */ - export function init(type="myreport",arg) { - // Save time by only starting up the Vue app if the required block element is present - const blockelement = document.getElementById('block_mytreestudyplan'); - if(blockelement){ - const app = new Vue({ - el: '#block_mytreestudyplan', - data: { - "studyplans": [], - }, - mounted() { - let call_method; - let call_args; - if(type == "teacher"){ - call_method = 'local_treestudyplan_get_teacher_studyplan'; - call_args = {}; - } - else if(type == "teaching"){ - call_method = 'local_treestudyplan_get_teaching_studyplans'; - call_args = {}; - } - else{ - call_method = 'local_treestudyplan_get_own_studyplan'; - call_args = {}; - } - call([{ - methodname: call_method, - args: call_args - }])[0].done(function(response){ - debug.info("Studyplans:",response); - const timingval = { future: 0, present: 1, past: 2, }; - response.sort((a,b) => { - const timinga = TSComponents.studyplanTiming(a); - const timingb = TSComponents.studyplanTiming(b); - - let t = timingval[timinga] - timingval[timingb]; - if(t == 0){ - // sort by start date if timing is equal - t = new Date(b.startdate).getTime() - new Date(a.startdate).getTime(); - - if (t == 0) { - // sort by name if timing is equal - t = a.name.localeCompare(b.name); - } - } - return t; - }); - app.studyplans = ProcessStudyplans(response); - }).fail(notification.exception); - - }, - created() { - - }, - updated() { - }, - methods: { - - }, - }); - } -} - - diff --git a/block_mytreestudyplan.php b/block_bibleblock.php similarity index 59% rename from block_mytreestudyplan.php rename to block_bibleblock.php index 155dce9..93177bd 100644 --- a/block_mytreestudyplan.php +++ b/block_bibleblock.php @@ -16,17 +16,16 @@ /** * Main block code * - * @package block_mytreestudyplan + * @package block_bibleblock * @copyright 2023 P.M. Kuipers * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -use local_treestudyplan\studyplan; /** * MyTreestudyplan block base code */ -class block_mytreestudyplan extends \block_base { +class block_bibleblock extends \block_base { /** * Plugin initialization (before $this->config and $this->page are loaded) @@ -39,22 +38,14 @@ class block_mytreestudyplan extends \block_base { */ public function specialization() { global $CFG; - $this->title = get_string('title', 'block_mytreestudyplan'); - - $systemcontext = \context_system::instance(); - $teachermode = has_capability("local/treestudyplan:viewuserreports", $systemcontext); + $this->title = get_string('title', 'block_bibleblock'); // Load CSS files from treestudyplan. try { - $this->page->requires->css(new \moodle_url($CFG->wwwroot.'/local/treestudyplan/css/bootstrap-vue/bootstrap-vue.min.css')); - if($CFG->debugdeveloper){ - $this->page->requires->css(new moodle_url($CFG->wwwroot.'/local/treestudyplan/css/devstyles.css')); - } - $this->page->add_body_class("features-treestudyplan"); // Mark body as containing treestudyplan content. // Include javascript and run studyplan renderer when page loading is complete. - $this->page->requires->js_call_amd('block_mytreestudyplan/block_mytreestudyplan', + $this->page->requires->js_call_amd('block_bibleblock/block_bibleblock', 'init', - [$teachermode ? 'teaching' : 'myreport']); + []); } catch (Exception $x) { // On some occasions (Plugin management), the plugin is loaded after HEAD has been printed. // In those cases we don't want to show the block anyway, so ignore the error that gets inevitably thrown. @@ -70,8 +61,8 @@ class block_mytreestudyplan extends \block_base { return [ 'admin' => false, 'site-index' => true, - 'course-view' => false, - 'mod' => false, + 'course-view' => true, + 'mod' => true, 'my' => true ]; } @@ -80,37 +71,15 @@ class block_mytreestudyplan extends \block_base { * Render block content */ public function get_content() { - global $CFG; - global $USER; - global $COURSE; global $OUTPUT; if ($this->content !== null) { return $this->content; } - $systemcontext = \context_system::instance(); - - // TODO: Check if they have the permission in any relevant context, not just system. - $teachermode = has_capability("local/treestudyplan:viewuserreports", $systemcontext); - + $data = []; $this->content = new \stdClass; - $this->content->text = ""; - - $mystudyplans = studyplan::find_for_user($USER->id); - - $data = [ - 'teachermode' => $teachermode, - ]; - - $this->content->text = $OUTPUT->render_from_template("block_mytreestudyplan/block", $data); - - $inviteurl = $CFG->wwwroot.'/local/treestudyplan/invitations.php'; - $invitetext = get_string('manage_invites', 'local_treestudyplan'); - - if ( (!$teachermode ) && count($mystudyplans) > 0) { - $this->content->footer = "  {$invitetext}"; - } + $this->content->text = $OUTPUT->render_from_template("block_bibleblock/block", $data); return $this->content; } diff --git a/db/access.php b/db/access.php index 2cd8c8a..463c6b2 100644 --- a/db/access.php +++ b/db/access.php @@ -15,14 +15,14 @@ // along with Moodle. If not, see . /** * Permission descriptions - * @package block_mytreestudyplan + * @package block_bibleblock * @copyright 2023 P.M. Kuipers * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); $capabilities = [ - 'block/mytreestudyplan:addinstance' => [ + 'block/bibleblock:addinstance' => [ 'riskbitmask' => RISK_SPAM | RISK_XSS, 'captype' => 'write', 'contextlevel' => CONTEXT_BLOCK, diff --git a/lang/en/block_mytreestudyplan.php b/lang/en/block_bibleblock.php similarity index 78% rename from lang/en/block_mytreestudyplan.php rename to lang/en/block_bibleblock.php index c69828a..575c755 100644 --- a/lang/en/block_mytreestudyplan.php +++ b/lang/en/block_bibleblock.php @@ -15,13 +15,12 @@ // along with Moodle. If not, see . /** * English language file - * @package block_mytreestudyplan + * @package block_bibleblock * @copyright 2023 P.M. Kuipers * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -$string['pluginname'] = 'My Treestudyplan'; -$string['mytreestudyplan'] = 'MyTreestudyplan'; -$string['title'] = 'My Studyplan'; -$string['mytreestudyplan:addinstance'] = 'Add my studyplan block'; +$string['pluginname'] = 'Bibleblock'; +$string['title'] = 'Bible verses'; +$string['bibleblock:addinstance'] = 'Add bibleblock'; diff --git a/lang/nl/block_mytreestudyplan.php b/lang/nl/block_bibleblock.php similarity index 77% rename from lang/nl/block_mytreestudyplan.php rename to lang/nl/block_bibleblock.php index 4328e7c..08bd3e6 100644 --- a/lang/nl/block_mytreestudyplan.php +++ b/lang/nl/block_bibleblock.php @@ -15,13 +15,12 @@ // along with Moodle. If not, see . /** * Dutch language file - * @package block_mytreestudyplan + * @package block_bibleblock * @copyright 2023 P.M. Kuipers * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -$string['pluginname'] = 'Mijn Treestudyplan'; -$string['mytreestudyplan'] = 'MyTreestudyplan'; -$string['title'] = 'Mijn Studieplan'; -$string['mytreestudyplan:addinstance'] = 'Voeg mijn studieplan block toe'; +$string['pluginname'] = 'Bibleblock'; +$string['title'] = 'Bible verses'; +$string['bibleblock:addinstance'] = 'Voeg bibleblock toe'; diff --git a/lib.php b/lib.php index b35e30c..7ed8983 100644 --- a/lib.php +++ b/lib.php @@ -15,7 +15,7 @@ // along with Moodle. If not, see . /** * Library page - * @package block_mytreestudyplan + * @package block_bibleblock * @copyright 2023 P.M. Kuipers * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/settings.php b/settings.php index e4823a1..ff94701 100644 --- a/settings.php +++ b/settings.php @@ -15,7 +15,7 @@ // along with Moodle. If not, see . /** * Settings page - * @package block_mytreestudyplan + * @package block_bibleblock * @copyright 2023 P.M. Kuipers * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/styles.css b/styles.css index eedbe8c..361fb14 100644 --- a/styles.css +++ b/styles.css @@ -1,10 +1,6 @@ /* stylelint-disable length-zero-no-unit, color-hex-case, color-hex-length*/ -.path-block-mytreestudyplan [v-cloak] { - visibility: hidden; -} -.path-block-mytreestudyplan .vue-loader { - width: 32px; - margin: auto; +.path-block-bibleblock #block_bibleblock_content { + overflow-y: auto; } diff --git a/templates/block.mustache b/templates/block.mustache index 7bcc047..0fb302f 100644 --- a/templates/block.mustache +++ b/templates/block.mustache @@ -15,7 +15,7 @@ along with Moodle. If not, see . }} {{! - @template block_mytreestudyplan/block + @template block_bibleblock/block Render my treestudyplan block @@ -33,19 +33,8 @@ } }} -
-
-
- Loading... -
-
-
- {{^teachermode}} - - {{/teachermode}} - {{#teachermode}} - - {{/teachermode}} - +
+

+
\ No newline at end of file diff --git a/version.php b/version.php index e3aa938..6ea3411 100644 --- a/version.php +++ b/version.php @@ -15,14 +15,14 @@ // along with Moodle. If not, see . /** * Version description - * @package block_mytreestudyplan + * @package block_bibleblock * @copyright 2023 P.M. Kuipers * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); -$plugin->component = 'block_mytreestudyplan'; // Recommended since 2.0.2 (MDL-26035). Required since 3.0 (MDL-48494). -$plugin->version = 2023090800; // YYYYMMDDHH (year, month, day, iteration). +$plugin->component = 'block_bibleblock'; // Recommended since 2.0.2 (MDL-26035). Required since 3.0 (MDL-48494). +$plugin->version = 2023111900; // YYYYMMDDHH (year, month, day, iteration). $plugin->requires = 2021051700; // YYYYMMDDHH (This is the release version for Moodle 3.11). $plugin->release = "1.0.0"; @@ -31,5 +31,5 @@ $plugin->maturity = MATURITY_RC; $plugin->supported = [ 311, 401 ]; $plugin->dependencies = [ - 'local_treestudyplan' => 2023090700, + 'filter_bibleversesnwt' => 2023111900, ];