Renaming function from saveExerciseAttempt to saveQuestionAttempt

skala
Julio Montoya 12 years ago
parent ef00553532
commit fddbc2f8c3
  1. 2
      .htaccess
  2. 30
      main/exercice/exercise.class.php
  3. 11
      main/inc/lib/events.lib.inc.php

@ -3,7 +3,7 @@
Options +FollowSymLinks Options +FollowSymLinks
RewriteEngine On RewriteEngine On
RewriteBase / RewriteBase /chamilogits
# Courses home # Courses home
RewriteCond %{QUERY_STRING} ^id_session=0 RewriteCond %{QUERY_STRING} ^id_session=0

@ -4272,21 +4272,21 @@ class Exercise
if ($final_answer == 0) { if ($final_answer == 0) {
$questionScore = 0; $questionScore = 0;
} }
saveExerciseAttempt($questionScore, 1, $quesId, $exeId, 0); // we always insert the answer_id 1 = delineation saveQuestionAttempt($questionScore, 1, $quesId, $exeId, 0); // we always insert the answer_id 1 = delineation
//in delineation mode, get the answer from $hotspot_delineation_result[1] //in delineation mode, get the answer from $hotspot_delineation_result[1]
saveExerciseAttemptHotspot($exeId, $quesId, $objAnswerTmp->getRealAnswerIdFromList(1), $hotspot_delineation_result[1], $exerciseResultCoordinates[$quesId]); saveExerciseAttemptHotspot($exeId, $quesId, $objAnswerTmp->getRealAnswerIdFromList(1), $hotspot_delineation_result[1], $exerciseResultCoordinates[$quesId]);
} else { } else {
if ($final_answer == 0) { if ($final_answer == 0) {
$questionScore = 0; $questionScore = 0;
$answer = 0; $answer = 0;
saveExerciseAttempt($questionScore, $answer, $quesId, $exeId, 0); saveQuestionAttempt($questionScore, $answer, $quesId, $exeId, 0);
if (is_array($exerciseResultCoordinates[$quesId])) { if (is_array($exerciseResultCoordinates[$quesId])) {
foreach ($exerciseResultCoordinates[$quesId] as $idx => $val) { foreach ($exerciseResultCoordinates[$quesId] as $idx => $val) {
saveExerciseAttemptHotspot($exeId, $quesId, $objAnswerTmp->getRealAnswerIdFromList($idx), 0, $val); saveExerciseAttemptHotspot($exeId, $quesId, $objAnswerTmp->getRealAnswerIdFromList($idx), 0, $val);
} }
} }
} else { } else {
saveExerciseAttempt($questionScore, $answer, $quesId, $exeId, 0); saveQuestionAttempt($questionScore, $answer, $quesId, $exeId, 0);
if (is_array($exerciseResultCoordinates[$quesId])) { if (is_array($exerciseResultCoordinates[$quesId])) {
foreach ($exerciseResultCoordinates[$quesId] as $idx => $val) { foreach ($exerciseResultCoordinates[$quesId] as $idx => $val) {
saveExerciseAttemptHotspot($exeId, $quesId, $objAnswerTmp->getRealAnswerIdFromList($idx), $choice[$idx], $val); saveExerciseAttemptHotspot($exeId, $quesId, $objAnswerTmp->getRealAnswerIdFromList($idx), $choice[$idx], $val);
@ -4349,13 +4349,13 @@ class Exercise
$reply = array_keys($choice); $reply = array_keys($choice);
for ($i = 0; $i < sizeof($reply); $i++) { for ($i = 0; $i < sizeof($reply); $i++) {
$ans = $reply[$i]; $ans = $reply[$i];
saveExerciseAttempt($questionScore, $ans.':'.$choice[$ans], $quesId, $exeId, $i, $this->id); saveQuestionAttempt($questionScore, $ans.':'.$choice[$ans], $quesId, $exeId, $i, $this->id);
if ($debug) { if ($debug) {
error_log('result =>'.$questionScore.' '.$ans.':'.$choice[$ans]); error_log('result =>'.$questionScore.' '.$ans.':'.$choice[$ans]);
} }
} }
} else { } else {
saveExerciseAttempt($questionScore, 0, $quesId, $exeId, 0, $this->id); saveQuestionAttempt($questionScore, 0, $quesId, $exeId, 0, $this->id);
} }
} elseif ($answerType == MULTIPLE_ANSWER || $answerType == GLOBAL_MULTIPLE_ANSWER) { } elseif ($answerType == MULTIPLE_ANSWER || $answerType == GLOBAL_MULTIPLE_ANSWER) {
if ($choice != 0) { if ($choice != 0) {
@ -4366,46 +4366,46 @@ class Exercise
} }
for ($i = 0; $i < sizeof($reply); $i++) { for ($i = 0; $i < sizeof($reply); $i++) {
$ans = $reply[$i]; $ans = $reply[$i];
saveExerciseAttempt($questionScore, $ans, $quesId, $exeId, $i, $this->id); saveQuestionAttempt($questionScore, $ans, $quesId, $exeId, $i, $this->id);
} }
} else { } else {
saveExerciseAttempt($questionScore, 0, $quesId, $exeId, 0, $this->id); saveQuestionAttempt($questionScore, 0, $quesId, $exeId, 0, $this->id);
} }
} elseif ($answerType == MULTIPLE_ANSWER_COMBINATION) { } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION) {
if ($choice != 0) { if ($choice != 0) {
$reply = array_keys($choice); $reply = array_keys($choice);
for ($i = 0; $i < sizeof($reply); $i++) { for ($i = 0; $i < sizeof($reply); $i++) {
$ans = $reply[$i]; $ans = $reply[$i];
saveExerciseAttempt($questionScore, $ans, $quesId, $exeId, $i, $this->id); saveQuestionAttempt($questionScore, $ans, $quesId, $exeId, $i, $this->id);
} }
} else { } else {
saveExerciseAttempt($questionScore, 0, $quesId, $exeId, 0, $this->id); saveQuestionAttempt($questionScore, 0, $quesId, $exeId, 0, $this->id);
} }
} elseif ($answerType == MATCHING || $answerType == DRAGGABLE) { } elseif ($answerType == MATCHING || $answerType == DRAGGABLE) {
if (isset($matching)) { if (isset($matching)) {
foreach ($matching as $j => $val) { foreach ($matching as $j => $val) {
saveExerciseAttempt($questionScore, $val, $quesId, $exeId, $j, $this->id); saveQuestionAttempt($questionScore, $val, $quesId, $exeId, $j, $this->id);
} }
} }
} elseif ($answerType == FREE_ANSWER) { } elseif ($answerType == FREE_ANSWER) {
$answer = $choice; $answer = $choice;
saveExerciseAttempt($questionScore, $answer, $quesId, $exeId, 0, $this->id); saveQuestionAttempt($questionScore, $answer, $quesId, $exeId, 0, $this->id);
} elseif ($answerType == ORAL_EXPRESSION) { } elseif ($answerType == ORAL_EXPRESSION) {
$answer = $choice; $answer = $choice;
saveExerciseAttempt($questionScore, $answer, $quesId, $exeId, 0, $this->id, $nano); saveQuestionAttempt($questionScore, $answer, $quesId, $exeId, 0, $this->id, $nano);
} elseif ($answerType == UNIQUE_ANSWER || $answerType == UNIQUE_ANSWER_IMAGE || $answerType == UNIQUE_ANSWER_NO_OPTION) { } elseif ($answerType == UNIQUE_ANSWER || $answerType == UNIQUE_ANSWER_IMAGE || $answerType == UNIQUE_ANSWER_NO_OPTION) {
$answer = $choice; $answer = $choice;
saveExerciseAttempt($questionScore, $answer, $quesId, $exeId, 0, $this->id); saveQuestionAttempt($questionScore, $answer, $quesId, $exeId, 0, $this->id);
// } elseif ($answerType == HOT_SPOT || $answerType == HOT_SPOT_DELINEATION) { // } elseif ($answerType == HOT_SPOT || $answerType == HOT_SPOT_DELINEATION) {
} elseif ($answerType == HOT_SPOT) { } elseif ($answerType == HOT_SPOT) {
saveExerciseAttempt($questionScore, $answer, $quesId, $exeId, 0, $this->id); saveQuestionAttempt($questionScore, $answer, $quesId, $exeId, 0, $this->id);
if (isset($exerciseResultCoordinates[$questionId]) && !empty($exerciseResultCoordinates[$questionId])) { if (isset($exerciseResultCoordinates[$questionId]) && !empty($exerciseResultCoordinates[$questionId])) {
foreach ($exerciseResultCoordinates[$questionId] as $idx => $val) { foreach ($exerciseResultCoordinates[$questionId] as $idx => $val) {
saveExerciseAttemptHotspot($exeId, $quesId, $objAnswerTmp->getRealAnswerIdFromList($idx), $choice[$idx], $val, $this->id); saveExerciseAttemptHotspot($exeId, $quesId, $objAnswerTmp->getRealAnswerIdFromList($idx), $choice[$idx], $val, $this->id);
} }
} }
} else { } else {
saveExerciseAttempt($questionScore, $answer, $quesId, $exeId, 0, $this->id); saveQuestionAttempt($questionScore, $answer, $quesId, $exeId, 0, $this->id);
} }
} }

@ -35,8 +35,9 @@ function event_open()
if ($pos === false && $referer != '') { if ($pos === false && $referer != '') {
$ip = api_get_real_ip(); $ip = api_get_real_ip();
$remhost = @ getHostByAddr($ip); $remhost = @ getHostByAddr($ip);
if ($remhost == $ip) if ($remhost == $ip) {
$remhost = "Unknown"; // don't change this $remhost = "Unknown"; // don't change this
}
$reallyNow = api_get_utc_datetime(); $reallyNow = api_get_utc_datetime();
$sql = "INSERT INTO ".$TABLETRACK_OPEN." $sql = "INSERT INTO ".$TABLETRACK_OPEN."
(open_remote_host, (open_remote_host,
@ -46,7 +47,7 @@ function event_open()
VALUES VALUES
('".$remhost."', ('".$remhost."',
'".Database::escape_string($_SERVER['HTTP_USER_AGENT'])."', '".Database::escape_string($referer)."', '$reallyNow')"; '".Database::escape_string($_SERVER['HTTP_USER_AGENT'])."', '".Database::escape_string($referer)."', '$reallyNow')";
$res = Database::query($sql); Database::query($sql);
} }
return 1; return 1;
} }
@ -119,7 +120,7 @@ function event_access_course()
VALUES (".$user_id.", '".$courseId."', '$now', '".$id_session."')"; VALUES (".$user_id.", '".$courseId."', '$now', '".$id_session."')";
Database::query($sql); Database::query($sql);
} }
// end "what's new" notification
return 1; return 1;
} }
@ -439,7 +440,7 @@ function createEventExercise($exo_id)
* @param integer Learnpath item ID (from the c_lp_item table). Default value of null means "get from context". * @param integer Learnpath item ID (from the c_lp_item table). Default value of null means "get from context".
* @return boolean Result of the insert query * @return boolean Result of the insert query
*/ */
function saveExerciseAttempt( function saveQuestionAttempt(
$score, $score,
$answer, $answer,
$question_id, $question_id,
@ -490,7 +491,7 @@ function saveExerciseAttempt(
$TBL_TRACK_ATTEMPT = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT); $TBL_TRACK_ATTEMPT = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
if ($debug) { if ($debug) {
error_log("----- entering saveExerciseAttempt() function ------"); error_log("----- entering saveQuestionAttempt() function ------");
error_log("answer: $answer"); error_log("answer: $answer");
error_log("score: $score"); error_log("score: $score");
error_log("question_id : $question_id"); error_log("question_id : $question_id");

Loading…
Cancel
Save