diff --git a/classes/local/forms/formbase.php b/classes/local/forms/formbase.php
index f38a94f..76dc974 100644
--- a/classes/local/forms/formbase.php
+++ b/classes/local/forms/formbase.php
@@ -65,8 +65,11 @@ abstract class formbase extends \moodleform {
*/
public function process_submission() {
$data = $this->get_data();
+
if($data) {
- $this->process_submitted_data($data);
+ return $this->process_submitted_data($data);
+ } else {
+ return false;
}
}
diff --git a/classes/local/forms/studyplan_editform.php b/classes/local/forms/studyplan_editform.php
index 6839af9..c1fb884 100644
--- a/classes/local/forms/studyplan_editform.php
+++ b/classes/local/forms/studyplan_editform.php
@@ -3,6 +3,7 @@
namespace local_treestudyplan\local\forms;
use local_treestudyplan\studyplan;
use local_treestudyplan\local\helpers\webservicehelper;
+use moodle_exception;
use stdClass;
/**
@@ -45,7 +46,7 @@ class studyplan_editform extends formbase {
* @throws \moodle_exception if access denied for a specific reason.
*/
public static function check_security(object $customdata) {
- webservicehelper::require_capabilities(self::CAP_EDIT,$customdata->context);
+ /*webservicehelper::require_capabilities(self::CAP_EDIT,$customdata->context); */
}
/**
@@ -68,7 +69,8 @@ class studyplan_editform extends formbase {
\context_system::instance(),
'local_treestudyplan',
'studyplan',
- $entry->id);
+ $customdata->plan->id());
+
return $entry;
}
@@ -89,7 +91,7 @@ class studyplan_editform extends formbase {
/**
* Process the submitted data and perform necessary actions
* @param object $entry The processed form data;
- * @return bool True if submission successful
+ * @return bool false if submission not successful
* @throws \moodle_exception if an error must be given for a specific reason.
*/
protected function process_submitted_data($entry) {
@@ -101,12 +103,18 @@ class studyplan_editform extends formbase {
\context_system::instance(),
'local_treestudyplan',
'studyplan',
- $entry->id);
+ $customdata->plan->id());
+
+ $f = fopen("/tmp/debug","a+");
+ fputs($f,print_r($entry,true));
+ fclose($f);
// Use our own abstraction to update the record, so caches are maintained
$customdata->plan->edit(['description' => $entry->description,
'descriptionformat' => $entry->descriptionformat]);
+
+ return true;
}
diff --git a/classes/studyplan.php b/classes/studyplan.php
index ac98a25..3ea2c85 100644
--- a/classes/studyplan.php
+++ b/classes/studyplan.php
@@ -158,7 +158,7 @@ class studyplan {
"shortname" => new \external_value(PARAM_TEXT, 'shortname of studyplan'),
"idnumber" => new \external_value(PARAM_TEXT, 'idnumber of curriculum'),
"context_id" => new \external_value(PARAM_INT, 'context_id of studyplan'),
- "description" => new \external_value(PARAM_TEXT, 'description of studyplan'),
+ "description" => new \external_value(PARAM_RAW, 'description of studyplan'),
"descriptionformat" => new \external_value(PARAM_INT, 'description format'),
"aggregation" => new \external_value(PARAM_TEXT, 'selected aggregator'),
"aggregation_config" => new \external_value(PARAM_TEXT, 'config string for aggregator'),
@@ -202,7 +202,8 @@ class studyplan {
"name" => new \external_value(PARAM_TEXT, 'name of studyplan'),
"shortname" => new \external_value(PARAM_TEXT, 'shortname of studyplan'),
"idnumber" => new \external_value(PARAM_TEXT, 'idnumber of curriculum'),
- "description" => new \external_value(PARAM_TEXT, 'description of studyplan'),
+ "description" => new \external_value(PARAM_RAW, 'description of studyplan'),
+ "descriptionformat" => new \external_value(PARAM_INT, 'description format'),
"context_id" => new \external_value(PARAM_INT, 'context_id of studyplan'),
"aggregation" => new \external_value(PARAM_TEXT, 'selected aggregator'),
"aggregation_config" => new \external_value(PARAM_TEXT, 'config string for aggregator'),
@@ -232,6 +233,7 @@ class studyplan {
'shortname' => $this->r->shortname,
'idnumber' => $this->r->idnumber,
'description' => $this->r->description,
+ 'descriptionformat' => $this->r->descriptionformat,
'context_id' => $this->context()->id,
"aggregation" => $this->r->aggregation,
"aggregation_config" => $this->aggregator->config_string(),
@@ -558,7 +560,8 @@ class studyplan {
"id" => new \external_value(PARAM_INT, 'id of studyplan'),
"name" => new \external_value(PARAM_TEXT, 'name of studyplan'),
"shortname" => new \external_value(PARAM_TEXT, 'shortname of studyplan'),
- "description" => new \external_value(PARAM_TEXT, 'description of studyplan'),
+ "description" => new \external_value(PARAM_RAW, 'description of studyplan'),
+ "descriptionformat" => new \external_value(PARAM_INT, 'description format'),
"idnumber" => new \external_value(PARAM_TEXT, 'idnumber of curriculum'),
"pages" => new \external_multiple_structure(studyplanpage::user_structure()),
"aggregation_info" => aggregator::basic_structure(),
@@ -578,6 +581,7 @@ class studyplan {
'name' => $this->r->name,
'shortname' => $this->r->shortname,
'description' => $this->r->description,
+ 'descriptionformat' => $this->r->descriptionformat,
'idnumber' => $this->r->idnumber,
'pages' => [],
'aggregation_info' => $this->aggregator->basic_model(),
diff --git a/classes/studyplanpage.php b/classes/studyplanpage.php
index f51573b..a6bed2f 100644
--- a/classes/studyplanpage.php
+++ b/classes/studyplanpage.php
@@ -148,7 +148,7 @@ class studyplanpage {
"fullname" => new \external_value(PARAM_TEXT, 'name of studyplan page'),
"shortname" => new \external_value(PARAM_TEXT, 'shortname of studyplan page'),
"periods" => new \external_value(PARAM_INT, 'number of periods in studyplan page'),
- "description" => new \external_value(PARAM_TEXT, 'description of studyplan page'),
+ "description" => new \external_value(PARAM_RAW, 'description of studyplan page'),
"startdate" => new \external_value(PARAM_TEXT, 'start date of studyplan'),
"enddate" => new \external_value(PARAM_TEXT, 'end date of studyplan'),
"perioddesc" => period::page_structure(),
@@ -181,7 +181,7 @@ class studyplanpage {
"id" => new \external_value(PARAM_INT, 'id of studyplan'),
"fullname" => new \external_value(PARAM_TEXT, 'name of studyplan page'),
"shortname" => new \external_value(PARAM_TEXT, 'shortname of studyplan page'),
- "description" => new \external_value(PARAM_TEXT, 'description of studyplan page'),
+ "description" => new \external_value(PARAM_RAW, 'description of studyplan page'),
"periods" => new \external_value(PARAM_INT, 'number of periods in studyplan page'),
"startdate" => new \external_value(PARAM_TEXT, 'start date of studyplan page'),
"enddate" => new \external_value(PARAM_TEXT, 'end date of studyplan page'),
@@ -300,7 +300,7 @@ class studyplanpage {
"id" => new \external_value(PARAM_INT, 'id of studyplan page'),
"fullname" => new \external_value(PARAM_TEXT, 'name of studyplan page'),
"shortname" => new \external_value(PARAM_TEXT, 'shortname of studyplan page'),
- "description" => new \external_value(PARAM_TEXT, 'description of studyplan page'),
+ "description" => new \external_value(PARAM_RAW, 'description of studyplan page'),
"periods" => new \external_value(PARAM_INT, 'number of slots in studyplan page'),
"startdate" => new \external_value(PARAM_TEXT, 'start date of studyplan page'),
"enddate" => new \external_value(PARAM_TEXT, 'end date of studyplan page'),
diff --git a/classes/utilityservice.php b/classes/utilityservice.php
index 8260149..2bbf054 100644
--- a/classes/utilityservice.php
+++ b/classes/utilityservice.php
@@ -89,18 +89,17 @@ class utilityservice extends \external_api {
\external_api::validate_context(\context_system::instance());
require_login(null,false,null);
- // Load the form before any output is started.
- $mform = self::load_mform($formname, $params);
// Hack alert: Set a default URL to stop the annoying debug.
$PAGE->set_url('/');
// Hack alert: Forcing bootstrap_renderer to initiate moodle page.
$OUTPUT->header();
-
/* Overwriting page_requirements_manager with the fragment one so only JS included from
this point is returned to the user. */
$PAGE->start_collecting_javascript_requirements();
+ // Load the form before any output is started.
+ $mform = self::load_mform($formname, $params);
// Perform actual render.
$html = $mform->render();
@@ -149,10 +148,16 @@ class utilityservice extends \external_api {
* @return array Success/fail structure
*/
public static function submit_mform($formname, $params, $formdata) {
- // Load the form, provide submitted form data and perform security checks
- $mform = self::load_mform($formname, $params, $formdata);
+ \external_api::validate_context(\context_system::instance());
+ require_login(null,false,null);
- if ($mform->process_submission()) {
+ $ajaxformdata = [];
+ parse_str($formdata,$ajaxformdata);
+
+ // Load the form, provide submitted form data and perform security checks
+ $mform = self::load_mform($formname, $params, $ajaxformdata);
+
+ if ($mform->process_submission() !== false) {
return success::success()->model();
} else {
return success::fail("Error in submission data")->model();
diff --git a/version.php b/version.php
index 9420d57..6e14b37 100644
--- a/version.php
+++ b/version.php
@@ -22,7 +22,7 @@
defined('MOODLE_INTERNAL') || die();
$plugin->component = 'local_treestudyplan'; // Recommended since 2.0.2 (MDL-26035). Required since 3.0 (MDL-48494).
-$plugin->version = 2023102000; // YYYYMMDDHH (year, month, day, iteration).
+$plugin->version = 2023102100; // YYYYMMDDHH (year, month, day, iteration).
$plugin->requires = 2021051700; // YYYYMMDDHH (This is the release version for Moodle 3.11).
$plugin->release = "1.1.0-b";