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
pull/2715/head
Julio Montoya 8 years ago
parent b0eac130b9
commit 601a1da769
  1. 5
      app/Migrations/Schema/V200/Version20.php
  2. 4
      main/admin/user_move_stats.php
  3. 8
      main/exercise/exercise.class.php
  4. 10
      main/exercise/exercise.php
  5. 6
      main/exercise/exercise_report.php
  6. 8
      main/exercise/exercise_result.class.php
  7. 2
      main/exercise/exercise_result.php
  8. 4
      main/exercise/exercise_submit.php
  9. 4
      main/exercise/hotpotatoes_exercise_report.php
  10. 10
      main/exercise/hotpotatoes_exercise_result.class.php
  11. 4
      main/exercise/overview.php
  12. 2
      main/exercise/recalculate.php
  13. 4
      main/exercise/savescores.php
  14. 16
      main/gradebook/lib/be/exerciselink.class.php
  15. 14
      main/inc/ajax/exercise.ajax.php
  16. 2
      main/inc/ajax/model.ajax.php
  17. 18
      main/inc/lib/events.lib.php
  18. 64
      main/inc/lib/exercise.lib.php
  19. 6
      main/inc/lib/myspace.lib.php
  20. 48
      main/inc/lib/tracking.lib.php
  21. 10
      main/lp/learnpath.class.php
  22. 14
      main/lp/learnpathItem.class.php
  23. 6
      main/lp/lp_view.php
  24. 2
      main/mySpace/exercise_category_report.php
  25. 6
      main/mySpace/progression.php
  26. 12
      main/session/index.php
  27. 2
      main/tracking/course_session_report.php
  28. 8
      main/tracking/exams.php
  29. 2
      main/tracking/lp_results_by_user.php
  30. 96
      src/CoreBundle/Entity/TrackEExercises.php
  31. 50
      src/CoreBundle/Entity/TrackEHotpotatoes.php
  32. 16
      tests/scripts/fix_exercise_score_in_lp.php
  33. 4
      tests/scripts/fix_restored_learnpaths.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']],

@ -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))) {

@ -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'],
];
}

@ -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 = '<a href="hotpotatoes_exercise_report.php?'.api_get_cidreq().'&path='.$path.'&filter_by_user='.$userId.'">'.Display::return_icon('test_results.png', get_lang('Results'), '', ICON_SIZE_SMALL).'</a>';
$attemptText = get_lang('LatestAttempt').' : ';
$attemptText .= ExerciseLib::show_score(
$attempt['exe_result'],
$attempt['exe_weighting']
$attempt['score'],
$attempt['max_score']
).' ';
$attemptText .= $actions;
} else {

@ -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

@ -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,

@ -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();

@ -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,

@ -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'],
];
}

@ -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;

@ -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&';

@ -63,7 +63,7 @@ foreach ($attempts as $attempt) {
$em->merge($attempt);
}
$trackedExercise->setExeResult($newResult);
$trackedExercise->setScore($newResult);
$em->merge($trackedExercise);
$em->flush();

@ -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);

@ -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'];
}
}
}

@ -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);

@ -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 = [];

@ -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'].'<br />';
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 = [];
}

@ -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;
}
}

@ -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++;
}

@ -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<br />";
}
$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'];
}
}
}

@ -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'];
}
}

@ -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;

@ -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'

@ -181,7 +181,7 @@ if ($form->validate() && !empty($courseInfo)) {
];
$columnModel[] = [
'name' => 'score',
'index' => 'exe_result',
'index' => 'score',
'width' => '50',
'align' => 'center',
'search' => 'true',

@ -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);

@ -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,

@ -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']++;
}
}

@ -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;

@ -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);

@ -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;
}
}

@ -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;
}
}

@ -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 '<br />';
continue;
}
echo "Score: ".$attempt['score']. ' - '.$item['exe_result'].'<br />';
echo "Score: ".$attempt['score']. ' - '.$item['score'].'<br />';
$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:<br />';
foreach ($attempts as $attempt) {
if ($attempt['score'] == $item['exe_result']) {
/*echo "Score: ".$attempt['score']. ' - '.$item['exe_result'].'<br />';
if ($attempt['score'] == $item['score']) {
/*echo "Score: ".$attempt['score']. ' - '.$item['score'].'<br />';
$itemViewId = $attempt['id'];
$sql = "UPDATE $tableExercise
SET orig_lp_item_view_id = $itemViewId

@ -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([

Loading…
Cancel
Save