Commit 35b1f0e3 authored by Francois Gannaz's avatar Francois Gannaz
Browse files

fix naming conventions imposed by Moodle

parent f08494eb
......@@ -93,7 +93,7 @@ class mod_labnbook_session
protected function fetchUserId($force = false) {
global $DB, $SESSION, $USER;
if ($force || !isset($SESSION->labnbook_userid)) {
$userId = $DB->get_field("mod_labnbook_user", "labnbook_userid", ['userid' => $USER->id]);
$userId = $DB->get_field("labnbook_user", "labnbook_userid", ['userid' => $USER->id]);
if (!$userId && $this->identifyByStudentNumber && $USER->idnumber) {
$userId = $this->fetch('GET', "/user/identify", null, ['idnumber' => $USER->idnumber]);
}
......
......@@ -4,7 +4,7 @@
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
>
<TABLES>
<TABLE NAME="mod_labnbook_user" COMMENT="matching users bewteen Moodle and LabNbook">
<TABLE NAME="labnbook_user" COMMENT="matching users bewteen Moodle and LabNbook">
<FIELDS>
<FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="labnbook_userid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
......@@ -15,19 +15,25 @@
<KEY NAME="userid" TYPE="foreign-unique" FIELDS="userid" REFTABLE="user" REFFIELDS="id"/>
</KEYS>
</TABLE>
<TABLE NAME="mod_labnbook" COMMENT="Activity instance">
<TABLE NAME="labnbook" COMMENT="Activity instance">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="labnbook_missionid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
<FIELD NAME="course" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="intro" TYPE="text" LENGTH="small" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="introformat" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="labnbook_missionid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="false" DEFAULT="0" SEQUENCE="false"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
</KEYS>
<INDEXES>
<INDEX NAME="course" UNIQUE="false" FIELDS="course"/>
</INDEXES>
</TABLE>
<TABLE NAME="mod_labnbook_teamconfig" COMMENT="configuration for teams in an activity">
<TABLE NAME="labnbook_teamconfig" COMMENT="configuration for teams in an activity">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
<FIELD NAME="instanceid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
......@@ -51,11 +57,11 @@
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
<KEY NAME="instanceid" TYPE="foreign" FIELDS="instanceid" REFTABLE="mod_labnbook" REFFIELDS="id"/>
<KEY NAME="instanceid" TYPE="foreign" FIELDS="instanceid" REFTABLE="labnbook" REFFIELDS="id"/>
<KEY NAME="groupid" TYPE="foreign" FIELDS="groupid" REFTABLE="group" REFFIELDS="id"/>
</KEYS>
</TABLE>
<TABLE NAME="mod_labnbook_team" COMMENT="team of users">
<TABLE NAME="labnbook_team" COMMENT="team of users">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
<FIELD NAME="teamconfigid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
......@@ -64,10 +70,10 @@
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
<KEY NAME="teamconfigid" TYPE="foreign" FIELDS="teamconfigid" REFTABLE="mod_labnbook_teamconfig" REFFIELDS="id"/>
<KEY NAME="teamconfigid" TYPE="foreign" FIELDS="teamconfigid" REFTABLE="labnbook_teamconfig" REFFIELDS="id"/>
</KEYS>
</TABLE>
<TABLE NAME="mod_labnbook_teammember" COMMENT="team of users">
<TABLE NAME="labnbook_teammember" COMMENT="team of users">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
<FIELD NAME="teamid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
......@@ -76,7 +82,7 @@
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
<KEY NAME="teamid" TYPE="foreign" FIELDS="teamid" REFTABLE="mod_labnbook_team" REFFIELDS="id"/>
<KEY NAME="teamid" TYPE="foreign" FIELDS="teamid" REFTABLE="labnbook_team" REFFIELDS="id"/>
<KEY NAME="userid" TYPE="foreign" FIELDS="userid" REFTABLE="user" REFFIELDS="id"/>
</KEYS>
</TABLE>
......
......@@ -24,13 +24,17 @@
defined('MOODLE_INTERNAL') || die();
define('LABNBOOK_TABLE', 'labnbook');
/* @var $DB moodle_database */
/**
* Return if the plugin supports $feature.
*
* @param string $feature Constant representing the feature.
* @return true | null True if the feature is supported, null otherwise.
*/
function mod_labnbook_supports($feature) {
function labnbook_supports($feature) {
switch ($feature) {
case FEATURE_GRADE_HAS_GRADE:
return true;
......@@ -54,12 +58,12 @@ function mod_labnbook_supports($feature) {
* @param mod_labnbook_mod_form $mform The form.
* @return int The id of the newly inserted record.
*/
function mod_labnbook_add_instance($moduleinstance, $mform = null) {
function labnbook_add_instance($moduleinstance, $mform = null) {
global $DB;
$moduleinstance->timecreated = time();
$id = $DB->insert_record('mod_labnbook', $moduleinstance);
$id = $DB->insert_record(LABNBOOK_TABLE, $moduleinstance);
return $id;
}
......@@ -74,13 +78,13 @@ function mod_labnbook_add_instance($moduleinstance, $mform = null) {
* @param mod_labnbook_mod_form $mform The form.
* @return bool True if successful, false otherwise.
*/
function mod_labnbook_update_instance($moduleinstance, $mform = null) {
function labnbook_update_instance($moduleinstance, $mform = null) {
global $DB;
$moduleinstance->timemodified = time();
$moduleinstance->id = $moduleinstance->instance;
return $DB->update_record('mod_labnbook', $moduleinstance);
return $DB->update_record(LABNBOOK_TABLE, $moduleinstance);
}
/**
......@@ -89,15 +93,15 @@ function mod_labnbook_update_instance($moduleinstance, $mform = null) {
* @param int $id Id of the module instance.
* @return bool True if successful, false on failure.
*/
function mod_labnbook_delete_instance($id) {
function labnbook_delete_instance($id) {
global $DB;
$exists = $DB->get_record('mod_labnbook', array('id' => $id));
$exists = $DB->get_record(LABNBOOK_TABLE, array('id' => $id));
if (!$exists) {
return false;
}
$DB->delete_records('mod_labnbook', array('id' => $id));
$DB->delete_records(LABNBOOK_TABLE, array('id' => $id));
return true;
}
......@@ -112,10 +116,10 @@ function mod_labnbook_delete_instance($id) {
* @param int $scaleid ID of the scale.
* @return bool True if the scale is used by the given mod_labnbook instance.
*/
function mod_labnbook_scale_used($moduleinstanceid, $scaleid) {
function labnbook_scale_used($moduleinstanceid, $scaleid) {
global $DB;
if ($scaleid && $DB->record_exists('mod_labnbook', array('id' => $moduleinstanceid, 'grade' => -$scaleid))) {
if ($scaleid && $DB->record_exists(LABNBOOK_TABLE, array('id' => $moduleinstanceid, 'grade' => -$scaleid))) {
return true;
} else {
return false;
......@@ -130,10 +134,10 @@ function mod_labnbook_scale_used($moduleinstanceid, $scaleid) {
* @param int $scaleid ID of the scale.
* @return bool True if the scale is used by any mod_labnbook instance.
*/
function mod_labnbook_scale_used_anywhere($scaleid) {
function labnbook_scale_used_anywhere($scaleid) {
global $DB;
if ($scaleid and $DB->record_exists('mod_labnbook', array('grade' => -$scaleid))) {
if ($scaleid and $DB->record_exists(LABNBOOK_TABLE, array('grade' => -$scaleid))) {
return true;
} else {
return false;
......@@ -149,7 +153,7 @@ function mod_labnbook_scale_used_anywhere($scaleid) {
* @param bool $reset Reset grades in the gradebook.
* @return void.
*/
function mod_labnbook_grade_item_update($moduleinstance, $reset=false) {
function labnbook_grade_item_update($moduleinstance, $reset=false) {
global $CFG;
require_once($CFG->libdir.'/gradelib.php');
......@@ -171,7 +175,7 @@ function mod_labnbook_grade_item_update($moduleinstance, $reset=false) {
$item['reset'] = true;
}
grade_update('/mod/labnbook', $moduleinstance->course, 'mod', 'mod_labnbook', $moduleinstance->id, 0, null, $item);
grade_update('/mod/labnbook', $moduleinstance->course, 'mod', LABNBOOK_TABLE, $moduleinstance->id, 0, null, $item);
}
/**
......@@ -180,11 +184,11 @@ function mod_labnbook_grade_item_update($moduleinstance, $reset=false) {
* @param stdClass $moduleinstance Instance object.
* @return grade_item.
*/
function mod_labnbook_grade_item_delete($moduleinstance) {
function labnbook_grade_item_delete($moduleinstance) {
global $CFG;
require_once($CFG->libdir.'/gradelib.php');
return grade_update('/mod/labnbook', $moduleinstance->course, 'mod', 'labnbook',
return grade_update('/mod/labnbook', $moduleinstance->course, 'mod', LABNBOOK_TABLE,
$moduleinstance->id, 0, null, array('deleted' => 1));
}
......@@ -196,13 +200,13 @@ function mod_labnbook_grade_item_delete($moduleinstance) {
* @param stdClass $moduleinstance Instance object with extra cmidnumber and modname property.
* @param int $userid Update grade of specific user only, 0 means all participants.
*/
function mod_labnbook_update_grades($moduleinstance, $userid = 0) {
function labnbook_update_grades($moduleinstance, $userid = 0) {
global $CFG, $DB;
require_once($CFG->libdir.'/gradelib.php');
// Populate array of grade objects indexed by userid.
$grades = array();
grade_update('/mod/labnbook', $moduleinstance->course, 'mod', 'mod_labnbook', $moduleinstance->id, 0, $grades);
grade_update('/mod/labnbook', $moduleinstance->course, 'mod', LABNBOOK_TABLE, $moduleinstance->id, 0, $grades);
}
/**
......@@ -215,7 +219,7 @@ function mod_labnbook_update_grades($moduleinstance, $userid = 0) {
* @param stdClass $module.
* @param cm_info $cm.
*/
function mod_labnbook_extend_navigation($labnbooknode, $course, $module, $cm) {
function labnbook_extend_navigation($labnbooknode, $course, $module, $cm) {
}
/**
......@@ -227,5 +231,5 @@ function mod_labnbook_extend_navigation($labnbooknode, $course, $module, $cm) {
* @param settings_navigation $settingsnav {@link settings_navigation}
* @param navigation_node $labnbooknode {@link navigation_node}
*/
function mod_labnbook_extend_settings_navigation($settingsnav, $labnbooknode = null) {
function labnbook_extend_settings_navigation($settingsnav, $labnbooknode = null) {
}
......@@ -55,7 +55,7 @@ class mod_labnbook_mod_form extends moodleform_mod {
$mform->addElement('header', 'external', "LabNbook");
$mform->addElement(
'select',
'missionid',
'labnbook_missionid',
get_string('mission', 'mod_labnbook'),
array_merge(['' => "-"], $missionsList),
[
......@@ -66,7 +66,7 @@ class mod_labnbook_mod_form extends moodleform_mod {
. 'document.querySelector("#id_introeditoreditable").innerHTML = missions[this.value].description;'
]
);
$mform->addRule('missionid', null, 'required', null, 'client');
$mform->addRule('labnbook_missionid', null, 'required', null, 'client');
// Adding the "general" fieldset, where all the common settings are showed.
$mform->addElement('header', 'general', get_string('general', 'form'));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment