Minor - Fix flint/psalm checks

pull/3543/head
Julio Montoya 4 years ago
parent 68c9e3a645
commit 41516e4e1a
  1. 12
      public/main/extra/myStudents.php
  2. 2
      public/main/gradebook/lib/be/attendancelink.class.php
  3. 38
      public/main/inc/lib/attendance.lib.php
  4. 4
      public/main/mySpace/myStudents.php
  5. 5
      public/plugin/dashboard/block_student/block_student.class.php
  6. 4
      public/plugin/dashboard/block_student_graph/block_student_graph.class.php

@ -737,7 +737,7 @@ if (!empty($studentId)) {
'<a title="'.get_lang('Go to attendances').'" href="'.api_get_path(
WEB_CODE_PATH
).'attendance/index.php?cidReq='.$courseCodeItem.'&id_session='.$sId.'&student_id='.$studentId.'">'.
$results_faults_avg['faults'].'/'.$results_faults_avg['total'].' ('.$results_faults_avg['porcent'].'%)</a>';
$results_faults_avg['faults'].'/'.$results_faults_avg['total'].' ('.$results_faults_avg['percent'].'%)</a>';
} else {
$attendances_faults_avg =
$results_faults_avg['faults'].'/'.
@ -1878,11 +1878,13 @@ if (empty($_GET['details'])) {
);
if (!empty($results_faults_avg['total'])) {
if (api_is_drh()) {
$attendances_faults_avg = '<a title="'.get_lang('Go to attendances').'" href="'.api_get_path(
WEB_CODE_PATH
).'attendance/index.php?cidReq='.$course_code.'&id_session='.$session_id.'&student_id='.$studentId.'">'.$results_faults_avg['faults'].'/'.$results_faults_avg['total'].' ('.$results_faults_avg['porcent'].'%)</a>';
$attendances_faults_avg =
'<a title="'.get_lang('Go to attendances').'" href="'.api_get_path(WEB_CODE_PATH).
'attendance/index.php?cidReq='.$course_code.'&id_session='.$session_id.'&student_id='.$studentId.'">'.
$results_faults_avg['faults'].'/'.$results_faults_avg['total'].' ('.$results_faults_avg['porcent'].'%)</a>';
} else {
$attendances_faults_avg = $results_faults_avg['faults'].'/'.$results_faults_avg['total'].' ('.$results_faults_avg['porcent'].'%)';
$attendances_faults_avg = $results_faults_avg['faults'].'/'.$results_faults_avg['total'].
' ('.$results_faults_avg['percent'].'%)';
}
} else {
$attendances_faults_avg = '0/0 (0%)';

@ -145,7 +145,7 @@ class AttendanceLink extends AbstractLink
if (!(array_key_exists($data['user_id'], $students))) {
if (0 != $attendance['attendance_qualify_max']) {
$students[$data['user_id']] = $data['score'];
++$rescount;
$rescount++;
$sum += $data['score'] / $attendance['attendance_qualify_max'];
$sumResult += $data['score'];
if ($data['score'] > $bestResult) {

@ -1105,17 +1105,18 @@ class Attendance
//$course_info = api_get_course_info($course_code);
$course_id = $course['real_id'];
$tbl_attendance_result = Database::get_course_table(TABLE_ATTENDANCE_RESULT);
$attendances_by_course = $this->get_attendances_list($course_id);
$attendances = $this->get_attendances_list($course_id);
foreach ($attendances_by_course as $attendance) {
foreach ($attendances as $attendance) {
$attendanceId = $attendance->getIid();
// get total faults and total weight
$total_done_attendance = $attendance['attendance_qualify_max'];
$total_done_attendance = $attendance->getAttendanceQualifyMax();
$sql = "SELECT score
FROM $tbl_attendance_result
WHERE
c_id = $course_id AND
user_id = $user_id AND
attendance_id = ".$attendance['iid'];
attendance_id = ".$attendanceId;
$rs = Database::query($sql);
$score = 0;
if (Database::num_rows($rs) > 0) {
@ -1129,10 +1130,10 @@ class Attendance
}
}
$porcent = $total_weight > 0 ? round(($total_faults * 100) / $total_weight, 0) : 0;
$percent = $total_weight > 0 ? round(($total_faults * 100) / $total_weight, 0) : 0;
$results['faults'] = $total_faults;
$results['total'] = $total_weight;
$results['porcent'] = $porcent;
$results['percent'] = $percent;
return $results;
}
@ -1145,32 +1146,27 @@ class Attendance
* @param int Session id (optional)
*
* @return array results containing number of faults,
* total done attendance, porcent of faults and color depend on result (red, orange)
* total done attendance, percent of faults and color depend on result (red, orange)
*/
public function get_faults_average_by_course(
$user_id,
$course_code,
$session_id = null
) {
public function get_faults_average_by_course($user_id, $course_code, $session_id = null)
{
// Database tables and variables
$course_info = api_get_course_info($course_code);
$tbl_attendance_result = Database::get_course_table(TABLE_ATTENDANCE_RESULT);
$user_id = (int) $user_id;
$results = [];
$total_faults = $total_weight = $porcent = 0;
$attendances_by_course = $this->get_attendances_list(
$course_info['real_id'],
$session_id
);
$attendances = $this->get_attendances_list($course_info['real_id'], $session_id);
foreach ($attendances_by_course as $attendance) {
foreach ($attendances as $attendance) {
$attendanceId = $attendance->getIid();
// Get total faults and total weight
$total_done_attendance = $attendance['attendance_qualify_max'];
$total_done_attendance = $attendance->getAttendanceQualifyMax();
$sql = "SELECT score FROM $tbl_attendance_result
WHERE
c_id = {$course_info['real_id']} AND
user_id = $user_id AND
attendance_id=".$attendance['iid'];
attendance_id=".$attendanceId;
$rs = Database::query($sql);
$score = 0;
if (Database::num_rows($rs) > 0) {
@ -1183,10 +1179,10 @@ class Attendance
$total_weight += $total_done_attendance;
}
$porcent = $total_weight > 0 ? round(($total_faults * 100) / $total_weight, 0) : 0;
$percent = $total_weight > 0 ? round(($total_faults * 100) / $total_weight, 0) : 0;
$results['faults'] = $total_faults;
$results['total'] = $total_weight;
$results['porcent'] = $porcent;
$results['percent'] = $percent;
return $results;
}

@ -1280,11 +1280,11 @@ if (empty($details)) {
.'attendance/index.php?cidReq='.$courseCodeItem.'&id_session='.$sId.'&student_id='
.$studentId.'">'
.$results_faults_avg['faults'].'/'.$results_faults_avg['total'].' ('
.$results_faults_avg['porcent'].'%)</a>';
.$results_faults_avg['percent'].'%)</a>';
} else {
$attendances_faults_avg = $results_faults_avg['faults'].'/'
.$results_faults_avg['total']
.' ('.$results_faults_avg['porcent'].'%)';
.' ('.$results_faults_avg['percent'].'%)';
}
$totalAttendance[0] += $results_faults_avg['faults'];
$totalAttendance[1] += $results_faults_avg['total'];

@ -166,7 +166,10 @@ class BlockStudent extends Block
// get average of faults in attendances by student
$results_faults_avg = $attendance->get_faults_average_inside_courses($student_id);
if (!empty($results_faults_avg)) {
$attendances_faults_avg = '<a title="'.get_lang('Go to learner details').'" href="'.api_get_path(WEB_CODE_PATH).'mySpace/myStudents.php?student='.$student_id.'">'.$results_faults_avg['faults'].'/'.$results_faults_avg['total'].' ('.$results_faults_avg['porcent'].'%)</a>';
$attendances_faults_avg = '<a
title="'.get_lang('Go to learner details').'"
href="'.api_get_path(WEB_CODE_PATH).'mySpace/myStudents.php?student='.$student_id.'">'.
$results_faults_avg['faults'].'/'.$results_faults_avg['total'].' ('.$results_faults_avg['percent'].'%)</a>';
} else {
$attendances_faults_avg = '0%';
}

@ -97,12 +97,10 @@ class BlockStudentGraph extends Block
if (is_array($students) && count($students) > 0) {
foreach ($students as $student) {
$student_id = $student['user_id'];
//$student_info = api_get_user_info($student_id);
// get average of faults in attendances by student
$results_faults_avg = $attendance->get_faults_average_inside_courses($student_id);
if (!empty($results_faults_avg)) {
$attendances_faults_avg[$student['lastname']] = $results_faults_avg['porcent'];
$attendances_faults_avg[$student['lastname']] = $results_faults_avg['percent'];
} else {
$attendances_faults_avg[$student['lastname']] = 0;
}

Loading…
Cancel
Save