Commit 5b7c2f3a authored by Francois Gannaz's avatar Francois Gannaz
Browse files

view: partially realized

parent 91ef6945
...@@ -103,6 +103,12 @@ class mod_labnbook_session ...@@ -103,6 +103,12 @@ class mod_labnbook_session
return $DB->get_field("labnbook", "labnbook_missionid", ['id' => $instanceId]); return $DB->get_field("labnbook", "labnbook_missionid", ['id' => $instanceId]);
} }
public function getReportId($missionId)
{
$userId = $this->getUserId();
return $this->fetch('GET', "/report", null, ['userid' => $userId, 'missionid' => $missionId]);
}
/** /**
* Return an URL that will authenticate the user in LabNbook * Return an URL that will authenticate the user in LabNbook
* *
......
<section>
<h2>{{title}}</h2>
<div>{{{description}}}</div>
<p>
<a href="{{url}}" class="btn btn-primary">Modifier le rapport LabNbook</a>
</p>
</section>
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
use \mod_labnbook_session as session;
require(__DIR__.'/../../config.php'); require(__DIR__.'/../../config.php');
require_once(__DIR__.'/lib.php'); require_once(__DIR__.'/lib.php');
...@@ -64,4 +66,19 @@ $PAGE->set_context($modulecontext); ...@@ -64,4 +66,19 @@ $PAGE->set_context($modulecontext);
echo $OUTPUT->header(); echo $OUTPUT->header();
$lnb = session::load();
if (has_capability('moodle/course:manageactivities', context_course::instance($course->id))) {
// editing teacher view
// ...
} else {
// student view
$reportId = $lnb->getReportId($moduleinstance->labnbook_missionid);
$data = [
'title' => $moduleinstance->name,
'description' => format_text($moduleinstance->intro, $moduleinstance->introformat, ['context' => $modulecontext]),
'url' => $lnb->createAuthenticatedUrl('/page/report.php?idr=' . $reportId),
];
$OUTPUT->render_from_template('mod_labnbook/view_student', $data);
}
echo $OUTPUT->footer(); echo $OUTPUT->footer();
Supports Markdown
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