Skip to content
Snippets Groups Projects
Commit 92335883 authored by DELARUELLE Myriam's avatar DELARUELLE Myriam
Browse files

fetch linked activities in evaluation modal and create a link with the student name when possible

parent 8d46e50a
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,7 @@
require_once('../../config.php');
require_once('entity/block_competency_iena_student.php');
require_once('../../user/lib.php');
global $COURSE, $DB, $USER, $CFG;
......@@ -27,31 +28,45 @@ if (!has_capability('moodle/course:update', $context = context_course::instance(
}
}
//fetch the linked activities for a competency/student and create a link to the corresponding page when possible
if(isset($_GET["action"]) && $_GET['action']=="get_links"){
$competencyid=$_GET["competencyid"];
$courseid=$_GET["courseid"];
if(isset($_GET["studentid"])){
$studentid=$_GET["studentid"];
}
else{
$studentid=$USER->id;
}
$cm_ids = \core_competency\api::list_course_modules_using_competency($competencyid, $courseid);
$data=array();
if ( count($cm_ids) !== 0 ) {
$modules=array();
$modinfo = get_fast_modinfo($courseid);
foreach ($cm_ids as $cm_id) {
$module=new StdClass();
//if the activity is an assignment or a quiz we'll try to redirect to the student submissions specifically
$is_assign = strpos($modinfo->cms[$cm_id]->url->out(), '/mod/assign') !== false;
$is_quiz= strpos($modinfo->cms[$cm_id]->url->out(), '/mod/quiz') !== false;
$module->url = $modinfo->cms[$cm_id]->url->out();
$user=$DB->get_record("user", array("id"=>$studentid));
//for the moment we don't manage accents in names
if (has_capability('mod/assign:grade', $context = context_course::instance($courseid), $USER->id) && $is_assign) {
$module->url = $module->url . "&action=grading&tifirst=" . $user->firstname[0] . "&tilast=". $user->lastname[0];
}
else if (has_capability('mod/quiz:grade', $context = context_course::instance($courseid), $USER->id) && $is_quiz) {
$module->url = $module->url . "&mode=responses&tifirst=" . $user->firstname[0] . "&tilast=". $user->lastname[0];
}
$module->link_icon=$CFG->wwwroot."/theme/image.php/boost/".$modinfo->cms[$cm_id]->modname."/1/icon";
$module->name=$modinfo->cms[$cm_id]->name;
array_push($modules, $module);
}
$data["modules"]=$modules;
$renderer = $PAGE->get_renderer('block_competency_iena');
echo $renderer->get_linked_activities($data);
//echo json_encode($html);
return;
}
echo "false";
return;
......
......@@ -179,10 +179,11 @@
});
function loadLinkedActivities(courseid, competencyid){
user=document.getElementById('studentid_sel').value;
$.ajax({
url: window.location.href,
type: 'GET',
data: {competencyid:competencyid, courseid:courseid, action:"get_links"},
data: {competencyid:competencyid, courseid:courseid, user:user, action:"get_links"},
success: function(html) {
if(html=='false'){
html="<p><i>Il n'y a aucune activité liée</i></p>"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment