Commit c57bb565 authored by Myriam Delaruelle's avatar Myriam Delaruelle
Browse files

Test content->text if not existing

parent 4ce1a2f5
......@@ -52,7 +52,6 @@ class block_mahara_iena extends block_base
require_once ('entity/block_mahara_iena_connexion.php');
$connexion = new block_mahara_iena_connexion($CFG->wstoken,$CFG->base_mahara);
$is_mahara_user = $connexion->ensure_user_exists_in_mahara($USER);
$result = $DB->get_records_sql('SELECT * FROM {block_mahara_iena} WHERE course = ?', array($COURSE->id));
// var_dump($result);
......@@ -77,9 +76,17 @@ class block_mahara_iena extends block_base
}
} 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>';
if(!isset($this->content->text)){
// 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>";
}
else{
// 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>";
}
}
}
......
......@@ -107,7 +107,6 @@ if (count($students) == 0) {
$resultPost = $connexion->httpPost($params, $murl);
// '@' is use because json_decode some time cause fatal error
$data = @json_decode($resultPost);
// var_dump($data);
$result = $DB->get_records_sql('SELECT * FROM {block_mahara_iena} WHERE course = ?', array($COURSE->id));
// IF json_decode fail we stop all
if ($data == null){
......
......@@ -58,7 +58,6 @@ if ( isset($_GET['connect_mahara']) && $_GET['connect_mahara'] == true ) {
redirect($url);
}
}
}
// if ($_GET['mahara_group']){
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment