Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions amd/build/module.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion amd/build/module.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 23 additions & 6 deletions amd/src/module.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,50 @@
// 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/>.

/**
* *************************************************************************
* * OOHOO - Tab Display **
* *************************************************************************
* @package mod **
* @package
* @subpackage tab **
* @name tab **
* @copyright oohoo.biz **
* @link http://oohoo.biz **
* @author Patrick Thibaudeau **
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later **
* *************************************************************************
* ************************************************************************ */
* ************************************************************************
*/

define(['jquery'], function($) {
var modtabjs = {
let modtabjs = {
obj: null,
init: function(id) {
modtabjs.obj = $('#' + id);
modtabjs.resizeobject();
window.onresize = function () {
window.onresize = function() {
modtabjs.resizeobject();
};
},
resizeobject: function() {
var newwidth = $('.tab-content').width();
let newwidth = $('.tab-content').width();

modtabjs.obj.css('width', '0px');
modtabjs.obj.css('height', '0px');

var newheight = window.visualViewport.height - $('div#page').height() - 40;
let newheight = window.visualViewport.height - $('div#page').height() - 40;

if (newwidth < 600) {
newwidth = 600;
Expand Down
77 changes: 45 additions & 32 deletions backup/moodle1/lib.php
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
<?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/>.

/**
* *************************************************************************
Expand All @@ -13,18 +27,17 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later **
* *************************************************************************
* ************************************************************************ */
defined('MOODLE_INTERNAL') || die();

/**
* Tab Display conversion handler
*/
class moodle1_mod_tab_handler extends moodle1_mod_handler {

/** @var moodle1_file_manager */
protected $fileman = null;
/** @var ?moodle1_file_manager */
protected ?moodle1_file_manager $fileman = null;

/** @var int cmid */
protected $moduleid = null;
/** @var ?int cmid */
protected ?int $moduleid = null;

/**
* Declare the paths in moodle.xml we are able to convert
Expand All @@ -39,22 +52,22 @@ class moodle1_mod_tab_handler extends moodle1_mod_handler {
*
* @return array of {@link convert_path} instances
*/
public function get_paths() {
return array(
public function get_paths(): array {
return [
new convert_path('tab', '/MOODLE_BACKUP/COURSE/MODULES/MOD/TAB'),
new convert_path('tab_contents', '/MOODLE_BACKUP/COURSE/MODULES/MOD/TAB/TABCONTENTS'),
new convert_path('tab_content', '/MOODLE_BACKUP/COURSE/MODULES/MOD/TAB/TABCONTENTS/TABCONTENT',
array(
'renamefields' => array(
[
'renamefields' => [
'format' => 'contentformat',
),
'newfields' => array(
'externalurl' => NULL,
],
'newfields' => [
'externalurl' => null,
'contentformat' => 1,
),
)
],
]
),
);
];
}

/**
Expand All @@ -63,24 +76,24 @@ public function get_paths() {
*/
public function process_tab($data) {

// get the course module id and context id
// Get the course module id and context id.
$instanceid = $data['id'];
$cminfo = $this->get_cminfo($instanceid);
$this->moduleid = $cminfo['id'];
$contextid = $this->converter->get_contextid(CONTEXT_MODULE, $this->moduleid);

// get a fresh new file manager for this instance
// Get a fresh new file manager for this instance.
$this->fileman = $this->converter->get_file_manager($contextid, 'mod_tab');

// convert course files embedded into the intro
//$this->fileman->filearea = 'tabcontent';
//$this->fileman->itemid = 0;
//$data['tabcontent'] = moodle1_converter::migrate_referenced_files($data['tabcontent'], $this->fileman);
// start writing choice.xml
$this->open_xml_writer("activities/tab_{$this->moduleid}/tab.xml");
$this->xmlwriter->begin_tag('activity', array('id' => $instanceid, 'moduleid' => $this->moduleid,
'modulename' => 'tab', 'contextid' => $contextid));
$this->xmlwriter->begin_tag('tab', array('id' => $instanceid));
// Vonvert course files embedded into the intro
// $this->fileman->filearea = 'tabcontent';
// $this->fileman->itemid = 0;
// $data['tabcontent'] = moodle1_converter::migrate_referenced_files($data['tabcontent'], $this->fileman);
// Start writing choice.xml.
$this->open_xml_writer("activities/tab_$this->moduleid/tab.xml");
$this->xmlwriter->begin_tag('activity', ['id' => $instanceid, 'moduleid' => $this->moduleid,
'modulename' => 'tab', 'contextid' => $contextid, ]);
$this->xmlwriter->begin_tag('tab', ['id' => $instanceid]);

foreach ($data as $field => $value) {
if ($field <> 'id') {
Expand All @@ -94,30 +107,30 @@ public function process_tab($data) {
/**
* This is executed when the parser reaches the <OPTIONS> opening element
*/
public function on_tab_contents_start() {
public function on_tab_contents_start(): void {
$this->xmlwriter->begin_tag('tab_contents');
}

/**
* This is executed every time we have one /MOODLE_BACKUP/COURSE/MODULES/MOD/CHOICE/OPTIONS/OPTION
* data available
*/
public function process_tab_content($data) {
$this->write_xml('tab_content', $data, array('/tab_content/id'));
public function process_tab_content($data): void {
$this->write_xml('tab_content', $data, ['/tab_content/id']);
}

/**
* This is executed when the parser reaches the closing </OPTIONS> element
*/
public function on_tab_contents_end() {
public function on_tab_contents_end(): void {
$this->xmlwriter->end_tag('tab_contents');
}

/**
* This is executed when we reach the closing </MOD> tag of our 'choice' path
*/
public function on_tab_end() {
// finalize tab.xml
public function on_tab_end(): void {
// Finalize tab.xml.
$this->xmlwriter->end_tag('tab');
$this->xmlwriter->end_tag('activity');
$this->close_xml_writer();
Expand Down
37 changes: 25 additions & 12 deletions backup/moodle2/backup_tab_activity_task.class.php
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
<?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/>.
/**
* *************************************************************************
* * OOHOO - Tab Display **
Expand All @@ -14,8 +27,10 @@
* *************************************************************************
* ************************************************************************ */

require_once($CFG->dirroot . '/mod/tab/backup/moodle2/backup_tab_stepslib.php'); // Because it exists (must)
require_once($CFG->dirroot . '/mod/tab/backup/moodle2/backup_tab_settingslib.php'); // Because it exists (optional)
defined('MOODLE_INTERNAL') || die;

require_once($CFG->dirroot . '/mod/tab/backup/moodle2/backup_tab_stepslib.php'); // Because it exists (must).
require_once($CFG->dirroot . '/mod/tab/backup/moodle2/backup_tab_settingslib.php'); // Because it exists (optional).

/**
* choice backup task that provides all the settings and steps to perform one
Expand All @@ -27,13 +42,13 @@ class backup_tab_activity_task extends backup_activity_task {
* Define (add) particular settings this activity can have
*/
protected function define_my_settings() {
// No particular settings for this activity
// No particular settings for this activity.
}

/**
* Define (add) particular steps this activity can have
*/
protected function define_my_steps() {
protected function define_my_steps(): void {
$this->add_step(new backup_tab_activity_structure_step('tab_structure', 'tab.xml'));
}

Expand All @@ -43,15 +58,13 @@ protected function define_my_steps() {
* @param string $content some HTML text that eventually contains URLs to the activity instance scripts
* @return string the content with the URLs encoded
*/
static public function encode_content_links($content) {
public static function encode_content_links($content): string {
global $CFG;

$base = preg_quote($CFG->wwwroot, "/");

// Link to page view by moduleid
$search = "/(" . $base . "\/mod\/tab\/view.php\?id\=)([0-9]+)/";
$content = preg_replace($search, '$@TABVIEWBYID*$2@$', $content);

return $content;
// Link to page view by moduleid.
$search = "/(" . $base . "\/mod\/tab\/view.php\?id=)([0-9]+)/";
return preg_replace($search, '$@TABVIEWBYID*$2@$', $content);
}
}
}
Loading