Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

Commit b092d457 authored by Francois Gannaz's avatar Francois Gannaz
Browse files

Add helper::grantTeacherAccess()

parent ded85e3e
......@@ -9,6 +9,11 @@ namespace mod_labnbook\local;
use mod_labnbook\fetch;
/* @var $DB \moodle_database */
/**
* Misc functions.
*/
class helper
{
/**
......@@ -40,4 +45,30 @@ class helper
throw new \moodle_exception("Unknown error with LabNbook");
}
}
/**
* Grant teacher access to the LnB missions and classes linked to the course.
*
* @param int $courseId
*/
public static function grantTeacherAccess($courseId)
{
global $DB, $SESSION;
if (!empty($SESSION->labnbook->grantTeacherAccess[$courseId])) {
return;
}
if (!fetch\user::isAuthenticated()) {
return;
}
$ids = $DB->get_fieldset_select("labnbook", "labnbook_teamconfigid", "courseid = " . (int) $courseId);
if ($ids) {
$userFetcher = new fetch\user();
$userFetcher->grantMissionsAccess($ids);
}
// use session to avoid repeating this query
if (empty($SESSION->labnbook->grantTeacherAccess)) {
$SESSION->labnbook->grantTeacherAccess = [];
}
$SESSION->labnbook->grantTeacherAccess[$courseId] = true;
}
}
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