summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sqlbox/README.txt42
-rw-r--r--sqlbox/db/access.php76
-rw-r--r--sqlbox/db/install.php42
-rw-r--r--sqlbox/db/install.xml25
-rw-r--r--sqlbox/db/log.php40
-rw-r--r--sqlbox/db/uninstall.php32
-rw-r--r--sqlbox/db/upgrade.php165
-rw-r--r--sqlbox/index.php88
-rw-r--r--sqlbox/lang/en/newmodule.php41
-rw-r--r--sqlbox/lib.php393
-rw-r--r--sqlbox/locallib.php40
-rw-r--r--sqlbox/mod_form.php79
-rw-r--r--sqlbox/pix/icon.gifbin0 -> 128 bytes
-rw-r--r--sqlbox/version.php37
-rw-r--r--sqlbox/view.php78
15 files changed, 1178 insertions, 0 deletions
diff --git a/sqlbox/README.txt b/sqlbox/README.txt
new file mode 100644
index 0000000..3b8a9ec
--- /dev/null
+++ b/sqlbox/README.txt
@@ -0,0 +1,42 @@
+The following steps should get you up and running with
+this module template code.
+
+* DO NOT PANIC!
+
+* Unzip the archive and read this file
+
+* Rename the newmodule/ folder to the name of your module (eg "widget").
+ The module folder MUST be lower case. You should check the CVS contrib
+ area at http://cvs.moodle.org/contrib/plugins/mod/ to make sure that
+ your name is not already used by an other module.
+
+* Edit all the files in this directory and its subdirectories and change
+ all the instances of the string "newmodule" to your module name
+ (eg "widget"). If you are using Linux, you can use the following command
+ $ find . -type f -exec sed -i 's/newmodule/widget/g' {} \;
+
+* Rename the file lang/en/newmodule.php to lang/en/widget.php
+ where "widget" is the name of your module
+
+* Place the widget folder into the /mod folder of the moodle
+ directory.
+
+* Go to Settings > Site Administration > Development > XMLDB editor
+ and modify the module's tables.
+
+* Modify version.php and set the initial version of you module.
+
+* Visit Settings > Site Administration > Notifications, you should find
+ the module's tables successfully created
+
+* Go to Site Administration > Plugins > Activity modules > Manage activities
+ and you should find that this newmodule has been added to the list of
+ installed modules.
+
+* You may now proceed to run your own code in an attempt to develop
+ your module. You will probably want to modify mod_form.php and view.php
+ as a first step. Check db/access.php to add capabilities.
+
+We encourage you to share your code and experience - visit http://moodle.org
+
+Good luck!
diff --git a/sqlbox/db/access.php b/sqlbox/db/access.php
new file mode 100644
index 0000000..71647d3
--- /dev/null
+++ b/sqlbox/db/access.php
@@ -0,0 +1,76 @@
+<?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Capability definitions for the newmodule module
+ *
+ * The capabilities are loaded into the database table when the module is
+ * installed or updated. Whenever the capability definitions are updated,
+ * the module version number should be bumped up.
+ *
+ * The system has four possible values for a capability:
+ * CAP_ALLOW, CAP_PREVENT, CAP_PROHIBIT, and inherit (not set).
+ *
+ * It is important that capability names are unique. The naming convention
+ * for capabilities that are specific to modules and blocks is as follows:
+ * [mod/block]/<plugin_name>:<capabilityname>
+ *
+ * component_name should be the same as the directory name of the mod or block.
+ *
+ * Core moodle capabilities are defined thus:
+ * moodle/<capabilityclass>:<capabilityname>
+ *
+ * Examples: mod/forum:viewpost
+ * block/recent_activity:view
+ * moodle/site:deleteuser
+ *
+ * The variable name for the capability definitions array is $capabilities
+ *
+ * @package mod
+ * @subpackage newmodule
+ * @copyright 2011 Your Name
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$capabilities = array(
+
+/***************************** remove these comment marks and modify the code as needed
+ 'mod/newmodule:view' => array(
+ 'captype' => 'read',
+ 'contextlevel' => CONTEXT_MODULE,
+ 'legacy' => array(
+ 'guest' => CAP_ALLOW,
+ 'student' => CAP_ALLOW,
+ 'teacher' => CAP_ALLOW,
+ 'editingteacher' => CAP_ALLOW,
+ 'admin' => CAP_ALLOW
+ )
+ ),
+
+ 'mod/newmodule:submit' => array(
+ 'riskbitmask' => RISK_SPAM,
+ 'captype' => 'write',
+ 'contextlevel' => CONTEXT_MODULE,
+ 'legacy' => array(
+ 'student' => CAP_ALLOW
+ )
+ ),
+******************************/
+);
+
diff --git a/sqlbox/db/install.php b/sqlbox/db/install.php
new file mode 100644
index 0000000..d81ba97
--- /dev/null
+++ b/sqlbox/db/install.php
@@ -0,0 +1,42 @@
+<?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * This file replaces the legacy STATEMENTS section in db/install.xml,
+ * lib.php/modulename_install() post installation hook and partially defaults.php
+ *
+ * @package mod
+ * @subpackage newmodule
+ * @copyright 2011 Your Name <your@email.adress>
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+/**
+ * Post installation procedure
+ *
+ * @see upgrade_plugins_modules()
+ */
+function xmldb_newmodule_install() {
+}
+
+/**
+ * Post installation recovery procedure
+ *
+ * @see upgrade_plugins_modules()
+ */
+function xmldb_newmodule_install_recovery() {
+}
diff --git a/sqlbox/db/install.xml b/sqlbox/db/install.xml
new file mode 100644
index 0000000..d5d861b
--- /dev/null
+++ b/sqlbox/db/install.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<XMLDB PATH="mod/newmodule/db" VERSION="20101203" COMMENT="XMLDB file for Moodle mod/newmodule"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
+>
+ <TABLES>
+ <TABLE NAME="newmodule" COMMENT="Default comment for newmodule, please edit me">
+ <FIELDS>
+ <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="course"/>
+ <FIELD NAME="course" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="Course newmodule activity belongs to" PREVIOUS="id" NEXT="name"/>
+ <FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" COMMENT="name field for moodle instances" PREVIOUS="course" NEXT="intro"/>
+ <FIELD NAME="intro" TYPE="text" LENGTH="big" NOTNULL="false" SEQUENCE="false" COMMENT="General introduction of the newmodule activity" PREVIOUS="name" NEXT="introformat"/>
+ <FIELD NAME="introformat" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Format of the intro field (MOODLE, HTML, MARKDOWN...)" PREVIOUS="intro" NEXT="timecreated"/>
+ <FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" PREVIOUS="introformat" NEXT="timemodified"/>
+ <FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="timecreated"/>
+ </FIELDS>
+ <KEYS>
+ <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
+ </KEYS>
+ <INDEXES>
+ <INDEX NAME="course" UNIQUE="false" FIELDS="course"/>
+ </INDEXES>
+ </TABLE>
+ </TABLES>
+</XMLDB>
diff --git a/sqlbox/db/log.php b/sqlbox/db/log.php
new file mode 100644
index 0000000..73561d7
--- /dev/null
+++ b/sqlbox/db/log.php
@@ -0,0 +1,40 @@
+<?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Definition of log events
+ *
+ * NOTE: this is an example how to insert log event during installation/update.
+ * It is not really essential to know about it, but these logs were created as example
+ * in the previous 1.9 NEWMODULE.
+ *
+ * @package mod
+ * @subpackage newmodule
+ * @copyright 2011 Your Name <your@email.adress>
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+global $DB;
+
+$logs = array(
+ array('module'=>'newmodule', 'action'=>'add', 'mtable'=>'newmodule', 'field'=>'name'),
+ array('module'=>'newmodule', 'action'=>'update', 'mtable'=>'newmodule', 'field'=>'name'),
+ array('module'=>'newmodule', 'action'=>'view', 'mtable'=>'newmodule', 'field'=>'name'),
+ array('module'=>'newmodule', 'action'=>'view all', 'mtable'=>'newmodule', 'field'=>'name')
+);
diff --git a/sqlbox/db/uninstall.php b/sqlbox/db/uninstall.php
new file mode 100644
index 0000000..22ad141
--- /dev/null
+++ b/sqlbox/db/uninstall.php
@@ -0,0 +1,32 @@
+<?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * @see uninstall_plugin()
+ *
+ * @package mod
+ * @subpackage newmodule
+ * @copyright 2011 Your Name <your@email.adress>
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+/**
+ * Custom uninstallation procedure
+ */
+function xmldb_newmodule_uninstall() {
+ return true;
+}
diff --git a/sqlbox/db/upgrade.php b/sqlbox/db/upgrade.php
new file mode 100644
index 0000000..7f74831
--- /dev/null
+++ b/sqlbox/db/upgrade.php
@@ -0,0 +1,165 @@
+<?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * This file keeps track of upgrades to the newmodule module
+ *
+ * Sometimes, changes between versions involve alterations to database
+ * structures and other major things that may break installations. The upgrade
+ * function in this file will attempt to perform all the necessary actions to
+ * upgrade your older installation to the current version. If there's something
+ * it cannot do itself, it will tell you what you need to do. The commands in
+ * here will all be database-neutral, using the functions defined in DLL libraries.
+ *
+ * @package mod
+ * @subpackage newmodule
+ * @copyright 2011 Your Name
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+/**
+ * Execute newmodule upgrade from the given old version
+ *
+ * @param int $oldversion
+ * @return bool
+ */
+function xmldb_newmodule_upgrade($oldversion) {
+ global $DB;
+
+ $dbman = $DB->get_manager(); // loads ddl manager and xmldb classes
+
+ // And upgrade begins here. For each one, you'll need one
+ // block of code similar to the next one. Please, delete
+ // this comment lines once this file start handling proper
+ // upgrade code.
+
+ // if ($oldversion < YYYYMMDD00) { //New version in version.php
+ //
+ // }
+
+ // Lines below (this included) MUST BE DELETED once you get the first version
+ // of your module ready to be installed. They are here only
+ // for demonstrative purposes and to show how the newmodule
+ // iself has been upgraded.
+
+ // For each upgrade block, the file newmodule/version.php
+ // needs to be updated . Such change allows Moodle to know
+ // that this file has to be processed.
+
+ // To know more about how to write correct DB upgrade scripts it's
+ // highly recommended to read information available at:
+ // http://docs.moodle.org/en/Development:XMLDB_Documentation
+ // and to play with the XMLDB Editor (in the admin menu) and its
+ // PHP generation posibilities.
+
+ // First example, some fields were added to install.xml on 2007/04/01
+ if ($oldversion < 2007040100) {
+
+ // Define field course to be added to newmodule
+ $table = new xmldb_table('newmodule');
+ $field = new xmldb_field('course', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'id');
+
+ // Add field course
+ if (!$dbman->field_exists($table, $field)) {
+ $dbman->add_field($table, $field);
+ }
+
+ // Define field intro to be added to newmodule
+ $table = new xmldb_table('newmodule');
+ $field = new xmldb_field('intro', XMLDB_TYPE_TEXT, 'medium', null, null, null, null,'name');
+
+ // Add field intro
+ if (!$dbman->field_exists($table, $field)) {
+ $dbman->add_field($table, $field);
+ }
+
+ // Define field introformat to be added to newmodule
+ $table = new xmldb_table('newmodule');
+ $field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0',
+ 'intro');
+
+ // Add field introformat
+ if (!$dbman->field_exists($table, $field)) {
+ $dbman->add_field($table, $field);
+ }
+
+ // Once we reach this point, we can store the new version and consider the module
+ // upgraded to the version 2007040100 so the next time this block is skipped
+ upgrade_mod_savepoint(true, 2007040100, 'newmodule');
+ }
+
+ // Second example, some hours later, the same day 2007/04/01
+ // two more fields and one index were added to install.xml (note the micro increment
+ // "01" in the last two digits of the version
+ if ($oldversion < 2007040101) {
+
+ // Define field timecreated to be added to newmodule
+ $table = new xmldb_table('newmodule');
+ $field = new xmldb_field('timecreated', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0',
+ 'introformat');
+
+ // Add field timecreated
+ if (!$dbman->field_exists($table, $field)) {
+ $dbman->add_field($table, $field);
+ }
+
+ // Define field timemodified to be added to newmodule
+ $table = new xmldb_table('newmodule');
+ $field = new xmldb_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0',
+ 'timecreated');
+
+ // Add field timemodified
+ if (!$dbman->field_exists($table, $field)) {
+ $dbman->add_field($table, $field);
+ }
+
+ // Define index course (not unique) to be added to newmodule
+ $table = new xmldb_table('newmodule');
+ $index = new xmldb_index('courseindex', XMLDB_INDEX_NOTUNIQUE, array('course'));
+
+ // Add index to course field
+ if (!$dbman->index_exists($table, $index)) {
+ $dbman->add_index($table, $index);
+ }
+
+ // Another save point reached
+ upgrade_mod_savepoint(true, 2007040101, 'newmodule');
+ }
+
+ // Third example, the next day, 2007/04/02 (with the trailing 00), some actions were performed to install.php,
+ // related with the module
+ if ($oldversion < 2007040200) {
+
+ // insert here code to perform some actions (same as in install.php)
+
+ upgrade_mod_savepoint(true, 2007040200, 'newmodule');
+ }
+
+ // And that's all. Please, examine and understand the 3 example blocks above. Also
+ // it's interesting to look how other modules are using this script. Remember that
+ // the basic idea is to have "blocks" of code (each one being executed only once,
+ // when the module version (version.php) is updated.
+
+ // Lines above (this included) MUST BE DELETED once you get the first version of
+ // yout module working. Each time you need to modify something in the module (DB
+ // related, you'll raise the version and add one upgrade block here.
+
+ // Final return of upgrade result (true, all went good) to Moodle.
+ return true;
+}
diff --git a/sqlbox/index.php b/sqlbox/index.php
new file mode 100644
index 0000000..60e85d0
--- /dev/null
+++ b/sqlbox/index.php
@@ -0,0 +1,88 @@
+<?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * This is a one-line short description of the file
+ *
+ * You can have a rather longer description of the file as well,
+ * if you like, and it can span multiple lines.
+ *
+ * @package mod
+ * @subpackage newmodule
+ * @copyright 2011 Your Name
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+/// Replace newmodule with the name of your module and remove this line
+
+require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
+require_once(dirname(__FILE__).'/lib.php');
+
+$id = required_param('id', PARAM_INT); // course
+
+$course = $DB->get_record('course', array('id' => $id), '*', MUST_EXIST);
+
+require_course_login($course);
+
+add_to_log($course->id, 'newmodule', 'view all', 'index.php?id='.$course->id, '');
+
+$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
+
+$PAGE->set_url('/mod/newmodule/index.php', array('id' => $id));
+$PAGE->set_title(format_string($course->fullname));
+$PAGE->set_heading(format_string($course->fullname));
+$PAGE->set_context($coursecontext);
+
+echo $OUTPUT->header();
+
+if (! $newmodules = get_all_instances_in_course('newmodule', $course)) {
+ notice(get_string('nonewmodules', 'newmodule'), new moodle_url('/course/view.php', array('id' => $course->id)));
+}
+
+if ($course->format == 'weeks') {
+ $table->head = array(get_string('week'), get_string('name'));
+ $table->align = array('center', 'left');
+} else if ($course->format == 'topics') {
+ $table->head = array(get_string('topic'), get_string('name'));
+ $table->align = array('center', 'left', 'left', 'left');
+} else {
+ $table->head = array(get_string('name'));
+ $table->align = array('left', 'left', 'left');
+}
+
+foreach ($newmodules as $newmodule) {
+ if (!$newmodule->visible) {
+ $link = html_writer::link(
+ new moodle_url('/mod/newmodule.php', array('id' => $newmodule->coursemodule)),
+ format_string($newmodule->name, true),
+ array('class' => 'dimmed'));
+ } else {
+ $link = html_writer::link(
+ new moodle_url('/mod/newmodule.php', array('id' => $newmodule->coursemodule)),
+ format_string($newmodule->name, true));
+ }
+
+ if ($course->format == 'weeks' or $course->format == 'topics') {
+ $table->data[] = array($newmodule->section, $link);
+ } else {
+ $table->data[] = array($link);
+ }
+}
+
+echo $OUTPUT->heading(get_string('modulenameplural', 'newmodule'), 2);
+echo html_writer::table($table);
+echo $OUTPUT->footer();
diff --git a/sqlbox/lang/en/newmodule.php b/sqlbox/lang/en/newmodule.php
new file mode 100644
index 0000000..822e6c4
--- /dev/null
+++ b/sqlbox/lang/en/newmodule.php
@@ -0,0 +1,41 @@
+<?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+
+/**
+ * English strings for newmodule
+ *
+ * You can have a rather longer description of the file as well,
+ * if you like, and it can span multiple lines.
+ *
+ * @package mod
+ * @subpackage newmodule
+ * @copyright 2011 Your Name
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$string['modulename'] = 'newmodule';
+$string['modulenameplural'] = 'newmodules';
+$string['modulename_help'] = 'Use the newmodule module for... | The newmodule module allows...';
+$string['newmodulefieldset'] = 'Custom example fieldset';
+$string['newmodulename'] = 'newmodule name';
+$string['newmodulename_help'] = 'This is the content of the help tooltip associated with the newmodulename field. Markdown syntax is supported.';
+$string['newmodule'] = 'newmodule';
+$string['pluginadministration'] = 'newmodule administration';
+$string['pluginname'] = 'newmodule';
diff --git a/sqlbox/lib.php b/sqlbox/lib.php
new file mode 100644
index 0000000..d84e480
--- /dev/null
+++ b/sqlbox/lib.php
@@ -0,0 +1,393 @@
+<?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Library of interface functions and constants for module newmodule
+ *
+ * All the core Moodle functions, neeeded to allow the module to work
+ * integrated in Moodle should be placed here.
+ * All the newmodule specific functions, needed to implement all the module
+ * logic, should go to locallib.php. This will help to save some memory when
+ * Moodle is performing actions across all modules.
+ *
+ * @package mod
+ * @subpackage newmodule
+ * @copyright 2011 Your Name
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+/** example constant */
+//define('NEWMODULE_ULTIMATE_ANSWER', 42);
+
+////////////////////////////////////////////////////////////////////////////////
+// Moodle core API //
+////////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Returns the information on whether the module supports a feature
+ *
+ * @see plugin_supports() in lib/moodlelib.php
+ * @param string $feature FEATURE_xx constant for requested feature
+ * @return mixed true if the feature is supported, null if unknown
+ */
+function newmodule_supports($feature) {
+ switch($feature) {
+ case FEATURE_MOD_INTRO: return true;
+ default: return null;
+ }
+}
+
+/**
+ * Saves a new instance of the newmodule into the database
+ *
+ * Given an object containing all the necessary data,
+ * (defined by the form in mod_form.php) this function
+ * will create a new instance and return the id number
+ * of the new instance.
+ *
+ * @param object $newmodule An object from the form in mod_form.php
+ * @param mod_newmodule_mod_form $mform
+ * @return int The id of the newly inserted newmodule record
+ */
+function newmodule_add_instance(stdClass $newmodule, mod_newmodule_mod_form $mform = null) {
+ global $DB;
+
+ $newmodule->timecreated = time();
+
+ # You may have to add extra stuff in here #
+
+ return $DB->insert_record('newmodule', $newmodule);
+}
+
+/**
+ * Updates an instance of the newmodule in the database
+ *
+ * Given an object containing all the necessary data,
+ * (defined by the form in mod_form.php) this function
+ * will update an existing instance with new data.
+ *
+ * @param object $newmodule An object from the form in mod_form.php
+ * @param mod_newmodule_mod_form $mform
+ * @return boolean Success/Fail
+ */
+function newmodule_update_instance(stdClass $newmodule, mod_newmodule_mod_form $mform = null) {
+ global $DB;
+
+ $newmodule->timemodified = time();
+ $newmodule->id = $newmodule->instance;
+
+ # You may have to add extra stuff in here #
+
+ return $DB->update_record('newmodule', $newmodule);
+}
+
+/**
+ * Removes an instance of the newmodule from the database
+ *
+ * Given an ID of an instance of this module,
+ * this function will permanently delete the instance
+ * and any data that depends on it.
+ *
+ * @param int $id Id of the module instance
+ * @return boolean Success/Failure
+ */
+function newmodule_delete_instance($id) {
+ global $DB;
+
+ if (! $newmodule = $DB->get_record('newmodule', array('id' => $id))) {
+ return false;
+ }
+
+ # Delete any dependent records here #
+
+ $DB->delete_records('newmodule', array('id' => $newmodule->id));
+
+ return true;
+}
+
+/**
+ * Returns a small object with summary information about what a
+ * user has done with a given particular instance of this module
+ * Used for user activity reports.
+ * $return->time = the time they did it
+ * $return->info = a short text description
+ *
+ * @return stdClass|null
+ */
+function newmodule_user_outline($course, $user, $mod, $newmodule) {
+
+ $return = new stdClass();
+ $return->time = 0;
+ $return->info = '';
+ return $return;
+}
+
+/**
+ * Prints a detailed representation of what a user has done with
+ * a given particular instance of this module, for user activity reports.
+ *
+ * @param stdClass $course the current course record
+ * @param stdClass $user the record of the user we are generating report for
+ * @param cm_info $mod course module info
+ * @param stdClass $newmodule the module instance record
+ * @return void, is supposed to echp directly
+ */
+function newmodule_user_complete($course, $user, $mod, $newmodule) {
+}
+
+/**
+ * Given a course and a time, this module should find recent activity
+ * that has occurred in newmodule activities and print it out.
+ * Return true if there was output, or false is there was none.
+ *
+ * @return boolean
+ */
+function newmodule_print_recent_activity($course, $viewfullnames, $timestart) {
+ return false; // True if anything was printed, otherwise false
+}
+
+/**
+ * Prepares the recent activity data
+ *
+ * This callback function is supposed to populate the passed array with
+ * custom activity records. These records are then rendered into HTML via
+ * {@link newmodule_print_recent_mod_activity()}.
+ *
+ * @param array $activities sequentially indexed array of objects with the 'cmid' property
+ * @param int $index the index in the $activities to use for the next record
+ * @param int $timestart append activity since this time
+ * @param int $courseid the id of the course we produce the report for
+ * @param int $cmid course module id
+ * @param int $userid check for a particular user's activity only, defaults to 0 (all users)
+ * @param int $groupid check for a particular group's activity only, defaults to 0 (all groups)
+ * @return void adds items into $activities and increases $index
+ */
+function newmodule_get_recent_mod_activity(&$activities, &$index, $timestart, $courseid, $cmid, $userid=0, $groupid=0) {
+}
+
+/**
+ * Prints single activity item prepared by {@see newmodule_get_recent_mod_activity()}
+
+ * @return void
+ */
+function newmodule_print_recent_mod_activity($activity, $courseid, $detail, $modnames, $viewfullnames) {
+}
+
+/**
+ * Function to be run periodically according to the moodle cron
+ * This function searches for things that need to be done, such
+ * as sending out mail, toggling flags etc ...
+ *
+ * @return boolean
+ * @todo Finish documenting this function
+ **/
+function newmodule_cron () {
+ return true;
+}
+
+/**
+ * Returns all other caps used in the module
+ *
+ * @example return array('moodle/site:accessallgroups');
+ * @return array
+ */
+function newmodule_get_extra_capabilities() {
+ return array();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// Gradebook API //
+////////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Is a given scale used by the instance of newmodule?
+ *
+ * This function returns if a scale is being used by one newmodule
+ * if it has support for grading and scales. Commented code should be
+ * modified if necessary. See forum, glossary or journal modules
+ * as reference.
+ *
+ * @param int $newmoduleid ID of an instance of this module
+ * @return bool true if the scale is used by the given newmodule instance
+ */
+function newmodule_scale_used($newmoduleid, $scaleid) {
+ global $DB;
+
+ /** @example */
+ if ($scaleid and $DB->record_exists('newmodule', array('id' => $newmoduleid, 'grade' => -$scaleid))) {
+ return true;
+ } else {
+ return false;
+ }
+}
+
+/**
+ * Checks if scale is being used by any instance of newmodule.
+ *
+ * This is used to find out if scale used anywhere.
+ *
+ * @param $scaleid int
+ * @return boolean true if the scale is used by any newmodule instance
+ */
+function newmodule_scale_used_anywhere($scaleid) {
+ global $DB;
+
+ /** @example */
+ if ($scaleid and $DB->record_exists('newmodule', array('grade' => -$scaleid))) {
+ return true;
+ } else {
+ return false;
+ }
+}
+
+/**
+ * Creates or updates grade item for the give newmodule instance
+ *
+ * Needed by grade_update_mod_grades() in lib/gradelib.php
+ *
+ * @param stdClass $newmodule instance object with extra cmidnumber and modname property
+ * @return void
+ */
+function newmodule_grade_item_update(stdClass $newmodule) {
+ global $CFG;
+ require_once($CFG->libdir.'/gradelib.php');
+
+ /** @example */
+ $item = array();
+ $item['itemname'] = clean_param($newmodule->name, PARAM_NOTAGS);
+ $item['gradetype'] = GRADE_TYPE_VALUE;
+ $item['grademax'] = $newmodule->grade;
+ $item['grademin'] = 0;
+
+ grade_update('mod/newmodule', $newmodule->course, 'mod', 'newmodule', $newmodule->id, 0, null, $item);
+}
+
+/**
+ * Update newmodule grades in the gradebook
+ *
+ * Needed by grade_update_mod_grades() in lib/gradelib.php
+ *
+ * @param stdClass $newmodule instance object with extra cmidnumber and modname property
+ * @param int $userid update grade of specific user only, 0 means all participants
+ * @return void
+ */
+function newmodule_update_grades(stdClass $newmodule, $userid = 0) {
+ global $CFG, $DB;
+ require_once($CFG->libdir.'/gradelib.php');
+
+ /** @example */
+ $grades = array(); // populate array of grade objects indexed by userid
+
+ grade_update('mod/newmodule', $newmodule->course, 'mod', 'newmodule', $newmodule->id, 0, $grades);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// File API //
+////////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Returns the lists of all browsable file areas within the given module context
+ *
+ * The file area 'intro' for the activity introduction field is added automatically
+ * by {@link file_browser::get_file_info_context_module()}
+ *
+ * @param stdClass $course
+ * @param stdClass $cm
+ * @param stdClass $context
+ * @return array of [(string)filearea] => (string)description
+ */
+function newmodule_get_file_areas($course, $cm, $context) {
+ return array();
+}
+
+/**
+ * File browsing support for newmodule file areas
+ *
+ * @package mod_newmodule
+ * @category files
+ *
+ * @param file_browser $browser
+ * @param array $areas
+ * @param stdClass $course
+ * @param stdClass $cm
+ * @param stdClass $context
+ * @param string $filearea
+ * @param int $itemid
+ * @param string $filepath
+ * @param string $filename
+ * @return file_info instance or null if not found
+ */
+function newmodule_get_file_info($browser, $areas, $course, $cm, $context, $filearea, $itemid, $filepath, $filename) {
+ return null;
+}
+
+/**
+ * Serves the files from the newmodule file areas
+ *
+ * @package mod_newmodule
+ * @category files
+ *
+ * @param stdClass $course the course object
+ * @param stdClass $cm the course module object
+ * @param stdClass $context the newmodule's context
+ * @param string $filearea the name of the file area
+ * @param array $args extra arguments (itemid, path)
+ * @param bool $forcedownload whether or not force download
+ * @param array $options additional options affecting the file serving
+ */
+function newmodule_pluginfile($course, $cm, $context, $filearea, array $args, $forcedownload, array $options=array()) {
+ global $DB, $CFG;
+
+ if ($context->contextlevel != CONTEXT_MODULE) {
+ send_file_not_found();
+ }
+
+ require_login($course, true, $cm);
+
+ send_file_not_found();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// Navigation API //
+////////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Extends the global navigation tree by adding newmodule nodes if there is a relevant content
+ *
+ * This can be called by an AJAX request so do not rely on $PAGE as it might not be set up properly.
+ *
+ * @param navigation_node $navref An object representing the navigation tree node of the newmodule module instance
+ * @param stdClass $course
+ * @param stdClass $module
+ * @param cm_info $cm
+ */
+function newmodule_extend_navigation(navigation_node $navref, stdclass $course, stdclass $module, cm_info $cm) {
+}
+
+/**
+ * Extends the settings navigation with the newmodule settings
+ *
+ * This function is called when the context for the page is a newmodule module. This is not called by AJAX
+ * so it is safe to rely on the $PAGE.
+ *
+ * @param settings_navigation $settingsnav {@link settings_navigation}
+ * @param navigation_node $newmodulenode {@link navigation_node}
+ */
+function newmodule_extend_settings_navigation(settings_navigation $settingsnav, navigation_node $newmodulenode=null) {
+}
diff --git a/sqlbox/locallib.php b/sqlbox/locallib.php
new file mode 100644
index 0000000..62a5f5e
--- /dev/null
+++ b/sqlbox/locallib.php
@@ -0,0 +1,40 @@
+<?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Internal library of functions for module newmodule
+ *
+ * All the newmodule specific functions, needed to implement the module
+ * logic, should go here. Never include this file from your lib.php!
+ *
+ * @package mod
+ * @subpackage newmodule
+ * @copyright 2011 Your Name
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+/**
+ * Does something really useful with the passed things
+ *
+ * @param array $things
+ * @return object
+ */
+//function newmodule_do_something_useful(array $things) {
+// return new stdClass();
+//}
diff --git a/sqlbox/mod_form.php b/sqlbox/mod_form.php
new file mode 100644
index 0000000..53fda02
--- /dev/null
+++ b/sqlbox/mod_form.php
@@ -0,0 +1,79 @@
+<?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * The main newmodule configuration form
+ *
+ * It uses the standard core Moodle formslib. For more info about them, please
+ * visit: http://docs.moodle.org/en/Development:lib/formslib.php
+ *
+ * @package mod
+ * @subpackage newmodule
+ * @copyright 2011 Your Name
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+require_once($CFG->dirroot.'/course/moodleform_mod.php');
+
+/**
+ * Module instance settings form
+ */
+class mod_newmodule_mod_form extends moodleform_mod {
+
+ /**
+ * Defines forms elements
+ */
+ public function definition() {
+
+ $mform = $this->_form;
+
+ //-------------------------------------------------------------------------------
+ // Adding the "general" fieldset, where all the common settings are showed
+ $mform->addElement('header', 'general', get_string('general', 'form'));
+
+ // Adding the standard "name" field
+ $mform->addElement('text', 'name', get_string('newmodulename', 'newmodule'), array('size'=>'64'));
+ if (!empty($CFG->formatstringstriptags)) {
+ $mform->setType('name', PARAM_TEXT);
+ } else {
+ $mform->setType('name', PARAM_CLEAN);
+ }
+ $mform->addRule('name', null, 'required', null, 'client');
+ $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
+ $mform->addHelpButton('name', 'newmodulename', 'newmodule');
+
+ // Adding the standard "intro" and "introformat" fields
+ $this->add_intro_editor();
+
+ //-------------------------------------------------------------------------------
+ // Adding the rest of newmodule settings, spreeading all them into this fieldset
+ // or adding more fieldsets ('header' elements) if needed for better logic
+ $mform->addElement('static', 'label1', 'newmodulesetting1', 'Your newmodule fields go here. Replace me!');
+
+ $mform->addElement('header', 'newmodulefieldset', get_string('newmodulefieldset', 'newmodule'));
+ $mform->addElement('static', 'label2', 'newmodulesetting2', 'Your newmodule fields go here. Replace me!');
+
+ //-------------------------------------------------------------------------------
+ // add standard elements, common to all modules
+ $this->standard_coursemodule_elements();
+ //-------------------------------------------------------------------------------
+ // add standard buttons, common to all modules
+ $this->add_action_buttons();
+ }
+}
diff --git a/sqlbox/pix/icon.gif b/sqlbox/pix/icon.gif
new file mode 100644
index 0000000..550df5d
--- /dev/null
+++ b/sqlbox/pix/icon.gif
Binary files differ
diff --git a/sqlbox/version.php b/sqlbox/version.php
new file mode 100644
index 0000000..dc1f915
--- /dev/null
+++ b/sqlbox/version.php
@@ -0,0 +1,37 @@
+<?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+
+/**
+ * Defines the version of newmodule
+ *
+ * This code fragment is called by moodle_needs_upgrading() and
+ * /admin/index.php
+ *
+ * @package mod
+ * @subpackage newmodule
+ * @copyright 2011 Your Name
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$module->version = 0; // If version == 0 then module will not be installed
+//$module->version = 2010032200; // The current module version (Date: YYYYMMDDXX)
+$module->requires = 2010031900; // Requires this Moodle version
+$module->cron = 0; // Period for cron to check this module (secs)
+$module->component = 'mod_newmodule'; // To check on upgrade, that module sits in correct place
diff --git a/sqlbox/view.php b/sqlbox/view.php
new file mode 100644
index 0000000..0a374b5
--- /dev/null
+++ b/sqlbox/view.php
@@ -0,0 +1,78 @@
+<?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Prints a particular instance of newmodule
+ *
+ * You can have a rather longer description of the file as well,
+ * if you like, and it can span multiple lines.
+ *
+ * @package mod
+ * @subpackage newmodule
+ * @copyright 2011 Your Name
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+/// (Replace newmodule with the name of your module and remove this line)
+
+require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
+require_once(dirname(__FILE__).'/lib.php');
+
+$id = optional_param('id', 0, PARAM_INT); // course_module ID, or
+$n = optional_param('n', 0, PARAM_INT); // newmodule instance ID - it should be named as the first character of the module
+
+if ($id) {
+ $cm = get_coursemodule_from_id('newmodule', $id, 0, false, MUST_EXIST);
+ $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
+ $newmodule = $DB->get_record('newmodule', array('id' => $cm->instance), '*', MUST_EXIST);
+} elseif ($n) {
+ $newmodule = $DB->get_record('newmodule', array('id' => $n), '*', MUST_EXIST);
+ $course = $DB->get_record('course', array('id' => $newmodule->course), '*', MUST_EXIST);
+ $cm = get_coursemodule_from_instance('newmodule', $newmodule->id, $course->id, false, MUST_EXIST);
+} else {
+ error('You must specify a course_module ID or an instance ID');
+}
+
+require_login($course, true, $cm);
+$context = get_context_instance(CONTEXT_MODULE, $cm->id);
+
+add_to_log($course->id, 'newmodule', 'view', "view.php?id={$cm->id}", $newmodule->name, $cm->id);
+
+/// Print the page header
+
+$PAGE->set_url('/mod/newmodule/view.php', array('id' => $cm->id));
+$PAGE->set_title(format_string($newmodule->name));
+$PAGE->set_heading(format_string($course->fullname));
+$PAGE->set_context($context);
+
+// other things you may want to set - remove if not needed
+//$PAGE->set_cacheable(false);
+//$PAGE->set_focuscontrol('some-html-id');
+//$PAGE->add_body_class('newmodule-'.$somevar);
+
+// Output starts here
+echo $OUTPUT->header();
+
+if ($newmodule->intro) { // Conditions to show the intro can change to look for own settings or whatever
+ echo $OUTPUT->box(format_module_intro('newmodule', $newmodule, $cm->id), 'generalbox mod_introbox', 'newmoduleintro');
+}
+
+// Replace the following lines with you own code
+echo $OUTPUT->heading('Yay! It works!');
+
+// Finish the page
+echo $OUTPUT->footer();