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 c8097088 authored by Francois Gannaz's avatar Francois Gannaz
Browse files

instance view for students and teachers

parent 9328ed06
......@@ -3,6 +3,6 @@
<div>{{{description}}}</div>
<p>
<a href="{{url}}" class="btn btn-primary">Modifier le rapport LabNbook</a>
<a href="{{redirecturl}}">{{#str}}gotoreport, mod_labnbook{{/str}}</a>
</p>
</section>
<section>
<h2>{{title}}</h2>
<div>{{description}}</div>
<ul>
<li>
<a href="{{redirecturl}}?token={{token_teaming}}">{{#str}}external_teaming, mod_labnbook{{/str}}</a>
<p>
{{#str}}external_teaming_descr, mod_labnbook{{/str}}
</p>
</li>
<li>
<a href="{{redirecturl}}?token={{token_reports}}">{{#str}}external_reports, mod_labnbook{{/str}}</a>
<p>
{{#str}}external_reports_descr, mod_labnbook{{/str}}
</p>
</li>
</ul>
</section>
......@@ -10,8 +10,7 @@
/* @var $DB moodle_database */
use \mod_labnbook\session\labnbook as labnbookSession;
use mod_labnbook\ar\teamconfig;
use mod_labnbook\fetch\user as fetchUser;
require(__DIR__.'/../../config.php');
require_once(__DIR__.'/lib.php');
......@@ -26,17 +25,22 @@ if ($id) {
$cm = get_coursemodule_from_id("labnbook", $id, 0, false, MUST_EXIST);
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
$moduleinstance = $DB->get_record(LABNBOOK_TABLE, array('id' => $cm->instance), '*', MUST_EXIST);
unset($id);
} else if ($l) {
$moduleinstance = $DB->get_record(LABNBOOK_TABLE, array('id' => $l), '*', MUST_EXIST);
$course = $DB->get_record('course', array('id' => $moduleinstance->course), '*', MUST_EXIST);
$cm = get_coursemodule_from_instance("labnbook", $moduleinstance->id, $course->id, false, MUST_EXIST);
unset($l);
} else {
print_error(get_string('missingidandcmid', mod_labnbook));
}
/* @var \mod_labnbook\ar\labnbook $moduleinstance */
require_login($course, true, $cm);
\mod_labnbook\local\helper::requireLabnbookAuthentication();
$modulecontext = context_module::instance($cm->id);
$coursecontext = context_course::instance($course->id);
/*
$event = \mod_labnbook\event\course_module_viewed::create(array(
......@@ -49,50 +53,32 @@ $event->trigger();
*/
/* @var $PAGE moodle_page */
$PAGE->set_url('/mod/labnbook/view.php', array('id' => $cm->id));
$PAGE->set_url('/mod/labnbook/view.php', ['id' => $cm->id]);
$PAGE->set_title(format_string($moduleinstance->name));
$PAGE->set_heading(format_string($course->fullname));
$PAGE->set_context($modulecontext);
$lnb = labnbookSession::load();
if (has_capability('moodle/course:manageactivities', context_course::instance($course->id))) {
$fetcher = new fetchUser();
$templateData = [
'title' => $moduleinstance->name,
'description' => format_text($moduleinstance->intro, $moduleinstance->introformat, ['context' => $modulecontext]),
'redirecturl' => $fetcher->getRedirectUrl(),
];
$isTeacher = has_capability('moodle/course:manageactivities', $coursecontext)
|| has_capability('mod/labnbook:addinstance', $coursecontext);
if ($isTeacher) {
// editing teacher view
// ...
$content = "TODO: teacher view";
$templateName = 'view_teacher';
$templateData['token_teaming'] = $fetcher->getTeamingTokenForRedirect();
$templateData['token_reports'] = $fetcher->getReportsTokenForRedirect();
} else {
// student view
$reportId = $lnb->getReportId($cm->id);
if (empty($reportId)) {
$groupids = groups_get_user_groups($cm->course)[0];
$teamconfig = teamconfig::findForGroups($cm->id, $groupids);
if ($teamconfig->method === teamconfig::METHOD_STUDENTCHOICE) {
redirect('/mod/labnbook/team/studentchoice.php?id=' . (int) $cm->id);
return;
} else if ($teamconfig->method === teamconfig::METHOD_TEACHERCHOICE) {
// TODO: warn the teacher that this student lacks a team
// TODO: warn the student that the teacher will have to put him in a team
$content = "TODO: no team, manual team creation";
} else if ($teamconfig->method === teamconfig::METHOD_RANDOM) {
// TODO:
// If $teamconfig.teamsmax is not reached and at least teamconfig.sizemin students are teamless, create a new team.
// Else add the user to one of the smallest teams.
// In both cases, create a LnB report matching the Moodle team.
// Then display this report
$content = "TODO: no team, random team creation";
} else {
throw new \Exception("Unknown teaming method.");
}
}
if ($reportId) {
$data = [
'title' => $moduleinstance->name,
'description' => format_text($moduleinstance->intro, $moduleinstance->introformat, ['context' => $modulecontext]),
'url' => new moodle_url('/mod/labnbook/redirect.php', ['reportId' => $reportId]),
];
$content = $OUTPUT->render_from_template('mod_labnbook/view_student', $data);
}
$templateName = 'view_student';
// TODO add user to the LnB class(es):
// 1. for this activity, or all activities of the course?
// 2. sync server to server, or async client to server (XHR), or on connection (when landing on report page)?
}
echo $OUTPUT->header();
echo $content;
echo $OUTPUT->render_from_template("mod_labnbook/$templateName", $templateData);
echo $OUTPUT->footer();
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