Skip to content

Commit

Permalink
initial wip version
Browse files Browse the repository at this point in the history
  • Loading branch information
Glutamat42 committed Sep 5, 2023
0 parents commit 2a80292
Show file tree
Hide file tree
Showing 9 changed files with 244 additions and 0 deletions.
33 changes: 33 additions & 0 deletions db/access.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
/**
* Capability definitions for the adleradaptivity module.
*
* @package mod_adleradaptivity
* @copyright 2023 Markus Heck <[email protected]>
*/

defined('MOODLE_INTERNAL') || die();

$capabilities = [
'mod/adleradaptivity:addinstance' => [
'riskbitmask' => RISK_XSS,
'captype' => 'write',
'contextlevel' => CONTEXT_COURSE,
'archetypes' => [
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW,
],
'clonepermissionsfrom' => 'moodle/course:manageactivities',
],
'mod/adleradaptivity:view' => [
'captype' => 'read',
'contextlevel' => CONTEXT_MODULE,
'archetypes' => [
'guest' => CAP_ALLOW,
'student' => CAP_ALLOW,
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW,
],
],
];
24 changes: 24 additions & 0 deletions db/install.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="mod/adleradaptivity/db" VERSION="20120122" COMMENT="XMLDB file for Moodle mod/adleradaptivity"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
>
<TABLES>
<TABLE NAME="adleradaptivity" COMMENT="Adler adaptivity activity module">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
<FIELD NAME="course" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false"/>
<FIELD NAME="intro" TYPE="text" NOTNULL="true" SEQUENCE="false"/>
<FIELD NAME="introformat" TYPE="int" LENGTH="4" NOTNULL="false" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
</KEYS>
<INDEXES>
<INDEX NAME="course" UNIQUE="false" FIELDS="course"/>
</INDEXES>
</TABLE>
</TABLES>
</XMLDB>
18 changes: 18 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

require_once('../../config.php');

// The `id` parameter is the course id.
$id = required_param('id', PARAM_INT);

// Fetch the requested course.
$course = $DB->get_record('course', ['id'=> $id], '*', MUST_EXIST);

// Require that the user is logged into the course.
require_course_login($course);

$modinfo = get_fast_modinfo($course);

foreach ($modinfo->get_instances_of('adleradaptivity') as $instanceid => $cm) {
// Display information about your activity.
}
17 changes: 17 additions & 0 deletions lang/en/adleradaptivity.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
/**
* Languages configuration for the mod_[modname] plugin.
*
* @package mod_adleradaptivity
* @copyright 2023, Markus Heck <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

$string['pluginname'] = 'Adler Adaptivity Activity Module';
$string['modulename'] = 'Adler Adaptivity';
$string['modulenameplural'] = 'Adler Adaptivities';
$string['modulename_help'] = 'Insert modulename help text here.';
$string['pluginadministration'] = 'Adler Adaptivity administration';

$string['form_field_title'] = 'Element title';
$string['form_field_intro'] = 'Description (currently unused but required field by moodle)';
48 changes: 48 additions & 0 deletions lib.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

use core_completion\api as completion_api;

/** The [modname]_add_instance() function is called when the activity
* creation form is submitted. This function is only called when adding
* an activity and should contain any logic required to add the activity.
*
* @param $instancedata
* @param $mform
* @return int
*/
function adleradaptivity_add_instance($instancedata, $mform = null): int {
global $DB;

$instancedata->timemodified = time();

$id = $DB->insert_record("adleradaptivity", $instancedata);

// Update completion date event. This is a default feature activated for all modules (create module -> Activity completion).
$completiontimeexpected = !empty($instancedata->completionexpected) ? $instancedata->completionexpected : null;
completion_api::update_completion_date_event($instancedata->coursemodule, 'adleradaptivity', $id, $completiontimeexpected);

return $id;

}

/** The [modname]_update_instance() function is called when the activity
* editing form is submitted.
*
* @param $instancedata
* @param $mform
* @return bool
*/
function adleradaptivity_update_instance($instancedata, $mform): bool {

}

/** The [modname]_delete_instance() function is called when the activity
* deletion is confirmed. It is responsible for removing all data associated
* with the instance.
*
* @param $id
* @return bool
*/
function adleradaptivity_delete_instance($id): bool {

}
29 changes: 29 additions & 0 deletions mod_form.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

require_once($CFG->dirroot.'/course/moodleform_mod.php');
require_once($CFG->dirroot.'/mod/adleradaptivity/lib.php');

class mod_adleradaptivity_mod_form extends moodleform_mod {

function definition() {
global $CFG, $DB, $OUTPUT;

$mform =& $this->_form;

$mform->addElement('text', 'name', get_string('form_field_title', 'mod_adleradaptivity'), ['size'=>'64']);
$mform->setType('name', PARAM_TEXT);
$mform->addRule('name', null, 'required', null, 'client');

$this->standard_intro_elements(get_string('form_field_intro', 'mod_adleradaptivity'));


// // Label does not add "Show description" checkbox meaning that 'intro' is always shown on the course page.
// $mform->addElement('hidden', 'showdescription', 1);
// $mform->setType('showdescription', PARAM_INT);

$this->standard_coursemodule_elements();

$this->add_action_buttons();
}

}
Binary file added pix/monologo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions version.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?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/>.

/**
* Label module version info
*
* @package mod_adleradaptivity
* @copyright 2023, Markus Heck <[email protected]>
*/

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2023062909;
$plugin->requires = 2021051712.05; // Moodle version
$plugin->component = 'mod_adleradaptivity'; // Full name of the plugin (used for diagnostics)
$plugin->maturity = MATURITY_ALPHA;
46 changes: 46 additions & 0 deletions view.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

require('../../config.php');

$id = required_param('id', PARAM_INT);
[$course, $cm] = get_course_and_cm_from_cmid($id, 'adleradaptivity');
$instance = $DB->get_record('adleradaptivity', ['id'=> $cm->instance], '*', MUST_EXIST);

global $PAGE, $OUTPUT;
require_course_login($course, true, $cm);



//require_once("../../config.php");
//
$id = optional_param('id',0,PARAM_INT); // Course Module ID, or
//$l = optional_param('l',0,PARAM_INT); // adleradaptivity ID
//
if ($id) {
$PAGE->set_url('/mod/adleradaptivity/view.php', array('id' => $id));
// if (! $cm = get_coursemodule_from_id('adleradaptivity', $id, 0, true)) {
// throw new \moodle_exception('invalidcoursemodule');
// }
//
// if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
// throw new \moodle_exception('coursemisconf');
// }
//
// if (! $adleradaptivity = $DB->get_record("adleradaptivity", array("id"=>$cm->instance))) {
// throw new \moodle_exception('invalidcoursemodule');
// }

//} else {
// $PAGE->set_url('/mod/adleradaptivity/view.php', array('l' => $l));
// if (! $adleradaptivity = $DB->get_record("adleradaptivity", array("id"=>$l))) {
// throw new \moodle_exception('invalidcoursemodule');
// }
// if (! $course = $DB->get_record("course", array("id"=>$adleradaptivity->course)) ){
// throw new \moodle_exception('coursemisconf');
// }
// if (! $cm = get_coursemodule_from_instance("adleradaptivity", $adleradaptivity->id, $course->id, true)) {
// throw new \moodle_exception('invalidcoursemodule');
// }
}

echo $OUTPUT->footer();

0 comments on commit 2a80292

Please sign in to comment.