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_forums.txt
Created January 9, 2019 14:38
MOODLE: Not sending forum emails
Aleshores vaig a tasques
Captura de Pantalla 2019-01-09 a les 15.03.15.png
i veig que fa un dia que no s'executa la d'enviament del fòrum (https://hubbik.elearnlab.org/admin/tool/task/scheduledtasks.php)
Aleshroes em connecto per SSH
sudo su
/usr/bin/php /var/www/html/moodle/admin/tool/task/cli/schedule_task.php --execute='\mod_forum\task\cron_task'
Retorna error "Cannot obtain task lock"
@xyulex
xyulex / add_id.php
Created February 28, 2018 13:04
MOODLE: Add column in user list
Añadir columna 'user id' en /admin/user.php
1)
$CFG->showuseridentity = 'id';
ó
2)
$table->head[] = 'Id';
$row[] = $user->id;
@xyulex
xyulex / local_wpsso.php
Last active February 26, 2018 13:32
MOODLE: WP SSO
<?php
/**
* @package local_wpsso
* @copyright 2018 Raúl Martínez <raul@tresipunt.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require('../../config.php');
require_once("$CFG->dirroot/group/lib.php");
@xyulex
xyulex / MOODLE: Obtener origen cadenas
Created February 1, 2018 15:48
MOODLE: Obtener origen cadenas
Marcar check en 'Depurando': mostrar origen de cadenas
Pasarle a una URL ?strings=1 para ver origen
Desactivar en producción
@xyulex
xyulex / wp.sh
Last active February 13, 2018 10:20
WP-CLI WordPress project start
#!/bin/bash
mkdir $1
cd $1
wp core download # DescargaR el último WordPress
wp config create --dbname=$1 --dbuser=root --dbpass=root --locale=es_ES --force # Crear wp-config
wp db create # Crea la base de datos
wp core install --url="http://localhost/$1/" --title="$2" --admin_user="admin_$1" --admin_password="martin82" --admin_email="admin@admin.xxx" # Instalar WordPress
wp scaffold child-theme $1-child --parent_theme=twentyseventeen # Crear child-theme
wp theme activate $1-child # Activa el child-theme
wp plugin uninstall hello # Elimina 'Hello Dolly'
@xyulex
xyulex / saveimagefrommform.php
Created November 27, 2017 11:15
MOODLE: Save image from mform
$name = $mform->get_new_filename('prizeimage');
$mform->save_stored_file('prizeimage',
context_system::instance()->id,
'fpa',
'prizeimage',
$USER->id,
'/',
$name,
true);
@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...)