Current version

This commit is contained in:
Kumi 2021-07-06 16:08:32 +02:00
commit 0236de8e96
10 changed files with 271 additions and 0 deletions

30
db/access.php Normal file
View file

@ -0,0 +1,30 @@
<?php
defined('MOODLE_INTERNAL') || die();
$capabilities = array(
'mod/expcontent:addinstance' => array(
'riskbitmask' => RISK_XSS,
'captype' => 'write',
'contextlevel' => CONTEXT_COURSE,
'archetypes' => array(
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW
),
'clonepermissionsfrom' => 'moodle/course:manageactivities'
),
'mod/expcontent:view' => array(
'captype' => 'read',
'contextlevel' => CONTEXT_MODULE,
'archetypes' => array(
'guest' => CAP_ALLOW,
'student' => CAP_ALLOW,
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW
)
)
);

26
db/install.xml Normal file
View file

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="mod/expcontent/db" VERSION="20210622" COMMENT="XMLDB file for Moodle mod/expcontent"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
>
<TABLES>
<TABLE NAME="expcontent" COMMENT="Default comment for expcontent, please edit me">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
<FIELD NAME="usermodified" 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="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="course" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
<FIELD NAME="name" TYPE="char" LENGTH="128" NOTNULL="true" SEQUENCE="false"/>
<FIELD NAME="contentid" TYPE="char" LENGTH="36" NOTNULL="true" SEQUENCE="false"/>
<FIELD NAME="intro" TYPE="text" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="introformat" TYPE="int" LENGTH="4" NOTNULL="true" SEQUENCE="false"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
<KEY NAME="usermodified" TYPE="foreign" FIELDS="usermodified" REFTABLE="user" REFFIELDS="id"/>
<KEY NAME="course" TYPE="foreign" FIELDS="course" REFTABLE="course" REFFIELDS="id"/>
</KEYS>
</TABLE>
</TABLES>
</XMLDB>

9
index.php Normal file
View file

@ -0,0 +1,9 @@
<?php
require_once('../../config.php');
$id = required_param('id', PARAM_INT);
if (!$course = $DB->get_record('course', array('id'=> $id))) {
print_error('Course ID is incorrect');
}

13
lang/en/expcontent.php Normal file
View file

@ -0,0 +1,13 @@
<?php
defined('MOODLE_INTERNAL') || die();
$string['modulename'] = 'EXP360 Content';
$string['settings'] = 'Settings';
$string['baseurl'] = 'Base URL';
$string['baseurl_help'] = 'Base URL of the EXP360 Content Server';
$string['name'] = 'Name';
$string['contentid'] = 'Content ID';

39
lib.php Normal file
View file

@ -0,0 +1,39 @@
<?php
if (!defined('MOODLE_INTERNAL')) die();
function expcontent_add_instance($expcontent) {
global $DB;
$expcontent->timemodified = time();
$expcontent->introformat = FORMAT_MOODLE;
$expcontent->id = $DB->insert_record('expcontent', $expcontent);
return $expcontent->id;
}
function expcontent_update_instance($expcontent) {
global $DB;
$expcontent->timemodified = time();
$expcontent->id = $expcontent->instance;
if (! $DB->update_record('expcontent', $expcontent)) {
return false;
}
return true;
}
function expcontent_delete_instance($id) {
global $DB;
if (! $expcontent = $DB->get_record('expcontent', array('id' => $id))) {
return false;
}
$DB->delete_records('expcontent', array('id' => $id));
return true;
}

28
mod_form.php Normal file
View file

@ -0,0 +1,28 @@
<?php
if (!defined('MOODLE_INTERNAL')) die();
require_once($CFG->dirroot.'/course/moodleform_mod.php');
require_once($CFG->dirroot.'/mod/expcontent/lib.php');
class mod_expcontent_mod_form extends moodleform_mod {
function definition() {
global $CFG, $DB, $OUTPUT;
$mform =& $this->_form;
$mform->addElement('text', 'name', get_string('name', 'expcontent'), array('size'=>'64'));
$mform->setType('name', PARAM_TEXT);
$mform->addRule('name', null, 'required', null, 'client');
$mform->addElement('text', 'contentid', get_string('contentid', 'expcontent'), array('size'=>'64'));
$mform->setType('contentid', PARAM_TEXT);
$mform->addRule('contentid', null, 'required', null, 'client');
$this->standard_coursemodule_elements();
$this->add_action_buttons();
}
}

BIN
pix/icon.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1,016 B

34
settings.php Normal file
View file

@ -0,0 +1,34 @@
<?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/>.
/**
* Administration settings definitions for the Diary module.
*
* @package mod_diary
* @copyright 2019 AL Rachels (drachels@drachels.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later.
*/
defined('MOODLE_INTERNAL') || die();
if ($ADMIN->fulltree) {
$settings->add(new admin_setting_heading('mod_expcontent/settings', get_string('settings'), ''));
$settings->add(new admin_setting_configtext('mod_expcontent/baseurl',
get_string('baseurl', 'expcontent'),
get_string('baseurl_help', 'expcontent'), 'http://expcontent.ahsoka.kumi.systems:7000/', PARAM_TEXT, 15));
}

9
version.php Normal file
View file

@ -0,0 +1,9 @@
<?php
defined('MOODLE_INTERNAL') || die();
$plugin->version = "2021070600";
$plugin->component = 'mod_expcontent';
$plugin->maturity = MATURITY_ALPHA;
$plugin->release = 'v0.0.1';
$plugin->requires = '2019111800';

83
view.php Normal file
View file

@ -0,0 +1,83 @@
<?php
require('../../config.php');
require_once('lib.php');
$id = required_param('id', PARAM_INT);
list ($course, $cm) = get_course_and_cm_from_cmid($id, 'expcontent');
$expcontent = $DB->get_record('expcontent', array('id'=> $cm->instance), '*', MUST_EXIST);
$expconfig = get_config('mod_expcontent');
$baseurl = $expconfig->baseurl;
if ($baseurl[-1] != "/") $baseurl += "/";
?>
<html>
<head>
<style>
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
flex: 0 0 auto;
}
li {
float: left;
height: auto;
position: relative;
font-family: "sans-serif";
}
li.right {
float: right;
}
li.logo {
margin-left: 2em;
margin-right: 2em;
}
li a,span {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
li a.hover:hover {
background-color: #111;
}
body {
display: flex;
flex-flow: column;
height: 100%;
margin: 0;
}
iframe {
flex: 1 1 auto;
}
img {
height: 100%;
width: auto;
}
</style>
<link rel="stylesheet" type="text/css" href="https://fa.kumi.systems/css/all.css">
<title><?php echo($expcontent->name); ?></title>
</head>
<body>
<ul>
<li class="logo"><img src="pix/icon.gif"></li>
<li><span><?php echo($expcontent->name); ?></span></li>
<li class="right"><a class="hover" href="javascript:history.back();"><i class="fas fa-times"></i></a></li>
</ul>
<iframe src='<?php echo($baseurl . "view-content/" . $expcontent->contentid); ?>' allow="autoplay; fullscreen"></iframe>
</body>
</html>