From 601a1da769cd4238cfbb2e50e91f9ca1a7975f72 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Fri, 7 Sep 2018 14:43:16 +0200 Subject: [PATCH] DB changes in track_e_exercises rename track_e_exercises.exe_weighting to track_e_exercises.max_score rename track_e_exercises.exe_result to track_e_exercises.score Same with hotpotatoes #2247 --- app/Migrations/Schema/V200/Version20.php | 5 + main/admin/user_move_stats.php | 4 +- main/exercise/exercise.class.php | 8 +- main/exercise/exercise.php | 10 +- main/exercise/exercise_report.php | 6 +- main/exercise/exercise_result.class.php | 8 +- main/exercise/exercise_result.php | 2 +- main/exercise/exercise_submit.php | 4 +- main/exercise/hotpotatoes_exercise_report.php | 4 +- .../hotpotatoes_exercise_result.class.php | 10 +- main/exercise/overview.php | 4 +- main/exercise/recalculate.php | 2 +- main/exercise/savescores.php | 4 +- main/gradebook/lib/be/exerciselink.class.php | 16 ++-- main/inc/ajax/exercise.ajax.php | 14 +-- main/inc/ajax/model.ajax.php | 2 +- main/inc/lib/events.lib.php | 18 ++-- main/inc/lib/exercise.lib.php | 64 ++++++------- main/inc/lib/myspace.lib.php | 6 +- main/inc/lib/tracking.lib.php | 48 +++++----- main/lp/learnpath.class.php | 10 +- main/lp/learnpathItem.class.php | 14 +-- main/lp/lp_view.php | 6 +- main/mySpace/exercise_category_report.php | 2 +- main/mySpace/progression.php | 6 +- main/session/index.php | 12 +-- main/tracking/course_session_report.php | 2 +- main/tracking/exams.php | 8 +- main/tracking/lp_results_by_user.php | 2 +- src/CoreBundle/Entity/TrackEExercises.php | 96 +++++++++---------- src/CoreBundle/Entity/TrackEHotpotatoes.php | 50 ++++------ tests/scripts/fix_exercise_score_in_lp.php | 16 ++-- tests/scripts/fix_restored_learnpaths.php | 4 +- 33 files changed, 226 insertions(+), 241 deletions(-) diff --git a/app/Migrations/Schema/V200/Version20.php b/app/Migrations/Schema/V200/Version20.php index 55c88e0b8b..634a58f68f 100644 --- a/app/Migrations/Schema/V200/Version20.php +++ b/app/Migrations/Schema/V200/Version20.php @@ -689,6 +689,11 @@ class Version20 extends AbstractMigrationChamilo $this->addSql('ALTER TABLE track_e_hotspot ADD CONSTRAINT FK_A89CC3B691D79BD3 FOREIGN KEY (c_id) REFERENCES course (id)'); $this->addSql('CREATE INDEX IDX_A89CC3B691D79BD3 ON track_e_hotspot (c_id)'); + $this->addSql('ALTER TABLE track_e_hotpotatoes CHANGE exe_result score SMALLINT NOT NULL'); + $this->addSql('ALTER TABLE track_e_hotpotatoes CHANGE exe_weighting max_score SMALLINT NOT NULL'); + $this->addSql('ALTER TABLE track_e_exercises CHANGE exe_weighting max_score DOUBLE PRECISION NOT NULL'); + $this->addSql('ALTER TABLE track_e_exercises CHANGE exe_result score DOUBLE PRECISION NOT NULL'); + // Drop unused columns $dropColumnsAndIndex = [ 'track_e_uploads' => ['columns' => ['upload_cours_id'], 'index' => ['upload_cours_id']], diff --git a/main/admin/user_move_stats.php b/main/admin/user_move_stats.php index 3eb7ef3d9f..f5c0bd81b3 100755 --- a/main/admin/user_move_stats.php +++ b/main/admin/user_move_stats.php @@ -43,8 +43,8 @@ function compare_data($result_message) //Process data $array = [ 'exe_date' => get_lang('Date'), - 'exe_result' => get_lang('Score'), - 'exe_weighting' => get_lang('Weighting'), + 'score' => get_lang('Score'), + 'max_score' => get_lang('Weighting'), ]; foreach ($item as $key => $value) { if (in_array($key, array_keys($array))) { diff --git a/main/exercise/exercise.class.php b/main/exercise/exercise.class.php index 864147da4c..e3d17bedf2 100755 --- a/main/exercise/exercise.class.php +++ b/main/exercise/exercise.class.php @@ -3043,10 +3043,10 @@ class Exercise 'orig_lp_id' => $safe_lp_id, 'orig_lp_item_id' => $safe_lp_item_id, 'orig_lp_item_view_id' => $safe_lp_item_view_id, - 'exe_weighting' => $weight, + 'max_score' => $weight, 'user_ip' => Database::escape_string(api_get_real_ip()), 'exe_date' => api_get_utc_datetime(), - 'exe_result' => 0, + 'score' => 0, 'steps_counter' => 0, 'exe_duration' => 0, 'expired_time_control' => $clock_expired_time, @@ -5792,7 +5792,7 @@ class Exercise if ($saved_results) { $statsTable = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES); $sql = "UPDATE $statsTable SET - exe_result = exe_result + ".floatval($questionScore)." + score = score + ".floatval($questionScore)." WHERE exe_id = $exeId"; Database::query($sql); if ($debug) { @@ -6126,7 +6126,7 @@ class Exercise } $result = [ 'score' => $totalScore, - 'weight' => $track_exercise_info['exe_weighting'], + 'weight' => $track_exercise_info['max_score'], ]; } diff --git a/main/exercise/exercise.php b/main/exercise/exercise.php index 4ae028fc3a..d918710dc5 100644 --- a/main/exercise/exercise.php +++ b/main/exercise/exercise.php @@ -1047,7 +1047,7 @@ if (!empty($exerciseList)) { if ($num > 0) { $row_track = Database :: fetch_array($qryres); $attempt_text = get_lang('LatestAttempt').' : '; - $attempt_text .= ExerciseLib::show_score($row_track['exe_result'], $row_track['exe_weighting']); + $attempt_text .= ExerciseLib::show_score($row_track['score'], $row_track['max_score']); } else { //No attempts $attempt_text = get_lang('NotAttempted'); @@ -1094,8 +1094,8 @@ if (!empty($exerciseList)) { $row_track = Database :: fetch_array($qryres); $attempt_text = get_lang('LatestAttempt').' : '; $attempt_text .= ExerciseLib::show_score( - $row_track['exe_result'], - $row_track['exe_weighting'] + $row_track['score'], + $row_track['max_score'] ); } else { $attempt_text = get_lang('NotAttempted'); @@ -1267,8 +1267,8 @@ if (isset($attribute['path']) && is_array($attribute['path'])) { $actions = ''.Display::return_icon('test_results.png', get_lang('Results'), '', ICON_SIZE_SMALL).''; $attemptText = get_lang('LatestAttempt').' : '; $attemptText .= ExerciseLib::show_score( - $attempt['exe_result'], - $attempt['exe_weighting'] + $attempt['score'], + $attempt['max_score'] ).' '; $attemptText .= $actions; } else { diff --git a/main/exercise/exercise_report.php b/main/exercise/exercise_report.php index e86e77850f..137990ae3f 100755 --- a/main/exercise/exercise_report.php +++ b/main/exercise/exercise_report.php @@ -171,7 +171,7 @@ if (isset($_REQUEST['comments']) && $lpItemId = $track_exercise_info['orig_lp_item_id']; $lp_item_view_id = $track_exercise_info['orig_lp_item_view_id']; $exerciseId = $track_exercise_info['exe_exo_id']; - $exeWeighting = $track_exercise_info['exe_weighting']; + $exeWeighting = $track_exercise_info['max_score']; $url = api_get_path(WEB_CODE_PATH).'exercise/result.php?id='.$track_exercise_info['exe_id'].'&'.api_get_cidreq().'&show_headers=1&id_session='.$session_id; @@ -237,7 +237,7 @@ if (isset($_REQUEST['comments']) && } $sql = "UPDATE $TBL_TRACK_EXERCISES - SET exe_result = '".floatval($tot)."' + SET score = '".floatval($tot)."' WHERE exe_id = ".$id; Database::query($sql); @@ -624,7 +624,7 @@ if ($is_allowedToEdit || $is_tutor) { ['name' => 'duration', 'index' => 'exe_duration', 'width' => '30', 'align' => 'left', 'search' => 'true'], ['name' => 'start_date', 'index' => 'start_date', 'width' => '60', 'align' => 'left', 'search' => 'true'], ['name' => 'exe_date', 'index' => 'exe_date', 'width' => '60', 'align' => 'left', 'search' => 'true'], - ['name' => 'score', 'index' => 'exe_result', 'width' => '50', 'align' => 'center', 'search' => 'true'], + ['name' => 'score', 'index' => 'score', 'width' => '50', 'align' => 'center', 'search' => 'true'], ['name' => 'ip', 'index' => 'user_ip', 'width' => '40', 'align' => 'center', 'search' => 'true'], ['name' => 'status', 'index' => 'revised', 'width' => '40', 'align' => 'left', 'search' => 'true', 'stype' => 'select', //for the bottom bar diff --git a/main/exercise/exercise_result.class.php b/main/exercise/exercise_result.class.php index 7fd0266dda..15e62937d2 100755 --- a/main/exercise/exercise_result.class.php +++ b/main/exercise/exercise_result.class.php @@ -70,8 +70,8 @@ class ExerciseResult $sql = "SELECT ".(api_is_western_name_order() ? "firstname as userpart1, lastname userpart2" : "lastname as userpart1, firstname as userpart2").", official_code, ce.title as extitle, - te.exe_result as exresult , - te.exe_weighting as exweight, + te.score as exresult , + te.max_score as exweight, te.exe_date as exdate, te.exe_id as exid, email as exemail, @@ -100,8 +100,8 @@ class ExerciseResult $sql = "SELECT ".(api_is_western_name_order() ? "firstname as userpart1, lastname userpart2" : "lastname as userpart1, firstname as userpart2").", official_code, ce.title as extitle, - te.exe_result as exresult, - te.exe_weighting as exweight, + te.score as exresult, + te.max_score as exweight, te.exe_date as exdate, te.exe_id as exid, email as exemail, diff --git a/main/exercise/exercise_result.php b/main/exercise/exercise_result.php index 5ef9de478d..c4a3dab64e 100755 --- a/main/exercise/exercise_result.php +++ b/main/exercise/exercise_result.php @@ -165,7 +165,7 @@ if ($objExercise->selectAttempts() > 0) { $total_score = 0; if (!empty($exercise_stat_info)) { - $total_score = $exercise_stat_info['exe_result']; + $total_score = $exercise_stat_info['score']; } $max_score = $objExercise->get_max_score(); diff --git a/main/exercise/exercise_submit.php b/main/exercise/exercise_submit.php index fad61ad295..85b9f74d8d 100755 --- a/main/exercise/exercise_submit.php +++ b/main/exercise/exercise_submit.php @@ -262,8 +262,8 @@ if ($objExercise->selectAttempts() > 0) { } } $score = ExerciseLib::show_score( - $last_attempt_info['exe_result'], - $last_attempt_info['exe_weighting'] + $last_attempt_info['score'], + $last_attempt_info['max_score'] ); $attempt_html .= Display::div( get_lang('YourTotalScore').' '.$score, diff --git a/main/exercise/hotpotatoes_exercise_report.php b/main/exercise/hotpotatoes_exercise_report.php index 077bdd3c55..2ad9014c91 100755 --- a/main/exercise/hotpotatoes_exercise_report.php +++ b/main/exercise/hotpotatoes_exercise_report.php @@ -202,7 +202,7 @@ if ($is_allowedToEdit || $is_tutor) { ], ['name' => 'group_name', 'index' => 'group_id', 'width' => '40', 'align' => 'left', 'search' => 'false'], ['name' => 'exe_date', 'index' => 'exe_date', 'width' => '60', 'align' => 'left', 'search' => 'false'], - ['name' => 'score', 'index' => 'exe_result', 'width' => '50', 'align' => 'left', 'search' => 'false'], + ['name' => 'score', 'index' => 'score', 'width' => '50', 'align' => 'left', 'search' => 'false'], ['name' => 'actions', 'index' => 'actions', 'width' => '60', 'align' => 'left', 'search' => 'false'], ]; @@ -228,7 +228,7 @@ if ($is_allowedToEdit || $is_tutor) { // @todo fix search firstname/lastname that doesn't work. rmove search for the moment $column_model = [ ['name' => 'exe_date', 'index' => 'exe_date', 'width' => '60', 'align' => 'left', 'search' => 'false'], - ['name' => 'score', 'index' => 'exe_result', 'width' => '50', 'align' => 'left', 'search' => 'false'], + ['name' => 'score', 'index' => 'score', 'width' => '50', 'align' => 'left', 'search' => 'false'], ['name' => 'actions', 'index' => 'actions', 'width' => '60', 'align' => 'left', 'search' => 'false'], ]; } diff --git a/main/exercise/hotpotatoes_exercise_result.class.php b/main/exercise/hotpotatoes_exercise_result.class.php index ead176d7d5..63f099f586 100755 --- a/main/exercise/hotpotatoes_exercise_result.class.php +++ b/main/exercise/hotpotatoes_exercise_result.class.php @@ -41,8 +41,8 @@ class HotpotatoesExerciseResult $sql = "SELECT firstname as userpart1, lastname as userpart2 , email, tth.exe_name, - tth.exe_result, - tth.exe_weighting, + tth.score, + tth.max_score, tth.exe_date FROM $TBL_TRACK_HOTPOTATOES tth, $TBL_USER tu WHERE tu.user_id=tth.exe_user_id AND @@ -51,7 +51,7 @@ class HotpotatoesExerciseResult ORDER BY tth.c_id ASC, tth.exe_date ASC"; } else { // get only this user's results - $sql = "SELECT '', exe_name, exe_result , exe_weighting, exe_date + $sql = "SELECT '', exe_name, score, max_score, exe_date FROM $TBL_TRACK_HOTPOTATOES WHERE exe_user_id = '".$user_id."' AND @@ -89,8 +89,8 @@ class HotpotatoesExerciseResult $return[$i]['title'] = $title; $return[$i]['exe_date'] = $hpresults[$i]['exe_date']; - $return[$i]['result'] = $hpresults[$i]['exe_result']; - $return[$i]['max'] = $hpresults[$i]['exe_weighting']; + $return[$i]['result'] = $hpresults[$i]['score']; + $return[$i]['max'] = $hpresults[$i]['max_score']; } } $this->results = $return; diff --git a/main/exercise/overview.php b/main/exercise/overview.php index 2de4eaa3a9..ccc7bad5e6 100755 --- a/main/exercise/overview.php +++ b/main/exercise/overview.php @@ -195,8 +195,8 @@ if (!empty($attempts)) { $i = $counter; foreach ($attempts as $attempt_result) { $score = ExerciseLib::show_score( - $attempt_result['exe_result'], - $attempt_result['exe_weighting'] + $attempt_result['score'], + $attempt_result['max_score'] ); $attempt_url = api_get_path(WEB_CODE_PATH).'exercise/result.php?'; $attempt_url .= api_get_cidreq().'&show_headers=1&'; diff --git a/main/exercise/recalculate.php b/main/exercise/recalculate.php index 02409560d6..b40ef7a4b0 100644 --- a/main/exercise/recalculate.php +++ b/main/exercise/recalculate.php @@ -63,7 +63,7 @@ foreach ($attempts as $attempt) { $em->merge($attempt); } -$trackedExercise->setExeResult($newResult); +$trackedExercise->setScore($newResult); $em->merge($trackedExercise); $em->flush(); diff --git a/main/exercise/savescores.php b/main/exercise/savescores.php index 8e9475c25e..7c308fc23e 100755 --- a/main/exercise/savescores.php +++ b/main/exercise/savescores.php @@ -59,8 +59,8 @@ function save_scores($file, $score) 'exe_user_id' => $user_id, 'exe_date' => $date, 'c_id' => $c_id, - 'exe_result' => $score, - 'exe_weighting' => $weighting, + 'score' => $score, + 'max_score' => $weighting, ]; Database::insert($TABLETRACK_HOTPOTATOES, $params); diff --git a/main/gradebook/lib/be/exerciselink.class.php b/main/gradebook/lib/be/exerciselink.class.php index 46cb500666..f42745a85f 100755 --- a/main/gradebook/lib/be/exerciselink.class.php +++ b/main/gradebook/lib/be/exerciselink.class.php @@ -246,7 +246,7 @@ class ExerciseLink extends AbstractLink if (isset($stud_id) && empty($type)) { // for 1 student if ($data = Database::fetch_array($scores)) { - return [$data['exe_result'], $data['exe_weighting']]; + return [$data['score'], $data['max_score']]; } else { return null; } @@ -276,15 +276,15 @@ class ExerciseLink extends AbstractLink } if (!isset($students[$data['exe_user_id']])) { - if ($data['exe_weighting'] != 0) { - $students[$data['exe_user_id']] = $data['exe_result']; + if ($data['max_score'] != 0) { + $students[$data['exe_user_id']] = $data['score']; $student_count++; - if ($data['exe_result'] > $bestResult) { - $bestResult = $data['exe_result']; + if ($data['score'] > $bestResult) { + $bestResult = $data['score']; } - $sum += $data['exe_result'] / $data['exe_weighting']; - $sumResult += $data['exe_result']; - $weight = $data['exe_weighting']; + $sum += $data['score'] / $data['max_score']; + $sumResult += $data['score']; + $weight = $data['max_score']; } } } diff --git a/main/inc/ajax/exercise.ajax.php b/main/inc/ajax/exercise.ajax.php index 59021acbc5..92ce1cf6f9 100755 --- a/main/inc/ajax/exercise.ajax.php +++ b/main/inc/ajax/exercise.ajax.php @@ -202,9 +202,9 @@ switch ($action) { lastname, aa.status, start_date, - exe_result, - exe_weighting, - exe_result/exe_weighting as score, + score, + max_score, + score/max_score as score, exe_duration, questions_to_check, orig_lp_id @@ -215,9 +215,9 @@ switch ($action) { t.exe_user_id, status, start_date, - exe_result, - exe_weighting, - exe_result/exe_weighting as score, + score, + max_score, + score/max_score as score, exe_duration, questions_to_check, orig_lp_id @@ -454,7 +454,7 @@ switch ($action) { if (!empty($exercise_stat_info)) { // We know the user we get the exe_id. $exeId = $exercise_stat_info['exe_id']; - $total_score = $exercise_stat_info['exe_result']; + $total_score = $exercise_stat_info['score']; // Getting the list of attempts $attemptList = Event::getAllExerciseEventByExeId($exeId); diff --git a/main/inc/ajax/model.ajax.php b/main/inc/ajax/model.ajax.php index 83770bb14d..8993b295dd 100755 --- a/main/inc/ajax/model.ajax.php +++ b/main/inc/ajax/model.ajax.php @@ -2041,7 +2041,7 @@ switch ($action) { $arrGrade = []; foreach ($exeResults as $exeResult) { - $arrGrade[$exeResult['exe_user_id']][$exeResult['exe_exo_id']] = $exeResult['exe_result']; + $arrGrade[$exeResult['exe_user_id']][$exeResult['exe_exo_id']] = $exeResult['score']; } $result = []; diff --git a/main/inc/lib/events.lib.php b/main/inc/lib/events.lib.php index e81bcf5c88..e5ddeef681 100644 --- a/main/inc/lib/events.lib.php +++ b/main/inc/lib/events.lib.php @@ -443,8 +443,8 @@ class Event $sql = "UPDATE $table SET exe_exo_id = $exoId, - exe_result = '$score', - exe_weighting = '$weighting', + score = '$score', + max_score = '$weighting', session_id = $sessionId, orig_lp_id = $learnpathId, orig_lp_item_id = $learnpathItemId, @@ -1494,14 +1494,12 @@ class Event $best_score_return = []; foreach ($list as $student_result) { $user_id = $student_result['exe_user_id']; - $current_best_score[$user_id] = $student_result['exe_result']; - - //echo $current_best_score[$user_id].' - '.$best_score_return[$user_id]['exe_result'].'
'; - if (!isset($best_score_return[$user_id]['exe_result'])) { + $current_best_score[$user_id] = $student_result['score']; + if (!isset($best_score_return[$user_id]['score'])) { $best_score_return[$user_id] = $student_result; } - if ($current_best_score[$user_id] > $best_score_return[$user_id]['exe_result']) { + if ($current_best_score[$user_id] > $best_score_return[$user_id]['score']) { $best_score_return[$user_id] = $student_result; } } @@ -1547,15 +1545,15 @@ class Event } //Getting the best results of every student $best_score_return = []; - $best_score_return['exe_result'] = 0; + $best_score_return['score'] = 0; foreach ($list as $result) { $current_best_score = $result; - if ($current_best_score['exe_result'] > $best_score_return['exe_result']) { + if ($current_best_score['score'] > $best_score_return['score']) { $best_score_return = $result; } } - if (!isset($best_score_return['exe_weighting'])) { + if (!isset($best_score_return['max_score'])) { $best_score_return = []; } diff --git a/main/inc/lib/exercise.lib.php b/main/inc/lib/exercise.lib.php index 615208c110..9f72e949e2 100644 --- a/main/inc/lib/exercise.lib.php +++ b/main/inc/lib/exercise.lib.php @@ -1869,7 +1869,7 @@ HOTSPOT; GroupManager::get_user_group_name($data['user_id']) ), 'exe_date' => $data['exe_date'], - 'score' => $data['exe_result'].' / '.$data['exe_weighting'], + 'score' => $data['score'].' / '.$data['max_score'], 'actions' => $actions, ]; } @@ -2117,8 +2117,8 @@ HOTSPOT; official_code, ce.title, username, - te.exe_result, - te.exe_weighting, + te.score, + te.max_score, te.exe_date, te.exe_id, te.session_id, @@ -2160,8 +2160,8 @@ HOTSPOT; username, official_code, tth.exe_name, - tth.exe_result , - tth.exe_weighting, + tth.score , + tth.max_score, tth.exe_date"; } @@ -2327,7 +2327,7 @@ HOTSPOT; $results[$i]['exe_duration'] = !empty($results[$i]['exe_duration']) ? round($results[$i]['exe_duration'] / 60) : 0; $user_list_id[] = $results[$i]['exe_user_id']; $id = $results[$i]['exe_id']; - $dt = api_convert_and_format_date($results[$i]['exe_weighting']); + $dt = api_convert_and_format_date($results[$i]['max_score']); // we filter the results if we have the permission to $result_disabled = 0; @@ -2335,8 +2335,8 @@ HOTSPOT; $result_disabled = (int) $results[$i]['results_disabled']; } if ($result_disabled == 0) { - $my_res = $results[$i]['exe_result']; - $my_total = $results[$i]['exe_weighting']; + $my_res = $results[$i]['score']; + $my_total = $results[$i]['max_score']; $results[$i]['start_date'] = api_get_local_time($results[$i]['start_date']); $results[$i]['exe_date'] = api_get_local_time($results[$i]['exe_date']); @@ -3377,8 +3377,8 @@ EOT; $position = 1; $my_ranking = []; foreach ($best_attempts as $user_id => $result) { - if (!empty($result['exe_weighting']) && intval($result['exe_weighting']) != 0) { - $my_ranking[$user_id] = $result['exe_result'] / $result['exe_weighting']; + if (!empty($result['max_score']) && intval($result['max_score']) != 0) { + $my_ranking[$user_id] = $result['score'] / $result['max_score']; } else { $my_ranking[$user_id] = 0; } @@ -3460,8 +3460,8 @@ EOT; $position = 1; $my_ranking = []; foreach ($user_results as $result) { - if (!empty($result['exe_weighting']) && intval($result['exe_weighting']) != 0) { - $my_ranking[$result['exe_id']] = $result['exe_result'] / $result['exe_weighting']; + if (!empty($result['max_score']) && intval($result['max_score']) != 0) { + $my_ranking[$result['exe_id']] = $result['score'] / $result['max_score']; } else { $my_ranking[$result['exe_id']] = 0; } @@ -3518,10 +3518,10 @@ EOT; $best_score = 0; if (!empty($user_results)) { foreach ($user_results as $result) { - if (!empty($result['exe_weighting']) && - intval($result['exe_weighting']) != 0 + if (!empty($result['max_score']) && + intval($result['max_score']) != 0 ) { - $score = $result['exe_result'] / $result['exe_weighting']; + $score = $result['score'] / $result['max_score']; if ($score >= $best_score) { $best_score = $score; $best_score_data = $result; @@ -3560,8 +3560,8 @@ EOT; $best_score = 0; if (!empty($user_results)) { foreach ($user_results as $result) { - if (!empty($result['exe_weighting']) && intval($result['exe_weighting']) != 0) { - $score = $result['exe_result'] / $result['exe_weighting']; + if (!empty($result['max_score']) && intval($result['max_score']) != 0) { + $score = $result['score'] / $result['max_score']; if ($score >= $best_score) { $best_score = $score; $best_score_data = $result; @@ -3592,8 +3592,8 @@ EOT; $avg_score = 0; if (!empty($user_results)) { foreach ($user_results as $result) { - if (!empty($result['exe_weighting']) && intval($result['exe_weighting']) != 0) { - $score = $result['exe_result'] / $result['exe_weighting']; + if (!empty($result['max_score']) && intval($result['max_score']) != 0) { + $score = $result['score'] / $result['max_score']; $avg_score += $score; } } @@ -3621,15 +3621,15 @@ EOT; $avg_score = 0; if (!empty($user_results)) { foreach ($user_results as $result) { - if (!empty($result['exe_weighting']) && intval( - $result['exe_weighting'] + if (!empty($result['max_score']) && intval( + $result['max_score'] ) != 0 ) { - $score = $result['exe_result'] / $result['exe_weighting']; + $score = $result['score'] / $result['max_score']; $avg_score += $score; } } - // We assume that all exe_weighting + // We assume that all max_score $avg_score = $avg_score / count($user_results); } @@ -3656,12 +3656,12 @@ EOT; $avg_score = 0; if (!empty($user_results)) { foreach ($user_results as $result) { - if (!empty($result['exe_weighting']) && intval($result['exe_weighting']) != 0) { - $score = $result['exe_result'] / $result['exe_weighting']; + if (!empty($result['max_score']) && intval($result['max_score']) != 0) { + $score = $result['score'] / $result['max_score']; $avg_score += $score; } } - // We assume that all exe_weighting + // We assume that all max_score $avg_score = ($avg_score / count($user_results)); } @@ -3691,14 +3691,12 @@ EOT; $avg_score = 0; if (!empty($user_results)) { foreach ($user_results as $result) { - if (!empty($result['exe_weighting']) && intval($result['exe_weighting']) != 0) { - $score = $result['exe_result'] / $result['exe_weighting']; + if (!empty($result['max_score']) && intval($result['max_score']) != 0) { + $score = $result['score'] / $result['max_score']; $avg_score += $score; } } - //We asumme that all exe_weighting - //$avg_score = show_score( $avg_score / count($user_results) , $result['exe_weighting']); - //$avg_score = ($avg_score / count($user_results)); + // We asumme that all max_score if (!empty($user_count)) { $avg_score = float_format($avg_score / $user_count, 1) * 100; } else { @@ -3731,8 +3729,8 @@ EOT; $avg_score = 0; if (!empty($user_results)) { foreach ($user_results as $result) { - if (!empty($result['exe_weighting']) && intval($result['exe_weighting']) != 0) { - $score = $result['exe_result'] / $result['exe_weighting']; + if (!empty($result['max_score']) && intval($result['max_score']) != 0) { + $score = $result['score'] / $result['max_score']; $avg_score += $score; } } diff --git a/main/inc/lib/myspace.lib.php b/main/inc/lib/myspace.lib.php index 9cd4c6ba5b..b827547883 100644 --- a/main/inc/lib/myspace.lib.php +++ b/main/inc/lib/myspace.lib.php @@ -1847,7 +1847,7 @@ class MySpace public static function exercises_results($user_id, $course_code, $session_id = false) { $courseId = api_get_course_int_id($course_code); - $sql = 'SELECT exe_result, exe_weighting + $sql = 'SELECT score, max_score FROM '.Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES)." WHERE c_id = ' . $courseId . ' AND @@ -1860,8 +1860,8 @@ class MySpace $score_possible = 0; $questions_answered = 0; while ($row = Database::fetch_array($result)) { - $score_obtained += $row['exe_result']; - $score_possible += $row['exe_weighting']; + $score_obtained += $row['score']; + $score_possible += $row['max_score']; $questions_answered++; } diff --git a/main/inc/lib/tracking.lib.php b/main/inc/lib/tracking.lib.php index ce1d7318d0..b0fc15253b 100755 --- a/main/inc/lib/tracking.lib.php +++ b/main/inc/lib/tracking.lib.php @@ -1016,8 +1016,8 @@ class Tracking if ($num_attempts > 0) { $n = 1; while ($row_attempts = Database::fetch_array($res_attempts)) { - $my_score = $row_attempts['exe_result']; - $my_maxscore = $row_attempts['exe_weighting']; + $my_score = $row_attempts['score']; + $my_maxscore = $row_attempts['max_score']; $my_exe_id = $row_attempts['exe_id']; $mktime_start_date = api_strtotime($row_attempts['start_date'], 'UTC'); $mktime_exe_date = api_strtotime($row_attempts['exe_date'], 'UTC'); @@ -2090,7 +2090,7 @@ class Tracking $count_quiz = Database::fetch_row(Database::query($sql)); $sql = "SELECT - SUM(exe_result/exe_weighting*100) as avg_score, + SUM(score/max_score*100) as avg_score, COUNT(*) as num_attempts $select_lp_id FROM $tbl_stats_exercise @@ -2284,8 +2284,8 @@ class Tracking $session_id ); - if (!empty($best_attempt) && !empty($best_attempt['exe_weighting'])) { - $result += $best_attempt['exe_result'] / $best_attempt['exe_weighting']; + if (!empty($best_attempt) && !empty($best_attempt['max_score'])) { + $result += $best_attempt['score'] / $best_attempt['max_score']; } } $result = $result / count($exercise_list); @@ -2894,9 +2894,9 @@ class Tracking // the current lp for the current user $order = 'exe_date DESC'; if ($getOnlyBestAttempt) { - $order = 'exe_result DESC'; + $order = 'score DESC'; } - $sql = "SELECT exe_id, exe_result + $sql = "SELECT exe_id, score FROM $tbl_stats_exercices WHERE exe_exo_id = '$item_path' AND @@ -2922,7 +2922,7 @@ class Tracking if ($debug) { echo "Following score comes from the track_exercise table not in the LP because the score is the best
"; } - $score = $attemptResult['exe_result']; + $score = $attemptResult['score']; } if ($debug) { @@ -4859,8 +4859,8 @@ class Tracking $best = 0; if (!empty($results)) { foreach ($results as $result) { - if (!empty($result['exe_weighting'])) { - $score = $result['exe_result'] / $result['exe_weighting']; + if (!empty($result['max_score'])) { + $score = $result['score'] / $result['max_score']; if ($score > $best) { $best = $score; } @@ -4996,8 +4996,8 @@ class Tracking ); $score = 0; - if (!empty($user_result_data['exe_weighting']) && intval($user_result_data['exe_weighting']) != 0) { - $score = intval($user_result_data['exe_result'] / $user_result_data['exe_weighting'] * 100); + if (!empty($user_result_data['max_score']) && intval($user_result_data['max_score']) != 0) { + $score = intval($user_result_data['score'] / $user_result_data['max_score'] * 100); } $time = api_strtotime($exercise_data['start_time']) ? api_strtotime($exercise_data['start_time'], 'UTC') : 0; $all_exercise_start_time[] = $time; @@ -5546,8 +5546,8 @@ class Tracking $best_score = ''; if (!empty($best_score_data)) { $best_score = ExerciseLib::show_score( - $best_score_data['exe_result'], - $best_score_data['exe_weighting'] + $best_score_data['score'], + $best_score_data['max_score'] ); } @@ -5560,8 +5560,8 @@ class Tracking ); if (!empty($exercise_stat)) { // Always getting the BEST attempt - $score = $exercise_stat['exe_result']; - $weighting = $exercise_stat['exe_weighting']; + $score = $exercise_stat['score']; + $weighting = $exercise_stat['max_score']; $exe_id = $exercise_stat['exe_id']; $latest_attempt_url .= api_get_path(WEB_CODE_PATH).'exercise/result.php?id='.$exe_id.'&cidReq='.$course_info['code'].'&show_headers=1&id_session='.$session_id; @@ -5985,12 +5985,12 @@ class Tracking foreach ($attempts as $attempt) { if (api_get_user_id() == $attempt['exe_user_id']) { - if ($attempt['exe_weighting'] != 0) { - $my_exercise_result_array[] = $attempt['exe_result'] / $attempt['exe_weighting']; + if ($attempt['max_score'] != 0) { + $my_exercise_result_array[] = $attempt['score'] / $attempt['max_score']; } } else { - if ($attempt['exe_weighting'] != 0) { - $exercise_result[] = $attempt['exe_result'] / $attempt['exe_weighting']; + if ($attempt['max_score'] != 0) { + $exercise_result[] = $attempt['score'] / $attempt['max_score']; } } } @@ -6173,12 +6173,12 @@ class Tracking } foreach ($attempts as $attempt) { if (api_get_user_id() == $attempt['exe_user_id']) { - if ($attempt['exe_weighting'] != 0) { - $my_exercise_result_array[] = $attempt['exe_result'] / $attempt['exe_weighting']; + if ($attempt['max_score'] != 0) { + $my_exercise_result_array[] = $attempt['score'] / $attempt['max_score']; } } else { - if ($attempt['exe_weighting'] != 0) { - $exercise_result[] = $attempt['exe_result'] / $attempt['exe_weighting']; + if ($attempt['max_score'] != 0) { + $exercise_result[] = $attempt['score'] / $attempt['max_score']; } } } diff --git a/main/lp/learnpath.class.php b/main/lp/learnpath.class.php index 3b8feb2609..84e042a253 100755 --- a/main/lp/learnpath.class.php +++ b/main/lp/learnpath.class.php @@ -12247,8 +12247,8 @@ EOD; continue; } - if (!empty($exerciseResultInfo['exe_weighting'])) { - $exerciseResult = $exerciseResultInfo['exe_result'] * 100 / $exerciseResultInfo['exe_weighting']; + if (!empty($exerciseResultInfo['max_score'])) { + $exerciseResult = $exerciseResultInfo['score'] * 100 / $exerciseResultInfo['max_score']; } else { $exerciseResult = 0; } @@ -12282,7 +12282,7 @@ EOD; $evaluationResultInfo = end($evaluationResultInfo); if ($evaluationResultInfo) { - $evaluationResult = $evaluationResultInfo['exe_result'] * 100 / $evaluationResultInfo['exe_weighting']; + $evaluationResult = $evaluationResultInfo['score'] * 100 / $evaluationResultInfo['max_score']; if ($evaluationResult >= 80) { $stars++; @@ -12364,7 +12364,7 @@ EOD; continue; } - $totalExercisesResult += $exerciseResultInfo['exe_result']; + $totalExercisesResult += $exerciseResultInfo['score']; } } @@ -12381,7 +12381,7 @@ EOD; $evaluationResultInfo = end($evaluationResultInfo); if ($evaluationResultInfo) { - $totalEvaluationResult += $evaluationResultInfo['exe_result']; + $totalEvaluationResult += $evaluationResultInfo['score']; } } diff --git a/main/lp/learnpathItem.class.php b/main/lp/learnpathItem.class.php index 06b3cc9382..fcfaafd87b 100755 --- a/main/lp/learnpathItem.class.php +++ b/main/lp/learnpathItem.class.php @@ -2482,7 +2482,7 @@ class learnpathItem // 2. If is completed we check the results in the DB of the quiz. if ($returnstatus) { //AND origin_lp_item_id = '.$user_id.' - $sql = 'SELECT exe_result, exe_weighting + $sql = 'SELECT score, max_score FROM '.Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES).' WHERE exe_exo_id = '.$items[$refs_list[$prereqs_string]]->path.' AND @@ -2500,8 +2500,8 @@ class learnpathItem if (isset($minScore) && isset($minScore)) { // Taking min/max prerequisites values see BT#5776 - if ($quiz['exe_result'] >= $minScore && - $quiz['exe_result'] <= $maxScore + if ($quiz['score'] >= $minScore && + $quiz['score'] <= $maxScore ) { $returnstatus = true; } else { @@ -2514,7 +2514,7 @@ class learnpathItem } } else { // Classic way - if ($quiz['exe_result'] >= + if ($quiz['score'] >= $items[$refs_list[$prereqs_string]]->get_mastery_score() ) { $returnstatus = true; @@ -2535,7 +2535,7 @@ class learnpathItem } else { // 3. For multiple attempts we check that there are minimum 1 item completed // Checking in the database. - $sql = 'SELECT exe_result, exe_weighting + $sql = 'SELECT score, max_score FROM '.Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES).' WHERE c_id = '.$course_id.' AND @@ -2552,7 +2552,7 @@ class learnpathItem if (isset($minScore) && isset($minScore)) { // Taking min/max prerequisites values see BT#5776 - if ($quiz['exe_result'] >= $minScore && $quiz['exe_result'] <= $maxScore) { + if ($quiz['score'] >= $minScore && $quiz['score'] <= $maxScore) { $returnstatus = true; break; } else { @@ -2564,7 +2564,7 @@ class learnpathItem $returnstatus = false; } } else { - if ($quiz['exe_result'] >= + if ($quiz['score'] >= $items[$refs_list[$prereqs_string]]->get_mastery_score() ) { $returnstatus = true; diff --git a/main/lp/lp_view.php b/main/lp/lp_view.php index 13c627ce32..b4dda17cc4 100755 --- a/main/lp/lp_view.php +++ b/main/lp/lp_view.php @@ -316,15 +316,15 @@ if (!empty($_REQUEST['exeId']) && if ($safe_id == strval(intval($safe_id)) && $safe_item_id == strval(intval($safe_item_id)) ) { - $sql = 'SELECT start_date, exe_date, exe_result, exe_weighting, exe_exo_id, exe_duration + $sql = 'SELECT start_date, exe_date, score, max_score, exe_exo_id, exe_duration FROM '.$TBL_TRACK_EXERCICES.' WHERE exe_id = '.$safe_exe_id; $res = Database::query($sql); $row_dates = Database::fetch_array($res); $duration = (int) $row_dates['exe_duration']; - $score = (float) $row_dates['exe_result']; - $max_score = (float) $row_dates['exe_weighting']; + $score = (float) $row_dates['score']; + $max_score = (float) $row_dates['max_score']; $sql = "UPDATE $TBL_LP_ITEM SET max_score = '$max_score' diff --git a/main/mySpace/exercise_category_report.php b/main/mySpace/exercise_category_report.php index 6b4bafc536..9d7aeaf0cc 100644 --- a/main/mySpace/exercise_category_report.php +++ b/main/mySpace/exercise_category_report.php @@ -181,7 +181,7 @@ if ($form->validate() && !empty($courseInfo)) { ]; $columnModel[] = [ 'name' => 'score', - 'index' => 'exe_result', + 'index' => 'score', 'width' => '50', 'align' => 'center', 'search' => 'true', diff --git a/main/mySpace/progression.php b/main/mySpace/progression.php index d4b507d66b..1a68750b6d 100755 --- a/main/mySpace/progression.php +++ b/main/mySpace/progression.php @@ -44,15 +44,15 @@ if (Database::num_rows($result_course) > 0) { $header = [get_lang('Course', ''), get_lang('TempsFrequentation', ''), get_lang('Progression', ''), get_lang('MoyenneTest', '')]; while ($a_course = Database::fetch_array($result_course)) { // TODO: This query is to be checked, there are no HotPotatoes tests results. - $sql_moy_test = "SELECT exe_result,exe_weighting + $sql_moy_test = "SELECT score,max_score FROM $tbl_track_exercice WHERE c_id = ".$a_course['id']; $result_moy_test = Database::query($sql_moy_test); $result = 0; $weighting = 0; while ($moy_test = Database::fetch_array($result_moy_test)) { - $result = $result + $moy_test['exe_result']; - $weighting = $weighting + $moy_test['exe_weighting']; + $result = $result + $moy_test['score']; + $weighting = $weighting + $moy_test['max_score']; } if ($weighting != 0) { $moyenne_test = round(($result * 100) / $weighting); diff --git a/main/session/index.php b/main/session/index.php index 185d444ff6..0166f25109 100755 --- a/main/session/index.php +++ b/main/session/index.php @@ -265,7 +265,7 @@ if (!empty($courseList)) { if (!empty($best_score_data)) { $best_score = ExerciseLib::show_score( $best_score_data['exe_result'], - $best_score_data['exe_weighting'] + $best_score_data['max_score'] ); } @@ -312,14 +312,14 @@ if (!empty($courseList)) { $counter = 1; foreach ($exerciseResultInfo as $result) { $platform_score = ExerciseLib::show_score( - $result['exe_result'], - $result['exe_weighting'] + $result['score'], + $result['max_score'] ); $my_score = 0; - if (!empty($result['exe_weighting']) && - intval($result['exe_weighting']) != 0 + if (!empty($result['max_score']) && + intval($result['max_score']) != 0 ) { - $my_score = $result['exe_result'] / $result['exe_weighting']; + $my_score = $result['score'] / $result['max_score']; } $position = ExerciseLib::get_exercise_result_ranking( $my_score, diff --git a/main/tracking/course_session_report.php b/main/tracking/course_session_report.php index a64961189f..f097e12037 100755 --- a/main/tracking/course_session_report.php +++ b/main/tracking/course_session_report.php @@ -113,7 +113,7 @@ foreach ($course_list as $current_course) { ); // Looping Exercise Attempts foreach ($exercise_stats as $stats) { - $attempt_result[$stats['exe_user_id']]['result'] += $stats['exe_result'] / $stats['exe_weighting']; + $attempt_result[$stats['exe_user_id']]['result'] += $stats['score'] / $stats['max_score']; $attempt_result[$stats['exe_user_id']]['attempts']++; } } diff --git a/main/tracking/exams.php b/main/tracking/exams.php index 6a850737d9..d3975931f5 100755 --- a/main/tracking/exams.php +++ b/main/tracking/exams.php @@ -553,21 +553,21 @@ function processStudentList($filter_score, $global, $exercise, $courseInfo, $ses $result = Database::query($sql); $attempts = Database::fetch_array($result); - $sql = "SELECT exe_id, exe_result, exe_weighting + $sql = "SELECT exe_id, score, max_score FROM $exerciseStatsTable WHERE exe_user_id = $studentId AND c_id = $courseId AND exe_exo_id = ".$exercise['id']." AND session_id = $sessionId - ORDER BY exe_result DESC + ORDER BY score DESC LIMIT 1"; $result = Database::query($sql); $score = 0; $weighting = 0; while ($scoreInfo = Database::fetch_array($result)) { - $score = $score + $scoreInfo['exe_result']; - $weighting = $weighting + $scoreInfo['exe_weighting']; + $score = $score + $scoreInfo['score']; + $weighting = $weighting + $scoreInfo['max_score']; } $percentageScore = 0; diff --git a/main/tracking/lp_results_by_user.php b/main/tracking/lp_results_by_user.php index 7e1fd602b0..7335afae27 100755 --- a/main/tracking/lp_results_by_user.php +++ b/main/tracking/lp_results_by_user.php @@ -200,7 +200,7 @@ if (!empty($main_result)) { $html_result .= Display::tag('td', $lp_list_name[$lp_id]); $html_result .= Display::tag('td', $exercise_list_name[$exercise_id]); $html_result .= Display::tag('td', $user_list_name[$user_id]); - $result = $attempt_data['exe_result'].' / '.$attempt_data['exe_weighting']; + $result = $attempt_data['score'].' / '.$attempt_data['max_score']; $html_result .= Display::tag('td', $attempt); $html_result .= Display::tag('td', api_get_local_time($attempt_data['exe_date'])); $html_result .= Display::tag('td', $result); diff --git a/src/CoreBundle/Entity/TrackEExercises.php b/src/CoreBundle/Entity/TrackEExercises.php index a253e08737..39f26afeb2 100644 --- a/src/CoreBundle/Entity/TrackEExercises.php +++ b/src/CoreBundle/Entity/TrackEExercises.php @@ -48,16 +48,16 @@ class TrackEExercises /** * @var float * - * @ORM\Column(name="exe_result", type="float", precision=6, scale=2, nullable=false) + * @ORM\Column(name="score", type="float", precision=6, scale=2, nullable=false) */ - protected $exeResult; + protected $score; /** * @var float * - * @ORM\Column(name="exe_weighting", type="float", precision=6, scale=2, nullable=false) + * @ORM\Column(name="max_score", type="float", precision=6, scale=2, nullable=false) */ - protected $exeWeighting; + protected $maxScore; /** * @var string @@ -248,54 +248,6 @@ class TrackEExercises return $this->exeExoId; } - /** - * Set exeResult. - * - * @param float $exeResult - * - * @return TrackEExercises - */ - public function setExeResult($exeResult) - { - $this->exeResult = $exeResult; - - return $this; - } - - /** - * Get exeResult. - * - * @return float - */ - public function getExeResult() - { - return $this->exeResult; - } - - /** - * Set exeWeighting. - * - * @param float $exeWeighting - * - * @return TrackEExercises - */ - public function setExeWeighting($exeWeighting) - { - $this->exeWeighting = $exeWeighting; - - return $this; - } - - /** - * Get exeWeighting. - * - * @return float - */ - public function getExeWeighting() - { - return $this->exeWeighting; - } - /** * Set userIp. * @@ -593,4 +545,44 @@ class TrackEExercises { return $this->exeId; } + + /** + * @return float + */ + public function getScore(): float + { + return $this->score; + } + + /** + * @param float $score + * + * @return TrackEExercises + */ + public function setScore(float $score): TrackEExercises + { + $this->score = $score; + + return $this; + } + + /** + * @return float + */ + public function getMaxScore(): float + { + return $this->maxScore; + } + + /** + * @param float $maxScore + * + * @return TrackEExercises + */ + public function setMaxScore(float $maxScore): TrackEExercises + { + $this->maxScore = $maxScore; + + return $this; + } } diff --git a/src/CoreBundle/Entity/TrackEHotpotatoes.php b/src/CoreBundle/Entity/TrackEHotpotatoes.php index c128ed933e..95a0f91417 100644 --- a/src/CoreBundle/Entity/TrackEHotpotatoes.php +++ b/src/CoreBundle/Entity/TrackEHotpotatoes.php @@ -56,16 +56,16 @@ class TrackEHotpotatoes /** * @var int * - * @ORM\Column(name="exe_result", type="smallint", nullable=false) + * @ORM\Column(name="score", type="smallint", nullable=false) */ - protected $exeResult; + protected $score; /** * @var int * - * @ORM\Column(name="exe_weighting", type="smallint", nullable=false) + * @ORM\Column(name="max_score", type="smallint", nullable=false) */ - protected $exeWeighting; + protected $maxScore; /** * Set exeName. @@ -164,60 +164,52 @@ class TrackEHotpotatoes } /** - * Set exeResult. - * - * @param int $exeResult + * Get id. * - * @return TrackEHotpotatoes + * @return int */ - public function setExeResult($exeResult) + public function getId() { - $this->exeResult = $exeResult; - - return $this; + return $this->id; } /** - * Get exeResult. - * * @return int */ - public function getExeResult() + public function getScore(): int { - return $this->exeResult; + return $this->score; } /** - * Set exeWeighting. - * - * @param int $exeWeighting + * @param int $score * * @return TrackEHotpotatoes */ - public function setExeWeighting($exeWeighting) + public function setScore(int $score): TrackEHotpotatoes { - $this->exeWeighting = $exeWeighting; + $this->score = $score; return $this; } /** - * Get exeWeighting. - * * @return int */ - public function getExeWeighting() + public function getMaxScore(): int { - return $this->exeWeighting; + return $this->maxScore; } /** - * Get id. + * @param int $maxScore * - * @return int + * @return TrackEHotpotatoes */ - public function getId() + public function setMaxScore(int $maxScore): TrackEHotpotatoes { - return $this->id; + $this->maxScore = $maxScore; + + return $this; } } diff --git a/tests/scripts/fix_exercise_score_in_lp.php b/tests/scripts/fix_exercise_score_in_lp.php index a4432bf756..cbb6a80416 100644 --- a/tests/scripts/fix_exercise_score_in_lp.php +++ b/tests/scripts/fix_exercise_score_in_lp.php @@ -16,9 +16,9 @@ $tableCourse = Database::get_main_table(TABLE_MAIN_COURSE); $sql = "SELECT exe_id, - exe_result, + score, exe_user_id, - exe_result, + score, exe_exo_id, orig_lp_id, orig_lp_item_view_id, @@ -74,17 +74,17 @@ if (!empty($items)) { $count = count($attempts); if ($count == 1) { $attempt = current($attempts); - $score = $item['exe_result']; + $score = $item['score']; - /* The attempt has empty exe_result and the LP is good + /* The attempt has empty score and the LP is good there must be another attempt, do nothing. */ - if ((empty($item['exe_result']) || $item['exe_result'] == 0) && !empty($attempt['score'])) { + if ((empty($item['score']) || $item['score'] == 0) && !empty($attempt['score'])) { var_dump('Skipped'); echo '
'; continue; } - echo "Score: ".$attempt['score']. ' - '.$item['exe_result'].'
'; + echo "Score: ".$attempt['score']. ' - '.$item['score'].'
'; $itemViewId = $attempt['lp_item_view_id']; $sql = "UPDATE $table SET @@ -106,8 +106,8 @@ if (!empty($items)) { } else { echo 'Cannot update multiple attempts checking attempts:
'; foreach ($attempts as $attempt) { - if ($attempt['score'] == $item['exe_result']) { - /*echo "Score: ".$attempt['score']. ' - '.$item['exe_result'].'
'; + if ($attempt['score'] == $item['score']) { + /*echo "Score: ".$attempt['score']. ' - '.$item['score'].'
'; $itemViewId = $attempt['id']; $sql = "UPDATE $tableExercise SET orig_lp_item_view_id = $itemViewId diff --git a/tests/scripts/fix_restored_learnpaths.php b/tests/scripts/fix_restored_learnpaths.php index da05aa783a..117e95d474 100644 --- a/tests/scripts/fix_restored_learnpaths.php +++ b/tests/scripts/fix_restored_learnpaths.php @@ -15,7 +15,7 @@ $qb1 = $em->createQueryBuilder(); $result1 = $qb1 ->select('lp') ->from('ChamiloCourseBundle:CLp', 'lp') - ->innerJoin('ChamiloCourseBundle:CTool', 't', JOIN::WITH, 'lp.cId = t.course AND lp.name = t.name') + ->innerJoin('ChamiloCourseBundle:CTool', 't', JOIN::WITH, 'lp.cId = t.cId AND lp.name = t.name') ->where( $qb1->expr()->eq('t.link', ':link') ) @@ -37,7 +37,7 @@ foreach ($result1 as $i => $lp) { $qb2->expr()->andX( $qb2->expr()->eq('t.link', ':link'), $qb2->expr()->eq('t.name', ':name'), - $qb2->expr()->eq('t.course', ':cid') + $qb2->expr()->eq('t.cId', ':cid') ) ) ->setParameters([