.$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>';
// create one mahara group for each moodle group (need groups)
$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>';
// Build user array to pass to mahara api for group inscription
// WARNING : not efficient with to much users in mahara databases
// $maharaUsers = $connexion->getMaharaUsers();
// foreach ($maharaUsers->users as $muser) {
// foreach ($students as $student) {
// if ($student->email == $muser->email){
// $role = "member";
// // Each teacher will be mahara group admin
// if (has_capability('moodle/course:update', $context = context_course::instance($COURSE->id), $student->id)) {
// $role = "admin";
// }
// array_push($usersTab,array(
// 'id' => $muser->id,
// 'username' => $muser->username,
// 'role' => $role,
// ));
// break;
// }
// }
// }
// WARNING : don't try to subscribe every course user to the group with >1000 users in mahara. Juste teacher. Minus 1 user is required to create a group.
// if user is not a mahara user, there will be an error : it's not supposed to be because mahara account is checked before to have a button to go in this page but... but.
if(!$mahara_user->error){
array_push($usersTab,array(
'id'=>$mahara_user[0]->id,
'username'=>$mahara_user[0]->username,
'role'=>"admin",
));
}else{
echo"<p style='color: red;'>You must have a Mahara account to do that.</p>";
die;
}
//All params used for mahara_group_create_groups her we can add/change some lines
// if user is not a mahara user, there will be an error : it's not supposed to be because mahara account is checked before to have a button to go in this page but... but.
if(!$mahara_user->error){
array_push($usersTab,array(
'id'=>$mahara_user[0]->id,
'username'=>$mahara_user[0]->username,
'role'=>"admin",
));
}else{
echo"<p style='color: red;'>You must have a Mahara account to do that.</p>";
die;
}
}
...
...
@@ -85,8 +100,7 @@ if (count($students) == 0) {
'request'=>true,
'public'=>false,
'institution'=>$CFG->instution_mahara,
'members'=>
$usersTab
'members'=>$usersTab
));
array_push($name_groups,array(
...
...
@@ -98,7 +112,7 @@ if (count($students) == 0) {
// var_dump($name_groups);
// die;
if(count($mahara_groups)==0){
echo"<div class=\"alert alert-warning\" role=\"alert\"><p><strong>Erreur : tous les groupes du cours sont vides. </strong></p><p>Pour utiliser cette fonctionnalité, il faut au préalable créer des groupes dans le cours et y ajouter des étudiants ou des enseignants.</p></div>";
echo"<div class=\"alert alert-warning\" role=\"alert\"><p><strong>Erreur : tous les groupes du cours sont vides. </strong></p><p>Pour utiliser cette fonctionnalité, il faut au préalable créer des groupes dans le cours et y ajouter des étudiants ou des enseignants. prout</p></div>";