Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
iena-competency-block
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
iena
iena-competency-block
Commits
7813f941
Commit
7813f941
authored
6 years ago
by
Thomas Fradet
Browse files
Options
Downloads
Patches
Plain Diff
add template graphic and history
parent
72a4bd43
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
course_competency.php
+167
-95
167 additions, 95 deletions
course_competency.php
with
167 additions
and
95 deletions
course_competency.php
+
167
−
95
View file @
7813f941
...
...
@@ -20,6 +20,7 @@ $PAGE->requires->js("/blocks/competency_iena/js/datalist-polyfill.min.js");
$PAGE
->
requires
->
js
(
"/blocks/competency_iena/js/stud-x-cpts.js"
);
$PAGE
->
requires
->
js
(
"/blocks/competency_iena/js/cpt-x-studs.js"
);
/* <<< GESTION DROITS D'ACCÈS >>> */
$context
=
context_course
::
instance
(
$courseid
);
...
...
@@ -42,15 +43,20 @@ if ( $is_teacher === false && $studentid != $USER->id ) {
echo
$OUTPUT
->
header
();
/* REVIEW DATA */
/* <<< REVIEW DATA >>> */
$sql_rev
=
"SELECT * FROM
{
competency_usercomp
}
WHERE userid = ? AND competencyid = ? AND status = ?"
;
$reviews_data
=
$DB
->
get_records_sql
(
$sql_rev
,
[
$studentid
,
$competencyid
,
1
]);
$review_asked
=
count
(
$reviews_data
)
>
0
?
true
:
false
;
/* <<< POST >>> */
/* POST EVALUATION */
if
(
isset
(
$_POST
[
'
competencyid
'
])
)
{
if
(
isset
(
$_POST
[
'
grade
'
])
)
{
$note
=
"Évaluation donnée pour le cours
{
$COURSE
->
fullname
}
par
{
$USER
->
firstname
}
{
$USER
->
lastname
}
. "
.
$_POST
[
'note'
];
\core_competency\api
::
grade_competency_in_course
(
$courseid
,
$studentid
,
$competencyid
,
$_POST
[
'grade'
],
$note
);
if
(
$review_asked
)
{
...
...
@@ -76,7 +82,8 @@ if ( isset($_POST['review']) ) {
}
/* HELPERS */
/* <<< HELPERS >>> */
function
_html
(
$el
,
$str
,
$class
=
""
)
{
$class
=
" class='"
.
$class
.
"'"
;
echo
"<"
.
$el
.
$class
.
">"
.
$str
.
"</"
.
$el
.
">"
;
...
...
@@ -86,12 +93,14 @@ function _modal_builder($id, $title, $body) {
return
"<div class='modal fade' id='
{
$id
}
' tabindex='-1' role='dialog' aria-labelledby='exampleModalScrollableTitle' aria-hidden='true'><div class='modal-dialog modal-dialog-scrollable' role='document'><div class='modal-content'><div class='modal-header'><h5 class='modal-title' id='exampleModalScrollableTitle'>
{
$title
}
</h5><button type='button' class='close' data-dismiss='modal' aria-label='Close'><span aria-hidden='true'>×</span></button></div><div class='modal-body'>
{
$body
}
</div></div></div></div>"
;
}
/* <<< GESTION ERREUR ACCÈS >>> */
if
(
$is_enrolled
===
false
)
{
_html
(
"p"
,
"L'étudiant demandé n'est pas inscrit dans ce cours."
,
"alert alert-warning"
);
}
/* <<< DATA >>> */
/* Student USER object */
...
...
@@ -116,84 +125,47 @@ if ( $u_c_cpt->get('grade') != null ) {
$eval
=
$cpt_scale
[
$u_c_cpt
->
get
(
'grade'
)
-
1
];
}
$proficiency
=
$u_c_cpt
->
get
(
'proficiency'
)
==
1
?
"Oui"
:
"Non"
;
$proficiency_class
=
$u_c_cpt
->
get
(
'proficiency'
)
==
1
?
"success"
:
"secondary"
;
/* All course competencies */
$course_cpts
=
\core_competency\course_competency
::
list_competencies
(
$COURSE
->
id
);
/* <<< PAGE >>> */
/*user_competency_request_review($userid, $competencyid)*/
echo
"<pre>"
;
// var_dump($u_c_cpt->get('proficiency'));
// var_dump($course_cpts);
// var_dump($students);
// var_dump($reviews_data);
// var_dump($review_asked);
// var_dump($proficiency);
// var_dump($u_c_cpt->get('grade'));
// var_dump($eval);
// var_dump($cpt_scale);
// // var_dump($cpt);
// var_dump($cpt->get('competencyframeworkid'));
// var_dump($cpt->get('parentid'));
/* <<< PAGE >>> */
echo
"</pre>"
;
// echo "<pre>";
// var_dump($_POST);
// echo "</pre>";
/* STUDENT NAME */
_html
(
"h2"
,
$student
->
firstname
.
" "
.
$student
->
lastname
);
_html
(
"h2"
,
$student
->
firstname
.
" "
.
$student
->
lastname
,
"h3' style='margin-bottom: 0.3rem;'"
);
/* SWITCH STUDENT FORM */
if
(
$is_teacher
&&
$students
!=
NULL
&&
count
(
$students
)
!=
0
)
{
echo
"<form action='
{
$CFG
->
wwwroot
}
/blocks/competency_iena/course_competency.php' id='change_stud_form' class='form-inline'>"
;
echo
"<form action='
{
$CFG
->
wwwroot
}
/blocks/competency_iena/course_competency.php' id='change_stud_form' class='form-inline
m-b-1
'>"
;
echo
"<input type='text' hidden name='courseid' value='
{
$courseid
}
'>"
;
echo
"<input type='text' hidden name='competencyid' value='
{
$competencyid
}
'>"
;
echo
"<span hidden id='studentid'>
{
$studentid
}
</span>"
;
echo
"<label class='m-y-1 m-r-1' for='studentid_sel' style='color: black;'>Etudiant</label>"
;
echo
"<input type='text' name='studentid' id='studentid_sel' value='' list='student_list' class='form-control
m-r-1
'>"
;
/*
echo "<label class='m-y-1 m-r-1' for='studentid_sel' style='color: black;'>Etudiant</label>";
*/
echo
"<input type='text' name='studentid' id='studentid_sel' value='' list='student_list' class='form-control
' style='font-size: .7rem; line-height: 1;
'>"
;
echo
"<datalist id='student_list' title='Select student'>"
;
foreach
(
$students
as
$stud
)
{
echo
"<option value='
{
$stud
->
firstname
}
{
$stud
->
lastname
}
(
{
$stud
->
id
}
)' data-value='
{
$stud
->
id
}
'>
{
$stud
->
firstname
}
{
$stud
->
lastname
}
(
{
$stud
->
id
}
)</option>"
;
}
echo
"</datalist>"
;
echo
"<div><button class='btn btn-secondary' id='prevStud'>Précédent</button>"
;
echo
"<button class='btn btn-secondary
m-l-1
' id='nextStud'>Suivant</button></div>"
;
echo
"<div><button class='btn btn-secondary' id='prevStud'
style='font-size: .8rem;line-height: 1.09; margin-left: 0.5rem;'
>Précédent</button>"
;
echo
"<button class='btn btn-secondary' id='nextStud'
style='font-size: .8rem;line-height: 1.09; margin-left: 0.5rem;'
>Suivant</button></div>"
;
echo
"</form>"
;
}
/* SWITCH COMPETENCY FORM */
echo
"<form action='
{
$CFG
->
wwwroot
}
/blocks/competency_iena/course_competency.php' id='change_cpt_form' class='form-inline'>"
;
echo
"<input type='text' hidden name='courseid' value='
{
$courseid
}
'>"
;
echo
"<input type='text' hidden name='studentid' value='
{
$studentid
}
'>"
;
echo
"<span hidden id='competencyid'>
{
$competencyid
}
</span>"
;
echo
"<label class='m-r-1' for='competencyid_sel' style=''>Changer de compétence</label>"
;
echo
"<input type='text' name='competencyid' id='competencyid_sel' value='' list='competency_list' class='form-control'>"
;
echo
"<datalist id='competency_list' title='Select competency'>"
;
foreach
(
$course_cpts
as
$course_cpt
)
{
echo
"<option value='
{
$course_cpt
->
get
(
'shortname'
)
}
(
{
$course_cpt
->
get
(
'id'
)
}
)' data-value='
{
$course_cpt
->
get
(
'id'
)
}
'>
{
$course_cpt
->
get
(
'shortname'
)
}
(
{
$course_cpt
->
get
(
'id'
)
}
)</option>"
;
}
echo
"</datalist>"
;
echo
"<button class='btn btn-secondary m-l-1' id='prevCpt'>Précédent</button>"
;
echo
"<button class='btn btn-secondary m-l-1' id='nextCpt'>Suivant</button>"
;
echo
"</form>"
;
/* INFO ABOUT COMPETENCIES, FRAMEWORK AND CURRENT GRADE */
/* LINKED MODULES */
if
(
count
(
$cm_ids
)
!==
0
)
{
$modinfo
=
get_fast_modinfo
(
$courseid
);
_html
(
"h3"
,
"Lié à cette compétence"
);
echo
"<div class='list-group'>"
;
foreach
(
$cm_ids
as
$cm_id
)
{
echo
"<a href='
{
$modinfo
->
cms
[
$cm_id
]
->
url
->
out
()
}
' target='_blank' class='list-group-item list-group-item-action'><img src='
$CFG->wwwroot
/theme/image.php/boost/
{
$modinfo
->
cms
[
$cm_id
]
->
modname
}
/1/icon>' style='height: 1.3rem;'><span class='align-middle'>
{
$modinfo
->
cms
[
$cm_id
]
->
name
}
</span></a>"
;
}
echo
"</div>"
;
}
else
{
_html
(
"p"
,
"Aucune ressource ou activité n'est liée à cette compétence dans ce cours. "
,
"alert alert-secondary"
);
}
_html
(
'h2'
,
$cpt
->
get
(
'shortname'
),
"h3' style='margin-bottom: 0.3rem;'"
);
/*
INFO ABOUT COMPETENCIES, FRAMEWORK AND CURRENT GRADE
*/
/*
COMPETENCY TREE PATH
*/
echo
"<div class='alert alert-secondary'>"
;
/* for competency info and grade info */
_html
(
'h2'
,
$cpt
->
get
(
'shortname'
));
/* Competency tree parents path from current to framework */
$cptid
=
$competencyid
;
$parent_cpts
=
array
();
...
...
@@ -210,16 +182,52 @@ foreach ($parent_cpts as $parent_cpt) {
}
echo
"<div style='margin-bottom: 0.7rem;'>"
.
$cpt_path_link
.
"</div>"
;
/* Current grade */
_html
(
'p'
,
"Validé :
{
$proficiency
}
<br>Évaluation :
{
$eval
}
"
);
/* SWITCH COMPETENCY FORM */
echo
"<form action='
{
$CFG
->
wwwroot
}
/blocks/competency_iena/course_competency.php' id='change_cpt_form' class='form-inline m-b-1'>"
;
echo
"<input type='text' hidden name='courseid' value='
{
$courseid
}
'>"
;
echo
"<input type='text' hidden name='studentid' value='
{
$studentid
}
'>"
;
echo
"<span hidden id='competencyid'>
{
$competencyid
}
</span>"
;
/*echo "<label class='m-r-1' for='competencyid_sel' style=''>Changer de compétence</label>";*/
echo
"<input type='text' name='competencyid' id='competencyid_sel' value='' list='competency_list' class='form-control' style='font-size: .7rem; line-height: 1;'>"
;
echo
"<datalist id='competency_list' title='Select competency'>"
;
foreach
(
$course_cpts
as
$course_cpt
)
{
echo
"<option value='
{
$course_cpt
->
get
(
'shortname'
)
}
(
{
$course_cpt
->
get
(
'id'
)
}
)' data-value='
{
$course_cpt
->
get
(
'id'
)
}
'>
{
$course_cpt
->
get
(
'shortname'
)
}
(
{
$course_cpt
->
get
(
'id'
)
}
)</option>"
;
}
echo
"</datalist>"
;
echo
"<button class='btn btn-secondary' id='prevCpt' style='font-size: .8rem;line-height: 1.09; margin-left: 0.5rem;'>Précédent</button>"
;
echo
"<button class='btn btn-secondary' id='nextCpt' style='font-size: .8rem;line-height: 1.09; margin-left: 0.5rem;'>Suivant</button>"
;
echo
"</form>"
;
/* END switch competency form */
/* EVALUATION INFOS AND ACTIONS */
/* Review */
echo
"<div class='row'>"
;
/* Proficiency info */
echo
"<div class='col-12 col-lg-3'>"
;
echo
"<div class='alert alert-
{
$proficiency_class
}
'>"
;
echo
"<h3 class='h4'>Validé</h3>"
;
echo
"<p class='m-b-0 btn p-l-0'>
{
$proficiency
}
</p>"
;
echo
"</div>"
;
echo
"</div>"
;
/* Grade info */
echo
"<div class='col-12 col-lg-3'>"
;
echo
"<div class='alert alert-
{
$proficiency_class
}
'>"
;
echo
"<h3 class='h4'>Évaluation</h3>"
;
echo
"<p class='m-b-0 btn p-l-0'>
{
$eval
}
</p>"
;
echo
"</div>"
;
echo
"</div>"
;
/* Review and grade ASK and ACTION */
$review_class
=
$review_asked
?
"info"
:
"secondary"
;
$review_msg
=
$review_asked
?
"Évaluation demandée"
:
"Aucune évaluation demandée"
;
echo
"<div class='col-12 col-lg-6'>"
;
echo
"<div class='alert alert-
{
$review_class
}
'>"
;
echo
"<h3 class='h4'>
{
$review_msg
}
</h3>"
;
if
(
$review_asked
)
{
echo
"<div class='alert alert-primary'>Évaluation demandée</div>"
;
/* Student can cancer his own request review */
/* Request review and cancel buttons */
if
(
$USER
->
id
==
$studentid
)
{
/* Student cancel review */
echo
"<form method='post' action='
{
$CFG
->
wwwroot
}
/blocks/competency_iena/course_competency.php?courseid=
{
$courseid
}
&studentid=
{
$studentid
}
&competencyid=
{
$competencyid
}
'>"
;
/* Student cancel
his own
review */
echo
"<form method='post' action='
{
$CFG
->
wwwroot
}
/blocks/competency_iena/course_competency.php?courseid=
{
$courseid
}
&studentid=
{
$studentid
}
&competencyid=
{
$competencyid
}
'
style='display: inline; margin-right: 1rem;'
>"
;
echo
"<input hidden style='display: none;' type='text' name='review' value='cancel'>"
;
echo
"<button type='submit' class='btn btn-secondary'>Annuler la demande</button>"
;
echo
"</form>"
;
...
...
@@ -227,55 +235,119 @@ if ( $review_asked ) {
}
else
{
if
(
$USER
->
id
==
$studentid
)
{
/* Student ask review */
echo
"<form method='post' action='
{
$CFG
->
wwwroot
}
/blocks/competency_iena/course_competency.php?courseid=
{
$courseid
}
&studentid=
{
$studentid
}
&competencyid=
{
$competencyid
}
'>"
;
echo
"<form method='post' action='
{
$CFG
->
wwwroot
}
/blocks/competency_iena/course_competency.php?courseid=
{
$courseid
}
&studentid=
{
$studentid
}
&competencyid=
{
$competencyid
}
'
style='display: inline; margin-right: 1rem;'
>"
;
echo
"<input hidden style='display: none;' type='text' name='review' value='request'>"
;
echo
"<button type='submit' class='btn btn-primary'>Demande d'évaluation</button>"
;
echo
"</form>"
;
}
}
echo
"</div>"
;
/* for competency info and grade info */
/* EVALUATION ACTION */
/* TODO : check if user is teacher */
echo
"<div class='alert alert-secondary'>"
;
echo
"<form method='post' action='
{
$CFG
->
wwwroot
}
/blocks/competency_iena/course_competency.php?courseid=
{
$courseid
}
&studentid=
{
$studentid
}
&competencyid=
{
$competencyid
}
'>"
;
echo
"<div class='form-group'>"
;
echo
"<label>Évaluation</label>"
;
echo
"<select name='grade' class='form-control'>"
;
foreach
(
$cpt_scale
as
$key
=>
$item
)
{
$grade
=
$key
+
1
;
$selected
=
""
;
if
(
$item
==
$eval
)
{
$selected
=
" selected"
;
if
(
$is_teacher
)
{
/* Evaluation button and modal */
echo
"<a href='#' data-toggle='modal' data-target='#modaleval' class='btn btn-primary'>Évaluer</a>"
;
$eval_modale_echo
=
""
;
$eval_modale_echo
.
=
"<form method='post' action='
{
$CFG
->
wwwroot
}
/blocks/competency_iena/course_competency.php?courseid=
{
$courseid
}
&studentid=
{
$studentid
}
&competencyid=
{
$competencyid
}
'><div class='form-group'><div class='form-group'><label>Évaluation</label><select name='grade' class='form-control'>"
;
foreach
(
$cpt_scale
as
$key
=>
$item
)
{
$grade
=
$key
+
1
;
$selected
=
""
;
if
(
$item
==
$eval
)
{
$selected
=
" selected"
;
}
$eval_modale_echo
.
=
"<option value='
{
$grade
}
'
{
$selected
}
>
{
$item
}
</option>"
;
}
echo
"<option value='
{
$grade
}
'
{
$selected
}
>
{
$item
}
</option>"
;
$eval_modale_echo
.
=
"</select></div><div class='form-group'><textarea name='note' class='form-control' placeholder=
\"
Commentaire d'évaluation
\"
></textarea></div><button type='submit' class='btn btn-primary'>Évaluer</button></form></div>"
;
echo
_modal_builder
(
"modaleval"
,
"Évaluation"
,
$eval_modale_echo
);
}
echo
"</select>"
;
echo
"</div>"
;
echo
"<div class='form-group'>"
;
echo
"<label>Commentaire d'évaluation</label>"
;
echo
"<textarea name='note' class='form-control' placeholder=
\"
Commentaire d'évaluation
\"
></textarea>"
;
echo
"</div>"
;
echo
"<button type='submit' class='btn btn-primary'>Évaluer</button>"
;
echo
"</form>"
;
echo
"</div>"
;
echo
"</div>"
;
/* END review and grade ASK and ACTION - col */
echo
"</div>"
;
/* END review and grade ASK and ACTION - alert */
echo
"</div>"
;
/* END evaluation info and actions row */
/* GRADES HISTORY CHART */
// quelle différence
// read_user_evidence($id)
// read_evidence($evidenceid)
// delete_user_evidence($id)
echo
"<pre>"
;
// var_dump($cpt->get_framework()->get('shortname'));
// var_dump($cpt->get_framework()->get('description'));
echo
"</pre>"
;
// pour toutes les cpt
// list_user_evidence($userid)
// lié à la compétence
// list_evidence($userid = 0, $competencyid = 0, $planid = 0, $sort = 'timecreated',
// $order = 'DESC', $skip = 0, $limit = 0)
// list_evidence_in_course($userid = 0, $courseid = 0, $competencyid = 0, $sort = 'timecreated',
// $order = 'DESC', $skip = 0, $limit = 0)
echo
$OUTPUT
->
footer
();
// OKOK
// $course_evidencies = \core_competency\api::list_evidence_in_course($studentid, $courseid, $competencyid, $sort = 'timecreated', $order = 'DESC', $skip = 0, $limit = 0);
// foreach ($course_evidencies as $evidence) {
// echo "<ul>";
// echo "<li>{$evidence->get('id')}</li>";
// echo "<li>Action : {$evidence->get('action')} (0 : log, 2 ou 3 : rating)</li>";
// $grade = $evidence->get('grade');
// if ( $grade != NULL ) { /* liéer à descidentifier == evidence_manualoverrideincourse ??? */
// $grade_label = $cpt_scale[$grade - 1];
// echo "<li>{$grade_label}</li>";
// }
// // evidence_manualoverride
// // evidence_manualoverrideinplan
// // evidence_manualoverrideincourse
// $evidence_type = $evidence->get('descidentifier');
// if ( $evidence_type == 'evidence_manualoverrideincourse' ) {
// $emitter = user_get_users_by_id([$evidence->get('actionuserid')])[$evidence->get('actionuserid')];
// echo "<li>{$emitter->firstname} {$emitter->lastname}</li>";
// } elseif ( $evidence_type == 'evidence_coursemodulecompleted' ) {
// echo "<li>{$evidence->get('desca')}</li>";
// }
// var_dump($evidence->get_description()->out());
// echo "</ul>";
// }
// echo "<pre>";
// var_dump($course_evidencies);
// echo "</pre>";
// $student = user_get_users_by_id($studentid)
// OK OK END
echo
"<div class='alert alert-secondary'>"
;
$labels
=
[
"Un"
,
"Deux"
,
"Trois"
];
$series_data
=
[
1
,
2
,
3
];
$chart
=
new
core\chart_bar
();
$series
=
new
core\chart_series
(
''
,
$series_data
);
$chart
->
add_series
(
$series
);
$chart
->
set_labels
(
$labels
);
echo
$OUTPUT
->
render
(
$chart
);
echo
"</div>"
;
/* LINKED MODULES */
if
(
count
(
$cm_ids
)
!==
0
)
{
$modinfo
=
get_fast_modinfo
(
$courseid
);
_html
(
"h3"
,
"Lié à cette compétence"
);
echo
"<div class='list-group'>"
;
foreach
(
$cm_ids
as
$cm_id
)
{
echo
"<a href='
{
$modinfo
->
cms
[
$cm_id
]
->
url
->
out
()
}
' target='_blank' class='list-group-item list-group-item-action'><img src='
$CFG->wwwroot
/theme/image.php/boost/
{
$modinfo
->
cms
[
$cm_id
]
->
modname
}
/1/icon>' style='height: 1.3rem;'><span class='align-middle'>
{
$modinfo
->
cms
[
$cm_id
]
->
name
}
</span></a>"
;
}
echo
"</div>"
;
}
else
{
_html
(
"p"
,
"Aucune ressource ou activité n'est liée à cette compétence dans ce cours. "
,
"alert alert-secondary"
);
}
echo
$OUTPUT
->
footer
();
?>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment