Browse Source

Adicionando arquivos da versão antiga

main
Victor Cabral 3 years ago
committed by GitHub
commit
31c6fbc080
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 0
      CHANGES.MD
  2. 29
      README.txt
  3. 134
      classes/event/mass_enrolment_created.php
  4. 134
      classes/event/mass_unenrolment_created.php
  5. 55
      db/access.php
  6. 202
      lang/de/local_mass_enroll.php
  7. 276
      lang/en/local_mass_enroll.php
  8. 276
      lang/en_us/local_mass_enroll.php
  9. 256
      lang/fr/local_mass_enroll.php
  10. 391
      lib.php
  11. 56
      mass_enroll.php
  12. 117
      mass_enroll_form.php
  13. 53
      mass_unenroll.php
  14. 103
      mass_unenroll_form.php
  15. BIN
      pix/icon.gif
  16. 210
      renderer.php
  17. 58
      settings.php
  18. 35
      version.php

0
CHANGES.MD

29
README.txt

@ -0,0 +1,29 @@
moodle_local_mass_enroll
========================
A Moodle 2.x tool for all teachers to enrol/unenrol existing users to their courses using CSV files (without bothering their admins)
Main features are :
* users can be specified by username, id number or email
* users can be optionally enroled to groups/groupings (autocreated if needed)
* email reports can be send
* import can be repeated if some users are to be in several groups
* usage can be restricted by modifying specific capabilities (local/mass_enroll:enrol and local:/mass_enroll:unenrol)
* can be inserted in Course's admin menu
This plugin has been tested from Moodle 2.7 onwards and is a continuation of
Patrick Pollet's initial work.
See the wiki page https://github.com/rogiervandongen/moodle-local_mass_enroll/wiki for installation and usage.
IMPORTANT MESSAGE:
Out of respect for Patrick and his family, and out of common courtesy, I have
removed Patrick Pollet's personal contact information from the source code, since
Patrick passed away on the 26th of January, 2015.
The initial copyright has been left intact, and was added to all source files
where it wasn't present.
I, and many Moodle users with me, have been greatful for his work on this plugin
and I'm happy to continue his excellent work where Patrick unfortunately couldn't.
Patrick's original work should still be available on github:
https://github.com/patrickpollet/moodle_local_mass_enroll

134
classes/event/mass_enrolment_created.php

@ -0,0 +1,134 @@
<?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/>.
/**
* The mass_enrolment_created event.
*
* File mass_enrolment_created.php
* Encoding UTF-8
*
* @package local_mass_enroll
*
* @copyright 2012 onwards Patrick Pollet
* @copyright 2015 onwards R.J. van Dongen <rogier@sebsoft.nl>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace local_mass_enroll\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mass_enrolment_created event class.
*
* @property-read array $other {
* Extra information about event.
*
* - PUT INFO HERE
* }
*
* @since Moodle 2.7
*
* @package local_mass_enroll
*
* @copyright 2012 onwards Patrick Pollet
* @copyright 2015 onwards R.J. van Dongen <rogier@sebsoft.nl>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
**/
class mass_enrolment_created extends \core\event\base {
/**
* Override in subclass.
*
* Set all required data properties:
* 1/ crud - letter [crud]
* 2/ edulevel - using a constant self::LEVEL_*.
* 3/ objecttable - name of database table if objectid specified
*
* Optionally it can set:
* a/ fixed system context
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'c';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'course';
}
/**
* Returns localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('event:massenrolcreated', 'local_mass_enroll');
}
/**
* Returns non-localised event description with id's for admin use only.
*
* @return string
*/
public function get_description() {
return "The user with id {$this->userid} created a mass enrolment in the course with id {$this->objectid}.";
}
/**
* Returns relevant URL.
*
* @return \moodle_url
*/
public function get_url() {
global $CFG;
return new \moodle_url($CFG->wwwroot . '/local/mass_enroll/mass_enroll.php', array('id' => $this->courseid));
}
/**
* Return legacy logdata.
*
* @return null|array of parameters to be passed to legacy add_to_log() function.
*/
public function get_legacy_logdata() {
// Override if you are migrating an add_to_log() call.
// Path must be relative to 'module name', here 'course'.
// Rev 12/11/2014 : some core function (get_recent_enrolments()) expect the
// info field of log record to be integer when action field is 'enrol'.
// This produced fatal SQL errors with PostGres see https://github.com/patrickpollet/moodle_local_mass_enroll/issues/5
// so we changed action value from 'enrol' to 'massenrol'.
return array($this->courseid, 'course', 'massenroll',
'../local/mass_enroll/mass_enroll.php?id=' . $this->courseid,
$this->other['info']);
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (empty($this->courseid)) {
throw new \coding_exception('The \'courseid\' must be set.');
}
if (!isset($this->other['info'])) {
throw new \coding_exception('The \'info\' field must be set in \'other\'.');
}
}
}

134
classes/event/mass_unenrolment_created.php

@ -0,0 +1,134 @@
<?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/>.
/**
* The mass_unenrolment_created event.
*
* File mass_unenrolment_created.php
* Encoding UTF-8
*
* @package local_mass_enroll
*
* @copyright 2012 onwards Patrick Pollet
* @copyright 2015 onwards R.J. van Dongen <rogier@sebsoft.nl>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace local_mass_enroll\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mass_unenrolment_created event class.
*
* @property-read array $other {
* Extra information about event.
*
* - PUT INFO HERE
* }
*
* @since Moodle 2.7
*
* @package local_mass_enroll
*
* @copyright 2012 onwards Patrick Pollet
* @copyright 2015 onwards R.J. van Dongen <rogier@sebsoft.nl>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
**/
class mass_unenrolment_created extends \core\event\base {
/**
* Override in subclass.
*
* Set all required data properties:
* 1/ crud - letter [crud]
* 2/ edulevel - using a constant self::LEVEL_*.
* 3/ objecttable - name of database table if objectid specified
*
* Optionally it can set:
* a/ fixed system context
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'c';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'course';
}
/**
* Returns localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('event:massunenrolcreated', 'local_mass_enroll');
}
/**
* Returns non-localised event description with id's for admin use only.
*
* @return string
*/
public function get_description() {
return "The user with id {$this->userid} performed a mass unenrolment in the course with id {$this->objectid}.";
}
/**
* Returns relevant URL.
*
* @return \moodle_url
*/
public function get_url() {
global $CFG;
return new \moodle_url($CFG->wwwroot . '/local/mass_enroll/mass_unenroll.php', array('id' => $this->courseid));
}
/**
* Return legacy logdata.
*
* @return null|array of parameters to be passed to legacy add_to_log() function.
*/
public function get_legacy_logdata() {
// Override if you are migrating an add_to_log() call.
// Path must be relative to 'module name', here 'course'.
// Rev 12/11/2014 : some core function (get_recent_enrolments()) expect the
// info field of log record to be integer when action field is 'enrol'.
// This produced fatal SQL errors with PostGres see https://github.com/patrickpollet/moodle_local_mass_enroll/issues/5
// so we changed action value from 'unenrol' to 'massunenrol'.
return array($this->courseid, 'course', 'massunenroll',
'../local/mass_enroll/mass_enroll.php?id=' . $this->courseid,
$this->other['info']);
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (empty($this->courseid)) {
throw new \coding_exception('The \'courseid\' must be set.');
}
if (!isset($this->other['info'])) {
throw new \coding_exception('The \'info\' field must be set in \'other\'.');
}
}
}

55
db/access.php

@ -0,0 +1,55 @@
<?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/>.
/**
* Capability definitions for the mass enrol local plugin.
*
* For naming conventions, see lib/db/access.php.
*
* File mass_enroll.php
* Encoding UTF-8
*
* @package local_mass_enroll
*
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @copyright 2012 onwards Patrick Pollet
* @copyright 2015 onwards R.J. van Dongen <rogier@sebsoft.nl>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$capabilities = array(
'local/mass_enroll:enrol' => array(
'riskbitmask' => RISK_XSS,
'captype' => 'write',
'contextlevel' => CONTEXT_COURSE,
'archetypes' => array(
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW
),
'clonepermissionsfrom' => 'moodle/role:assign'
),
// Not given by default to editingteacher ( life is tough).
'local/mass_enroll:unenrol' => array(
'riskbitmask' => RISK_XSS | RISK_DATALOSS,
'captype' => 'write',
'contextlevel' => CONTEXT_COURSE,
'archetypes' => array(
'manager' => CAP_ALLOW
),
'clonepermissionsfrom' => 'moodle/role:assign'
),
);

202
lang/de/local_mass_enroll.php

@ -0,0 +1,202 @@
<?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/>.
/**
* Language file for local_mass_enroll, DE
*
* German translation courtesy of Björn Fisseler <bjoern.fisseler@fernuni-hagen.de>
*
* File local_mass_enroll.php
* Encoding UTF-8
*
* @package local_mass_enroll
*
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @copyright 2012 onwards Patrick Pollet
* @copyright 2015 onwards R.J. van Dongen <rogier@sebsoft.nl>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['pluginname'] = 'Mass enrolments';
// Capabilities name required Moodle 2.3.
$string['mass_enroll:enrol'] = 'Einschreiben von Nutzer/innen in einen Kurs per CSV-Datei';
$string['mass_enroll:unenrol'] = 'Austragen von Nutzer/innen aus einem Kurs per CSV-Datei';
$string['mass_enroll'] = 'Massen-Einschreibung';
$string['mass_unenroll'] = 'Massen-Austragung';
$string['mass_enroll_info'] = '
<p>Mit dieser Option schreiben Sie eine Liste mit bekannten Nutzer/innen ein. Verwenden Sie dazu eine Datei mit einem Nutzerkonto pro Zeile.</p>
<p><strong>Die erste Zeile,</strong> leere Zeilen oder unbekannte Konten werden &uuml;bersprungen. </p>
<p>Die Datei darf eine oder zwei Spalten enthalten, die durch ein Komma, Semikolon oder Tab voneinander getrennt sind.<br/>
<strong>Die erste Spalte muss eine eindeutige Kontenbezeichnung enthalten: ID-Nummer (voreingestellt), Anmeldename oder Email </strong> des einzutragenden Nutzerkontos.</p>
<p>Die zweite Spalte,<strong>sofern vorhanden,</strong> enth&auml;lt den Gruppennamen der Gruppe, zu der das Nutzerkonto hinzugef&uuml;gt werden soll.</p>
<p>Diese Aktion kann beliebig oft wiederholt werden, wenn beispielsweise der Gruppenname vergessen oder falsch angegeben wurde.</p>
';
$string['mass_unenroll_info'] = '
<p>Mit dieser Option tragen Sie eine Liste mit bekannten Nutzer/innen aus. Verwenden Sie dazu eine Datei mit einem Nutzerkonto pro Zeile.</p>
<p><strong>Die erste Zeile,</strong> leere Zeilen oder unbekannte Konten werden &uuml;bersprungen. </p>
<p>Die Datei darf eine oder zwei Spalten enthalten, die durch ein Komma, Semikolon oder Tab voneinander getrennt sind.
<strong>Die erste Spalte muss eine eindeutige Kontenbezeichnung enthalten: ID-Nummer (voreingestellt), Anmeldename oder Email </strong> des auszutragenden Nutzerkontos.</p>
<p>Andere Spalten, sofern vorhanden, werden ignoriert. Daher kann die zur Einschreibung genutzte CSV-Datei auch f&uuml;r die Austragung verwendet werden.
</p>
';
$string['enroll'] = 'In meinen Kurs einschreiben';
$string['unenroll'] = 'Aus meinem Kurs austragen';
$string['mailreport'] = 'Mail-Report schicken';
$string['creategroups'] = 'Bei Bedarf Gruppe(n) erstellen';
$string['creategroupings'] = 'Bei Bedarf Gruppierung(en) erstellen';
$string['firstcolumn'] = 'Erste Spalte enth&auml;lt';
$string['roleassign'] = 'Zuzuweisende Rolle';
$string['idnumber'] = 'ID-Nummer';
$string['username'] = 'Login';
$string['mail_enrolment_subject'] = 'Massen-Einschreibung in {$a}';
$string['mail_unenrolment_subject'] = 'Massen-Austragung in {$a}';
$string['mail_enrolment'] = '
Guten Tag,
Sie haben gerade folgende Nutzerinnen und Nutzer in Ihren Kurs \'{$a->course}\' eingeschrieben.
Hier ist ein Bericht der Aktionen :
{$a->report}
Mit freundlichen Grüßen.
';
$string['mail_unenrolment'] = '
Guten Tag,
Sie haben gerade folgende Nutzerinnen und Nutzer aus Ihrem Kurs \'{$a->course}\' ausgetragen.
Hier ist ein Bericht der Aktionen :
{$a->report}
Mit freundlichen Grüßen.
';
$string['im:using_role'] = 'Nutzer/in eingeschrieben als: {$a} ';
$string['im:not_in'] = '{$a} NICHT eingeschrieben ';
$string['im:unenrolled_ok'] = '{$a} ausgetragen ';
$string['im:error_out'] = 'Fehler beim austragen von {$a}';
$string['email_sent'] = 'Email geschickt an {$a}';
$string['im:opening_file'] = '&Ouml;ffne Datei: {$a} ';
$string['im:user_unknown'] = '{$a} unbekannt - Überspringe Zeile';
$string['im:already_in'] = '{$a} bereits eingeschrieben ';
$string['im:enrolled_ok'] = '{$a} eingeschrieben ';
$string['im:error_in'] = 'Fehler bei Einschreibung von {$a}';
$string['im:error_addg'] = 'Fehler beim Hinzuf&uuml;gen von Gruppe {$a->groupe} zu Kurs {$a->courseid} ';
$string['im:error_g_unknown'] = 'Fehler - unbekannte Gruppe {$a} ';
$string['im:error_add_grp'] = 'Fehler beim Hinzuf&uuml;gen von Gruppierung {$a->groupe} zu Kurs {$a->courseid}';
$string['im:error_add_g_grp'] = 'Fehler beim Hinzuf&uuml;gen von Gruppe {$a->groupe} zu Gruppierung {$a->groupe}';
$string['im:and_added_g'] = ' und zur Moodle-Gruppe {$a} hinzugef&uuml;gt';
$string['im:error_adding_u_g'] = 'Fehler beim Hinzuf&uuml;gen zu Gruppe {$a}';
$string['im:already_in_g'] = ' bereits in Gruppe {$a}';
$string['im:stats_i'] = '{$a} eingeschrieben';
$string['im:stats_g'] = '{$a->nb} Gruppe(n) erstellt: {$a->what}';
$string['im:stats_grp'] = '{$a->nb} Gruppierungen erstellt: {$a->what}';
$string['im:err_opening_file'] = 'Fehler beim &Ouml;ffnen von Datei {$a}';
$string['im:stats_ui'] = '{$a} ausgetragen';
$string['mass_enroll_help'] = '
<h1>Masseneinschreibung</h1>
<p>Mit dieser Option schreiben Sie eine Liste mit bekannten Nutzerinnen und Nutzern ein. Verwenden Sie dazu eine Datei mit einem Nutzerkonto pro Zeile.</p>
<p><strong>Die erste Zeile,</strong> leere Zeilen oder unbekannte Konten werden &uuml;bersprungen. </p>
<p>Die Datei darf eine oder zwei Spalten enthalten, die durch ein Komma, Semikolon oder Tab voneinander getrennt sind.<br/>
Sie sollten die Datei mit einer Tabellenkalkulation auf Grundlage offizieller Teilnehmendenlisten erstellen und dann bei Bedarf eine Spalte mit den Gruppen hinzuf&uuml;gen, zu denen die Teilnehmenden zugewiesen werden sollen. Speichern Sie die Datei abschlie�end als <abbr title"Comma Separated Value">CSV</abbr>.(*)</p>
<p><strong>Die erste Spalte muss eine eindeutige Kontenbezeichnung enthalten: ID-Nummer (voreingestellt), Anmeldename oder Email </strong> des einzutragenden Nutzerkontos.(**)</p>
<p>Die zweite Spalte,<strong>sofern vorhanden,</strong> enth&auml;lt den Gruppennamen der Gruppe, zu der das Nutzerkonto hinzugef&uuml;gt werden soll.</p>
<p>Wenn die Gruppe nicht existiert, wird sie in dem Kurs erstellt, gemeinsam mit einer Gruppierung mit demselben Namen, zu dem die Gruppe hinzugef&uuml;gt wird.<br/>
Das geschieht deshalb, weil Moodle Aktivit&auml;ten auf Gruppierungen (Gruppen von Gruppen) beschr&auml;nkt werden k&ouml;nnen, nicht aber auf Gruppen. Deshalb wird dieses Vorgehen Ihr Leben leichter machen. Allerdings m&uuml;ssen Gruppierungen vom Admin freigegeben sein.</p>
<p>In der gleichen CSV-Datei k&ouml;nnen verschiedene Gruppen verwendet werden oder auch Nutzerkonten ohne Gruppenzuweisung genutzt werden.</p>
<p>Sie k&ouml;nnen die entsprechenden Optionen auch deaktivieren, wenn Sie sicher sind, dass die Gruppen und Gruppierungen schon vorhanden sind.</p>
<p>�blicherweise werden die Nutzer/innen als Studierende eingeschrieben, aber Sie k&ouml;nnen auch andere Rollen ausw&auml;hlen, wenn Sie die daf&uuml;r erforderlichen Rechte besitzen.</p>
<p>Diese Aktion kann beliebig oft wiederholt werden, wenn beispielsweise der Gruppenname vergessen oder falsch angegeben wurde.</p>
<h2>Beispieldatei</h2>
<p>ID-Nummern und eine Gruppen, die bei Bedarf im Kurs erstellt wird(*)</p>
<pre>
"idnumber";"group"
" 2513110";" 4GEN"
" 2512334";" 4GEN"
" 2314149";" 4GEN"
" 2514854";" 4GEN"
" 2734431";" 4GEN"
" 2514934";" 4GEN"
" 2631955";" 4GEN"
" 2512459";" 4GEN"
" 2510841";" 4GEN"
</pre>
<p>Nur ID-Nummern (**)</p>
<pre>
idnumber
2513110
2512334
2314149
2514854
2734431
2514934
2631955
</pre>
<p>Nur Email-Adressen(**)</p>
<pre>
email
toto@insa-lyon.fr
titi@]insa-lyon.fr
tutu@insa-lyon.fr
</pre>
<p>Kontobezeichnungen und Gruppen, durch Tabulatoren getrennt:</p>
<pre>
username group
ppollet groupe_de_test wird in die Gruppe eingetragen
codet groupe_de_test ebenso
astorck autre_groupe wird in eine andere Gruppe eingetragen
yjayet keine Gruppe f&uuml;r dieses Konto
leere Zeile wird &uuml;bersprungen
unknown unbekanntes Konto wird ignoriert
</pre>
<p><span <font color=\'red\'>(*) </font></span>: doppelte Anf&uuml;hrungszeichen und Leerzeichen werden entfernt.</p>
<p><span <font color=\'red\'>(**) </font></span>: Die Nutzerkonten m&uuml;ssen in Moodle vorhanden sein. Das ist normalerweise der Fall, wenn Moodle mit einem externen Verzeichnis (LDAP, ...) synchronisiert wird.</p>
';
$string['mass_unenroll_help'] = '
<h1>Massen-Austragung</h1>
<p>Mit dieser Option tragen Sie eine Liste mit bekannten Nutzer/innen aus Ihrem Kurs aus. Verwenden Sie dazu eine Datei mit einem Nutzerkonto pro Zeile.</p>
<p><strong>Die erste Zeile,</strong> leere Zeilen oder unbekannte Konten werden &uuml;bersprungen.</p>
<p>Die Datei darf eine oder zwei Spalten enthalten, die durch ein Komma, Semikolon oder Tab voneinander getrennt sind.<br/>
Sie sollten die Datei mit einer Tabellenkalkulation auf Grundlage offizieller Teilnehmendenlisten erstellen und dann bei Bedarf eine Spalte mit den Gruppen hinzuf&uuml;gen, zu denen die Teilnehmenden zugewiesen werden sollen. Speichern Sie die Datei abschlie�end als <abbr title"Comma Separated Value">CSV</abbr>.(*)</p>
<p><strong>Die erste Spalte muss eine eindeutige Kontenbezeichnung enthalten: ID-Nummer (voreingestellt), Anmeldename oder Email </strong> des einzutragenden Nutzerkontos.(**)</p>
<p>Die zweite Spalte,<strong>sofern vorhanden,</strong> wird ignoriert.</p>
<p>Diese Aktion kann beliebig oft wiederholt werden, wenn beispielsweise der Gruppenname vergessen oder falsch angegeben wurde.</p>
<p><span <font color=\'red\'>(*) </font></span>: doppelte Anf&uuml;hrungszeichen und Leerzeichen werden entfernt.</p>
<p><span <font color=\'red\'>(**) </font></span>: Die Nutzerkonten m&uuml;ssen in Moodle vorhanden sein. Das ist normalerweise der Fall, wenn Moodle mit einem externen Verzeichnis (LDAP, ...) synchronisiert wird.</p>
';

276
lang/en/local_mass_enroll.php

@ -0,0 +1,276 @@
<?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/>.
/**
* Language file for local_mass_enroll, EN
*
* File local_mass_enroll.php
* Encoding UTF-8
*
* @package local_mass_enroll
*
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @copyright 2012 onwards Patrick Pollet
* @copyright 2015 onwards R.J. van Dongen <rogier@sebsoft.nl>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['pluginname'] = 'Mass enrolments';
// Capabilities name required Moodle 2.3.
$string['mass_enroll:enrol'] = 'Enrol users to a course by CSV file';
$string['mass_enroll:unenrol'] = 'Unenrol users from a course by CSV file';
$string['mass_enroll'] = 'Bulk enrolments';
$string['mass_unenroll'] = 'Bulk unenrolments';
$string['mass_enroll_info'] = '
<p>
With this option you are going to enrol a list of known users from a file with one account per line
</p>
<p>
<b> The firstline </b> the empty lines or unknown accounts will be skipped. </p>
<p>
The file may contains several columns, separated by a comma, a semi-column or a tabulation.
<br/>
<b>The first one must contains a unique account identifier : idnumber (by default) login or email </b> of the target user. <br/>
The second <b>if present,</b> contains the group name in wich you want that user be be added. <br/>
You may repeat this operation at will without damages, for example if you forgot the group for some users.
</p>
';
$string['mass_unenroll_info'] = '
<p>
With this option you are going to unenrol a list on users from a file with one account per line.
</p>
<p>
<b> The firstline </b> the empty lines or unknown accounts will be skipped. </p>
</p>
<p>
The file may contains several columns, separated by a comma, a semi-column or a tabulation.
<br/>
<b>The first one must contains a unique account identifier : idnumber (by default) login or email </b> of the target user. <br/>
Other columns, if present, will be ignored. Thus the file can be the same as the one user to mass enrol users into this course.<br/>
You may repeat this operation at will without damages, for example if you forgot some users to unenroll.
</p>
';
$string['enroll'] = 'Enrol them to my course';
$string['unenroll'] = 'Unenrol them from my course';
$string['mailreport'] = 'Send me a mail report';
$string['creategroups'] = 'Create group(s) if needed';
$string['creategroupings'] = 'Create grouping(s) if needed';
$string['firstcolumn'] = 'First column contains';
$string['roleassign'] = 'Role to assign';
$string['idnumber'] = 'Id number';
$string['username'] = 'Login';
$string['mail_enrolment_subject'] = 'Bulk enrolments on {$a}';
$string['mail_unenrolment_subject'] = 'Bulk unenrolments on {$a}';
$string['mail_enrolment'] = '
Hello,
You just enroled the following list of users to your course \'{$a->course}\'.
Here is a report of operations :
{$a->report}
Sincerly.
';
$string['mail_unenrolment'] = '
Hello,
You just unenroled the following list of users to your course \'{$a->course}\'.
Here is a report of operations :
{$a->report}
Sincerly.
';
$string['email_sent'] = 'email sent to {$a}';
$string['im:using_role'] = 'Enroling users as : {$a} ';
$string['im:opening_file'] = 'Opening file : {$a} ';
$string['im:user_unknown'] = '{$a} unknown - skipping line';
$string['im:already_in'] = '{$a} already enroled ';
$string['im:enrolled_ok'] = '{$a} enroled ';
$string['im:error_in'] = 'error enroling {$a}';
$string['im:not_in'] = '{$a} NOT enroled ';
$string['im:unenrolled_ok'] = '{$a} unenroled ';
$string['im:error_out'] = 'error unenroling {$a}';
$string['im:error_addg'] = 'error adding group {$a->groupe} to course {$a->courseid} ';
$string['im:error_g_unknown'] = 'error unkown group {$a} ';
$string['im:error_add_grp'] = 'error adding grouping {$a->groupe} to course {$a->courseid}';
$string['im:error_add_g_grp'] = 'error adding group {$a->groupe} to grouping {$a->groupe}';
$string['im:and_added_g'] = ' and added to Moodle\'s group {$a}';
$string['im:error_adding_u_g'] = 'error adding to group {$a}';
$string['im:already_in_g'] = ' already in group {$a}';
$string['im:stats_i'] = '{$a} enroled';
$string['im:stats_ui'] = '{$a} unenroled';
$string['im:stats_g'] = '{$a->nb} group(s) created : {$a->what}';
$string['im:stats_grp'] = '{$a->nb} grouping(s) created : {$a->what}';
$string['im:err_opening_file'] = 'error opening file {$a}';
$string['mass_enroll_help'] = '
<h1>Bulk enrolments</h1>
<p>
With this option you are going to enrol a list of known users from a file with one account per line
</p>
<p>
<b> The firstline </b> the empty lines or unknown accounts will be skipped. </p>
<p>
The file may contains one or two columns, separated by a comma, a semi-column or a tabulation.
You should prepare it from your usual spreadsheet program from official lists of students, for example,
and add if needed a column with groups to which you want these users to be added. Finally export it as CSV. (*)</p>
<p>
<b> The first one must contains a unique account identifier </b>: idnumber (by default) login or email of the target user. (**). </p>
<p>
The second <b>if present,</b> contains the group name in wich you want that user to be added. </p>
<p>
If the group name does not exist, it will be created in your course, together with a grouping of the same name to which the group will be added.
.<br/>
This is due to the fact that in Moodle, activities can be restricted to groupings (group of groups), not groups,
so it will make your life easier. (this requires that groupings are enabled by your site administrator).
<p>
You may have in the same file different target groups or no groups for some accounts
</p>
<p>
You may unselect options to create groups and groupings if you are sure that they already exist in the course.
</p>
<p>
By default the users will be enroled as students but you may select other roles that you are allowed to manage (teacher, non editing teacher
or any custom roles)
</p>
<p>
You may repeat this operation at will without dammages, for example if you forgot or mispelled the target group.
</p>
<h2> Sample files </h2>
Id numbers and a group name to be created in needed in the course (*)
<pre>
"idnumber";"group"
" 2513110";" 4GEN"
" 2512334";" 4GEN"
" 2314149";" 4GEN"
" 2514854";" 4GEN"
" 2734431";" 4GEN"
" 2514934";" 4GEN"
" 2631955";" 4GEN"
" 2512459";" 4GEN"
" 2510841";" 4GEN"
</pre>
only idnumbers (**)
<pre>
idnumber
2513110
2512334
2314149
2514854
2734431
2514934
2631955
</pre>
only emails (**)
<pre>
email
toto@insa-lyon.fr
titi@]insa-lyon.fr
tutu@insa-lyon.fr
</pre>
usernames and groups, separated by a tab :
<pre>
username group
ppollet groupe_de_test will be in that group
codet groupe_de_test also him
astorck autre_groupe will be in another group
yjayet no group for this one
empty line skipped
unknown unknown account skipped
</pre>
<p>
<span <font color=\'red\'>(*) </font></span>: double quotes and spaces, added by some spreadsheet programs will be removed.
</p>
<p>
<span <font color=\'red\'>(**) </font></span>: target account must exist in Moodle ; this is normally the case if Moodle is synchronized with
some external directory (LDAP...)
</p>
';
$string['mass_unenroll_help'] = '
<h1>Bulk unenrolments</h1>
<p>
With this option you are going to unenrol a list of users from a file with one account per line
</p>
<p>
<b> The firstline </b> the empty lines or unknown accounts will be skipped. </p>
<p>
The file may contains several columns, separated by a comma, a semi-column or a tabulation.
You should prepare it from your usual spreadsheet program from an official lists of students, for example,
by exporting the course gradebook to CSV, or use the very same file as the one used to mass enrol users. (*)</p>
<p>
<b> The first one must contains a unique account identifier </b>: idnumber (by default) login or email of the target user. (**). </p>
<p>
All other columns will be ignored. </p>
<p>
By default the users will be enroled as students but you may select other roles that you are allowed to manage (teacher, non editing teacher
or any custom roles)
</p>
<p>
You may repeat this operation at will without dammages, for example if you forgot some users to unenrol.
</p>
<p>
<span <font color=\'red\'>(*) </font></span>: double quotes and spaces, added by some spreadsheet programs will be removed.
</p>
<p>
<span <font color=\'red\'>(**) </font></span>: target account must exist in Moodle and be enrolled to this course.
</p>
';
$string['massenrollsettings'] = 'Mass enrol settings';
$string['localmassenrolldefaults'] = 'Mass enrol default settings';
$string['enablemassenrol'] = 'Allow mass enrolment from course administration';
$string['enablemassenrol_help'] = 'Check this option to allow extension for mass enrolment in the course administration tree';
$string['enablemassunenrol'] = 'Allow mass unenrolment from course administration';
$string['enablemassunenrol_help'] = 'Check this option to allow extension for mass unenrolment in the course administration tree';
$string['localmassenrollextensions'] = 'Menu extension settings';
$string['mailreportdefault'] = 'Send reports default';
$string['mailreportdefault_help'] = 'Configure the default setting for sending reports for the bulk (un)enrolment forms';

276
lang/en_us/local_mass_enroll.php

@ -0,0 +1,276 @@
<?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/>.
/**
* Language file for local_mass_enroll, EN-US
*
* File local_mass_enroll.php
* Encoding UTF-8
*
* @package local_mass_enroll
*
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @copyright 2012 onwards Patrick Pollet
* @copyright 2015 onwards R.J. van Dongen <rogier@sebsoft.nl>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['pluginname'] = 'Mass enrollments';
// Capabilities name required Moodle 2.3.
$string['mass_enroll:enrol'] = 'Enroll users to a course by CSV file';
$string['mass_enroll:unenrol'] = 'Unenroll users from a course by CSV file';
$string['mass_enroll'] = 'Bulk enrollments';
$string['mass_unenroll'] = 'Bulk unenrollments';
$string['mass_enroll_info'] = '
<p>
With this option you are going to enroll a list of known users from a file with one account per line
</p>
<p>
<b> The firstline </b> the empty lines or unknown accounts will be skipped. </p>
<p>
The file may contains several columns, separated by a comma, a semi-column or a tabulation.
<br/>
<b>The first one must contains a unique account identifier : idnumber (by default) login or email </b> of the target user. <br/>
The second <b>if present,</b> contains the group name in wich you want that user be be added. <br/>
You may repeat this operation at will without damages, for example if you forgot the group for some users.
</p>
';
$string['mass_unenroll_info'] = '
<p>
With this option you are going to unenroll a list on users from a file with one account per line.
</p>
<p>
<b> The firstline </b> the empty lines or unknown accounts will be skipped. </p>
</p>
<p>
The file may contains several columns, separated by a comma, a semi-column or a tabulation.
<br/>
<b>The first one must contains a unique account identifier : idnumber (by default) login or email </b> of the target user. <br/>
Other columns, if present, will be ignored. Thus the file can be the same as the one user to mass enroll users into this course.<br/>
You may repeat this operation at will without damages, for example if you forgot some users to unenroll.
</p>
';
$string['enroll'] = 'Enroll them to my course';
$string['unenroll'] = 'Unenroll them from my course';
$string['mailreport'] = 'Send me a mail report';
$string['creategroups'] = 'Create group(s) if needed';
$string['creategroupings'] = 'Create grouping(s) if needed';
$string['firstcolumn'] = 'First column contains';
$string['roleassign'] = 'Role to assign';
$string['idnumber'] = 'Id number';
$string['username'] = 'Login';
$string['mail_enrolment_subject'] = 'Bulk enrollments on {$a}';
$string['mail_unenrolment_subject'] = 'Bulk unenrollments on {$a}';
$string['mail_enrolment'] = '
Hello,
You just enrolled the following list of users to your course \'{$a->course}\'.
Here is a report of operations :
{$a->report}
Sincerly.
';
$string['mail_unenrolment'] = '
Hello,
You just unenrolled the following list of users to your course \'{$a->course}\'.
Here is a report of operations :
{$a->report}
Sincerly.
';
$string['email_sent'] = 'email sent to {$a}';
$string['im:using_role'] = 'Enrolling users as : {$a} ';
$string['im:opening_file'] = 'Opening file : {$a} ';
$string['im:user_unknown'] = '{$a} unknown - skipping line';
$string['im:already_in'] = '{$a} already enrolled ';
$string['im:enrolled_ok'] = '{$a} enrolled ';
$string['im:error_in'] = 'error enrolling {$a}';
$string['im:not_in'] = '{$a} NOT enrolled ';
$string['im:unenrolled_ok'] = '{$a} unenrolled ';
$string['im:error_out'] = 'error unenrolling {$a}';
$string['im:error_addg'] = 'error adding group {$a->groupe} to course {$a->courseid} ';
$string['im:error_g_unknown'] = 'error unkown group {$a} ';
$string['im:error_add_grp'] = 'error adding grouping {$a->groupe} to course {$a->courseid}';
$string['im:error_add_g_grp'] = 'error adding group {$a->groupe} to grouping {$a->groupe}';
$string['im:and_added_g'] = ' and added to Moodle\'s group {$a}';
$string['im:error_adding_u_g'] = 'error adding to group {$a}';
$string['im:already_in_g'] = ' already in group {$a}';
$string['im:stats_i'] = '{$a} enrolled';
$string['im:stats_ui'] = '{$a} unenrolled';
$string['im:stats_g'] = '{$a->nb} group(s) created : {$a->what}';
$string['im:stats_grp'] = '{$a->nb} grouping(s) created : {$a->what}';
$string['im:err_opening_file'] = 'error opening file {$a}';
$string['mass_enroll_help'] = '
<h1>Bulk enrollments</h1>
<p>
With this option you are going to enroll a list of known users from a file with one account per line
</p>
<p>
<b> The firstline </b> the empty lines or unknown accounts will be skipped. </p>
<p>
The file may contains one or two columns, separated by a comma, a semi-column or a tabulation.
You should prepare it from your usual spreadsheet program from official lists of students, for example,
and add if needed a column with groups to which you want these users to be added. Finally export it as CSV. (*)</p>
<p>
<b> The first one must contains a unique account identifier </b>: idnumber (by default) login or email of the target user. (**). </p>
<p>
The second <b>if present,</b> contains the group name in wich you want that user to be added. </p>
<p>
If the group name does not exist, it will be created in your course, together with a grouping of the same name to which the group will be added.
.<br/>
This is due to the fact that in Moodle, activities can be restricted to groupings (group of groups), not groups,
so it will make your life easier. (this requires that groupings are enabled by your site administrator).
<p>
You may have in the same file different target groups or no groups for some accounts
</p>
<p>
You may unselect options to create groups and groupings if you are sure that they already exist in the course.
</p>
<p>
By default the users will be enrolled as students but you may select other roles that you are allowed to manage (teacher, non editing teacher
or any custom roles)
</p>
<p>
You may repeat this operation at will without dammages, for example if you forgot or mispelled the target group.
</p>
<h2> Sample files </h2>
Id numbers and a group name to be created in needed in the course (*)
<pre>
"idnumber";"group"
" 2513110";" 4GEN"
" 2512334";" 4GEN"
" 2314149";" 4GEN"
" 2514854";" 4GEN"
" 2734431";" 4GEN"
" 2514934";" 4GEN"
" 2631955";" 4GEN"
" 2512459";" 4GEN"
" 2510841";" 4GEN"
</pre>
only idnumbers (**)
<pre>
idnumber
2513110
2512334
2314149
2514854
2734431
2514934
2631955
</pre>
only emails (**)
<pre>
email
toto@insa-lyon.fr
titi@]insa-lyon.fr
tutu@insa-lyon.fr
</pre>
usernames and groups, separated by a tab :
<pre>
username group
ppollet groupe_de_test will be in that group
codet groupe_de_test also him
astorck autre_groupe will be in another group
yjayet no group for this one
empty line skipped
unknown unknown account skipped
</pre>
<p>
<span <font color=\'red\'>(*) </font></span>: double quotes and spaces, added by some spreadsheet programs will be removed.
</p>
<p>
<span <font color=\'red\'>(**) </font></span>: target account must exist in Moodle ; this is normally the case if Moodle is synchronized with
some external directory (LDAP...)
</p>
';
$string['mass_unenroll_help'] = '
<h1>Bulk unenrollments</h1>
<p>
With this option you are going to unenroll a list of users from a file with one account per line
</p>
<p>
<b> The firstline </b> the empty lines or unknown accounts will be skipped. </p>
<p>
The file may contains several columns, separated by a comma, a semi-column or a tabulation.
You should prepare it from your usual spreadsheet program from an official lists of students, for example,
by exporting the course gradebook to CSV, or use the very same file as the one used to mass enroll users. (*)</p>
<p>
<b> The first one must contains a unique account identifier </b>: idnumber (by default) login or email of the target user. (**). </p>
<p>
All other columns will be ignored. </p>
<p>
By default the users will be enrolled as students but you may select other roles that you are allowed to manage (teacher, non editing teacher
or any custom roles)
</p>
<p>
You may repeat this operation at will without dammages, for example if you forgot some users to unenrol.
</p>
<p>
<span <font color=\'red\'>(*) </font></span>: double quotes and spaces, added by some spreadsheet programs will be removed.
</p>
<p>
<span <font color=\'red\'>(**) </font></span>: target account must exist in Moodle and be enrolled to this course.
</p>
';
$string['massenrollsettings'] = 'Mass enrol settings';
$string['localmassenrolldefaults'] = 'Mass enrol default settings';
$string['enablemassenrol'] = 'Allow mass enrolment from course administration';
$string['enablemassenrol_help'] = 'Check this option to allow extension for mass enrolment in the course administration tree';
$string['enablemassunenrol'] = 'Allow mass unenrolment from course administration';
$string['enablemassunenrol_help'] = 'Check this option to allow extension for mass unenrolment in the course administration tree';
$string['localmassenrollextensions'] = 'Menu extension settings';
$string['mailreportdefault'] = 'Send reports default';
$string['mailreportdefault_help'] = 'Configure the default setting for sending reports for the bulk (un)enrolment forms';

256
lang/fr/local_mass_enroll.php

@ -0,0 +1,256 @@
<?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/>.
/**
* Language file for local_mass_enroll, EN
*
* File local_mass_enroll.php
* Encoding UTF-8
*
* @package local_mass_enroll
*
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @copyright 2012 onwards Patrick Pollet
* @copyright 2015 onwards R.J. van Dongen <rogier@sebsoft.nl>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['pluginname'] = 'Inscriptions massives';
// Capabilities name required Moodle 2.3.
$string['mass_enroll:enrol'] = 'Inscrire des utilisateurs à un cours par fichier CSV';
$string['mass_enroll:unenrol'] = 'Désinscrire des utilisateurs d\' un cours par fichier CSV';
$string['mass_enroll'] = 'Inscriptions massives';
$string['mass_unenroll'] = 'Désinscriptions massives';
$string['mass_enroll_info'] = '
<p>
Avec cette option vous allez pouvoir inscrire massivement à votre cours une liste d\'utilisateurs existants dans Moodle
contenue dans un fichier que vous avez préparé, un compte par ligne
</p>
<p>
<b>La premiere ligne </b>, les lignes vides, ou celles contenant un identifiant de compte inconnu seront ignorées.
</p>
<p>
Ce fichier peut contenir une ou deux colonnes, séparées alors par une virgule, ou point-virgule ou une tabulation. <br/>
<b>La première doit contenir un identifiant unique : N° étudiant (idnumber Moodle), login ou email </b> de l\'utilisateur concerné. <br/>
La seconde, <b>si elle est présente, </b> indique le groupe (au sens de ce cours Moodle) ou vous voulez inscrire cet utilisateur. <br/>
Vous pouvez répéter l\'opération plusieurs fois sans dommages, par exemple si vous avez oublié le groupe ou inscrire les utilisateurs.
</p>
';
$string['mass_unenroll_info'] = '
<p>
Avec cette option vous allez pouvoir désinscrire massivement de votre cours une liste d\'utilisateurs déja inscrits à ce cours, contenue dans un fichier que vous avez préparé, un compte par ligne
</p>
<p>
<b>La premiere ligne </b>, les lignes vides, ou celles contenant un identifiant de compte inconnu seront ignorées.
</p>
<p>
Ce fichier peut contenir plusieurs colonnes, séparées alors par une virgule, ou point-virgule ou une tabulation. <br/>
<b>La première doit contenir un identifiant unique : N° étudiant (idnumber Moodle), login ou email </b> de l\'utilisateur concerné. <br/>
Les autres colonnes, si présente seront simplement ignorées. Ce fichier peut donc être le même que celui utilisé lors d\'une inscription massive.<br/>
Vous pouvez répéter l\'opération plusieurs fois sans dommages, par exemple si vous avez oublié quelques utilisateurs.
</p>
';
$string['enroll'] = 'Les inscrire à mon cours';
$string['unenroll'] = 'Les désincrire de mon cours';
$string['mailreport'] = 'M\'envoyer un rapport par mail';
$string['creategroups'] = 'Créer le(s) groupe(s) si nécessaire';
$string['creategroupings'] = 'Créer le(s) groupement(s) si nécessaire';
$string['firstcolumn'] = 'La première colonne contient';
$string['roleassign'] = 'Inscrire comme';
$string['idnumber'] = 'Numéro d\'étudiant';
$string['username'] = 'Login';
$string['mail_enrolment_subject'] = 'Inscriptions massives sur {$a}';
$string['mail_unenrolment_subject'] = 'Désinscriptions massives sur {$a}';
$string['mail_enrolment'] = '
Bonjour,
Vous venez d\'inscrire la liste d\'utilisateurs suivants à votre cours \'{$a->course}\'.
Voici un rapport des opérations :
{$a->report}
Cordialement.
';
$string['mail_unenrolment'] = '
Bonjour,
Vous venez de désinscrire la liste d\'utilisateurs suivants de votre cours \'{$a->course}\'.
Voici un rapport des opérations :
{$a->report}
Cordialement.
';
$string['email_sent'] = 'email envoyé à {$a}';
$string['im:using_role'] = 'Utilisateurs inscrits comme : {$a} ';
$string['im:user_unknown'] = '{$a} inconnu - ligne ignorée';
$string['im:already_in'] = '{$a} DÉJA inscrit ';
$string['im:enrolled_ok'] = '{$a} inscrit ';
$string['im:error_in'] = 'erreur en inscrivant {$a}';
$string['im:not_in'] = '{$a} PAS inscrit ';
$string['im:unenrolled_ok'] = '{$a} désinscrit ';
$string['im:error_out'] = 'erreur en désinscrivant {$a}';
$string['im:error_addg'] = 'erreur en ajoutant le groupe {$a->groupe} au cours {$a->courseid} ';
$string['im:error_g_unknown'] = 'erreur groupe {$a} inconnu';
$string['im:error_add_grp'] = 'erreur en ajoutant le groupement {$a->groupe} au cours {$a->courseid}';
$string['im:error_add_g_grp'] = 'erreur en ajoutant le groupe {$a->groupe} au groupement {$a->groupe}';
$string['im:and_added_g'] = ' et ajouté au groupe Moodle {$a}';
$string['im:error_adding_u_g'] = 'impossible d\'ajouter au groupe {$a}';
$string['im:already_in_g'] = ' DEJA dans le groupe {$a}';
$string['im:stats_i'] = '{$a} inscrits';
$string['im:stats_ui'] = '{$a} désinscrits';
$string['im:stats_g'] = '{$a->nb} groupe(s) créé(s) : {$a->what}';
$string['im:stats_grp'] = '{$a->nb} groupement(s) créé(s) : {$a->what}';
$string['im:err_opening_file'] = 'ERREUR en ouvrant le fichier {$a}';
$string['mass_enroll_help'] = '
<h1>Inscriptions massives</h1>
<p>
Avec cette option vous allez pouvoir inscrire massivement à votre cours une liste d\'utilisateurs existants dans Moodle
contenue dans un fichier que vous avez préparé, un compte par ligne
</p>
<p>
<b>La premiere ligne </b>, les lignes vides, ou celles contenant un identifiant de compte inconnu seront ignorées.
</p>
<p>
Ce fichier peut contenir <b>plusieurs colonnes</b>, séparées alors par une virgule, ou point-virgule ou une tabulation.
Il peut être préparé à partir de vos listes de Scolarité par une simple remise en forme et un export CSV depuis votre tableur favori (*)</p>
<p>
<b>La première colonne doit contenir un identifiant unique de l\'utilisateur concerné</b>, par défaut son numéro interne (idnumber),
mais vous pouvez choisir aussi une liste d\'adresses email ou de logins (**). </p>
<p>
La seconde, <b>si elle est présente, </b> indique le groupe (au sens de ce cours Moodle) ou vous voulez inscrire cet étudiant. <br/>
Si ce groupe n existe pas déja dans votre cours, il sera automatiquement créé, ainsi que le groupement homonyme correspondant.<br/>
En effet sous Moodle vous pouvez restreindre toute activité à un groupement (un groupe de groupes) mais pas à un groupe.<br/>
Il est tout à fait possible dans un même fichier d\'avoir des groupes différents (ou pas de groupes) dans certaines lignes. <br/>
Vous pouvez décocher ces options de création automatique si le groupe/groupement visé existe déjé ;
</p>
<p>
Par défaut cette liste est censée contenir des étudiants à inscrire, mais vous pouvez aussi spécifier qu\'ils auront
le rôle enseignant ou enseignant non éditeur.
</p>
<p>
Vous pouvez répéter l\'opération plusieurs fois sans dommages, par exemple si vous avez oublié le groupe ou inscrire les étudiants
ou si vous l\'avez mal orthographié.
</p>
<h2> Exemples de fichiers </h2>
des numéros INSA et un groupe a créer si nécessaire dans le cours (*)
<pre>
"numéro INSA";"groupe"
" 2513110";" 4GEN"
" 2512334";" 4GEN"
" 2314149";" 4GEN"
" 2514854";" 4GEN"
" 2734431";" 4GEN"
" 2514934";" 4GEN"
" 2631955";" 4GEN"
" 2512459";" 4GEN"
" 2510841";" 4GEN"
</pre>
juste des numéros INSA (**)
<pre>
numéro INSA
2513110
2512334
2314149
2514854
2734431
2514934
2631955
</pre>
juste des emails (**)
<pre>
email
toto@insa-lyon.fr
titi@]insa-lyon.fr
tutu@insa-lyon.fr
</pre>
des logins et des groupes (separés içi par une tabulation) :
<pre>
login groupe
ppollet groupe_de_test sera dans ce groupe
codet groupe_de_test lui aussi
astorck autre_groupe et lui dans l\'autre groupe
yjayet n\'a pas de groupe proposé
ligne vide ignorée
inconnu existe pas ligne ignorée
</pre>
<p>
<span <font color=\'red\'>(*) </font></span>: les éventuelles apostrophes ou espaces ajoutées lors de l\'export CSV depuis votre tableur favori seront écartés.
</p>
<p>
<span <font color=\'red\'>(**) </font></span>: les comptes visés doivent exister dans Moodle, ce qui est normalement le cas après la synchronisation qui s\'effectue chaque nuit
avec l\'annuaire LDAP de l\'établissement.
</p>
';
$string['mass_unenroll_help'] = '
<h1>Désinscriptions massives</h1>
<p>
Avec cette option vous allez pouvoir désinscrire massivement de votre cours une liste d\'utilisateurs existants dans Moodle
contenue dans un fichier que vous avez préparé, un compte par ligne.
</p>
<p>
<b>La premiere ligne </b>, les lignes vides, ou celles contenant un identifiant de compte inconnu ou non inscrit au cours seront ignorées.
</p>
<p>
Ce fichier peut contenir <b>plusieurs colonnes</b>, séparées alors par une virgule, ou point-virgule ou une tabulation.
Il peut être préparé à partir de vos listes de Scolarité ou par un export du carnet de notes du cours ou en utilisant
le même fichier que celui utilisé lors d\'une inscription massive. (*)</p>
<p>
<b>La première colonne doit contenir un identifiant unique de l\'utilisateur concerné</b>, par défaut son numéro interne (idnumber),
mais vous pouvez choisir aussi une liste d\'adresses email ou de logins (**). </p>
<p>
Toutes les autres colonnes seront ignorées. </p>
<p>
Vous pouvez répéter l\'opération plusieurs fois sans dommages, par exemple si vous avez oublié quelques utilisateurs à désinscrire.
</p>
<p>
<span <font color=\'red\'>(*) </font></span>: les éventuelles apostrophes ou espaces ajoutées lors de l\'export CSV depuis votre tableur favori seront écartés.
</p>
<p>
<span <font color=\'red\'>(**) </font></span>: les comptes visés doivent exister dans Moodle et être inscrits à ce cours.
</p>
';

391
lib.php

@ -0,0 +1,391 @@
<?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/>.
/**
* Code for handling mass enrolment from a cvs file
*
* File lib.php
* Encoding UTF-8
*
* @package local_mass_enroll
*
* @copyright 1999 onwards Martin Dougiamas and others {@link http://moodle.com}
* @copyright 2012 onwards Patrick Pollet
* @copyright 2015 onwards R.J. van Dongen <rogier@sebsoft.nl>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
/**
* Quick fix for Moodle 2.9
*
* @param settings_navigation $navigation
* @param course_context $context
* @return void
*/
function local_mass_enroll_extend_settings_navigation(settings_navigation $navigation, $context) {
local_mass_enroll_extends_settings_navigation($navigation, $context);
}
/**
* Hook to insert a link in settings navigation menu block
*
* @param settings_navigation $navigation
* @param course_context $context
* @return void
*/
function local_mass_enroll_extends_settings_navigation(settings_navigation $navigation, $context) {
global $CFG;
// If not in a course context, then leave.
if ($context == null || $context->contextlevel != CONTEXT_COURSE) {
return;
}
// Front page has a 'frontpagesettings' node, other courses will have 'courseadmin' node.
if (null == ($courseadminnode = $navigation->get('courseadmin'))) {
// Keeps us off the front page.
return;
}
if (null == ($useradminnode = $courseadminnode->get('users'))) {
return;
}
$config = get_config('local_mass_enroll');
if ((bool)$config->enablemassenrol) {
if (has_capability('local/mass_enroll:enrol', $context)) {
$url = new moodle_url($CFG->wwwroot . '/local/mass_enroll/mass_enroll.php', array('id' => $context->instanceid));
$useradminnode->add(get_string('mass_enroll', 'local_mass_enroll'), $url,
navigation_node::TYPE_SETTING, null, 'massenrols', new pix_icon('i/admin', ''));
}
}
if ((bool)$config->enablemassunenrol) {
if (has_capability('local/mass_enroll:unenrol', $context)) {
$url = new moodle_url($CFG->wwwroot . '/local/mass_enroll/mass_unenroll.php', array('id' => $context->instanceid));
$useradminnode->add(get_string('mass_unenroll', 'local_mass_enroll'), $url,
navigation_node::TYPE_SETTING, null, 'massunenrols', new pix_icon('i/admin', ''));
}
}
}
/**
* process the mass enrolment
*
* @param csv_import_reader $cir an import reader created by caller
* @param stdClass $course a course record from table mdl_course
* @param stdClass $context course context instance
* @param stdClass $data data from a moodleform
* @return string log of operations
*/
function mass_enroll($cir, $course, $context, $data) {
global $CFG, $DB;
require_once($CFG->dirroot . '/group/lib.php');
$result = '';
$roleid = $data->roleassign;
$useridfield = $data->firstcolumn;
$enrollablecount = 0;
$createdgroupscount = 0;
$createdgroupingscount = 0;
$createdgroups = '';
$createdgroupings = '';
$role = $DB->get_record('role', array('id' => $roleid));
$result .= get_string('im:using_role', 'local_mass_enroll', $role->name) . "\n";
$plugin = enrol_get_plugin('manual');
// Moodle 2.x enrolment and role assignment are different.
// Assure course has manual enrolment plugin instance we are going to use.
// Only one instance is allowed; see enrol/manual/lib.php get_new_instance().
$instance = $DB->get_record('enrol', array('courseid' => $course->id, 'enrol' => 'manual'));
if (empty($instance)) {
// Only add an enrol instance to the course if non-existent.
$enrolid = $plugin->add_instance($course);
$instance = $DB->get_record('enrol', array('id' => $enrolid));
}
// Init csv import helper.
$cir->init();
while ($fields = $cir->next()) {
$a = new stdClass();
if (empty($fields)) {
continue;
}
// First column = id Moodle (idnumber,username or email).
// Get rid on eventual double quotes unfortunately not done by Moodle CSV importer.
$fields[0] = str_replace('"', '', trim($fields[0]));
if (!$user = $DB->get_record('user', array($useridfield => $fields[0]))) {
$result .= get_string('im:user_unknown', 'local_mass_enroll', $fields[0]) . "\n";
continue;
}
// Already enroled?
// We DO NOT support multiple roles in a course.
if ($ue = $DB->get_record('user_enrolments', array('enrolid' => $instance->id, 'userid' => $user->id))) {
$result .= get_string('im:already_in', 'local_mass_enroll', fullname($user));
} else {
// Take care of timestart/timeend in course settings.
$timestart = time();
// Remove time part from the timestamp and keep only the date part.
$timestart = make_timestamp(date('Y', $timestart), date('m', $timestart), date('d', $timestart), 0, 0, 0);
if ($instance->enrolperiod) {
$timeend = $timestart + $instance->enrolperiod;
} else {
$timeend = 0;
}
// Enrol the user with this plugin instance (unfortunately return void, no more status).
$plugin->enrol_user($instance, $user->id, $roleid, $timestart, $timeend);
$result .= get_string('im:enrolled_ok', 'local_mass_enroll', fullname($user));
$enrollablecount++;
}
$group = str_replace('"', '', trim($fields[1]));
// 2nd column?
if (empty($group)) {
$result .= "\n";
continue; // No group for this one.
}
// Create group if needed.
if (!($gid = mass_enroll_group_exists($group, $course->id))) {
if ($data->creategroups) {
if (!($gid = mass_enroll_add_group($group, $course->id))) {
$a->group = $group;
$a->courseid = $course->id;
$result .= get_string('im:error_addg', 'local_mass_enroll', $a) . "\n";
continue;
}
$createdgroupscount++;
$createdgroups .= " $group";
} else {
$result .= get_string('im:error_g_unknown', 'local_mass_enroll', $group) . "\n";
continue;
}
}
// If groupings are enabled on the site (should be?).
if (!($gpid = mass_enroll_grouping_exists($group, $course->id))) {
if ($data->creategroupings) {
if (!($gpid = mass_enroll_add_grouping($group, $course->id))) {
$a->group = $group;
$a->courseid = $course->id;
$result .= get_string('im:error_add_grp', 'local_mass_enroll', $a) . "\n";
continue;
}
$createdgroupingscount++;
$createdgroupings .= " $group";
}
}
// If grouping existed or has just been created.
if ($gpid && !(mass_enroll_group_in_grouping($gid, $gpid))) {
if (!(mass_enroll_add_group_grouping($gid, $gpid))) {
$a->group = $group;
$result .= get_string('im:error_add_g_grp', 'local_mass_enroll', $a) . "\n";
continue;
}
}
// Finally add to group if needed.
if (!groups_is_member($gid, $user->id)) {
$ok = groups_add_member($gid, $user->id);
if ($ok) {
$result .= get_string('im:and_added_g', 'local_mass_enroll', $group) . "\n";
} else {
$result .= get_string('im:error_adding_u_g', 'local_mass_enroll', $group) . "\n";
}
} else {
$result .= get_string('im:already_in_g', 'local_mass_enroll', $group) . "\n";
}
}
// Recap final.
$result .= get_string('im:stats_i', 'local_mass_enroll', $enrollablecount) . "\n";
$a->nb = $createdgroupscount;
$a->what = $createdgroups;
$result .= get_string('im:stats_g', 'local_mass_enroll', $a) . "\n";
$a->nb = $createdgroupingscount;
$a->what = $createdgroupings;
$result .= get_string('im:stats_grp', 'local_mass_enroll', $a) . "\n";
// Trigger event.
$event = \local_mass_enroll\event\mass_enrolment_created::create(
array(
'objectid' => $course->id,
'courseid' => $course->id,
'context' => \context_course::instance($course->id),
'other' => array('info' => get_string('mass_enroll', 'local_mass_enroll'))
)
);
$event->trigger();
return $result;
}
/**
* process the mass unenrolment
*
* @param csv_import_reader $cir an import reader created by caller
* @param stdClass $course a course record from table mdl_course
* @param stdClass $context course context instance
* @param stdClass $data data from a moodleform
* @return string log of operations
*/
function mass_unenroll($cir, $course, $context, $data) {
global $DB;
$result = '';
$useridfield = $data->firstcolumn;
$unenrollablecount = 0;
$plugin = enrol_get_plugin('manual');
// Moodle 2.x enrolment and role assignment are different.
// Assure course has manual enrolment plugin instance we are going to use.
// Only one instance is allowed; see enrol/manual/lib.php get_new_instance().
$instance = $DB->get_record('enrol', array('courseid' => $course->id, 'enrol' => 'manual'));
if (empty($instance)) {
// Only add an enrol instance to the course if non-existent.
$enrolid = $plugin->add_instance($course);
$instance = $DB->get_record('enrol', array('id' => $enrolid));
}
// Init csv import helper.
$cir->init();
while ($fields = $cir->next()) {
$a = new stdClass();
if (empty($fields)) {
continue;
}
// First column = id Moodle (idnumber,username or email).
// Get rid on eventual double quotes unfortunately not done by Moodle CSV importer.
$fields[0] = str_replace('"', '', trim($fields[0]));
if (!$user = $DB->get_record('user', array($useridfield => $fields[0]))) {
$result .= get_string('im:user_unknown', 'local_mass_enroll', $fields[0]) . "\n";
continue;
}
// Already enroled?
if (!$ue = $DB->get_record('user_enrolments', array('enrolid' => $instance->id, 'userid' => $user->id))) {
// Weird, user not enrolled.
$result .= get_string('im:not_in', 'local_mass_enroll', fullname($user)) . "\n";
} else {
// Enrol the user with this plugin instance (unfortunately return void, no more status).
$plugin->unenrol_user($instance, $user->id);
$result .= get_string('im:unenrolled_ok', 'local_mass_enroll', fullname($user)) . "\n";
$unenrollablecount++;
}
}
// Recap final.
$result .= get_string('im:stats_ui', 'local_mass_enroll', $unenrollablecount) . "\n";
// Trigger event.
$event = \local_mass_enroll\event\mass_unenrolment_created::create(
array(
'objectid' => $course->id,
'courseid' => $course->id,
'context' => context_course::instance($course->id),
'other' => array('info' => get_string('mass_unenroll', 'local_mass_enroll'))
)
);
$event->trigger();
return $result;
}
/**
* Add a group
*
* @param string $newgroupname
* @param int $courseid
* @return int id Moodle id of inserted record
*/
function mass_enroll_add_group($newgroupname, $courseid) {
$newgroup = new stdClass();
$newgroup->name = $newgroupname;
$newgroup->courseid = $courseid;
$newgroup->lang = current_language();
return groups_create_group($newgroup);
}
/**
* Add a grouping
*
* @param string $newgroupingname
* @param int $courseid
* @return int id Moodle id of inserted record
*/
function mass_enroll_add_grouping($newgroupingname, $courseid) {
$newgrouping = new stdClass();
$newgrouping->name = $newgroupingname;
$newgrouping->courseid = $courseid;
return groups_create_grouping($newgrouping);
}
/**
* Check if a group exists
*
* @param string $name group name
* @param int $courseid course
* @return string or false
*/
function mass_enroll_group_exists($name, $courseid) {
return groups_get_group_by_name($courseid, $name);
}
/**
* Check if a grouping exists
*
* @param string $name group name
* @param int $courseid course
* @return string or false
*/
function mass_enroll_grouping_exists($name, $courseid) {
return groups_get_grouping_by_name($courseid, $name);
}
/**
* Get a group in a grouping
*
* @param int $gid group ID
* @param int $gpid grouping ID
* @return mixed a fieldset object containing the first matching record or false
*/
function mass_enroll_group_in_grouping($gid, $gpid) {
global $DB;
$conditions = array('groupingid' => $gpid, 'groupid' => $gid);
return $DB->get_record('groupings_groups', $conditions, '*', IGNORE_MISSING);
}
/**
* Add a grouping
*
* @param int $gid group ID
* @param int $gpid grouping ID
* @return bool|int true or new id
* @throws dml_exception A DML specific exception is thrown for any errors.
*/
function mass_enroll_add_group_grouping($gid, $gpid) {
global $DB;
$new = new stdClass();
$new->groupid = $gid;
$new->groupingid = $gpid;
$new->timeadded = time();
return $DB->insert_record('groupings_groups', $new);
}

56
mass_enroll.php

@ -0,0 +1,56 @@
<?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/>.
/**
* A bulk enrolment plugin allowing teachers to enrol accounts to their courses, optionally adding every user to a group.
*
* Version for Moodle 1.9.x courtesy of Patrick POLLET & Valery FREMAUX France, February 2010
* Version for Moodle 2.x by pp@patrickpollet.net March 2012
*
* File mass_enroll.php
* Encoding UTF-8
*
* @package local_mass_enroll
*
* @copyright 1999 onwards Martin Dougiamas and others {@link http://moodle.com}
* @copyright 2012 onwards Patrick Pollet
* @copyright 2015 onwards R.J. van Dongen <rogier@sebsoft.nl>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require(dirname(dirname(dirname(__FILE__))) . '/config.php');
// Get params.
$id = required_param('id', PARAM_INT);
if (!$course = $DB->get_record('course', array('id' => $id))) {
error("Course is misconfigured");
}
// Security and access check.
require_course_login($course);
$context = context_course::instance($course->id);
require_capability('local/mass_enroll:enrol', $context);
// Start making page.
$strinscriptions = get_string('mass_enroll', 'local_mass_enroll');
$PAGE->set_pagelayout('incourse');
$PAGE->set_url(new moodle_url($CFG->wwwroot . '/local/mass_enroll/mass_enroll.php', array('id' => $id)));
$PAGE->set_title($course->fullname . ': ' . $strinscriptions);
$PAGE->set_heading($course->fullname . ': ' . $strinscriptions);
$renderer = $PAGE->get_renderer('local_mass_enroll');
echo $renderer->page_mass_enrol();
exit;

117
mass_enroll_form.php

@ -0,0 +1,117 @@
<?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/>.
/**
* Bulk enrolment form
*
* File mass_enroll.php
* Encoding UTF-8
*
* @package local_mass_enroll
*
* @copyright 2012 onwards Patrick Pollet
* @copyright 2015 onwards R.J. van Dongen <rogier@sebsoft.nl>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir . '/formslib.php');
/**
* Bulk enrolment form
*
* @package local_mass_enroll
*
* @copyright 2012 onwards Patrick Pollet
* @copyright 2015 onwards R.J. van Dongen <rogier@sebsoft.nl>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class mass_enroll_form extends moodleform {
/**
* Form definition
*/
public function definition() {
global $DB;
$mform = & $this->_form;
$course = $this->_customdata['course'];
$context = $this->_customdata['context'];
$config = get_config('local_mass_enroll');
$mform->addElement('header', 'general', ''); // Fill in the data depending on page params.
// Later using set_data.
$mform->addElement('filepicker', 'attachment', get_string('location', 'enrol_flatfile'));
$mform->addRule('attachment', null, 'required');
$choices = csv_import_reader::get_delimiter_list();
$mform->addElement('select', 'delimiter_name', get_string('csvdelimiter', 'tool_uploaduser'), $choices);
if (array_key_exists('cfg', $choices)) {
$mform->setDefault('delimiter_name', 'cfg');
} else if (get_string('listsep', 'langconfig') == ';') {
$mform->setDefault('delimiter_name', 'semicolon');
} else {
$mform->setDefault('delimiter_name', 'comma');
}
$choices = \core_text::get_encodings();
$mform->addElement('select', 'encoding', get_string('encoding', 'tool_uploaduser'), $choices);
$mform->setDefault('encoding', 'UTF-8');
$roles = get_assignable_roles($context);
$mform->addElement('select', 'roleassign', get_string('roleassign', 'local_mass_enroll'), $roles);
$studentrole = $DB->get_record('role', array('archetype' => 'student'));
$mform->setDefault('roleassign', $studentrole->id);
$ids = array(
'idnumber' => get_string('idnumber', 'local_mass_enroll'),
'username' => get_string('username', 'local_mass_enroll'),
'email' => get_string('email')
);
$mform->addElement('select', 'firstcolumn', get_string('firstcolumn', 'local_mass_enroll'), $ids);
$mform->setDefault('firstcolumn', 'idnumber');
$mform->addElement('selectyesno', 'creategroups', get_string('creategroups', 'local_mass_enroll'));
$mform->setDefault('creategroups', 1);
$mform->addElement('selectyesno', 'creategroupings', get_string('creategroupings', 'local_mass_enroll'));
$mform->setDefault('creategroupings', 1);
$mform->addElement('selectyesno', 'mailreport', get_string('mailreport', 'local_mass_enroll'));
$mform->setDefault('mailreport', (int)$config->mailreportdefault);
// Buttons.
$this->add_action_buttons(true, get_string('enroll', 'local_mass_enroll'));
$mform->addElement('hidden', 'id', $course->id);
$mform->setType('id', PARAM_INT);
}
/**
* Form data validation
*
* @param \stdClass $data
* @param array $files
* @return array
*/
public function validation($data, $files) {
$errors = parent::validation($data, $files);
return $errors;
}
}

53
mass_unenroll.php

@ -0,0 +1,53 @@
<?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/>.
/**
* Mass unenrol
*
* File mass_unenroll.php
* Encoding UTF-8
*
* @package local_mass_enroll
*
* @copyright 1999 onwards Martin Dougiamas and others {@link http://moodle.com}
* @copyright 2012 onwards Patrick Pollet
* @copyright 2015 onwards R.J. van Dongen <rogier@sebsoft.nl>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require(dirname(dirname(dirname(__FILE__))) . '/config.php');
// Get params.
$id = required_param('id', PARAM_INT);
if (!$course = $DB->get_record('course', array('id' => $id))) {
error("Course is misconfigured");
}
// Security and access check.
require_course_login($course);
$context = context_course::instance($course->id);
require_capability('local/mass_enroll:unenrol', $context);
// Start making page.
$strinscriptions = get_string('mass_unenroll', 'local_mass_enroll');
$PAGE->set_pagelayout('incourse');
$PAGE->set_url(new moodle_url($CFG->wwwroot . '/local/mass_enroll/mass_unenroll.php', array('id' => $id)));
$PAGE->set_title($course->fullname . ': ' . $strinscriptions);
$PAGE->set_heading($course->fullname . ': ' . $strinscriptions);
$renderer = $PAGE->get_renderer('local_mass_enroll');
echo $renderer->page_mass_unenrol();
exit;

103
mass_unenroll_form.php

@ -0,0 +1,103 @@
<?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/>.
/**
* Bulk unenrolment form
*
* File mass_enroll.php
* Encoding UTF-8
*
* @package local_mass_enroll
*
* @copyright 2012 onwards Patrick Pollet
* @copyright 2015 onwards R.J. van Dongen <rogier@sebsoft.nl>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir . '/formslib.php');
/**
* Bulk unenrolment form
*
* @package local_mass_enroll
*
* @copyright 2012 onwards Patrick Pollet
* @copyright 2015 onwards R.J. van Dongen <rogier@sebsoft.nl>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class mass_unenroll_form extends moodleform {
/**
* Form definition
*/
public function definition() {
$mform = & $this->_form;
$course = $this->_customdata['course'];
$config = get_config('local_mass_enroll');
$mform->addElement('header', 'general', ''); // Fill in the data depending on page params.
// Later using set_data.
$mform->addElement('filepicker', 'attachment', get_string('location', 'enrol_flatfile'));
$mform->addRule('attachment', null, 'required');
$choices = csv_import_reader::get_delimiter_list();
$mform->addElement('select', 'delimiter_name', get_string('csvdelimiter', 'tool_uploaduser'), $choices);
if (array_key_exists('cfg', $choices)) {
$mform->setDefault('delimiter_name', 'cfg');
} else if (get_string('listsep', 'langconfig') == ';') {
$mform->setDefault('delimiter_name', 'semicolon');
} else {
$mform->setDefault('delimiter_name', 'comma');
}
$choices = \core_text::get_encodings();
$mform->addElement('select', 'encoding', get_string('encoding', 'tool_uploaduser'), $choices);
$mform->setDefault('encoding', 'UTF-8');
$ids = array(
'idnumber' => get_string('idnumber', 'local_mass_enroll'),
'username' => get_string('username', 'local_mass_enroll'),
'email' => get_string('email')
);
$mform->addElement('select', 'firstcolumn', get_string('firstcolumn', 'local_mass_enroll'), $ids);
$mform->setDefault('firstcolumn', 'idnumber');
$mform->addElement('selectyesno', 'mailreport', get_string('mailreport', 'local_mass_enroll'));
$mform->setDefault('mailreport', (int)$config->mailreportdefault);
// Buttons.
$this->add_action_buttons(true, get_string('unenroll', 'local_mass_enroll'));
$mform->addElement('hidden', 'id', $course->id);
$mform->setType('id', PARAM_INT);
}
/**
* Form data validation
*
* @param \stdClass $data
* @param array $files
* @return array
*/
public function validation($data, $files) {
$errors = parent::validation($data, $files);
return $errors;
}
}

BIN
pix/icon.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 B

210
renderer.php

@ -0,0 +1,210 @@
<?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/>.
/**
* Renderer implementation for local_mass_enroll
*
* File renderer.php
* Encoding UTF-8
*
* @package local_mass_enroll
*
* @copyright 2012 onwards Patrick Pollet
* @copyright 2015 onwards R.J. van Dongen <rogier@sebsoft.nl>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
/**
* local_mass_enroll_renderer
*
* @package local_mass_enroll
*
* @copyright Sebsoft.nl
* @author R.J. van Dongen <rogier@sebsoft.nl>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class local_mass_enroll_renderer extends \plugin_renderer_base {
/**
* return content for mass enrolment page.
*/
public function page_mass_enrol() {
global $CFG, $USER;
require_once($CFG->libdir . '/csvlib.class.php');
require_once($CFG->dirroot . '/local/mass_enroll/mass_enroll_form.php');
require_once($CFG->dirroot . '/local/mass_enroll/lib.php');
$course = $this->page->course;
$context = $this->page->context;
$mform = new mass_enroll_form(new moodle_url($CFG->wwwroot . '/local/mass_enroll/mass_enroll.php'), array(
'course' => $course,
'context' => $context
));
$currenttab = 'mass_enroll';
$out = '';
$strinscriptions = get_string('mass_enroll', 'local_mass_enroll');
if ($mform->is_cancelled()) {
redirect(new moodle_url('/course/view.php', array('id' => $course->id)));
} else if ($data = $mform->get_data(false)) {
$content = $mform->get_file_content('attachment');
$iid = csv_import_reader::get_new_iid('uploaduser');
$cir = new csv_import_reader($iid, 'uploaduser');
$readcount = $cir->load_csv_content($content, $data->encoding, $data->delimiter_name);
unset($content);
$returnurl = $this->page->url;
if ($readcount === false) {
print_error('csvloaderror', '', $returnurl);
} else if ($readcount == 0) {
print_error('csvemptyfile', 'error', $returnurl);
}
$result = mass_enroll($cir, $course, $context, $data);
$cir->close();
$cir->cleanup(false); // Only currently uploaded CSV file.
if ($data->mailreport) {
$a = new stdClass();
$a->course = $course->fullname;
$a->report = $result;
email_to_user($USER, $USER, get_string('mail_enrolment_subject', 'local_mass_enroll', $CFG->wwwroot),
get_string('mail_enrolment', 'local_mass_enroll', $a));
$result .= "\n" . get_string('email_sent', 'local_mass_enroll', $USER->email);
}
$out .= $this->header();
$out .= $this->get_tabs($context, $currenttab, array('id' => $course->id));
$out .= $this->heading($strinscriptions);
$out .= $this->box(nl2br($result), 'center');
$out .= $this->continue_button($this->page->url); // Back to this page.
$out .= $this->footer($course);
return $out;
}
$out .= $this->header();
$out .= $this->get_tabs($context, $currenttab, array('id' => $course->id));
$out .= $this->heading_with_help($strinscriptions, 'mass_enroll', 'local_mass_enroll',
'icon', get_string('mass_enroll', 'local_mass_enroll'));
$out .= $this->box(get_string('mass_enroll_info', 'local_mass_enroll'), 'center');
$out .= $mform->render();
$out .= $this->footer($course);
return $out;
}
/**
* return content for mass unenrolment page.
*/
public function page_mass_unenrol() {
global $CFG, $USER;
require_once($CFG->libdir . '/csvlib.class.php');
require_once($CFG->dirroot . '/local/mass_enroll/mass_unenroll_form.php');
require_once($CFG->dirroot . '/local/mass_enroll/lib.php');
$course = $this->page->course;
$context = $this->page->context;
$mform = new mass_unenroll_form(new moodle_url($CFG->wwwroot . '/local/mass_enroll/mass_unenroll.php'), array(
'course' => $course,
'context' => $context
));
$currenttab = 'mass_unenroll';
$out = '';
$strinscriptions = get_string('mass_unenroll', 'local_mass_enroll');
if ($mform->is_cancelled()) {
redirect(new moodle_url('/course/view.php', array('id' => $course->id)));
} else if ($data = $mform->get_data(false)) {
$content = $mform->get_file_content('attachment');
$iid = csv_import_reader::get_new_iid('uploaduser');
$cir = new csv_import_reader($iid, 'uploaduser');
$readcount = $cir->load_csv_content($content, $data->encoding, $data->delimiter_name);
unset($content);
$returnurl = $this->page->url;
if ($readcount === false) {
print_error('csvloaderror', '', $returnurl);
} else if ($readcount == 0) {
print_error('csvemptyfile', 'error', $returnurl);
}
$result = mass_unenroll($cir, $course, $context, $data);
$cir->close();
$cir->cleanup(false); // Only currently uploaded CSV file.
if ($data->mailreport) {
$a = new stdClass();
$a->course = $course->fullname;
$a->report = $result;
email_to_user($USER, $USER, get_string('mail_unenrolment_subject', 'local_mass_enroll', $CFG->wwwroot),
get_string('mail_unenrolment', 'local_mass_enroll', $a));
$result .= "\n" . get_string('email_sent', 'local_mass_enroll', $USER->email);
}
$out .= $this->header();
$out .= $this->get_tabs($context, $currenttab, array('id' => $course->id));
$out .= $this->heading($strinscriptions);
$out .= $this->box(nl2br($result), 'center');
$out .= $this->continue_button($this->page->url); // Back to this page.
$out .= $this->footer($course);
return $out;
}
$out .= $this->header();
$out .= $this->get_tabs($context, $currenttab, array('id' => $course->id));
$out .= $this->heading_with_help($strinscriptions, 'mass_unenroll', 'local_mass_enroll',
'icon', get_string('mass_unenroll', 'local_mass_enroll'));
$out .= $this->box(get_string('mass_unenroll_info', 'local_mass_enroll'), 'center');
$out .= $mform->render();
$out .= $this->footer($course);
return $out;
}
/**
* Get tabs
*
* @param \context $context
* @param string $selected
* @param array $params page parameters
* @return string
*/
protected function get_tabs($context, $selected, $params = array()) {
global $CFG;
$tabs = array();
if (has_capability('local/mass_enroll:enrol', $context)) {
$enrol = new \moodle_url($CFG->wwwroot . '/local/mass_enroll/mass_enroll.php', $params);
$tabs[] = new \tabobject('mass_enroll', $enrol, get_string('mass_enroll', 'local_mass_enroll'));
}
if (has_capability('local/mass_enroll:unenrol', $context)) {
$unenrol = new \moodle_url($CFG->wwwroot . '/local/mass_enroll/mass_unenroll.php', $params);
$tabs[] = new \tabobject('mass_unenroll', $unenrol, get_string('mass_unenroll', 'local_mass_enroll'));
}
return '<div class="groupdisplay">' . $this->tabtree($tabs, $selected) . '</div>';
}
}

58
settings.php

@ -0,0 +1,58 @@
<?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/>.
/**
* Mass enrol admin settings and defaults
*
* File settings.php
* Encoding UTF-8
*
* @package local_mass_enroll
*
* @copyright Sebsoft.nl
* @copyright 2012 onwards Patrick Pollet
* @copyright 2015 onwards R.J. van Dongen <rogier@sebsoft.nl>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die;
if ($hassiteconfig) {
$settings = new admin_settingpage('localsettingmassenroll', new lang_string('massenrollsettings', 'local_mass_enroll'));
$settings->add(new admin_setting_heading('localmassenrolldefaults',
get_string('localmassenrolldefaults', 'local_mass_enroll'),
''));
$yesno = array(0 => get_string('no'), 1 => get_string('yes'));
$settings->add(new admin_setting_configselect('local_mass_enroll/mailreportdefault',
get_string('mailreportdefault', 'local_mass_enroll'),
get_string('mailreportdefault_help', 'local_mass_enroll'), 1, $yesno));
$settings->add(new admin_setting_heading('localmassenrollextensions',
get_string('localmassenrollextensions', 'local_mass_enroll'),
''));
$settings->add(new admin_setting_configcheckbox('local_mass_enroll/enablemassenrol',
get_string('enablemassenrol', 'local_mass_enroll'),
get_string('enablemassenrol_help', 'local_mass_enroll'), 1));
$settings->add(new admin_setting_configcheckbox('local_mass_enroll/enablemassunenrol',
get_string('enablemassunenrol', 'local_mass_enroll'),
get_string('enablemassunenrol_help', 'local_mass_enroll'), 1));
$ADMIN->add('localplugins', $settings);
}

35
version.php

@ -0,0 +1,35 @@
<?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/>.
/**
* Version information
*
* File version.php
* Encoding UTF-8
*
* @package local_mass_enroll
*
* @copyright 1999 onwards Martin Dougiamas and others {@link http://moodle.com}
* @copyright 2012 onwards Patrick Pollet
* @copyright 2015 onwards R.J. van Dongen <rogier@sebsoft.nl>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2015092402; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2014051200; // Moodle 2.7 onwards.
$plugin->component = 'local_mass_enroll'; // Full name of the plugin (used for diagnostics).
$plugin->maturity = MATURITY_STABLE; // Required for registering to Moodle's database of plugins.
$plugin->release = '2.7.0 (Build 2015092402)';// Required for registering to Moodle's database of plugins.
Loading…
Cancel
Save