Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
LabNbook
LabNbook-Moodle
Commits
c8097088
Commit
c8097088
authored
Nov 05, 2019
by
Francois Gannaz
Browse files
instance view for students and teachers
parent
9328ed06
Changes
3
Hide whitespace changes
Inline
Side-by-side
templates/view_student.mustache
View file @
c8097088
...
...
@@ -3,6 +3,6 @@
<div>
{{{
description
}}}
</div>
<p>
<a
href=
"
{{
url
}}
"
class=
"btn btn-primary"
>
Modifier le rapport L
ab
N
book
</a>
<a
href=
"
{{
redirecturl
}}
"
>
{{#
str
}}
gotoreport, mod_l
ab
n
book
{{/
str
}}
</a>
</p>
</section>
templates/view_teacher.mustache
View file @
c8097088
<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>
view.php
View file @
c8097088
...
...
@@ -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
();
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment