Skip to content

Commit

Permalink
Fix ANFA field 4_3 'Location' postprocessing (disabled it)
Browse files Browse the repository at this point in the history
  • Loading branch information
vfremaux committed Nov 20, 2024
1 parent 16e250c commit 0b77989
Show file tree
Hide file tree
Showing 141 changed files with 7,479 additions and 7,066 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,12 @@ and quick deployment mode.

Changes for 2019062000 (x.x.0010)
=================================
Add capabilities to control classification and classification tokens deletion.

Add capabilities to control classification and classification tokens deletion.
Changes for 2024052400 (x.x.0012)
=================================
Fixes CSS link color on metadata popup tabs.

Changes for 2024093000 (x.x.0014)
=================================
Global review for moodle CI checks and code normalization. Deep fixes and optimlizations.
6 changes: 4 additions & 2 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,12 @@ and quick deployment mode.

Changes for 2019062000 (x.x.0010)
=================================

Add capabilities to control classification and classification tokens deletion.

Changes for 2024052400 (x.x.0012)
=================================

Fixes CSS link color on metadata popup tabs.

Changes for 2024093000 (x.x.0014)
=================================
Global review for moodle CI checks and code normalization. Deep fixes and optimlizations.
66 changes: 27 additions & 39 deletions addlocaltocourse.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,25 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
*
* @package mod_sharedresource
* @author Valery Fremaux <[email protected]>
* @copyright Valery Fremaux (activeprolearn.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
*/

/*
* TODO : clarify doc.
* this action screen allows adding a sharedresource from an external browse or search result
* directly in the current course and the resource results being already known as a local proxy, or
* it is a locally stored resource.
* This possibility will only be available when
* external resource repositories are queried from a course starting context.
* Adding local resource should always provide identifier.
*
* @package mod_sharedresource
* @category mod
* @author Valery Fremaux <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com
*/
use \mod_sharedresource\entry_factory;
use \mod_sharedresource\entry;
use \mod_sharedresource\entry_extended;
use mod_sharedresource\entry_factory;
use mod_sharedresource\entry;
use mod_sharedresource\entry_extended;

require('../../config.php');
require_once($CFG->libdir.'/adminlib.php');
Expand All @@ -44,10 +47,10 @@
$section = optional_param('section', '', PARAM_INT);
$identifier = required_param('identifier', PARAM_TEXT);
$mode = optional_param('mode', 'shared', PARAM_ALPHA);
$course = $DB->get_record('course', array('id' => "$courseid"));
$course = $DB->get_record('course', ['id' => "$courseid"]);

if (empty($course)) {
print_error('coursemisconf');
throw new moodle_exception('coursemisconf');
}

if (!$section) {
Expand All @@ -59,15 +62,15 @@

require_login($course);
$context = context_course::instance($course->id);
if (!has_any_capability(array('repository/sharedresources:use', 'repository/sharedresources:create'), $context)) {
print_error('noaccessform', 'sharedresource');
if (!has_any_capability(['repository/sharedresources:use', 'repository/sharedresources:create'], $context)) {
throw new moodle_exception('noaccessform', 'sharedresource');
}

$config = get_config('sharedresource');

$strtitle = get_string('addlocal', 'sharedresource');

$params = array('id' => $courseid, 'identifier' => $identifier, 'mode' => $mode);
$params = ['id' => $courseid, 'identifier' => $identifier, 'mode' => $mode];
$url = new moodle_url('/mod/sharedresource/addlocaltocourse.php', $params);
$PAGE->set_url($url);
$PAGE->set_pagelayout('standard');
Expand All @@ -86,21 +89,6 @@
$shrentry = entry::read($identifier);
}

/*
// Obsolete.
if ($mode == 'file') {
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('addfile', 'sharedresource'));
// This is the simple "file" mode that gets back the resource file into course file scope.
print_string('fileadvice', 'sharedresource');
$return = new moodle_url('/files/index.php', array('id' => $courseid));
echo $OUTPUT->continue_button($return);
echo $OUTPUT->footer($course);
die;
}
*/

/*
* The sharedresource has been recognized as a deployable backup.
* Take the physical file and deploy it with the activity publisher utility.
Expand All @@ -111,7 +99,7 @@
if (file_exists($CFG->dirroot.'/blocks/activity_publisher/lib/activity_publisher.class.php')) {
sharedresource_deploy_activity($shrentry, $course, $section);
// TODO : Terminate procedure and return to course silently.
redirect(new moodle_url('/course/view.php', array('id' => $course->id)));
redirect(new moodle_url('/course/view.php', ['id' => $course->id]));
}

// No one should be here....
Expand All @@ -127,7 +115,7 @@
*/
list($cm, $instance, $modname) = sharedresource_deploy_scorm($shrentry, $course, $section);
// TODO : Terminate procedure and return to course silently.
redirect(new moodle_url('/course/view.php', array('id' => $course->id)));
redirect(new moodle_url('/course/view.php', ['id' => $course->id]));
}

/*
Expand All @@ -153,7 +141,7 @@
$instance->timemodified = time();

if (!$instance->id = $instance->add_instance($instance)) {
print_error('erroraddinstance', 'sharedresource');
throw new moodle_exception('erroraddinstance', 'sharedresource');
}

$modulename = 'sharedresource';
Expand All @@ -168,18 +156,18 @@
$DB->update_record('course', $course);

if (!$sectionid = course_add_cm_to_section($course, $cm->id, $section)) {
print_error('errorsectionaddition', 'sharedresource');
throw new moodle_exception('errorsectionaddition', 'sharedresource');
}

if (!$DB->set_field('course_modules', 'section', $sectionid, array('id' => $cm->id))) {
print_error('errorcmsectionbinding', 'sharedresource');
if (!$DB->set_field('course_modules', 'section', $sectionid, ['id' => $cm->id])) {
throw new moodle_exception('errorcmsectionbinding', 'sharedresource');
}

// If we are in page format, add page_item to section bound page.
if ($course->format == 'page') {
require_once($CFG->dirroot.'/course/format/page/classes/page.class.php');
require_once($CFG->dirroot.'/course/format/page/lib.php');
$coursepage = \format\page\course_page::get_current_page($course->id);
$coursepage = \format_page\course_page::get_current_page($course->id);
$coursepage->add_cm_to_page($cm->id);
}

Expand Down Expand Up @@ -216,11 +204,11 @@
echo $report;
echo '</pre>';

echo $OUTPUT->continue_button(new moodle_url('/course/view.php', array('id' => $course->id)));
echo $OUTPUT->continue_button(new moodle_url('/course/view.php', ['id' => $course->id]));
echo $OUTPUT->footer();
die;
} else {
// TODO : Terminate procedure and return to course silently.
redirect(new moodle_url('/course/view.php', array('id' => $course->id)));
redirect(new moodle_url('/course/view.php', ['id' => $course->id]));
die;
}
}
57 changes: 30 additions & 27 deletions addremotetocourse.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,18 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Add a remote search result in course as sharedresource.
*
* @package mod_sharedresource
* @author Valery Fremaux <[email protected]>
* @copyright Valery Fremaux (activeprolearn.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
*/

/*
* this action screen allows adding a sharedresource from an external search result
* directly in the current course. This possibility will only be available when
* external resource repositories are queried from a course starting context
*
* @package mod_sharedresource
* @category mod
* @author Valery Fremaux <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com
*/
require('../../config.php');
require_once($CFG->libdir.'/adminlib.php');
Expand All @@ -45,13 +48,13 @@
$url .= '&token='.$token;
}

$course = $DB->get_record('course', array('id' => "$courseid"));
$course = $DB->get_record('course', ['id' => "$courseid"]);
if (empty($course)) {
print_error('coursemisconf');
throw new moodle_exception('coursemisconf');
}

// Some attributes of $PAGE must be defined.
$params = array('id' => $courseid, 'url' => $url, 'file' => $filename);
$params = ['id' => $courseid, 'url' => $url, 'file' => $filename];
$pageurl = new moodle_url('/mod/sharedresource/addremotetocourse.php', $params);
$PAGE->set_url($pageurl);

Expand All @@ -60,8 +63,8 @@
require_login($course);

$context = context_course::instance($course->id);
if (!has_any_capability(array('repository/sharedresources:use', 'repository/sharedresources:create'), $context)) {
print_error('noaccessform', 'sharedresource');
if (!has_any_capability(['repository/sharedresources:use', 'repository/sharedresources:create'], $context)) {
throw new moodle_exception('noaccessform', 'sharedresource');
}

if (!$section) {
Expand Down Expand Up @@ -127,9 +130,9 @@
if (file_exists($CFG->dirroot.'/blocks/activity_publisher/lib/activity_publisher.class.php')) {
sharedresource_deploy_activity($shrentry, $course, $section, $tempfile);
// TODO : Terminate procedure and return to course silently.
redirect(new moodle_url('/course/view.php', array('id' => $course->id)));
redirect(new moodle_url('/course/view.php', ['id' => $course->id]));
} else {
print_error('Activity publisher not installed. Deployment cannot be performed.');
throw new moodle_exception('Activity publisher not installed. Deployment cannot be performed.');
}

// No one should be here....
Expand All @@ -151,30 +154,30 @@
$draftid = $tempfile->get_itemid();
}
if (empty($draftid) && ($config->scormintegration == SCORM_TYPE_LOCAL)) {
print_error('errorscormtypelocalwithnofile', 'sharedresource');
throw new moodle_exception('errorscormtypelocalwithnofile', 'sharedresource');
}

list($cm, $instance, $modname) = sharedresource_deploy_scorm($shrentry, $course, $section, $draftid);

if (empty($cm)) {
print_error('errorscorm', 'sharedresource');
throw new moodle_exception('errorscorm', 'sharedresource');
}

// TODO : Terminate procedure and return to course silently.
redirect(new moodle_url('/course/view.php', array('id' => $course->id)));
redirect(new moodle_url('/course/view.php', ['id' => $course->id]));
}

if (!in_array($mode, array('file', 'lticonfirm', 'ltiinstall', 'mplayerdeploy'))) {
if (!in_array($mode, ['file', 'lticonfirm', 'ltiinstall', 'mplayerdeploy'])) {
/*
* The resource IS NOT known in the local repository but we may have the identifier and the provider
* if identifier is empty the resource is submitted from an external search interface.
* if not empty, the resource comes from another MNET shared repository
*/
if (!$DB->record_exists('sharedresource_entry', array('identifier' => $shrentry->identifier))) {
if (!$DB->record_exists('sharedresource_entry', ['identifier' => $shrentry->identifier])) {
$shrentry->add_instance();
} else {
if (!$shrentry = \mod_sharedresource\entry::read($identifier)) {
print_error('errorinvalididentifier', 'sharedresource');
throw new moodle_exception('errorinvalididentifier', 'sharedresource');
}
}

Expand All @@ -196,15 +199,15 @@

// If we have a physical file we have to bind it to the resource.
if (!empty($filename)) {
$resource = $DB->get_record('resource', array('id' => $resourceid));
$resource = $DB->get_record('resource', ['id' => $resourceid]);
$resource->reference = basename($filename);
$DB->update_record('resource', $resource);
}

$modulename = 'resource';
} else {
if (!$instance->id = $instance->add_instance($instance)) {
print_error('erroraddinstance', 'sharedresource');
throw new moodle_exception('erroraddinstance', 'sharedresource');
}
$modulename = 'sharedresource';
}
Expand All @@ -218,18 +221,18 @@
}

if (!$sectionid = course_add_cm_to_section($courseid, $cm->id, $section)) {
print_error('errorsectionaddition', 'sharedresource');
throw new moodle_exception('errorsectionaddition', 'sharedresource');
}

if (!$DB->set_field('course_modules', 'section', $sectionid, array('id' => $cm->id))) {
print_error('errorcmsectionbinding', 'sharedresource');
if (!$DB->set_field('course_modules', 'section', $sectionid, ['id' => $cm->id])) {
throw new moodle_exception('errorcmsectionbinding', 'sharedresource');
}

// If we are in page format, add page_item to section bound page.
if ($course->format == 'page') {
require_once($CFG->dirroot.'/course/format/page/classes/page.class.php');
require_once($CFG->dirroot.'/course/format/page/lib.php');
$coursepage = \format\page\course_page::get_current_page($course->id);
$coursepage = \format_page\course_page::get_current_page($course->id);
$coursepage->add_cm_to_page($cm->id);
}

Expand All @@ -240,13 +243,13 @@
$PAGE->set_cacheable(true);
$PAGE->set_button('');
$PAGE->set_pagelayout('standard');
$PAGE->navbar->add($course->shortname, new moodle_url('/course/view.php', array('id' => $course->id)));
$PAGE->navbar->add($course->shortname, new moodle_url('/course/view.php', ['id' => $course->id]));
$PAGE->navbar->add(get_string('addremote', 'sharedresource'));

echo $OUTPUT->header();

echo $OUTPUT->heading(get_string('addremote', 'sharedresource').' : '.get_string('pluginname', $modulename));

echo $OUTPUT->continue_button(new moodle_url('/course/view.php', array('id' => $courseid)));
echo $OUTPUT->continue_button(new moodle_url('/course/view.php', ['id' => $courseid]));
echo $OUTPUT->footer($course);
die;
Loading

0 comments on commit 0b77989

Please sign in to comment.