Skip to content

Instantly share code, notes, and snippets.

View xyulex's full-sized avatar

Raúl Martínez xyulex

View GitHub Profile
@xyulex
xyulex / MOODLE: Enrol user as a student
Created July 14, 2017 09:52
MOODLE: Enrol user as a student
$plugin_instance = $DB->get_record("enrol", array('courseid' => $courseid, 'enrol'=>'manual'));
$plugin = enrol_get_plugin('manual');
$roleid = $DB->get_field('role', 'id', array('shortname' => 'student'));
$plugin->enrol_user($plugin_instance, $userid, $roleid);
@xyulex
xyulex / MOODLE: Eventos al borrar un curso1
Last active July 4, 2017 09:36
MOODLE: Eventos al borrar un curso
<?php
// local/altamarimport/db/events.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,
@xyulex
xyulex / MOODLE: Descargar fichero externo y grabarlo en el Moodle
Last active June 29, 2017 09:55
MOODLE: Descargar fichero externo y grabarlo en el Moodle
<?php
$record = new StdClass();
$record->course = $courseid;
$record->contextid = $usercontextid;
$record->userid = $USER->id;
$record->component = 'user';
$record->filearea = 'draft';
$record->itemid = $draftitemid;
$record->filename = $scormFilename;
$record->filepath = '/';
@xyulex
xyulex / MOODLE: Criterios completion
Created June 29, 2017 09:52
MOODLE: Completion state
$quizdata->completion = 2;
$quizdata->completionview = 1; // Requerir ver la actividad (para URL, SCORMS...)
$quizdata->completionexpected = 0;
$quizdata->completionusegrade = 1; // Requerir recibir nota (para Quizzes, Assigns...)
@xyulex
xyulex / bc.php
Created May 31, 2017 13:21
MOODLE: CLI delete courses
#!/usr/bin/php
<?php
define('CLI_SCRIPT', true);
require_once('/var/www/html/altamar/config.php');
require_once('/var/www/html/altamar/course/lib.php');
// to delete a specific course id
if (isset($argv[1])) {
@xyulex
xyulex / MOODLE: Restrict Archivos privados
Created May 16, 2017 14:55
MOODLE: Restrict Archivos privados
moodle:/user/manageownfiles
@xyulex
xyulex / TinyMCE: Eliminar botónes de selector de H1,H2....
Created January 20, 2017 08:33
TinyMCE: Eliminar botónes de selector de H1,H2....
<?php
// Do NOT include the opening php tag above
add_filter('tiny_mce_before_init', 'tiny_mce_remove_unused_formats' );
/*
* Modify TinyMCE editor to remove H1.
*/
function tiny_mce_remove_unused_formats($init) {
// Add block format elements you want to show in dropdown
$init['block_formats'] = 'Paragraph=p;Heading 2=h2;Heading 3=h3;Heading 4=h4;Heading 5=h5;Heading 6=h6;Address=address;Pre=pre';
return $init;
@xyulex
xyulex / MOODLE: Retocar plantilla de desgar en XLS, ODT....
Created January 12, 2017 12:02
MOODLE: Retocar plantilla de desgar en XLS, ODT....
Retocar en /lib/templates/dataformat_selector.mustache
@xyulex
xyulex / GIT: No mirar cambios de permisos
Created December 13, 2016 11:34
GIT: No mirar cambios de permisos en ficheros modificados
git config --global core.filemode false
@xyulex
xyulex / WordPress: desactivar actualización plugin
Created October 25, 2016 07:06
WordPress: desactivar actualización plugin
function disable_filter_plugin_updates( $value ) {
unset( $value->response['read-offline/read-offline.php'] );
return $value;
}
add_filter( 'site_transient_update_plugins', 'disable_filter_plugin_updates' );