diff --git a/composer.json b/composer.json index 29ed1f2f86..f3a90dcd5f 100755 --- a/composer.json +++ b/composer.json @@ -58,7 +58,6 @@ "ext-zip": "*", "ext-zlib": "*", "a2lix/translation-form-bundle": "^3.0", - "stof/doctrine-extensions-bundle": "~1.4", "api-platform/api-pack": "^1.2", "beberlei/doctrineextensions": "^1.2", "brumann/polyfill-unserialize": "^1.0", @@ -118,6 +117,7 @@ "sensio/framework-extra-bundle": "~5.0", "sensiolabs/security-checker": "~6.0", "sonata-project/exporter": "^2.2", + "stof/doctrine-extensions-bundle": "~1.4", "sunra/php-simple-html-dom-parser": "~1.5", "symfony/apache-pack": "^1.0", "symfony/asset": "^5.0", @@ -141,9 +141,10 @@ "symfony/webpack-encore-bundle": "^1.7", "symfony/yaml": "^5.0", "symfonycasts/reset-password-bundle": "^1.1", + "szymach/c-pchart": "^3.0", "tgalopin/html-sanitizer-bundle": "^1.1", - "twig/intl-extra": "^3.0", "twig/extensions": "^1.5", + "twig/intl-extra": "^3.0", "vich/uploader-bundle": "^1.13", "webit/eval-math": "~1.0" }, diff --git a/psalm.xml b/psalm.xml index 6f08ecbdce..777c858d3b 100644 --- a/psalm.xml +++ b/psalm.xml @@ -25,16 +25,14 @@ - + + - - - @@ -136,6 +134,7 @@ + diff --git a/public/main/gradebook/certificate_report.php b/public/main/gradebook/certificate_report.php index 1a17e5ff9c..6e1cfb72a3 100644 --- a/public/main/gradebook/certificate_report.php +++ b/public/main/gradebook/certificate_report.php @@ -50,6 +50,8 @@ foreach ($sessionsList as $session) { $sessions[$session['id']] = $session['name']; } +$selfUrl = api_get_self(); + if ($selectedSession > 0) { if (!SessionManager::isValidId($selectedSession)) { Display::addFlash(Display::return_message(get_lang('The session could not be found'))); diff --git a/public/main/gradebook/gradebook.php b/public/main/gradebook/gradebook.php index 09598ad51c..be6074528f 100644 --- a/public/main/gradebook/gradebook.php +++ b/public/main/gradebook/gradebook.php @@ -506,6 +506,8 @@ if (!empty($keyword)) { foreach ($data_array as $data) { $newarray[] = array_slice($data, 1); } + + /* @todo use pdf.lib.php $pdf = new Cezpdf(); $pdf->selectFont(api_get_path(LIBRARY_PATH).'ezpdf/fonts/Courier.afm'); $pdf->ezSetMargins(30, 30, 50, 30); @@ -526,7 +528,7 @@ if (!empty($keyword)) { 'width' => 500, ] ); - $pdf->ezStream(); + $pdf->ezStream();*/ exit; } } elseif (!empty($_GET['export_certificate'])) { @@ -553,19 +555,19 @@ if (!empty($keyword)) { $stud_ln = $user['lastname']; $certif_text = sprintf(get_lang('%s certifies that - %s + %s -has successfully completed the course +has successfully completed the course - \'%s\' + \'%s\' with a grade of \'%s\''), $organization_name, $stud_fn.' '.$stud_ln, $category[0]->get_name(), $scorecourse_display); $certif_text = str_replace("\\n", "\n", $certif_text); $date = api_convert_and_format_date(null, DATE_FORMAT_SHORT); - - $pdf = new Cezpdf('a4', 'landscape'); + // @todo use pdf.lib.php + /*$pdf = new Cezpdf('a4', 'landscape'); $pdf->selectFont(api_get_path(LIBRARY_PATH).'ezpdf/fonts/Courier.afm'); $pdf->ezSetMargins(30, 30, 50, 50); //line Y coordinates in landscape mode are upside down (500 is on top, 10 is on the bottom) @@ -581,7 +583,7 @@ with a grade of $pdf->ezText($organization_name, 22, ['justification' => 'left']); $pdf->ezSetY(580); $pdf->ezText($portal_name, 22, ['justification' => 'right']); - $pdf->ezStream(); + $pdf->ezStream();*/ } exit; } else { diff --git a/public/main/gradebook/gradebook_display_certificate.php b/public/main/gradebook/gradebook_display_certificate.php index 0d65a6604e..8933a1f0df 100644 --- a/public/main/gradebook/gradebook_display_certificate.php +++ b/public/main/gradebook/gradebook_display_certificate.php @@ -48,7 +48,7 @@ if ('true' === $filter) { 'POST', api_get_self().'?'.api_get_cidreq().'&cat_id='.$categoryId ); - $form->addElement('select', 'filter', get_lang('Code'), $options); + $form->addSelect('filter', get_lang('Code'), $options); $form->addButton('submit', get_lang('Submit')); $filterForm = '
'.$form->returnForm(); diff --git a/public/main/gradebook/index.php b/public/main/gradebook/index.php index f95c095cdd..40a544b57e 100644 --- a/public/main/gradebook/index.php +++ b/public/main/gradebook/index.php @@ -694,7 +694,8 @@ if (isset($_GET['studentoverview'])) { foreach ($data_array as $data) { $newarray[] = array_slice($data, 1); } - $pdf = new Cezpdf(); + // @todo use pdf.lib.php + /*$pdf = new Cezpdf(); $pdf->selectFont(api_get_path(LIBRARY_PATH).'ezpdf/fonts/Courier.afm'); $pdf->ezSetMargins(30, 30, 50, 30); $pdf->ezSetY(810); @@ -722,7 +723,7 @@ if (isset($_GET['studentoverview'])) { ] ); $pdf->ezStream(); - exit; + exit;*/ } } else { // Student view diff --git a/public/main/gradebook/lib/GradebookUtils.php b/public/main/gradebook/lib/GradebookUtils.php index 5520bf7aad..ca21d18e73 100644 --- a/public/main/gradebook/lib/GradebookUtils.php +++ b/public/main/gradebook/lib/GradebookUtils.php @@ -1141,7 +1141,7 @@ class GradebookUtils * * @param string $courseCode * - * @deprecated use CourseManager + * @todo use CourseManager * * @return array */ diff --git a/public/main/gradebook/lib/be/category.class.php b/public/main/gradebook/lib/be/category.class.php index afbd1ed66a..1f910d0b9c 100644 --- a/public/main/gradebook/lib/be/category.class.php +++ b/public/main/gradebook/lib/be/category.class.php @@ -873,7 +873,7 @@ class Category implements GradebookItem /** * Calculate the score of this category. * - * @param int $stud_id student id (default: all students - then the average is returned) + * @param int $studentId student id (default: all students - then the average is returned) * @param $type * @param string $course_code * @param int $session_id @@ -882,12 +882,12 @@ class Category implements GradebookItem * or null if no scores available */ public function calc_score( - $stud_id = null, + $studentId = null, $type = null, $course_code = '', $session_id = null ) { - $key = 'category:'.$this->id.'student:'.(int) $stud_id.'type:'.$type.'course:'.$course_code.'session:'.(int) $session_id; + $key = 'category:'.$this->id.'student:'.(int) $studentId.'type:'.$type.'course:'.$course_code.'session:'.(int) $session_id; $useCache = api_get_configuration_value('gradebook_use_apcu_cache'); $cacheAvailable = api_get_configuration_value('apc') && $useCache; @@ -898,19 +898,19 @@ class Category implements GradebookItem } } // Classic - if (!empty($stud_id) && '' == $type) { + if (!empty($studentId) && '' == $type) { if (!empty($course_code)) { $cats = $this->get_subcategories( - $stud_id, + $studentId, $course_code, $session_id ); - $evals = $this->get_evaluations($stud_id, false, $course_code); - $links = $this->get_links($stud_id, false, $course_code); + $evals = $this->get_evaluations($studentId, false, $course_code); + $links = $this->get_links($studentId, false, $course_code); } else { - $cats = $this->get_subcategories($stud_id); - $evals = $this->get_evaluations($stud_id); - $links = $this->get_links($stud_id); + $cats = $this->get_subcategories($studentId); + $evals = $this->get_evaluations($studentId); + $links = $this->get_links($studentId); } // Calculate score @@ -925,7 +925,7 @@ class Category implements GradebookItem $cat->set_course_code($course_code); $cat->setStudentList($this->getStudentList()); $score = $cat->calc_score( - $stud_id, + $studentId, null, $course_code, $session_id @@ -947,7 +947,7 @@ class Category implements GradebookItem /** @var Evaluation $eval */ foreach ($evals as $eval) { $eval->setStudentList($this->getStudentList()); - $evalres = $eval->calc_score($stud_id); + $evalres = $eval->calc_score($studentId); if (isset($evalres) && 0 != $eval->get_weight()) { $evalweight = $eval->get_weight(); $weightsum += $evalweight; @@ -972,7 +972,7 @@ class Category implements GradebookItem $link->set_session_id($session_id); } - $linkres = $link->calc_score($stud_id, null); + $linkres = $link->calc_score($studentId, null); if (!empty($linkres) && 0 != $link->get_weight()) { $linkweight = $link->get_weight(); $link_res_denom = 0 == $linkres[1] ? 1 : $linkres[1]; @@ -1104,7 +1104,7 @@ class Category implements GradebookItem $link->set_session_id($session_id); } - $linkres = $link->calc_score($stud_id, $type); + $linkres = $link->calc_score($studentId, $type); if (!empty($linkres) && 0 != $link->get_weight()) { $linkweight = $link->get_weight(); @@ -1154,7 +1154,7 @@ class Category implements GradebookItem // function get_data return null; - return AbstractLink::getCurrentUserRanking($stud_id, []); + return AbstractLink::getCurrentUserRanking($studentId, []); break; default: if ($cacheAvailable) { @@ -1548,7 +1548,7 @@ class Category implements GradebookItem * * @return array 2-dimensional array - every element contains 2 subelements (code, title) */ - public function get_all_courses($user_id) + public static function get_all_courses($user_id) { $tbl_main_courses = Database::get_main_table(TABLE_MAIN_COURSE); $tbl_main_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER); @@ -2013,7 +2013,7 @@ class Category implements GradebookItem * * @return array category objects matching the search criterium */ - public function find_category($name_mask, $allcat) + public static function find_category($name_mask, $allcat) { $categories = []; foreach ($allcat as $search_cat) { diff --git a/public/main/gradebook/lib/be/evallink.class.php b/public/main/gradebook/lib/be/evallink.class.php index ec4551974d..34f414097c 100644 --- a/public/main/gradebook/lib/be/evallink.class.php +++ b/public/main/gradebook/lib/be/evallink.class.php @@ -27,11 +27,11 @@ abstract class EvalLink extends AbstractLink * * @return array */ - public function calc_score($userId = null, $type = null) + public function calc_score($studentId = null, $type = null) { $eval = $this->get_evaluation(); - return $eval->calc_score($userId, $type); + return $eval->calc_score($studentId, $type); } public function get_link() diff --git a/public/main/gradebook/lib/be/evaluation.class.php b/public/main/gradebook/lib/be/evaluation.class.php index f86d2e0eaa..a9b084a604 100644 --- a/public/main/gradebook/lib/be/evaluation.class.php +++ b/public/main/gradebook/lib/be/evaluation.class.php @@ -512,14 +512,14 @@ class Evaluation implements GradebookItem /** * Calculate the score of this evaluation. * - * @param int $stud_id (default: all students who have results for this eval - then the average is returned) + * @param int $studentId (default: all students who have results for this eval - then the average is returned) * @param string $type (best, average, ranking) * * @return array (score, max) if student is given * array (sum of scores, number of scores) otherwise * or null if no scores available */ - public function calc_score($stud_id = null, $type = null) + public function calc_score($studentId = null, $type = null) { $allowStats = api_get_configuration_value('allow_gradebook_stats'); if ($allowStats) { @@ -547,17 +547,17 @@ class Evaluation implements GradebookItem return $result; break; case 'ranking': - $ranking = AbstractLink::getCurrentUserRanking($stud_id, $evaluation->getUserScoreList()); + $ranking = AbstractLink::getCurrentUserRanking($studentId, $evaluation->getUserScoreList()); return $ranking; break; default: $weight = $evaluation->getMax(); - if (!empty($stud_id)) { + if (!empty($studentId)) { $scoreList = $evaluation->getUserScoreList(); $result = [0, $weight]; - if (isset($scoreList[$stud_id])) { - $result = [$scoreList[$stud_id], $weight]; + if (isset($scoreList[$studentId])) { + $result = [$scoreList[$studentId], $weight]; } return $result; @@ -574,8 +574,8 @@ class Evaluation implements GradebookItem } $useSession = true; - if (isset($stud_id) && empty($type)) { - $key = 'result_score_student_list_'.api_get_course_int_id().'_'.api_get_session_id().'_'.$this->id.'_'.$stud_id; + if (isset($studentId) && empty($type)) { + $key = 'result_score_student_list_'.api_get_course_int_id().'_'.api_get_session_id().'_'.$this->id.'_'.$studentId; $data = Session::read('calc_score'); $results = isset($data[$key]) ? $data[$key] : null; @@ -584,7 +584,7 @@ class Evaluation implements GradebookItem } $results = null; if (empty($results)) { - $results = Result::load(null, $stud_id, $this->id); + $results = Result::load(null, $studentId, $this->id); Session::write('calc_score', [$key => $results]); } @@ -649,7 +649,7 @@ class Evaluation implements GradebookItem $students[$res->get_user_id()] = $score; } - return AbstractLink::getCurrentUserRanking($stud_id, $students); + return AbstractLink::getCurrentUserRanking($studentId, $students); break; default: return [$sum, $count]; @@ -783,7 +783,7 @@ class Evaluation implements GradebookItem * * @todo can be written more efficiently using a new (but very complex) sql query */ - public function findEvaluations($name_mask, $selectcat) + public static function findEvaluations($name_mask, $selectcat) { $rootcat = Category::load($selectcat); $evals = $rootcat[0]->get_evaluations( diff --git a/public/main/gradebook/lib/be/exerciselink.class.php b/public/main/gradebook/lib/be/exerciselink.class.php index 8283e91c13..fdf133a4b5 100644 --- a/public/main/gradebook/lib/be/exerciselink.class.php +++ b/public/main/gradebook/lib/be/exerciselink.class.php @@ -116,7 +116,7 @@ class ExerciseLink extends AbstractLink /** * Get the score of this exercise. Only the first attempts are taken into account. * - * @param int $stud_id student id (default: all students who have results - + * @param int $studentId student id (default: all students who have results - * then the average is returned) * @param string $type * @@ -124,7 +124,7 @@ class ExerciseLink extends AbstractLink * array (sum of scores, number of scores) otherwise * or null if no scores available */ - public function calc_score($stud_id = null, $type = null) + public function calc_score($studentId = null, $type = null) { $allowStats = api_get_configuration_value('allow_gradebook_stats'); @@ -156,11 +156,11 @@ class ExerciseLink extends AbstractLink return [null, null]; break; default: - if (!empty($stud_id)) { + if (!empty($studentId)) { $scoreList = $link->getUserScoreList(); $result = [0, $weight]; - if (isset($scoreList[$stud_id])) { - $result = [$scoreList[$stud_id], $weight]; + if (isset($scoreList[$studentId])) { + $result = [$scoreList[$studentId], $weight]; } return $result; @@ -186,7 +186,7 @@ class ExerciseLink extends AbstractLink $courseId = $this->getCourseId(); $exerciseData = $this->get_exercise_data(); $exerciseId = isset($exerciseData['id']) ? (int) $exerciseData['id'] : 0; - $stud_id = (int) $stud_id; + $studentId = (int) $studentId; if (empty($exerciseId)) { return null; @@ -194,7 +194,7 @@ class ExerciseLink extends AbstractLink $key = 'exercise_link_id:'. $this->get_id(). - 'exerciseId:'.$exerciseId.'student:'.$stud_id.'session:'.$sessionId.'courseId:'.$courseId.'type:'.$type; + 'exerciseId:'.$exerciseId.'student:'.$studentId.'session:'.$sessionId.'courseId:'.$courseId.'type:'.$type; $useCache = api_get_configuration_value('gradebook_use_apcu_cache'); $cacheAvailable = api_get_configuration_value('apc') && $useCache; @@ -243,8 +243,8 @@ class ExerciseLink extends AbstractLink c_id = $courseId "; } - if (!empty($stud_id) && 'ranking' !== $type) { - $sql .= " AND exe_user_id = $stud_id "; + if (!empty($studentId) && 'ranking' !== $type) { + $sql .= " AND exe_user_id = $studentId "; } $sql .= ' ORDER BY exe_id DESC'; } else { @@ -255,14 +255,14 @@ class ExerciseLink extends AbstractLink hp.c_id = $courseId AND doc.iid = $exerciseId"; - if (!empty($stud_id)) { - $sql .= " AND hp.exe_user_id = $stud_id "; + if (!empty($studentId)) { + $sql .= " AND hp.exe_user_id = $studentId "; } } $scores = Database::query($sql); - if (isset($stud_id) && empty($type)) { + if (isset($studentId) && empty($type)) { // for 1 student if ($data = Database::fetch_array($scores, 'ASSOC')) { $attempts = Database::query($sql); @@ -357,7 +357,7 @@ class ExerciseLink extends AbstractLink return $result; break; case 'ranking': - $ranking = AbstractLink::getCurrentUserRanking($stud_id, $students); + $ranking = AbstractLink::getCurrentUserRanking($studentId, $students); if ($cacheAvailable) { $cacheDriver->save($key, $ranking); } diff --git a/public/main/gradebook/lib/be/forumthreadlink.class.php b/public/main/gradebook/lib/be/forumthreadlink.class.php index 851d77bd28..595f38e14e 100644 --- a/public/main/gradebook/lib/be/forumthreadlink.class.php +++ b/public/main/gradebook/lib/be/forumthreadlink.class.php @@ -99,12 +99,12 @@ class ForumThreadLink extends AbstractLink } /** - * @param int $stud_id + * @param int $studentId * @param string $type * * @return array|null */ - public function calc_score($stud_id = null, $type = null) + public function calc_score($studentId = null, $type = null) { require_once api_get_path(SYS_CODE_PATH).'forum/forumfunction.inc.php'; $threadInfo = get_thread_information('', $this->get_ref_id()); @@ -133,8 +133,8 @@ class ForumThreadLink extends AbstractLink iid = ".$this->get_ref_id()." $sessionCondition "; - if (isset($stud_id)) { - $sql .= ' AND user_id = '.intval($stud_id); + if (isset($studentId)) { + $sql .= ' AND user_id = '.intval($studentId); } // order by id, that way the student's first attempt is accessed first @@ -142,7 +142,7 @@ class ForumThreadLink extends AbstractLink $scores = Database::query($sql); // for 1 student - if (isset($stud_id)) { + if (isset($studentId)) { if (0 == $threadInfo['thread_peer_qualify']) { // Classic way of calculate score if ($data = Database::fetch_array($scores)) { @@ -207,7 +207,7 @@ class ForumThreadLink extends AbstractLink return [$sumResult / $counter, $weight]; break; case 'ranking': - return AbstractLink::getCurrentUserRanking($stud_id, $students); + return AbstractLink::getCurrentUserRanking($studentId, $students); break; default: return [$sum, $counter]; diff --git a/public/main/gradebook/lib/be/gradebookitem.class.php b/public/main/gradebook/lib/be/gradebookitem.class.php index 4a36789d3a..0cd8e77e02 100644 --- a/public/main/gradebook/lib/be/gradebookitem.class.php +++ b/public/main/gradebook/lib/be/gradebookitem.class.php @@ -30,5 +30,5 @@ interface GradebookItem public function setStudentList($list); - public function calc_score($stud_id = null, $type = null); + public function calc_score($studentId = null, $type = null); } diff --git a/public/main/gradebook/lib/be/learnpathlink.class.php b/public/main/gradebook/lib/be/learnpathlink.class.php index edd9cda596..863c3f736f 100644 --- a/public/main/gradebook/lib/be/learnpathlink.class.php +++ b/public/main/gradebook/lib/be/learnpathlink.class.php @@ -1,4 +1,5 @@ get_session_id(); @@ -90,8 +91,8 @@ class LearnpathLink extends AbstractLink lp_id = ".$this->get_ref_id()." AND session_id = $session_id "; - if (isset($stud_id)) { - $sql .= ' AND user_id = '.intval($stud_id); + if (isset($studentId)) { + $sql .= ' AND user_id = '.intval($studentId); } // order by id, that way the student's first attempt is accessed first @@ -99,7 +100,7 @@ class LearnpathLink extends AbstractLink $scores = Database::query($sql); // for 1 student - if (isset($stud_id)) { + if (isset($studentId)) { if ($data = Database::fetch_assoc($scores)) { return [$data['progress'], 100]; } else { @@ -137,7 +138,7 @@ class LearnpathLink extends AbstractLink return [$sumResult / $rescount, 100]; break; case 'ranking': - return AbstractLink::getCurrentUserRanking($stud_id, $students); + return AbstractLink::getCurrentUserRanking($studentId, $students); break; default: return [$sum, $rescount]; diff --git a/public/main/gradebook/lib/be/linkfactory.class.php b/public/main/gradebook/lib/be/linkfactory.class.php index 65bfb25e60..e64b0e459f 100644 --- a/public/main/gradebook/lib/be/linkfactory.class.php +++ b/public/main/gradebook/lib/be/linkfactory.class.php @@ -45,7 +45,7 @@ class LinkFactory /** * Get the link object referring to an evaluation. */ - public function get_evaluation_link($eval_id) + public static function get_evaluation_link($eval_id) { $links = AbstractLink::load(null, null, $eval_id); foreach ($links as $link) { @@ -60,13 +60,13 @@ class LinkFactory /** * Find links by name. * - * @param string $name_mask search string + * @param string $name search string * * @return array link objects matching the search criterium */ - public function find_links($name_mask, $selectcat) + public static function find_links($name, $selectcat) { - return AbstractLink::find_links($name_mask, $selectcat); + return AbstractLink::find_links($name, $selectcat); } /** diff --git a/public/main/gradebook/lib/be/studentpublicationlink.class.php b/public/main/gradebook/lib/be/studentpublicationlink.class.php index 7f2c00a189..ea1cba194f 100644 --- a/public/main/gradebook/lib/be/studentpublicationlink.class.php +++ b/public/main/gradebook/lib/be/studentpublicationlink.class.php @@ -147,13 +147,13 @@ class StudentPublicationLink extends AbstractLink } /** - * @param null $stud_id + * @param null $studentId * * @return array */ - public function calc_score($stud_id = null, $type = null) + public function calc_score($studentId = null, $type = null) { - $stud_id = (int) $stud_id; + $studentId = (int) $studentId; $em = Database::getManager(); $data = $this->get_exercise_data(); @@ -206,9 +206,9 @@ class StudentPublicationLink extends AbstractLink ]; } - if (!empty($stud_id)) { + if (!empty($studentId)) { $dql .= ' AND a.userId = :student '; - $params['student'] = $stud_id; + $params['student'] = $studentId; } $order = api_get_setting('student_publication_to_take_in_gradebook'); @@ -228,7 +228,7 @@ class StudentPublicationLink extends AbstractLink $scores = $em->createQuery($dql)->execute($params); // for 1 student - if (!empty($stud_id)) { + if (!empty($studentId)) { if (!count($scores)) { return [null, null]; } @@ -279,7 +279,7 @@ class StudentPublicationLink extends AbstractLink return [$sumResult / $rescount, $weight]; break; case 'ranking': - return AbstractLink::getCurrentUserRanking($stud_id, $students); + return AbstractLink::getCurrentUserRanking($studentId, $students); break; default: return [$sum, $rescount]; diff --git a/public/main/gradebook/lib/be/surveylink.class.php b/public/main/gradebook/lib/be/surveylink.class.php index 6753477cb4..c76a3d8332 100644 --- a/public/main/gradebook/lib/be/surveylink.class.php +++ b/public/main/gradebook/lib/be/surveylink.class.php @@ -1,4 +1,5 @@ getCourseId(); $tbl_survey = Database::get_course_table(TABLE_SURVEY); $tbl_survey_invitation = Database::get_course_table(TABLE_SURVEY_INVITATION); - $get_individual_score = !is_null($stud_id); + $get_individual_score = !is_null($studentId); $sql = "SELECT i.answered FROM $tbl_survey AS s @@ -158,7 +159,7 @@ class SurveyLink extends AbstractLink "; if ($get_individual_score) { - $sql .= ' AND i.user = '.intval($stud_id); + $sql .= ' AND i.user = '.intval($studentId); } $sql_result = Database::query($sql); diff --git a/public/main/gradebook/lib/fe/catform.class.php b/public/main/gradebook/lib/fe/catform.class.php index 658757f494..3f5ceb42bc 100644 --- a/public/main/gradebook/lib/fe/catform.class.php +++ b/public/main/gradebook/lib/fe/catform.class.php @@ -190,8 +190,7 @@ class CatForm extends FormValidator */ protected function build_select_course_form() { - $select = $this->addElement( - 'select', + $select = $this->addSelect( 'select_course', [get_lang('Pick a course'), 'test'], null @@ -253,8 +252,7 @@ class CatForm extends FormValidator if ($allowSkillEdit) { if (Skill::isToolAvailable()) { - $skillSelect = $this->addElement( - 'select_ajax', + $skillSelect = $this->addSelectAjax( 'skills', [ get_lang('Skills'), diff --git a/public/main/gradebook/lib/fe/dataform.class.php b/public/main/gradebook/lib/fe/dataform.class.php index 9b0b1e00cb..650df41f8e 100644 --- a/public/main/gradebook/lib/fe/dataform.class.php +++ b/public/main/gradebook/lib/fe/dataform.class.php @@ -51,9 +51,9 @@ class DataForm extends FormValidator parent::display(); } - public function setDefaults($defaults = [], $filter = null) + public function setDefaults($defaultValues = [], $filter = null) { - parent::setDefaults($defaults, $filter); + parent::setDefaults($defaultValues, $filter); } protected function build_pdf_export_form() diff --git a/public/main/gradebook/lib/fe/displaygradebook.php b/public/main/gradebook/lib/fe/displaygradebook.php index 6e28379719..a6511803a5 100644 --- a/public/main/gradebook/lib/fe/displaygradebook.php +++ b/public/main/gradebook/lib/fe/displaygradebook.php @@ -249,7 +249,7 @@ class DisplayGradebook * @param $selectcat * @param bool $is_course_admin * @param bool $is_platform_admin - * @param bool $simple_search_form + * @param FormValidator $simple_search_form * @param bool $show_add_qualification Whether to show or not the link to add a new qualification * (we hide it in case of the course-embedded tool where we have only one * per course or session) diff --git a/public/main/gradebook/lib/fe/evalform.class.php b/public/main/gradebook/lib/fe/evalform.class.php index 8455c018e4..4ad27dbcbb 100644 --- a/public/main/gradebook/lib/fe/evalform.class.php +++ b/public/main/gradebook/lib/fe/evalform.class.php @@ -27,7 +27,7 @@ class EvalForm extends FormValidator * * @param int $form_type 1=add, 2=edit,3=move,4=result_add * @param Evaluation $evaluation_object the category object - * @param obj $result_object the result object + * @param $result_object the result object * @param string $form_name * @param string $method * @param string $action @@ -85,9 +85,9 @@ class EvalForm extends FormValidator parent::display(); } - public function setDefaults($defaults = [], $filter = null) + public function setDefaults($defaultValues = [], $filter = null) { - parent::setDefaults($defaults, $filter); + parent::setDefaults($defaultValues, $filter); } public function sort_by_user($item1, $item2) @@ -114,9 +114,8 @@ class EvalForm extends FormValidator */ protected function build_add_user_to_eval() { - $this->addElement('header', get_lang('Choose users for this evaluation')); - $select = $this->addElement( - 'select', + $this->addHeader(get_lang('Choose users for this evaluation')); + $select = $this->addSelect( 'firstLetterUser', get_lang('First letter'), null, @@ -133,8 +132,7 @@ class EvalForm extends FormValidator $select->addOption($letter, $letter); } } - $select = $this->addElement( - 'select', + $select = $this->addSelect( 'add_users', null, null, @@ -290,7 +288,7 @@ class EvalForm extends FormValidator $renderer->setCustomElementTemplate('{element} '); $this->addElement('static', null, null, '"'.$this->evaluation_object->get_name().'" '); $this->addElement('static', null, null, get_lang('Move to').' : '); - $select = $this->addElement('select', 'move_cat', null, null); + $select = $this->addSelect('move_cat', null, null); $line = ''; foreach ($this->evaluation_object->get_target_categories() as $cat) { for ($i = 0; $i < $cat[2]; $i++) { @@ -558,8 +556,7 @@ class EvalForm extends FormValidator if (1 == count($all_categories)) { $this->addElement('hidden', 'hid_category_id', $cat_id); } else { - $select_gradebook = $this->addElement( - 'select', + $select_gradebook = $this->addSelect( 'hid_category_id', get_lang('Select assessment'), [], diff --git a/public/main/gradebook/lib/fe/exportgradebook.php b/public/main/gradebook/lib/fe/exportgradebook.php index 56a5876b9d..f035becab6 100644 --- a/public/main/gradebook/lib/fe/exportgradebook.php +++ b/public/main/gradebook/lib/fe/exportgradebook.php @@ -136,6 +136,7 @@ function export_pdf_with_html($headers_table, $data_table, $headers_pdf, $footer } $items_per_page = 30; $count_pages = ceil(count($data_table) / $items_per_page); + $content_table = ''; for ($x = 0; $x < $count_pages; $x++) { $content_table .= ''; // header table diff --git a/public/main/gradebook/lib/fe/gradebooktable.class.php b/public/main/gradebook/lib/fe/gradebooktable.class.php index d3796ecfb1..fe33666c91 100644 --- a/public/main/gradebook/lib/fe/gradebooktable.class.php +++ b/public/main/gradebook/lib/fe/gradebooktable.class.php @@ -1165,7 +1165,7 @@ class GradebookTable extends SortableTable $categoryId = $item->getCategory()->get_id(); $cat = new Category(); - + $is_student = api_is_student(); switch ($item->get_item_type()) { case 'C': // Category diff --git a/public/main/gradebook/lib/fe/linkaddeditform.class.php b/public/main/gradebook/lib/fe/linkaddeditform.class.php index 529bdb12d8..ee1d1b5c85 100644 --- a/public/main/gradebook/lib/fe/linkaddeditform.class.php +++ b/public/main/gradebook/lib/fe/linkaddeditform.class.php @@ -50,10 +50,10 @@ class LinkAddEditForm extends FormValidator if ($link->needs_name_and_description()) { $this->addText('name', get_lang('Name'), true, ['size' => '40', 'maxlength' => '40']); } else { - $select = $this->addElement('select', 'select_link', get_lang('ChooseItem')); + $select = $this->addSelect('select_link', get_lang('ChooseItem')); foreach ($link->get_all_links() as $newlink) { $name = strip_tags(Exercise::get_formated_title_variable($newlink[1])); - $select->addoption($name, $newlink[0]); + $select->addOption($name, $newlink[0]); } } } else { @@ -74,8 +74,7 @@ class LinkAddEditForm extends FormValidator if (1 == count($category_object)) { $this->addElement('hidden', 'select_gradebook', $category_object[0]->get_id()); } else { - $select_gradebook = $this->addElement( - 'select', + $select_gradebook = $this->addSelect( 'select_gradebook', get_lang('Select assessment'), [], @@ -90,12 +89,12 @@ class LinkAddEditForm extends FormValidator if (empty($grade_model_id)) { if (0 == $my_cat->get_parent_id()) { $default_weight = $my_cat->get_weight(); - $select_gradebook->addoption(get_lang('Default'), $my_cat->get_id()); + $select_gradebook->addOption(get_lang('Default'), $my_cat->get_id()); } else { - $select_gradebook->addoption($my_cat->get_name(), $my_cat->get_id()); + $select_gradebook->addOption($my_cat->get_name(), $my_cat->get_id()); } } else { - $select_gradebook->addoption(get_lang('Select'), 0); + $select_gradebook->addOption(get_lang('Select'), 0); } if ($link->get_category_id() == $my_cat->get_id()) { $default_weight = $my_cat->get_weight(); diff --git a/public/main/gradebook/lib/fe/linkform.class.php b/public/main/gradebook/lib/fe/linkform.class.php index 2255231d93..93b79c5f7c 100644 --- a/public/main/gradebook/lib/fe/linkform.class.php +++ b/public/main/gradebook/lib/fe/linkform.class.php @@ -68,7 +68,7 @@ class LinkForm extends FormValidator '"'.$this->link_object->get_name().'" ' ); $this->addElement('static', null, null, get_lang('Move to').' : '); - $select = $this->addElement('select', 'move_cat', null, null); + $select = $this->addSelect('move_cat', null, null); $line = ''; foreach ($this->link_object->get_target_categories() as $cat) { for ($i = 0; $i < $cat[2]; $i++) { @@ -86,8 +86,7 @@ class LinkForm extends FormValidator protected function build_create() { $this->addHeader(get_lang('Add online activity')); - $select = $this->addElement( - 'select', + $select = $this->addSelect( 'select_link', get_lang('Choose type of activity to assess'), null, diff --git a/public/main/gradebook/lib/fe/userform.class.php b/public/main/gradebook/lib/fe/userform.class.php index 9ced5af6b5..3d85142c56 100644 --- a/public/main/gradebook/lib/fe/userform.class.php +++ b/public/main/gradebook/lib/fe/userform.class.php @@ -15,9 +15,9 @@ class UserForm extends FormValidator /** * Builds a form containing form items based on a given parameter. * - * @param int form_type 1 = user_info - * @param user array - * @param string form name + * @param int $form_type 1 = user_info + * @param array $user + * @param string $form_name * @param string $method * @param string $action */ @@ -28,9 +28,9 @@ class UserForm extends FormValidator if (isset($user)) { $this->user_info = $user; } - if (isset($result_object)) { + /*if (isset($result_object)) { $this->result_object = $result_object; - } + }*/ if (self::TYPE_USER_INFO == $this->form_type) { $this->build_user_info_form(); } elseif (self::TYPE_SIMPLE_SEARCH == $this->form_type) { @@ -44,9 +44,9 @@ class UserForm extends FormValidator parent::display(); } - public function setDefaults($defaults = [], $filter = null) + public function setDefaults($defaultValues = [], $filter = null) { - parent::setDefaults($defaults, $filter); + parent::setDefaults($defaultValues, $filter); } protected function build_simple_search() diff --git a/public/main/gradebook/lib/gradebook_data_generator.class.php b/public/main/gradebook/lib/gradebook_data_generator.class.php index 82a722ab99..f62084af24 100644 --- a/public/main/gradebook/lib/gradebook_data_generator.class.php +++ b/public/main/gradebook/lib/gradebook_data_generator.class.php @@ -245,6 +245,7 @@ class GradebookDataGenerator $evals = []; $links = []; if ('C' === $item->get_item_type()) { + /** @var Category $item */ $evals = $item->get_evaluations(null); $links = $item->get_links(null); } diff --git a/public/main/gradebook/lib/gradebook_result.class.php b/public/main/gradebook/lib/gradebook_result.class.php index 9319ab23fe..f0745a84bf 100644 --- a/public/main/gradebook/lib/gradebook_result.class.php +++ b/public/main/gradebook/lib/gradebook_result.class.php @@ -21,7 +21,7 @@ class GradeBookResult /** * Exports the complete report as a CSV file. * - * @param string $dato Document path inside the document tool + * @param array $dato Document path inside the document tool * * @return bool False on error */ @@ -32,7 +32,6 @@ class GradeBookResult $data = ''; //build the results //titles - foreach ($dato[0] as $header_col) { if (!empty($header_col)) { if (is_array($header_col)) { @@ -82,9 +81,6 @@ class GradeBookResult * Exports the complete report as an XLS file. * * @param array $data - * - * @throws PHPExcel_Exception - * @throws PHPExcel_Writer_Exception */ public function exportCompleteReportXLS($data) { diff --git a/public/main/gradebook/user_stats.php b/public/main/gradebook/user_stats.php index 5df94e8ab4..f4391343a3 100644 --- a/public/main/gradebook/user_stats.php +++ b/public/main/gradebook/user_stats.php @@ -54,7 +54,7 @@ if (isset($_GET['exportpdf'])) { $newarray[] = array_slice($data, 1); } $userInfo = api_get_user_info($userId); - $html .= get_lang('Results and feedback').' : '.$userInfo['complete_name_with_username'].' ('.api_get_local_time().')'; + $html = get_lang('Results and feedback').' : '.$userInfo['complete_name_with_username'].' ('.api_get_local_time().')'; if ($displayscore->is_custom()) { $header_names = [