Replaced wol link with ajax retrieval. Fixed local settings
This commit is contained in:
parent
919ec571c8
commit
ad852c72d5
24
amd/src/block_bibleblock.js
Normal file
24
amd/src/block_bibleblock.js
Normal file
|
@ -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() {
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -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: {
|
||||
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -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 = " <a class='btn btn-primary' href='{$inviteurl}'>{$invitetext}</a>";
|
||||
}
|
||||
$this->content->text = $OUTPUT->render_from_template("block_bibleblock/block", $data);
|
||||
|
||||
return $this->content;
|
||||
}
|
|
@ -15,14 +15,14 @@
|
|||
// along with Moodle. If not, see <https://www.gnu.org/licenses/>.
|
||||
/**
|
||||
* 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,
|
||||
|
|
|
@ -15,13 +15,12 @@
|
|||
// along with Moodle. If not, see <https://www.gnu.org/licenses/>.
|
||||
/**
|
||||
* 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';
|
||||
|
|
@ -15,13 +15,12 @@
|
|||
// along with Moodle. If not, see <https://www.gnu.org/licenses/>.
|
||||
/**
|
||||
* 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';
|
||||
|
2
lib.php
2
lib.php
|
@ -15,7 +15,7 @@
|
|||
// along with Moodle. If not, see <https://www.gnu.org/licenses/>.
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
// along with Moodle. If not, see <https://www.gnu.org/licenses/>.
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
}}
|
||||
{{!
|
||||
@template block_mytreestudyplan/block
|
||||
@template block_bibleblock/block
|
||||
|
||||
Render my treestudyplan block
|
||||
|
||||
|
@ -33,19 +33,8 @@
|
|||
}
|
||||
}}
|
||||
|
||||
<div id='block_mytreestudyplan'>
|
||||
<div class='vue-loader' v-show='false'>
|
||||
<div class='spinner-border text-primary' role='status'>
|
||||
<span class='sr-only'>Loading...</span>
|
||||
</div>
|
||||
</div>
|
||||
<div v-cloak>
|
||||
{{^teachermode}}
|
||||
<r-report v-model='studyplans'></r-report>
|
||||
{{/teachermode}}
|
||||
{{#teachermode}}
|
||||
<r-report v-model='studyplans' teachermode></r-report>
|
||||
{{/teachermode}}
|
||||
|
||||
<div id='block_bibleblock'>
|
||||
<h4 id="block_bibleblock_heading"></h4>
|
||||
<div id="block_bibleblock_content">
|
||||
</div>
|
||||
</div>
|
|
@ -15,14 +15,14 @@
|
|||
// along with Moodle. If not, see <https://www.gnu.org/licenses/>.
|
||||
/**
|
||||
* 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,
|
||||
];
|
||||
|
|
Loading…
Reference in New Issue
Block a user