This Moodle plugin create group(s) in Mahara, based on Moodle course users. You can either create one Mahara group per Moodle course user groups.
## Authors
- Vrignaud Camille *(cvrignaud@softia.fr)*
- Lebeau Michaël *(mlebeau@softia.fr)*
- Thomas Fradet *(thomas.fradet@univ-lorraine.fr)*
## Compatibility and support
The plugin was tested in Moodle 3.3, 3.4 and 3.5.
For more information contact : support_git@softia.fr or iena-contact@univ-lorraine.fr.
## Installation
The plugin installs with the classical way but require a specific configuration to link moodle and mahara.
Installation :
- Trough the Moodle Administration section "Plugin" -> Add plugin
- Add block in edit mode
Configuration :
???
## Functionalities
By clicking a button in this block, editing teachers can create one mahara group within every student enrolled in the moodle course will become members of the mahara group. Moodle course enrolled users with the role of "teacher" and "editingteacher" will have the role of "admin" in the mahara group, other will be simple members.
After group creation, every user enrolled in this moodle cours will be able to see and click a button witch grand access to the mahara group previously created.
Alternatively, if they are user groups within the moodle cours, teacher can choose to create one mahara group per moodle course group. In this case, students and teachers will be enroll in the mahara group witch correspond to they moodle group. Warning : if one user is in two groups in moodle course, only the first will be considerated by this plugin to grand access to mahara group.
Usecase : place 3 groups with 1 teacher and n students in a moodle course and create in one click 3 mahara groups where each teacher will be able to administrate his mahara group and each student will be able to access the right group in mahara, based on the moodle group.
## Warning
This plugin is currently under development.
This plugin does not support groupments (moodle group of group) in addition to the creation of a mahara group for each moodle group. If you have groupments in moodle, choose to create on mahara group for all the moodle course participants or place the groupes in groupment 0.
In the case of generating one mahara group for each moodle group, if one user is in two groups in moodle course, only the first will be considerated by this plugin to grand access to mahara group.
.$COURSE->id.'" class="btn btn-block btn-primary iena-btn-big">'.get_string('create_group','block_mahara_iena',$CFG->mahara_alias).'</a><p class="text-muted">Créer un groupe dans '.$CFG->mahara_alias.'.</p>';
$groups=groups_get_all_groups($COURSE->id);
if($groups==null){
$this->content->text.='<button type="button" class="btn btn-block btn-primary iena-btn-big" disabled >'.get_string('create_groups_groups','block_mahara_iena',$CFG->mahara_alias).'</button><p class="text-muted text-warning">Créer un groupe dans '.$CFG->mahara_alias.' pour chaque groupe du cours. <strong>Les groupes doivent exister dans le cours.</strong></p>';
.$COURSE->id.'" class="btn btn-block btn-primary iena-btn-big">'.get_string('create_groups_groups','block_mahara_iena',$CFG->mahara_alias).'</a><p class="text-muted">Créer un groupe dans '.$CFG->mahara_alias.' pour chaque groupe du cours. Les groupes doivent exister dans le cours et ne pas tous être vides.</p>';
}
}elseif(count($result)==0&&!$is_mahara_user){
// connect and create account in mahara for teacher before he can create groupes
$this->content->text.='<a target="_blank" href="'.$CFG->wwwroot.'/blocks/mahara_iena/mahara_iena_link.php?courseid='.$COURSE->id.'&connect_mahara=true" class="btn btn-block btn-success iena-btn-big">Connexion à '.$CFG->base_mahara.'</a><p class="text-muted">Vous devez vous connecter à '.$CFG->base_mahara.' pour y initialiser votre compte avant d\'utiliser ce block.</p>';
// $this->content->text .= "<div class=\"alert alert-warning\">Vous devez avoir un compte sur <a href=\"$CFG->base_mahara\" target=\"_blank\">$CFG->base_mahara</a> avant de pouvoir créer des groupes sur cette plateforme.</div>";
}
}
// for teachers and students
if(count($result)==0){
$this->content->text.='<button type="button" class="btn btn-block btn-primary iena-btn-big" disabled >'.get_string('acces_group','block_mahara_iena',$CFG->mahara_alias).'</button><p class="text-muted">Aucun groupe '.$CFG->mahara_alias.' n\'a encore été créé par l\'enseignant.</p>';
}
elseif($is_mahara_user){
// check if they are one mahara group per moodle group of juste one group and set link
// user will be placed or will access the first group he has (no multiple group access)
// if moodle group is not 0, their is multiple mahara groupes ($has_groups)
// if ($has_groups) {
// $result_for_group = $DB->get_records_sql('SELECT * FROM {block_mahara_iena} WHERE course = ? AND moodle_group_id = ?', array($COURSE->id, $user_groups[0][0]));
// }
// if their is one mahara group per moodle group and student have no group, display decline message
if($has_groups&&count($user_groups[0])==0){
$this->content->text.='<button type="button" class="btn btn-block btn-primary iena-btn-big" disabled >Accéder au groupe sur '.$CFG->mahara_alias."</button><p class=\"text-muted\">Vous n'avez pas accès à un groupe sur <a href=\"$CFG->base_mahara\" target=\"_blank\">$CFG->base_mahara</a> car vous n'avez été placé dans aucun groupe de ce cours.</p>";
/* afficher la liste des groupes s'il y en a (on est déjà dans une condition où il y en a toujours en théorie) */
if(count($ma_links)!=0){
if(count($ma_links)==1){
/* si il n'y a qu'un groupe, on affiche un bouton */
$this->content->text.="<a target='_blank' class='btn btn-block btn-primary iena-btn-big' href='$CFG->wwwroot/blocks/mahara_iena/mahara_iena_link.php?courseid=$COURSE->id&mahara_group=".$ma_links[0]['ma_group_id']."&moodle_group=".$ma_links[0]['mo_gr_id']."'>Aller à mon groupe sur ".$CFG->mahara_alias."</a><p class='alert alert-secondary'>Mon groupe : ".$ma_links[0]['mo_gr_name'].".</p>";
}elseif(count($ma_links)>1&&count($ma_links)<=5){
/* si il y a entre 2 et 5 groupes inclus, on affiche une liste */
$this->content->text.="<p style='border-left: 2px solid #1177d1;padding-left: 0.5rem;font-weight: 600;margin-bottom: 0.5rem;'>Accéder à mon groupe sur $CFG->mahara_alias : </p>
/* si il y a plus de 5 groupes, on affiche une liste pour 3 d'entre-eux puis un lien pour déplier le reste de la liste en JS */
$this->content->text.="<p style='border-left: 2px solid #1177d1;padding-left: 0.5rem;font-weight: 600;margin-bottom: 0.5rem;'>Accéder à mon groupe sur $CFG->mahara_alias : </p>
$this->content->text.="<a href='#' style='margin-bottom: 1rem;display: inline-block;' onclick='iena_ma_group(event)'>Voir toute la liste</a><script type='text/javascript'>function iena_ma_group(e){e.preventDefault();var lis=document.querySelectorAll('.iena-ma_group');for(var i=0;i<lis.length;i++){if(lis[i].getAttribute('class')=='d-none iena-ma_group'){lis[i].setAttribute('class', 'd-inherit iena-ma_group')}else{lis[i].setAttribute('class', 'd-none iena-ma_group')}}}</script>";
}
}
}else{
/* quand un seul groupe mahara pour tout le cours ($hasgroup à false) */
$this->content->text.="<a target='_blank' class='btn btn-block btn-primary iena-btn-big' href='$CFG->wwwroot/blocks/mahara_iena/mahara_iena_link.php?courseid=$COURSE->id&mahara_group=".reset($result)->mahara_group_id."&moodle_group=nogroups'>Aller au groupe sur ".$CFG->mahara_alias."</a>";
}
/* permet à l'enseignant de créer tous les groupes mahara en fonction des groupes moodle existant à un temps t. Ca n'inscrit pas les utilisateurs à part lui. */
$this->content->text.='<a href="'.$CFG->wwwroot.'/blocks/mahara_iena/mahara_iena_groups_all.php?courseid='.$COURSE->id.'&create_all_groups=1" class="btn btn-block btn-warning iena-btn-big">Créer tous les groupes</a><p class="text-muted">Créer manuellement tous les groupes sur '.$CFG->mahara_alias.' liés à ce cours et s\'y inscrire en tant qu\'enseignant.</p>';
// $this->content->text .= '<a href="'.$CFG->wwwroot . '/blocks/mahara_iena/mahara_iena_groups_all.php?courseid=' . $COURSE->id . '" class="btn btn-block btn-warning iena-btn-big">S\'inscrire dans tous les groupes</a><p class="text-muted">S\'inscrire en tant qu\'enseignant dans tous les groupes '.$CFG->mahara_alias.' liés à ce cours.</p>';
/* POUR PLUS TARD : liste les groupes moodle liés à mahara qui n'existent plus dans moodle */
/* si n'est pas membre de mahara (car sinon quand on essaie d'inscrire dans un groupe par l'api un user qui n'existe pas ça bug). Si le groupe existe déjà, l'utilisateur y est inscrit. */
$this->content->text.='<a onclick="ma_register_click()" target="_blank" href="'.$CFG->wwwroot.'/blocks/mahara_iena/mahara_iena_link.php?courseid='.$COURSE->id.'&connect_mahara=true" class="btn btn-block btn-success iena-btn-big">Créer son compte sur '.$CFG->mahara_alias.'</a><p class="alert alert-warning mt-2">Pour accéder au groupe '.$CFG->mahara_alias.' lié à ce cours, vous devez d\'abord vous inscrire sur '.$CFG->mahara_alias.' en cliquant sur le bouton ci-dessus, puis revenir sur cette page.</p>';
/* recharge la page quand on y revient après avoir cliqué sur le bouton pour aller sur mahara se créer un compte */
* Fonction duplique un bout de ensure_user_is_mahara_group_member et est utilisée pour créer des groupes mahara à partir de groupes moodle par le fichier mahara_iena_groups_all avec le get create_all_groups pour créer des groupes mahara pour chaque groupe moodle existant. Cette fonction n'est disponible que pour l'enseignant.
* @param $mo_group : le groupe moodle à créer dans mahara avec au moins les clefs id et le name
* @param $mo_user : l'utilisateur à inscrire dans le groupe (il en faut forcément un), dans ce cas, l'enseignant qui a demandé la création de tous les groupes.