diff --git a/notemyprogress/ajax.php b/notemyprogress/ajax.php index 4b96853cd9c800460ed84264fe0b2815334216c6..15a22ddcda3121b47ff306e5a65a92e241045dca 100644 --- a/notemyprogress/ajax.php +++ b/notemyprogress/ajax.php @@ -328,7 +328,7 @@ function local_sr_metareflexion_get_week($weekcode, $courseid, $userid, $profile $course_interaction = $teacher->hours_report_metereflexion($weekcode); $response['course_report_hours'] = $course_interaction; //} - $response['students_planification'] = $reports->students_planification_summary($weekcode); + //$response['students_planification'] = $reports->students_planification_summary($weekcode); local_notemyprogress_ajax_response($response); } diff --git a/notemyprogress/amd/build/gamification.js b/notemyprogress/amd/build/gamification.js index e6643fb4eb924165f8bb6cc97fe99b7f56b5d3db..a3de1091011f36aa3f44942b6a5e2c9c51f67f01 100644 --- a/notemyprogress/amd/build/gamification.js +++ b/notemyprogress/amd/build/gamification.js @@ -9,7 +9,7 @@ define([ "use strict"; function init(content) { - console.log(content); + //console.log(content); Vue.use(Vuetify); Vue.component("pageheader", PageHeader); Vue.component("chart", ChartDynamic); diff --git a/notemyprogress/amd/build/metareflexion.js b/notemyprogress/amd/build/metareflexion.js index e5bbeb5e395b966f0baafd890a3acd27309a6369..9dc457ade8518681becb264baba2a241ca330f08 100644 --- a/notemyprogress/amd/build/metareflexion.js +++ b/notemyprogress/amd/build/metareflexion.js @@ -20,9 +20,9 @@ define([ ) { "use strict"; - function clone(obj) { - return JSON.parse(JSON.stringify(obj)); - } + // function clone(obj) { + // return JSON.parse(JSON.stringify(obj)); + // } function init(content) { Vue.use(Vuetify); @@ -30,12 +30,11 @@ define([ Vue.component("chart", ChartStatic); Vue.component("pageheader", Pageheader); - let vue = new Vue({ + const vue = new Vue({ delimiters: ["[[", "]]"], el: "#metareflexion", vuetify: new Vuetify(), - data() { - return { + data: { test: true, module_groups: content.module_groups, indicators: content.indicators, @@ -136,7 +135,6 @@ define([ }, img_no_data: content.image_no_data, - }; }, mounted() { @@ -154,6 +152,11 @@ define([ this.paginator_week = page; } }); + + setTimeout(function () { + vue.setGraphicsEventListeners(); + }, 500); + vue.setGraphicsEventListeners(); // if (typeof this.past_week.id != "undefined") { // this.disabled_form = true; // } @@ -222,7 +225,7 @@ define([ methods: { get_modules(day, cmid) { - return this.current_week[0].weekly_schedules_days.dias_planificados[ + return this.current_week[0].weekly_schedules_days.days_planned[ day ].includes(cmid); }, @@ -401,16 +404,16 @@ define([ update_module(day, module_id, event) { if (event) { - this.current_week[0].weekly_schedules_days.dias_planificados[ + this.current_week[0].weekly_schedules_days.days_planned[ day ].push(module_id); } else { const i = - this.current_week[0].weekly_schedules_days.dias_planificados[ + this.current_week[0].weekly_schedules_days.days_planned[ day ].indexOf(module_id); //console.log(i); - this.current_week[0].weekly_schedules_days.dias_planificados[ + this.current_week[0].weekly_schedules_days.days_planned[ day ].splice(i, 1); } @@ -554,7 +557,7 @@ define([ data.labels = [inverted, planified]; var dataset = new Object(); dataset.label = "Horas"; - + dataset.data = [ parseFloat(this.data_report_meta_hours.hours_worked), parseInt(this.data_report_meta_hours.hours_planned), @@ -617,11 +620,10 @@ define([ action: "updatemetareflexion", metareflexionid: course_module.weekly_schedules_id, // days: days_committed, - hours: - this.current_week[0].weekly_schedules_hours.hours_planned, + hours: this.current_week[0].weekly_schedules_hours.hours_planned, goals: this.current_week[0].weekly_schedules_goals, days: JSON.stringify( - this.current_week[0].weekly_schedules_days.dias_planificados + this.current_week[0].weekly_schedules_days.days_planned ), courseid: this.courseid, weekcode: course_module.weekcode, @@ -653,11 +655,10 @@ define([ courseid: this.courseid, weekcode: course_module.weekcode, - hours: - this.current_week[0].weekly_schedules_hours.hours_planned, + hours: this.current_week[0].weekly_schedules_hours.hours_planned, goals: this.current_week[0].weekly_schedules_goals, days: JSON.stringify( - this.current_week[0].weekly_schedules_days.dias_planificados + this.current_week[0].weekly_schedules_days.days_planned ), }; @@ -777,11 +778,11 @@ define([ }); }, - get_icon(dias_planificados_trabajados, position) { + get_icon(days_planned_trabajados, position) { var icon_name = "remove"; - if (dias_planificados_trabajados.dias_planificados[position]) { - if (dias_planificados_trabajados.dias_trabajados[position] > 0) { + if (days_planned_trabajados.days_planned[position]) { + if (days_planned_trabajados.days_worked[position] > 0) { icon_name = "mdi-thumb-up-outline"; } else { icon_name = "mdi-mdi-thumb-down-outline"; @@ -890,6 +891,62 @@ define([ this.get_interactions(week); this.get_interacions_last_week(week); }, + setGraphicsEventListeners() { + let graphics = document.querySelectorAll(".highcharts-container"); + if (graphics.length < 1) { + setTimeout(vue.setGraphicsEventListeners, 500); + } else { + graphics[0].id = "EfficiencyChart"; + graphics.forEach((graph) => { + graph.addEventListener("mouseenter", vue.addLogsViewGraphic); + }); + } + }, + addLogsViewGraphic(e) { + event.stopPropagation(); + var action = ""; + var objectName = ""; + var objectType = ""; + var objectDescription = ""; + switch (e.target.id) { + case "EfficiencyChart": + action = "viewed"; + objectName = "reflection_chart"; + objectType = "chart"; + objectDescription = "A bar chart"; + break; + default: + action = "viewed"; + objectName = ""; + objectType = "chart"; + objectDescription = "A chart"; + break; + } + vue.addLogsIntoDB(action, objectName, objectType, objectDescription); + }, + addLogsIntoDB(action, objectName, objectType, objectDescription) { + let data = { + courseid: content.courseid, + userid: content.userid, + action: "addLogs", + sectionname: "META_REFLECTION", + actiontype: action, + objectType: objectType, + objectName: objectName, + currentUrl: document.location.href, + objectDescription: objectDescription, + }; + Axios({ + method: "get", + url: M.cfg.wwwroot + "/local/notemyprogress/ajax.php", + params: data, + }) + .then((response) => { + if (response.status == 200 && response.data.ok) { + } + }) + .catch((e) => {}); + }, }, }); } diff --git a/notemyprogress/amd/build/student_gamification.js b/notemyprogress/amd/build/student_gamification.js index d7fb47847300386cc9b36ae99c5382f37b04e6d9..2c4c8bf0051a4c697d0b36a28e9ccd352c3d9af9 100644 --- a/notemyprogress/amd/build/student_gamification.js +++ b/notemyprogress/amd/build/student_gamification.js @@ -4,13 +4,15 @@ define([ "local_notemyprogress/axios", "local_notemyprogress/alertify", "local_notemyprogress/pageheader", -], function (Vue, Vuetify, Axios, Alertify, PageHeader) { + "local_notemyprogress/chartdynamic", +], function (Vue, Vuetify, Axios, Alertify, PageHeader, ChartDynamic) { "use strict"; function init(content) { // console.log(content); Vue.use(Vuetify); Vue.component("pageheader", PageHeader); + Vue.component("chart", ChartDynamic); const app = new Vue({ delimiters: ["[[", "]]"], el: "#student_gamification", @@ -126,6 +128,115 @@ define([ }) .catch((e) => {}); }, + chart_spread() { + let chart = new Object(); + chart.chart = { + type: "column", + backgroundColor: null, + }; + chart.title = { + text: this.strings.chartTitle, + }; + chart.colors = ["#118AB2"]; + (chart.xAxis = { + type: "category", + labels: { + rotation: -45, + style: { + fontSize: "13px", + fontFamily: "Verdana, sans-serif", + }, + }, + }), + (chart.yAxis = { + min: 0, + title: { + text: this.strings.chartYaxis, + }, + }); + chart.legend = { + enabled: false, + }; + (chart.series = [ + { + name: null, + data: this.strings.chart_data, //[["level : 1", 1]], + dataLabels: { + enabled: true, + rotation: -90, + color: "#FFFFFF", + align: "right", + format: "{point.y:.1f}", // one decimal + y: 10, // 10 pixels down from the top + style: { + fontSize: "13px", + fontFamily: "Verdana, sans-serif", + }, + }, + }, + ]), + console.log("series: "); + console.log(this.chart_data); + return chart; + }, + setGraphicsEventListeners() { + console.log("Listeners set"); + let graphics = document.querySelectorAll(".highcharts-container"); + if (graphics.length < 1) { + setTimeout(app.setGraphicsEventListeners, 500); + } else { + graphics[0].id = "SpreadChart"; + graphics.forEach((graph) => { + graph.addEventListener("mouseenter", app.addLogsViewGraphic); + }); + } + }, + addLogsViewGraphic(e) { + event.stopPropagation(); + var action = ""; + var objectName = ""; + var objectType = ""; + var objectDescription = ""; + switch (e.target.id) { + case "SpreadChart": + action = "viewed"; + objectName = "spreading_chart"; + objectType = "chart"; + objectDescription = + "Bar chart that shows the level repartition in gamification"; + break; + default: + action = "viewed"; + objectName = ""; + objectType = "chart"; + objectDescription = "A chart"; + break; + } + app.addLogsIntoDB(action, objectName, objectType, objectDescription); + }, + addLogsIntoDB(action, objectName, objectType, objectDescription) { + let data = { + courseid: content.courseid, + userid: content.userid, + action: "addLogs", + sectionname: "STUDENTS_GAMIFICATION", + actiontype: action, + objectType: objectType, + objectName: objectName, + currentUrl: document.location.href, + objectDescription: objectDescription, + }; + Axios({ + method: "get", + url: M.cfg.wwwroot + "/local/notemyprogress/ajax.php", + params: data, + }) + .then((response) => { + if (response.status == 200 && response.data.ok) { + } + }) + .catch((e) => {}); + }, }, }); } diff --git a/notemyprogress/classes/configgamification.php b/notemyprogress/classes/configgamification.php index 3fb9d502f2dcd001c6e220e6eddce06380f743c5..2957ad39714bc8b1cd6134c09310ddedd84953a9 100644 --- a/notemyprogress/classes/configgamification.php +++ b/notemyprogress/classes/configgamification.php @@ -157,11 +157,6 @@ class configgamification { $param->userid = $this->user->id; if ($enable){ $param->enablegamification =1;}else{ $param->enablegamification =0;} $param->timecreated = self::now_timestamp(); - //if ($timecreated == null){$result = 1;} - //if ($timecreated === null){$result = 2;} - //if ($timecreated == 'null'){$result = 3;} - //if ($timecreated->maximum == null){$result = 9;} - //if ($timecreated->maximum === null){$result = 10;} $DB->insert_record("notemyprogress_gamification", $param,true); } /** diff --git a/notemyprogress/classes/metareflexion.php b/notemyprogress/classes/metareflexion.php index e7ee98d542433927fbc385c09e93ac330ea65603..aa9b7b217660f02559b5a7ddd7657419b9d38e51 100644 --- a/notemyprogress/classes/metareflexion.php +++ b/notemyprogress/classes/metareflexion.php @@ -56,7 +56,7 @@ class metareflexion public function get_days_committed($id_module) { global $DB; - $sql = "select d.description from {notemyprogress_days} d,{notemyprogress_days_modules} dm where d.id = dm.id_days and dm.id_course_modules = ?"; + $sql = "select dm.description from {notemyprogress_days_modules} dm where dm.id_course_modules = ?"; $days = $DB->get_records_sql($sql, array($id_module)); return $days; } @@ -97,7 +97,7 @@ class metareflexion if (empty($this->past_week)) { return null; } else { - $sql = "select * from {st_rpt_work_last_weeks} where weekcode = ? and userid = ? order by id desc limit 1"; + $sql = "select * from {notemyprogress_last_weeks} where weekcode = ? and userid = ? order by id desc limit 1"; $last_week_query = $DB->get_record_sql($sql, array($this->past_week->weekcode, $this->user->id)); if (!empty($last_week_query)) { $last_week = $last_week_query; @@ -108,14 +108,14 @@ class metareflexion } /** - * Get the the answers of - * - * @return object the last week with the answers + * Get the questions and answers with their text + * @param object last week without the answer selected + * @return object the last week with the answers selecteds and the text associated */ private function find_questions($last_week) { global $DB; - $sql = "select * from {st_rpt_questions}"; + $sql = "select * from {notemyprogress_questions}"; $questions = $DB->get_records_sql($sql); foreach ($questions as $key => $question) { $answers = self::find_answers($question->id); @@ -139,6 +139,12 @@ class metareflexion return $questions; } + /** + * Associates text to questions and answers + * + * @param object $questions questions without their text associated + * @return object questions and answers with their text + */ private function update_texts_from_strings($questions) { foreach ($questions as $question) { @@ -150,16 +156,27 @@ class metareflexion return $questions; } + /** + * Associates text to questions and answers + * + * @param string $id_questions id of the question + * @return object questions and answers with their text + */ public function find_answers($id_questions) { global $DB; - $sql = "select * from {st_rpt_answers} where questionid = ?"; + $sql = "select * from {notemyprogress_answers} where questionid = ?"; $answers = $DB->get_records_sql($sql, array($id_questions)); return $answers; } - + /** + * Get the current week schedule + * + * @param object reports object containing useful fonctions and corresponding to the current week + * @return object the current week + */ public function find_current_week_new($reports) { $array_current_week = array(); @@ -190,7 +207,7 @@ class metareflexion $current_week->weekcode = $this->current_week->weekcode; $current_week->weekly_schedules_goals = []; - $dias_planificados = array( + $days_planned = array( "monday" => array(), "tuesday" => array(), "wednesday" => array(), @@ -199,7 +216,7 @@ class metareflexion "saturday" => array(), "sunday" => array(), ); - $dias_trabajados = array( + $days_worked = array( "monday" => array(), "tuesday" => array(), "wednesday" => array(), @@ -209,8 +226,8 @@ class metareflexion "sunday" => array(), ); $weekly_schedules_days = new stdClass(); - $weekly_schedules_days->dias_planificados = $dias_planificados; - $weekly_schedules_days->dias_trabajados = $dias_trabajados; + $weekly_schedules_days->days_planned = $days_planned; + $weekly_schedules_days->days_worked = $days_worked; $current_week->weekly_schedules_days = $weekly_schedules_days; $current_week->weekly_schedules_hours = 0; @@ -222,7 +239,6 @@ class metareflexion $current_week->weekly_schedules_id = $current_wk_schedule->id; $current_week->weekly_schedules_goals = $reports->goals_report_metereflexion($current_week->weekcode); $current_week->weekly_schedules_days = $reports->days_report_metereflexion($current_week->weekcode); - //array_push($goals_committed, self::get_goals_id($current_wk_schedule)); } $current_week->weekly_schedules_hours = $reports->hours_report_metereflexion($current_week->weekcode); $current_week->goals_categories = $goals_cat; @@ -232,15 +248,25 @@ class metareflexion return $array_current_week; } + /** + * Get the current week schedule's entry in the db for a specific weekcode + * + * @param string $weekcode code assigned to the week + * @return object the current week entry + */ public function get_schedules($weekcode) { global $DB; - $sql = "select * from {st_rpt_weekly_schedules} where userid = ? and weekcode = ?"; + $sql = "select * from {notemyprogress_wk} where userid = ? and weekcode = ?"; $cm_week_schedules = $DB->get_record_sql($sql, array($this->user->id, $weekcode)); return $cm_week_schedules; } - + /** + * Save the schedule the user has just created for the current week. + * + * @return object informations about the schedule entry + */ public function save_metareflexion() { if (!isset($this->weekcode) || !isset($this->days) || !isset($this->goals_committed) || !isset($this->hours)) { @@ -248,7 +274,7 @@ class metareflexion } global $DB; - //Add the weekly schedule to the st_rpt_weekly_schedules table + //Add the weekly schedule to the notemyprogress_wk table $metareflexion = new stdClass(); $metareflexion->userid = $this->user->id; $metareflexion->weekcode = $this->weekcode; @@ -256,7 +282,7 @@ class metareflexion $metareflexion->hours = $this->hours; $metareflexion->timecreated = self::now_timestamp(); $metareflexion->timemodified = self::now_timestamp(); - $meta = $DB->insert_record("st_rpt_weekly_schedules", $metareflexion, true); + $meta = $DB->insert_record("notemyprogress_wk", $metareflexion, true); //Add goals committed to the notemyprogress_goals table foreach ($this->goals_committed as $key => $id_goal_cat) { @@ -271,17 +297,20 @@ class metareflexion //Create days in notemyprogress_days table $day_descriptions = array("monday", "tuesday", "wednesday", "thursday", "friday", 'saturday', 'sunday'); $d_array = json_decode($this->days, true); - foreach ($day_descriptions as $day_description) { + foreach ($day_descriptions as $day_desc) { $day = new stdClass(); $day->userid = $this->user->id; $day->id_weekly_schedules = $meta; - $day->description = $day_description; - $id_day = $DB->insert_record("notemyprogress_days", $day, true); + $day->description = $day_desc; + //$id_day = $DB->insert_record("notemyprogress_days", $day, true); //Create an entry in notemyprogress_days_modules table for each day and module associated - foreach ($d_array[$day_description] as $key => $id_module) { + foreach ($d_array[$day_desc] as $key => $id_module) { $days_modules = new stdClass(); $days_modules->id_course_modules = $id_module; - $days_modules->id_days = $id_day; + //$days_modules->id_days = $id_day; + $days_modules->id_weekly_schedules = $meta; + $days_modules->day_description = $day_desc; + $DB->insert_record("notemyprogress_days_modules", $days_modules, true); } } @@ -291,18 +320,23 @@ class metareflexion return $metareflexion; } + + /** + * Update the current week schedule in the db + * + * @return object informations about the schedule entry + */ public function update_metareflexion() { if (!isset($this->metareflexionid) || !isset($this->days) || !isset($this->goals_committed) || !isset($this->hours)) { return false; } global $DB; - //update schedule $metareflexion = new stdClass(); $metareflexion->id = $this->metareflexionid; $metareflexion->hours = $this->hours; $metareflexion->timemodified = self::now_timestamp(); - $sql = "update {st_rpt_weekly_schedules} set hours = ?, timemodified = ? where id = ?"; + $sql = "update {notemyprogress_wk} set hours = ?, timemodified = ? where id = ?"; $result = $DB->execute($sql, array($this->hours, self::now_timestamp(), $this->metareflexionid)); // //delete or add goals committed to the notemyprogress_goals table @@ -343,24 +377,33 @@ class metareflexion } //Delete previous notemyprogress_days_modules entries - $sql = "delete from {notemyprogress_days_modules} where id_days in (Select id from {notemyprogress_days} where id_weekly_schedules = ?) "; + $sql = "delete from {notemyprogress_days_modules} where id_weekly_schedules = ?"; $result = $DB->execute($sql,array($metareflexion->id)); //Add entries $d_array = json_decode($this->days, true); - foreach ($d_array as $key => $day) { - $sql = "select id from {notemyprogress_days} where id_weekly_schedules = ? and description = ? "; - $id_day = $DB->get_record_sql($sql, array($this->metareflexionid, $key)); + foreach ($d_array as $key_day => $day) { + //$sql = "select id from {notemyprogress_days} where id_weekly_schedules = ? and description = ? "; + //$id_day = $DB->get_record_sql($sql, array($this->metareflexionid, $key)); //Create an entry in notemyprogress_days_modules table for each day and module associated foreach ($day as $key => $id_module) { $days_modules = new stdClass(); $days_modules->id_course_modules = $id_module; - $days_modules->id_days = $id_day->id; + $days_modules->id_weekly_schedules = $this->metareflexionid; + $days_modules->day_description = $key_day; + + //$days_modules->id_days = $id_day->id; $DB->insert_record("notemyprogress_days_modules", $days_modules, true); } } return $metareflexion; } + + /** + * Save the answers to the reflexion questionnaire + * + * @return object informations about the answers to the reflexion questionnaire + */ public function save_lastweek() { global $DB; @@ -373,11 +416,16 @@ class metareflexion $lastweek->previous_class_learning = $this->previous_class_learning; $lastweek->benefit_going_class = $this->benefit_going_class; $lastweek->feeling = $this->feeling; - $id = $DB->insert_record("st_rpt_work_last_weeks", $lastweek, true); + $id = $DB->insert_record("notemyprogress_last_weeks", $lastweek, true); $lastweek->id = $id; return $lastweek; } + /** + * Updates the answers to the reflexion questionnaire + * + * @return object informations about the answers to the reflexion questionnaire + */ public function update_lastweek() { if (!isset($this->lastweekid) || !isset($this->classroom_hours) || !isset($this->hours_off_course) || !isset($this->previous_class_learning) || !isset($this->benefit_going_class)) { @@ -392,11 +440,16 @@ class metareflexion $lastweek->previous_class_learning = $this->previous_class_learning; $lastweek->benefit_going_class = $this->benefit_going_class; $lastweek->feeling = $this->feeling; - $sql = "update {st_rpt_work_last_weeks} set classroom_hours = ?, hours_off_course = ?,objectives_reached = ?, previous_class_learning = ?, benefit_going_class = ? ,feeling = ? where id = ?"; + $sql = "update {notemyprogress_last_weeks} set classroom_hours = ?, hours_off_course = ?,objectives_reached = ?, previous_class_learning = ?, benefit_going_class = ? ,feeling = ? where id = ?"; $result = $DB->execute($sql, array($lastweek->classroom_hours, $lastweek->hours_off_course,$lastweek->objectives_reached ,$lastweek->previous_class_learning, $lastweek->benefit_going_class,$lastweek->feeling, $lastweek->id)); return $lastweek; } - + + /** + * Get all goals categories from the notemyprogress_goals_ct table + * + * @return object all goal categories + */ public function get_goals_cat() { global $DB; @@ -404,11 +457,4 @@ class metareflexion $goals_cat_res = $DB->get_records_sql($sql); return $goals_cat_res; } - public function get_goals_id($week_schedule) - { - global $DB; - $sql = "select g.id from {notemyprogress_goals} g"; - $goals_res = $DB->get_records_sql($sql); - return $goals_res; - } } diff --git a/notemyprogress/classes/report.php b/notemyprogress/classes/report.php index 9cdf8cc9c7e3e94773a35898887a7c24bf311797..5728f7fa256282e32a8cca8972481068457469a2 100644 --- a/notemyprogress/classes/report.php +++ b/notemyprogress/classes/report.php @@ -130,7 +130,7 @@ abstract class report private function find_questions($last_week) { global $DB; - $sql = "select * from {st_rpt_questions}"; + $sql = "select * from {notemyprogress_questions}"; $questions = $DB->get_records_sql($sql); foreach ($questions as $key => $question) { $answers = self::find_answers($question->id); @@ -179,20 +179,20 @@ abstract class report public function find_answers($id_question) { global $DB; - $sql = "select * from {st_rpt_answers} where questionid = ?"; + $sql = "select * from {notemyprogress_answers} where questionid = ?"; $answers = $DB->get_records_sql($sql, array($id_question)); return $answers; } /** - * Find the st_rpt_work_last_weeks entry corresponding to a weekcode + * Find the notemyprogress_last_weeks entry corresponding to a weekcode * * @param string $weekcode identifier of the week * @return object the answer for the question id */ public function get_last($weekcode){ global $DB; - $sql = "select * from {st_rpt_work_last_weeks} where weekcode = ? and userid = ? order by id desc limit 1"; + $sql = "select * from {notemyprogress_last_weeks} where weekcode = ? and userid = ? order by id desc limit 1"; $last_week_query = $DB->get_record_sql($sql, array($weekcode, $this->user->id)); return $last_week_query; } @@ -208,7 +208,7 @@ abstract class report global $DB; $weeks = $this->weeks; $array_ws = []; - $sql = "select * from {st_rpt_weekly_schedules} where userid = ?"; + $sql = "select * from {notemyprogress_wk} where userid = ?"; $week_schedules = $DB->get_records_sql($sql, array($this->user->id)); foreach($weeks as $week){ $array_ws[$week->weekcode] = false; @@ -397,6 +397,15 @@ abstract class report return $complete; } + /** + * Returns how many times a user has interacted with a course module + * + * @param object $user user + * @param string $cm_id id of the module + * + * @return object interactions of the user on the module + */ + private function count_cm_interactions($user, $cm_id) { $cm_logs = 0; @@ -408,6 +417,7 @@ abstract class report return $cm_logs; } + protected function get_sessions_by_weeks($user_sessions) { $months = array(); @@ -699,6 +709,7 @@ abstract class report return $conditions; } + private function get_sessions($logs) { $sessions = array(); @@ -1071,7 +1082,13 @@ abstract class report //Planning - + /** + * Get an array representing the status of planned days (planned/pending/completed/failed) for a specific week + * + * @param string $weekcode code of the week + * + * @return array an array with the status of the days of the week + */ public function status_planning($weekcode = null) { if (!self::course_in_transit()) { @@ -1091,73 +1108,16 @@ abstract class report return $status; } - public function students_planification_summary($weekcode = null) - { - if (!self::course_in_transit()) { - return null; - } - if (!self::course_has_users()) { - return null; - } - $week = $this->current_week; - if (!empty($weekcode)) { - $week = self::find_week($weekcode); - } - $schedule = self::get_schedule($week->weekcode); - $worked_sessions = self::get_work_sessions($week->weekstart, $week->weekend); - $summary = self::verify_students_planifications($worked_sessions, $schedule); - $summary = self::summary_process($summary); - return $summary; - } - - private function summary_process($days) - { - foreach ($days as $day) { - $day->percentage = 0; - $day->count_students = count($day->students); - if ($day->count_planned > 0) { - $day->percentage = round(($day->count_accomplished * 100 / $day->count_planned), 1); - } - } - return $days; - } - - private function verify_students_planifications($worked_sessions, $planifications) - { - $worked_sessions = self::update_array_key_by('userid', $worked_sessions); - $summary = self::create_planifications_week_summary(); - foreach ($planifications as $planification) { - $days = explode(',', $planification->days); - foreach ($days as $day) { - if (!in_array($planification->userid, $summary[$day]->students)) { - $summary[$day]->count_planned++; - if (self::planned_accomplished($day, $planification->userid, $worked_sessions)) { - $summary[$day]->count_accomplished++; - } - array_push($summary[$day]->students, $planification->userid); - } - } - } - return $summary; - } - - private function planned_accomplished($day, $userid, $course_sessions) - { - $tz = self::get_timezone(); - date_default_timezone_set($tz); - $accomplished = false; - if (isset($course_sessions[$userid])) { - $user_sessions = $course_sessions[$userid]; - foreach ($user_sessions->sessions as $session) { - if (self::day_to_english($day) == strtolower(date('D', $session->start))) { - $accomplished = true; - break; - } - } - } - return $accomplished; - } + /** + * Returns if the day is completed or not + * + * @param object $day day specified + * @param string $userid id of the user + * @param object $course_sessions sessions of the course + * + * @return boolean if the day is completed or not + */ private function create_planifications_week_summary() { $summary = new stdClass(); @@ -1176,13 +1136,29 @@ abstract class report return $week; } + + /** + * Get the schedule for a specific week and the current user + * + * @param string $weekcode code of the week + * + * @return object the schedule for a specific week and the current user + */ private function get_schedule($weekcode) { global $DB; - $planifications = $DB->get_records('st_rpt_weekly_schedules', array('weekcode' => $weekcode,'userid' => $this->user->id)); + $planifications = $DB->get_records('notemyprogress_wk', array('weekcode' => $weekcode,'userid' => $this->user->id)); return reset($planifications); } + + /** + * Get the informations about the modules planned and worked for each day of a specific week + * + * @param string $weekcode code of the week + * + * @return object the informations about the modules planned and worked + */ public function days_report_metereflexion($weekcode = null) { if (!self::course_in_transit()) { @@ -1196,47 +1172,27 @@ abstract class report $week = self::find_week($weekcode); } - //$number_planned_days = self::planned_days($weekcode); $days_module_planned = self::get_modules_days_planned($week->weekcode); $work_sessions = self::get_work_sessions($week->weekstart, $week->weekend); $days_module_worked = self::get_modules_days_worked($work_sessions); - //$number_planned_days_logs = self::number_schedules_day_log($work_sessions); $data_report_meta = new stdClass(); - $data_report_meta->dias_planificados = $days_module_planned; - $data_report_meta->dias_trabajados = $days_module_worked; + $data_report_meta->days_planned = $days_module_planned; + $data_report_meta->days_worked = $days_module_worked; return $data_report_meta; } - protected function planned_days($weekcode = null) - { - if (empty($this->users)) { - return null; - } - - $week = $this->current_week; - if (!empty($weekcode)) { - $week = self::find_week($weekcode); - } - - global $DB; - - list($in, $invalues) = $DB->get_in_or_equal($this->users); - $params = array_merge(array($week->weekcode), $invalues); - $sql = "select * from {st_rpt_weekly_schedules} where weekcode = ? and userid $in"; - $week_schedules = $DB->get_records_sql($sql, $params); - - $number_per_day = self::number_schedules_day($week_schedules); - - return $number_per_day; - } - - /** - * Gets the module id from mdl_course_modules with the instance and type of the 'mdl_{type}' table" - **/ + /** + * Gets the module id from mdl_course_modules with the instance and the type of the 'mdl_{type}' table" + * + * @param string $instance instance int the 'mdl_{type}' table" + * @param string $type name of the table + * + * @return object the id of the module + */ protected function get_module_id($instance, $type) { @@ -1246,6 +1202,14 @@ abstract class report return $id; } + + /** + * Get the modules accessed for each day of the specified week and for the current user + * + * @param object $work_sessions informations containing the sessions and the logs of the current user + * + * @return object modules accessed for each week + */ protected function get_modules_days_worked($work_sessions) { $days_worked = array( @@ -1288,7 +1252,14 @@ abstract class report } return $days_worked; } - + + /** + * Get the modules planned for each day of the specified week for the current user + * + * @param string $weekcode code of the week specified + * + * @return object the modules planned for each day of the specified week + */ protected function get_modules_days_planned($weekcode) { $days_planned = array( @@ -1307,14 +1278,29 @@ abstract class report return $days_planned; } + + /** + * Get the notemyprogress_days_modules ids, the course module ids and the days description for a specified week. + * + * @param string $weekcode code of the week specified + * + * @return object the notemyprogress_days_modules ids, the course module ids and the days description + */ protected function get_modules_days_by_week($weekcode) { global $DB; - $sql = "select dm.id, dm.id_course_modules cmid, d.description daydesc from {notemyprogress_days_modules} dm,{notemyprogress_days} d, {st_rpt_weekly_schedules} ws where dm.id_days = d.id and d.id_weekly_schedules = ws.id and ws.weekcode = ? and ws.userid = ? "; + $sql = "select dm.id, dm.id_course_modules cmid, dm.day_description daydesc from {notemyprogress_days_modules} dm, {notemyprogress_wk} ws where dm.id_weekly_schedules = ws.id and ws.weekcode = ? and ws.userid = ? "; $mods_weeks = $DB->get_records_sql($sql, array($weekcode,$this->user->id)); return $mods_weeks; } + /** + * Give the index of the day string specified + * + * @param object $day day specified + * + * @return object the index of the day string specified + */ protected function get_num_day($day){ if ($day == "monday" ){ return 1; @@ -1339,11 +1325,18 @@ abstract class report } } - + /** + * Get an array containing the status (planned,pending,failed,completed) of each day of the specified week + * + * @param object $planifications informations about the days planned and the days worked + * @param object $week week specified + * + * @return array array containing the status of each day of the specified week + */ protected function get_respect_planning($planifications,$week) { - $days_module_planned = $planifications->dias_planificados; - $days_module_worked = $planifications->dias_trabajados; + $days_module_planned = $planifications->days_planned; + $days_module_worked = $planifications->days_worked; $status = []; $weekstart = $week->weekstart; $current_time = time(); @@ -1367,107 +1360,13 @@ abstract class report return $status; } - - protected function number_schedules_day_log($work_sessions) - { - $count_days_log = new stdClass(); - $count_days_log->lun = 0; - $count_days_log->mar = 0; - $count_days_log->mie = 0; - $count_days_log->jue = 0; - $count_days_log->vie = 0; - $count_days_log->sab = 0; - $count_days_log->dom = 0; - foreach ($work_sessions as $key => $work_session) { - $lun_status = false; - $mar_status = false; - $mie_status = false; - $jue_status = false; - $vie_status = false; - $sab_status = false; - $dom_status = false; - foreach ($work_session->sessions as $key => $session) { - $day = self::day_week($session->end); - switch ($day) { - case 'lun': - if (!$lun_status) { - $count_days_log->lun++; - $lun_status = true; - } - break; - case 'mar': - if (!$mar_status) { - $count_days_log->mar++; - $mar_status = true; - } - break; - case 'mie': - if (!$mie_status) { - $count_days_log->mie++; - $mie_status = true; - } - break; - case 'jue': - if (!$jue_status) { - $count_days_log->jue++; - $jue_status = true; - } - break; - case 'vie': - if (!$vie_status) { - $count_days_log->vie++; - $vie_status = true; - } - break; - case 'sab': - if (!$sab_status) { - $count_days_log->sab++; - $sab_status = true; - } - break; - case 'dom': - if (!$dom_status) { - $count_days_log->dom++; - $dom_status = true; - } - break; - } - } - } - $data_days = array(); - foreach (array_values((array)$count_days_log) as $key => $value) { - array_push($data_days, $value); - } - return $data_days; - } - - protected function day_week($fecha) - { - switch (date('w', $fecha)) { - case 1: - return "lun"; - break; - case 2: - return "mar"; - break; - case 3: - return "mie"; - break; - case 4: - return "jue"; - break; - case 5: - return "vie"; - break; - case 6: - return "sab"; - break; - case 7: - return "dom"; - break; - } - } - + /** + * Get the goals selected for a specific week + * + * @param string $weekcode code of the week specified + * + * @return array the goals selected for a specific week + */ public function goals_report_metereflexion($weekcode = null) { if (!self::course_in_transit()) { @@ -1489,10 +1388,17 @@ abstract class report return $query_goals; } + /** + * Get the goals selected for a specific week + * + * @param string $weekcode code of the week specified + * + * @return array the goals selected for a specific week + */ public function get_goals_id($week_schedule) { global $DB; - $sql = "select g.id_goals_categories from {notemyprogress_goals} g,{st_rpt_weekly_schedules} ws where g.id_weekly_schedules = ws.id and g.id_weekly_schedules = ? and ws.userid = ? "; + $sql = "select g.id_goals_categories from {notemyprogress_goals} g,{notemyprogress_wk} ws where g.id_weekly_schedules = ws.id and g.id_weekly_schedules = ? and ws.userid = ? "; $goals_res = array_values($DB->get_records_sql($sql, array($week_schedule->id,$this->user->id))); $arr_goal = []; foreach($goals_res as $key=>$id_obj){ @@ -1501,7 +1407,13 @@ abstract class report return $arr_goal; } - + /** + * Get informations about the hours planned and worked by the user for a specific week + * + * @param string $weekcode code of the week specified + * + * @return object informations about the hours planned and worked + */ public function hours_report_metereflexion($weekcode = null) { if (!self::course_in_transit()) { @@ -1536,7 +1448,7 @@ abstract class report $sum_hours_per_week = self::planned_week($weekcode); $data_report_meta_hours = new stdClass(); - $data_report_meta_hours->title = 'Tiempo invertido'; + $data_report_meta_hours->title = 'Time invested'; $data_report_meta_hours->hours_worked = $sum_hours_work; $data_report_meta_hours->label_hours_worked = $label_horas; $data_report_meta_hours->hours_planned = $sum_hours_per_week != null ? $sum_hours_per_week : 0 ; @@ -1546,6 +1458,13 @@ abstract class report return $data_report_meta_hours; } + /** + * Get the hours planned for a specific week + * + * @param string $weekcode code of the week specified + * + * @return string hours planned for a specific week + */ protected function planned_week($weekcode = null) { $week = $this->current_week; @@ -1557,14 +1476,21 @@ abstract class report return 0; } list($in, $invalues) = $DB->get_in_or_equal($this->users); - $sql = "select * from {st_rpt_weekly_schedules} where weekcode = ? and userid $in"; + $sql = "select * from {notemyprogress_wk} where weekcode = ? and userid $in"; $params = array_merge(array($week->weekcode), $invalues); $week_schedules = $DB->get_records_sql($sql, $params); $result = self::calculate_average("hours", $week_schedules); $result = $result->average; return $result; } - + + /** + * Get the hours planned for a specific week + * + * @param string $weekcode code of the week specified + * + * @return string hours planned for a specific week + */ public function classroom_report_metareflexion($weekcode = null) { if (!self::course_in_transit()) { @@ -1600,7 +1526,7 @@ abstract class report } list($in, $invalues) = $DB->get_in_or_equal($this->users); - $sql = "select * from {st_rpt_work_last_weeks} where weekcode = ? and userid $in"; + $sql = "select * from {notemyprogress_last_weeks} where weekcode = ? and userid $in"; $params = array_merge(array($week->weekcode), $invalues); $presence_clases = $DB->get_records_sql($sql, $params); @@ -1630,7 +1556,7 @@ abstract class report } list($in, $invalues) = $DB->get_in_or_equal($this->users); - $sql = "select * from {st_rpt_work_last_weeks} where weekcode = ? and userid $in"; + $sql = "select * from {notemyprogress_last_weeks} where weekcode = ? and userid $in"; $params = array_merge(array($week->weekcode), $invalues); $presence_clases = $DB->get_records_sql($sql, $params); @@ -1648,6 +1574,13 @@ abstract class report return $average_horas_presence_clases; } + /** + * Get reflection questions of the week specified + * + * @param string $weekcode code of the week specified + * + * @return object reflection questions of the week specified + */ public function report_last_week($weekcode = null) { if (!self::course_in_transit()) { @@ -1665,15 +1598,31 @@ abstract class report return $work; } + + /** + * Get questions from the notemyprogress_questions table for a specific week + * + * @param object $week code of the week specified + * + * @return object questions from the notemyprogress_questions table + */ private function get_work_last_week($week) { global $DB; - $sql = "select * from {st_rpt_questions}"; + $sql = "select * from {notemyprogress_questions}"; $questions = $DB->get_records_sql($sql); $questions = self::add_question_alternatives($questions, $week); return $questions; } - + + /** + * Add possible answers to the questions structure for a specific week + * + * @param object $questions question structure + * @param object $week specified week + * + * @return object questions with possible answers + */ private function add_question_alternatives($questions, $week) { global $DB; @@ -1688,8 +1637,8 @@ abstract class report array_push($params, $week->weekcode); $params = array_merge($params, $invalues); array_push($params, $question->id); - $sql = "select a.*, (select count(*) from {st_rpt_work_last_weeks} where weekcode = ? and userid $in and (previous_class_learning = a.id or benefit_going_class = a.id)) as count_selections - from {st_rpt_answers} a where a.questionid = ?"; + $sql = "select a.*, (select count(*) from {notemyprogress_last_weeks} where weekcode = ? and userid $in and (objectives_reached = a.id or previous_class_learning = a.id or benefit_going_class = a.id or feeling = a.id)) as count_selections + from {notemyprogress_answers} a where a.questionid = ?"; $answers = $DB->get_records_sql($sql, $params); foreach ($answers as $key => $answer) { $answer->enunciated = get_string($answer->enunciated, "local_notemyprogress"); @@ -1698,4 +1647,107 @@ abstract class report } return $questions; } + + + //////// Old functions : was used to make a planning based on the interactions on each day of the week (not the completion of planned modules) ////////// + + /** + * Get statistics about the progression of the students for a specific week + * + * @param string $weekcode code of the week + * + * @return array an array with statistics about the progression of the students + */ + public function students_planification_summary($weekcode = null) + { + if (!self::course_in_transit()) { + return null; + } + if (!self::course_has_users()) { + return null; + } + $week = $this->current_week; + if (!empty($weekcode)) { + $week = self::find_week($weekcode); + } + $schedule = self::get_schedule($week->weekcode); + $worked_sessions = self::get_work_sessions($week->weekstart, $week->weekend); + $summary = self::verify_students_planifications($worked_sessions, $schedule); + $summary = self::summary_process($summary); + return $summary; + } + + /** + * Get the percentage of courses comleted among the courses planned by day + * + * @param object $days statistics on module completion + * + * @return object an object with statistics about the progression of the courses completed + */ + private function summary_process($days) + { + file_put_contents('D:\Alexis\Stage_IRIT\NMP\debug\log.txt', print_r($days, TRUE) . "\r\n"); + foreach ($days as $day) { + $day->percentage = 0; + $day->count_students = count($day->students); + if ($day->count_planned > 0) { + $day->percentage = round(($day->count_accomplished * 100 / $day->count_planned), 1); + } + } + return $days; + } + + /** + * Get the percentage of courses comleted among the courses planned by day + * + * @param object $worked_sessions sessions of the week + * @param object $planifications schedule informations + * + * @return object an object with statistics about the progression of courses completed + */ + private function verify_students_planifications($worked_sessions, $planifications) + { + $worked_sessions = self::update_array_key_by('userid', $worked_sessions); + $summary = self::create_planifications_week_summary(); + foreach ($planifications as $planification) { + $days = explode(',', $planification->days); + foreach ($days as $day) { + if (!in_array($planification->userid, $summary[$day]->students)) { + $summary[$day]->count_planned++; + if (self::planned_accomplished($day, $planification->userid, $worked_sessions)) { + $summary[$day]->count_accomplished++; + } + array_push($summary[$day]->students, $planification->userid); + } + } + } + return $summary; + } + + + /** + * Returns if the day is completed or not + * + * @param object $day day specified + * @param string $userid id of the user + * @param object $course_sessions sessions of the course + * + * @return boolean if the day is completed or not + */ + private function planned_accomplished($day, $userid, $course_sessions) + { + $tz = self::get_timezone(); + date_default_timezone_set($tz); + $accomplished = false; + if (isset($course_sessions[$userid])) { + $user_sessions = $course_sessions[$userid]; + foreach ($user_sessions->sessions as $session) { + if (self::day_to_english($day) == strtolower(date('D', $session->start))) { + $accomplished = true; + break; + } + } + } + return $accomplished; + } } diff --git a/notemyprogress/db/install.php b/notemyprogress/db/install.php index f882841f9cfe0e75e5d38600b0e4a8b731ad7789..2b8a121e78cf689ca7a4f13142cb9fc22d3788e7 100644 --- a/notemyprogress/db/install.php +++ b/notemyprogress/db/install.php @@ -42,118 +42,103 @@ function xmldb_local_notemyprogress_install() $DB->insert_record("notemyprogress_goals_ct", $goal2, true); $DB->insert_record("notemyprogress_goals_ct", $goal3, true); - //Create questions - $question1 = new stdClass(); - $question2 = new stdClass(); - $question3 = new stdClass(); - $question4 = new stdClass(); - $question1->description = "question1"; - $question2->description = "question2"; - $question3->description = "question3"; - $question4->description = "question3"; - $DB->insert_record("notemyprogress_questions_ct", $question1, true); - $DB->insert_record("notemyprogress_questions_ct", $question2, true); - $DB->insert_record("notemyprogress_questions_ct", $question3, true); - $DB->insert_record("notemyprogress_questions_ct", $question4, true); - - //Question 1 $question = new stdClass(); $question->enunciated = 'question_number_one'; - $questionid = $DB->insert_record("st_rpt_questions", $question, true); + $questionid = $DB->insert_record("notemyprogress_questions", $question, true); $answer = new stdClass(); $answer->questionid = $questionid; $answer->enunciated = 'answers_number_one_option_one'; - $DB->insert_record("st_rpt_answers", $answer, true); + $DB->insert_record("notemyprogress_answers", $answer, true); $answer = new stdClass(); $answer->questionid = $questionid; $answer->enunciated = 'answers_number_one_option_two'; - $DB->insert_record("st_rpt_answers", $answer, true); + $DB->insert_record("notemyprogress_answers", $answer, true); //Question 2 $question = new stdClass(); $question->enunciated = 'question_number_two'; - $questionid = $DB->insert_record("st_rpt_questions", $question, true); + $questionid = $DB->insert_record("notemyprogress_questions", $question, true); $answer = new stdClass(); $answer->questionid = $questionid; $answer->enunciated = 'answers_number_two_option_one'; - $DB->insert_record("st_rpt_answers", $answer, true); + $DB->insert_record("notemyprogress_answers", $answer, true); $answer = new stdClass(); $answer->questionid = $questionid; $answer->enunciated = 'answers_number_two_option_two'; - $DB->insert_record("st_rpt_answers", $answer, true); + $DB->insert_record("notemyprogress_answers", $answer, true); $answer = new stdClass(); $answer->questionid = $questionid; $answer->enunciated = 'answers_number_two_option_three'; - $DB->insert_record("st_rpt_answers", $answer, true); + $DB->insert_record("notemyprogress_answers", $answer, true); //Question 3 $question = new stdClass(); $question->enunciated = 'question_number_three'; - $questionid = $DB->insert_record("st_rpt_questions", $question, true); + $questionid = $DB->insert_record("notemyprogress_questions", $question, true); $answer = new stdClass(); $answer->questionid = $questionid; $answer->enunciated = 'answers_number_three_option_one'; - $DB->insert_record("st_rpt_answers", $answer, true); + $DB->insert_record("notemyprogress_answers", $answer, true); $answer = new stdClass(); $answer->questionid = $questionid; $answer->enunciated = 'answers_number_three_option_two'; - $DB->insert_record("st_rpt_answers", $answer, true); + $DB->insert_record("notemyprogress_answers", $answer, true); $answer = new stdClass(); $answer->questionid = $questionid; $answer->enunciated = 'answers_number_three_option_three'; - $DB->insert_record("st_rpt_answers", $answer, true); + $DB->insert_record("notemyprogress_answers", $answer, true); $answer = new stdClass(); $answer->questionid = $questionid; $answer->enunciated = 'answers_number_three_option_four'; - $DB->insert_record("st_rpt_answers", $answer, true); + $DB->insert_record("notemyprogress_answers", $answer, true); $answer = new stdClass(); $answer->questionid = $questionid; $answer->enunciated = 'answers_number_three_option_five'; - $DB->insert_record("st_rpt_answers", $answer, true); + $DB->insert_record("notemyprogress_answers", $answer, true); $answer = new stdClass(); $answer->questionid = $questionid; $answer->enunciated = 'answers_number_three_option_six'; - $DB->insert_record("st_rpt_answers", $answer, true); + $DB->insert_record("notemyprogress_answers", $answer, true); //Question 4 $question = new stdClass(); $question->enunciated = 'question_number_four'; - $questionid = $DB->insert_record("st_rpt_questions", $question, true); + $questionid = $DB->insert_record("notemyprogress_questions", $question, true); $answer = new stdClass(); $answer->questionid = $questionid; $answer->enunciated = 'answers_number_four_option_one'; - $DB->insert_record("st_rpt_answers", $answer, true); + $DB->insert_record("notemyprogress_answers", $answer, true); $answer = new stdClass(); $answer->questionid = $questionid; $answer->enunciated = 'answers_number_four_option_two'; - $DB->insert_record("st_rpt_answers", $answer, true); + $DB->insert_record("notemyprogress_answers", $answer, true); $answer = new stdClass(); $answer->questionid = $questionid; $answer->enunciated = 'answers_number_four_option_three'; - $DB->insert_record("st_rpt_answers", $answer, true); + $DB->insert_record("notemyprogress_answers", $answer, true); $answer = new stdClass(); $answer->questionid = $questionid; $answer->enunciated = 'answers_number_four_option_four'; - $DB->insert_record("st_rpt_answers", $answer, true); + $DB->insert_record("notemyprogress_answers", $answer, true); } \ No newline at end of file diff --git a/notemyprogress/db/install.xml b/notemyprogress/db/install.xml index 61b51441ca44979aba5fbd8a5477ee631f2183e9..717619297c41d4b1cf15298b14f8fb7e2bbc4634 100644 --- a/notemyprogress/db/install.xml +++ b/notemyprogress/db/install.xml @@ -36,7 +36,7 @@ <INDEX NAME="instanceid" UNIQUE="false" FIELDS="instanceid" HINTS="instanceid" COMMENT="instanceid index"/> </INDEXES> </TABLE> - <TABLE NAME="st_rpt_weekly_schedules" COMMENT="table st_rpt_weekly_schedules"> + <TABLE NAME="notemyprogress_wk" COMMENT="table notemyprogress_wk"> <FIELDS> <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/> <FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/> @@ -49,7 +49,7 @@ <KEY NAME="primary" TYPE="primary" FIELDS="id"/> </KEYS> </TABLE> - <TABLE NAME="st_rpt_work_last_weeks" COMMENT="table st_rpt_work_last_weeks"> + <TABLE NAME="notemyprogress_last_weeks" COMMENT="table notemyprogress_last_weeks"> <FIELDS> <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/> <FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/> @@ -84,45 +84,13 @@ <KEY NAME="primary" TYPE="primary" FIELDS="id"/> </KEYS> </TABLE> - <TABLE NAME="notemyprogress_questions" COMMENT="table notemyprogress_questions"> - <FIELDS> - <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/> - <FIELD NAME="id_questions_categories" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/> - <FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/> - <FIELD NAME="weekcode" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/> - <FIELD NAME="answer" TYPE="char" LENGTH="1333" NOTNULL="true" SEQUENCE="false"/> - <FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/> - <FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false"/> - </FIELDS> - <KEYS> - <KEY NAME="primary" TYPE="primary" FIELDS="id"/> - </KEYS> - </TABLE> - <TABLE NAME="notemyprogress_questions_ct" COMMENT="table notemyprogress_questions_ct"> - <FIELDS> - <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/> - <FIELD NAME="description" TYPE="char" LENGTH="1333" NOTNULL="true" SEQUENCE="false"/> - </FIELDS> - <KEYS> - <KEY NAME="primary" TYPE="primary" FIELDS="id"/> - </KEYS> - </TABLE> - <TABLE NAME="notemyprogress_days" COMMENT="table notemyprogress_days"> - <FIELDS> - <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/> - <FIELD NAME="id_weekly_schedules" TYPE="int" LENGTH="20" NOTNULL="true" SEQUENCE="false"/> - <FIELD NAME="description" TYPE="char" LENGTH="1333" NOTNULL="true" SEQUENCE="false"/> - </FIELDS> - <KEYS> - <KEY NAME="primary" TYPE="primary" FIELDS="id"/> - </KEYS> - </TABLE> <TABLE NAME="notemyprogress_days_modules" COMMENT="table notemyprogress_days_modules"> <FIELDS> <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/> <FIELD NAME="id_course_modules" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/> - <FIELD NAME="id_days" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/> + <FIELD NAME="id_weekly_schedules" TYPE="int" LENGTH="20" NOTNULL="true" SEQUENCE="false"/> + <FIELD NAME="day_description" TYPE="char" LENGTH="1333" NOTNULL="true" SEQUENCE="false"/> </FIELDS> <KEYS> <KEY NAME="primary" TYPE="primary" FIELDS="id"/> @@ -130,7 +98,7 @@ </TABLE> - <TABLE NAME="st_rpt_questions" COMMENT="table st_rpt_questions"> + <TABLE NAME="notemyprogress_questions" COMMENT="table notemyprogress_questions"> <FIELDS> <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/> <FIELD NAME="enunciated" TYPE="char" LENGTH="1333" NOTNULL="true" SEQUENCE="false"/> @@ -139,7 +107,7 @@ <KEY NAME="primary" TYPE="primary" FIELDS="id"/> </KEYS> </TABLE> - <TABLE NAME="st_rpt_answers" COMMENT="table st_rpt_answers"> + <TABLE NAME="notemyprogress_answers" COMMENT="table notemyprogress_answers"> <FIELDS> <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/> <FIELD NAME="questionid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/> diff --git a/notemyprogress/lang/en/local_notemyprogress.php b/notemyprogress/lang/en/local_notemyprogress.php index 9180c8f4db7091658fb591f991985697d3b6d99e..46e9955c58596acd9efb5a600b4b23f0fbfd0e12 100644 --- a/notemyprogress/lang/en/local_notemyprogress.php +++ b/notemyprogress/lang/en/local_notemyprogress.php @@ -1099,6 +1099,8 @@ $string['group_allstudent'] = "All students"; $string['nmp_use_navbar_menu'] = 'Activate new menu'; $string['nmp_use_navbar_menu_desc'] = 'Display the plugin menu in the top navigation bar, otherwise it will include the menu in the navigation block.'; /* Gamification */ +$string['tg_tab1']="Chart"; +$string['tg_tab2']="Ranking"; $string['EnableGame']="Disable/Enable :"; $string['studentRanking1']="Do you want to appear in the Ranking Board ?"; $string['studentRanking2']=" /!\ All the registered in this course having accepted you will see. Accepting is final:"; diff --git a/notemyprogress/lang/es/local_notemyprogress.php b/notemyprogress/lang/es/local_notemyprogress.php index 5157e0d089db112fb5b66a6fc51c95f4d7a46bb4..94e166b7b7211d3f28ba169c142d1cd6479ef0ed 100644 --- a/notemyprogress/lang/es/local_notemyprogress.php +++ b/notemyprogress/lang/es/local_notemyprogress.php @@ -1099,6 +1099,8 @@ $string['group_allstudent'] = 'Todos los estudiantes'; $string['nmp_use_navbar_menu'] = 'Habilitar nuevo menú'; $string['nmp_use_navbar_menu_desc'] = 'Despliega el menú del plugin en la barra de navegación superior, del contrario incluirá el menú en el bloque de navegación.'; /* Gamification */ +$string['tg_tab1']="Cuadro"; +$string['tg_tab2']="Clasificación"; $string['EnableGame']="Desactivar/Activar :"; $string['studentRanking1']="¿Quieres aparecer en el ranking ? "; $string['studentRanking2']="/!\ Te verán todos los inscritos en este curso que hayan aceptado. Aceptar es definitivo: "; diff --git a/notemyprogress/lang/fr/local_notemyprogress.php b/notemyprogress/lang/fr/local_notemyprogress.php index 25080a1748217fc3e94731b842c08476837356c0..d92153eb5d091a8bd395582455874723722163ce 100644 --- a/notemyprogress/lang/fr/local_notemyprogress.php +++ b/notemyprogress/lang/fr/local_notemyprogress.php @@ -1101,6 +1101,8 @@ $string['nmp_use_navbar_menu'] = 'Activer le nouveau menu'; $string['nmp_use_navbar_menu_desc'] = 'Afficher le menu du plugin dans la barre de navigation supérieure, sinon il inclura le menu dans le bloc de navigation.'; /* Gamification */ +$string['tg_tab1']="Répartition"; +$string['tg_tab2']="Classement"; $string['EnableGame']="Désactiver/Activer :"; $string['studentRanking1']="Voulez vous apparaitre dans le ranking board ? "; $string['studentRanking2']= "/!\ Tout les inscrits à ce cours ayant accepté vous verrons. Accepter est définitif:"; diff --git a/notemyprogress/lib.php b/notemyprogress/lib.php index 95b9ec7190073768af2252440527173e46a58c7d..ef55353de6638ba0f009fb681fdb077981c55336 100644 --- a/notemyprogress/lib.php +++ b/notemyprogress/lib.php @@ -114,11 +114,11 @@ function local_notemyprogress_render_navbar_output(\renderer_base $renderer) array_push($items, local_notemyprogress_new_menu_item(s($text), $url)); } - if (has_capability('local/notemyprogress:teacher_planning', $context) && $configuration_is_set) { - $text = get_string('menu_planning', 'local_notemyprogress'); - $url = new moodle_url('/local/notemyprogress/metareflexion.php?courseid=' . $COURSE->id); - array_push($items, local_notemyprogress_new_menu_item(s($text), $url)); - } + // if (has_capability('local/notemyprogress:teacher_planning', $context) && $configuration_is_set) { + // $text = get_string('menu_planning', 'local_notemyprogress'); + // $url = new moodle_url('/local/notemyprogress/metareflexion.php?courseid=' . $COURSE->id); + // array_push($items, local_notemyprogress_new_menu_item(s($text), $url)); + // } if (has_capability('local/notemyprogress:student_planning', $context) && !is_siteadmin() && $configuration_is_set) { $text = get_string('menu_planning', 'local_notemyprogress'); diff --git a/notemyprogress/metareflexion.php b/notemyprogress/metareflexion.php index cdf73d07a45f874d5d0cbf57bb2f613d295eed4a..d124f0d9c40b65a4423eb98623eb6634fac949f6 100644 --- a/notemyprogress/metareflexion.php +++ b/notemyprogress/metareflexion.php @@ -214,7 +214,6 @@ $content = [ 'calendar_icon' => "{$CFG->wwwroot}/local/notemyprogress/img/calendar.png", 'inverted_time_colors' => array('#118AB2', '#118AB2', '#06D6A0'), 'sessions_count_colors' => array('#FFD166', '#06D6A0', '#118AB2'), - //'students_planification' => $reports->students_planification_summary(), //Classroom UNUSED //'data_report_classroom' => $reports->classroom_report_metareflexion(), diff --git a/notemyprogress/student_gamification.php b/notemyprogress/student_gamification.php index cbdf5159391176d6d031400911396b7187b5b6d1..14542d24578daf44f2ab0e7fd27a1d280b0b6fdd 100644 --- a/notemyprogress/student_gamification.php +++ b/notemyprogress/student_gamification.php @@ -76,11 +76,17 @@ $content = [ 'studentRanking2'=>get_string("studentRanking2","local_notemyprogress"), 'studentRanking3'=>get_string("studentRanking3","local_notemyprogress"), 'overview'=>get_string("overview","local_notemyprogress"), + 'chartTitle'=>get_string("gm_Chart_Title","local_notemyprogress"), + 'chartYaxis'=>get_string("gm_Chart_Y","local_notemyprogress"), + 'chart_data' => $configgamification->get_spread_chart($courseid), + 'tg_tab1'=> get_string("tg_tab1","local_notemyprogress"), + 'tg_tab2' =>get_string("tg_tab2","local_notemyprogress") ], 'levels_data' => $configgamification->get_levels_data(), 'indicators' => $es->get_user_info(), 'ranking' => $es->get_ranking(1), + ]; $templatecontext = [ diff --git a/notemyprogress/templates/gamification.mustache b/notemyprogress/templates/gamification.mustache index da85c84fce866f04f705a2d0b10c88f44435ba57..799c17357f7338031fcdd7d678b570c7f28ee9bc 100644 --- a/notemyprogress/templates/gamification.mustache +++ b/notemyprogress/templates/gamification.mustache @@ -248,6 +248,7 @@ :chart="chart_spread()" :lang="strings.chart" ></chart> + </v-card> </v-row> </v-col> </v-row> diff --git a/notemyprogress/templates/student_gamification.mustache b/notemyprogress/templates/student_gamification.mustache index e464216de1cc646ed7a5d23197bbb90db37e66a2..a7a052019e528d569a361afe606c3fdebbeea2d9 100644 --- a/notemyprogress/templates/student_gamification.mustache +++ b/notemyprogress/templates/student_gamification.mustache @@ -82,6 +82,23 @@ </v-col> </v-col> <v-col cols=12 lg="6"> + <v-tabs v-model="tab" background-color="transparent"> + <v-tab v-text="strings.tg_tab1"></v-tab> + <v-tab v-text="strings.tg_tab2"></v-tab> + </v-tabs> + <v-tabs-items v-model="tab"> + <v-tab-item> + <v-row class =" justify-center"> + <v-card elevation = 2 id="SpreadChart"> + <chart + :container="'week_resourcess'" + :chart="chart_spread()" + :lang="strings.chart" + ></chart> + </v-card> + </v-row> + </v-tab-item> + <v-tab-item> <!-- Level and settings --> <v-row v-if="strings.rankable"class="py-5 px-8"> <v-col cols="12" md="12"> <v-data-table @@ -152,6 +169,7 @@ </v-card-actions> </v-card> </v-row> + </v-tab-item> </v-col> </v-row> </v-card>