public static function get_activities_list($id_course, $DB) { $listid = report_activities_manager::extract_items_id_list_from_db($id_course, $DB); $listinfos = report_activities_manager::extract_info_grades_list_from_db($listid, $DB); $listidmoy = report_activities_manager::mapping_id_moy($listid, $listinfos); $listecart = report_activities_manager::extract_ecart_from_db($listidmoy, $DB); $final_result = report_activities_manager::mapping_data($listid, $listinfos, $listecart); return $final_result; }
$PAGE->set_url(new moodle_url('/report/studentreport/index.php', array('userid' => $theuser->id))); $PAGE->set_title(get_string('pluginname', 'report_studentreport')); $PAGE->set_heading(get_string('pluginname', 'report_studentreport')); echo $OUTPUT->header(); /*extaction of all courses (id and names) that this user is rolled in */ $courseListDisplay = report_course_manager::get_course_list($theuser->id, $DB); /*extaction of all domaines */ $courseListDomaine = report_course_manager::extract_list_domaine($courseListDisplay, $DB); /*mapping courses et domaines*/ $courseListFinal = report_course_manager::mapping_final_course_domaine($courseListDisplay, $courseListDomaine); /*extraction of the activities related to the course : id,name,maximum_mark, student_mark*/ $listiditems = report_activities_manager::extract_items_id_list_from_db($courseListDisplay, $DB); $listname = report_activities_manager::extract_info_grades_list_from_db($listiditems, $DB); $listgradeuser = report_activities_manager::extract_user_grades_list_from_db($listiditems, $theuser->id, $DB); /*Final table with activities information and the student's marks in every activity*/ $listitems = report_activities_manager::mapping_data_activities($listiditems, $listname, $listgradeuser, $DB); /*arrays for the radar chart*/ $tabModule = array(); $tabNote = array(); $tabMoyenne = array(); foreach ($courseListDomaine as $key1 => $var1) { echo "<div id=\"cadreDomaine\"><a href=\"javascript:unhide('__" . $key1 . "');\"><font color=\"white\">{$var1}</font></a><br /></div>\n"; // affichage nom domaine echo "<div id=\"__" . $key1 . "\" class=\"hidden\">"; if (is_array($courseListFinal) and $courseListFinal != null) { $count_cor = 0; // calculer nombre de module dans le domaine courant foreach ($courseListFinal as $var2) { if ($var2["domaine"] == $var1) { $count_cor++; $id_course = $var2["id"];
public static function mapping_data_activities($listid, $liststat, $listmarks, $DB) { $arr_final = array(); $ind = 0; foreach ($listid as $var1) { $id = $var1->id; $max = 0; $min = 0; $moy = 0; $ecart = 0; $finalgrade = 0; $aux = array(); foreach ($liststat as $var2) { if ($id == $var2->itemid) { $max = $var2->maxg; $min = $var2->ming; $moy = $var2->avgg; $ecart = report_activities_manager::extract_ecart_type_from_db($id, $DB, $moy); } } foreach ($listmarks as $var3) { if ($id == $var3->itemid) { $finalgrade = $var3->finalgrade; } } if ($var1->itemname != "") { $aux["id"] = $id; $aux["courseid"] = $var1->courseid; $aux["itemname"] = $var1->itemname; $aux["grademax"] = $var1->grademax; $aux["maxg"] = $max; $aux["ming"] = $min; $aux["avgg"] = $moy; $aux["ecart"] = $ecart; $aux["finalgrade"] = $finalgrade; $arr_final[$ind] = $aux; $ind++; } } return $arr_final; }
// check that the user has the right to access this page $theuser = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST); //does the id exists in the database $usercontext = CONTEXT_USER::instance($theuser->id); $PAGE->set_pagelayout('report'); $PAGE->set_context(context_system::instance()); $PAGE->set_url(new moodle_url('/report/teacherreport/index.php', array('userid' => $theuser->id))); $PAGE->set_title(get_string('pluginname', 'report_teacherreport')); $PAGE->set_heading(get_string('pluginname', 'report_teacherreport')); echo $OUTPUT->header(); if (!isset($_GET["data"])) { echo get_string('T_noid', 'report_teacherreport'); //// } else { $idcourse = $_GET["data"]; $activitiesListDisplay = report_activities_manager::get_activities_list($idcourse, $DB); $studentsListDisplay = report_students_manager::get_students_list($idcourse, $DB, $activitiesListDisplay); $stringOut = "<table class=\"tg\"><tr><th class=\"tg-s6z2\">nom étudiant</th><th class=\"tg-s6z2\">niveau général</th>"; foreach ($activitiesListDisplay as $var) { $stringOut = $stringOut . "<th class=\"tg-s6z2\"> " . $var["name"] . " </th>"; } $stringOut = $stringOut . "</tr>"; foreach ($studentsListDisplay as $key1 => $var1) { $stringOut = $stringOut . "<tr><td>" . $var1["firstname"] . " " . $var1["lastname"] . "</td>"; $stringAux = ""; $ind = 0; $nbSupMoy = 0; foreach ($var1["grade"] as $key2 => $var2) { $Gavg = $activitiesListDisplay[$ind]["moyenne"]; $ecartType = $activitiesListDisplay[$ind]["ecarttype"]; $userGrade = $var2;