Updating from mine repo.

skala
Julio Montoya 12 years ago
parent aa2d77466d
commit c4f1dc053d
  1. 52
      main/exercice/exercise.class.php
  2. 3
      main/exercice/testcategory.class.php
  3. 51
      main/inc/lib/exercise.lib.php

@ -606,6 +606,20 @@ class Exercise
return $count;
}
public function getQuestionOrderedListByName()
{
$TBL_EXERCICE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
$TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
// Getting question list from the order (question list drag n drop interface ).
$sql = "SELECT e.question_id
FROM $TBL_EXERCICE_QUESTION e INNER JOIN $TBL_QUESTIONS q
ON (e.question_id= q.iid)
WHERE e.c_id = {$this->course_id} AND e.exercice_id = '".Database::escape_string($this->id)."'
ORDER BY q.question";
$result = Database::query($sql);
return $result->fetchAll();
}
/**
* Gets the question list ordered by the question_order setting (drag and drop)
* @return array
@ -859,7 +873,7 @@ class Exercise
* @param bool $from_db
* @return array question ID list
*/
private function selectQuestionList($from_db = false)
public function selectQuestionList($from_db = false)
{
if ($from_db && !empty($this->id)) {
@ -4290,7 +4304,7 @@ class Exercise
}
saveQuestionAttempt($questionScore, 1, $quesId, $exeId, 0, null, $updateResults); // we always insert the answer_id 1 = delineation
//in delineation mode, get the answer from $hotspot_delineation_result[1]
saveExerciseAttemptHotspot($exeId, $quesId, $objAnswerTmp->getRealAnswerIdFromList(1), $hotspot_delineation_result[1], $exerciseResultCoordinates[$quesId], null, $updateResults);
saveExerciseAttemptHotspot($exeId, $quesId, $objAnswerTmp->getRealAnswerIdFromList(1), $hotspot_delineation_result[1], $exerciseResultCoordinates[$quesId], $updateResults);
} else {
if ($final_answer == 0) {
$questionScore = 0;
@ -4742,10 +4756,15 @@ class Exercise
$array[] = array('title' => get_lang("User"), 'content' => $user_data);
}
// Description can be very long and is generally meant to explain
// rules *before* the exam. Leaving here to make display easier if
// necessary
/*
if (!empty($this->description)) {
$array[] = array('title' => get_lang("Description"), 'content' => $this->description);
}
*/
if (!empty($start_date)) {
$array[] = array('title' => get_lang("StartDate"), 'content' => $start_date);
}
@ -5702,19 +5721,21 @@ class Exercise
$before = 0;
if (!empty($categories)) {
/*
$newCategoryList = array();
/*var_dump($categories);
foreach ($categories as $category) {
var_dump($this->getFirstParent($category['id']));
$newCategoryList = $category;
foreach ($categories as $category) {
foreach ($categories as $category) {
}
if (!isset($newCategoryList[$category['root']])) {
$newCategoryList[$category['root']] = $category;
} else {
$oldQuestionList = $newCategoryList[$category['root']]['question_list'];
$category['question_list'] = array_merge($oldQuestionList , $category['question_list']);
$newCategoryList[$category['root']] = $category;
}
}*/
//$categories = $newCategoryList;
foreach ($categories as $category) {
$questionList = $category['question_list'];
// Check if in this category there questions added in a media
@ -6349,19 +6370,4 @@ class Exercise
}
public function getQuestionOrderedListByName()
{
$TBL_EXERCICE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
$TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
// Getting question list from the order (question list drag n drop interface ).
$sql = "SELECT e.question_id
FROM $TBL_EXERCICE_QUESTION e INNER JOIN $TBL_QUESTIONS q
ON (e.question_id= q.iid)
WHERE e.c_id = {$this->course_id} AND e.exercice_id = '".Database::escape_string($this->id)."'
ORDER BY q.question";
$result = Database::query($sql);
return $result->fetchAll();
}
}

@ -15,6 +15,7 @@ class Testcategory
public $type;
public $course_id;
public $c_id; // from db
public $root;
/**
* Constructor of the class Category
@ -42,6 +43,7 @@ class Testcategory
$this->parent_id = $tmpobj->parent_id;
$this->parent_path = $this->name;
$this->c_id = $tmpobj->c_id;
$this->root = $tmpobj->root;
if (!empty($tmpobj->parent_id)) {
$category = new Testcategory($tmpobj->parent_id);
@ -86,6 +88,7 @@ class Testcategory
$this->description = $row['description'];
$this->parent_id = $row['parent_id'];
$this->c_id = $row['c_id'];
$this->root = $row['root'];
} else {
return false;
}

@ -14,6 +14,7 @@
* Code
*/
use ChamiloSession as Session;
class ExerciseLib
{
/**
@ -2295,6 +2296,56 @@ class ExerciseLib
$sql = "UPDATE $exercice_attemp_table SET tms = '".api_get_utc_datetime()."'
WHERE exe_id = $exeId AND tms = '".$last_attempt_date."' ";
Database::query($sql);
}
public static function getExerciseResult($trackExerciseInfo)
{
$TBL_EXERCICE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
$TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
$TBL_TRACK_EXERCICES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$TBL_TRACK_ATTEMPT = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
$query = "SELECT attempts.question_id, answer
FROM ".$TBL_TRACK_ATTEMPT." as attempts
INNER JOIN ".$TBL_TRACK_EXERCICES." AS stats_exercices
ON stats_exercices.exe_id=attempts.exe_id
INNER JOIN ".$TBL_EXERCICE_QUESTION." AS quizz_rel_questions
ON quizz_rel_questions.exercice_id=stats_exercices.exe_exo_id AND
quizz_rel_questions.question_id = attempts.question_id AND
quizz_rel_questions.c_id=".$trackExerciseInfo['c_id']."
INNER JOIN ".$TBL_QUESTIONS." AS questions
ON questions.iid=quizz_rel_questions.question_id AND
questions.c_id = ".$trackExerciseInfo['c_id']."
WHERE attempts.exe_id='".$trackExerciseInfo['exe_id']."' AND user_id=".intval($trackExerciseInfo['exe_user_id'])."
GROUP BY quizz_rel_questions.question_order, attempts.question_id";
$result = Database::query($query);
$exerciseResult = array();
while ($row = Database::fetch_array($result)) {
$exerciseResult[$row['question_id']] = $row['answer'];
}
return $exerciseResult;
}
public static function getExerciseResults($exerciseId, $courseId, $sessionId)
{
$track_exercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$track_attempt = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
$exerciseId = intval($exerciseId);
$courseId = intval($courseId);
$sessionId = intval($sessionId);
$sql = "SELECT DISTINCT e.exe_id, e.data_tracking
FROM $track_exercises e INNER JOIN $track_attempt a ON (a.exe_id = e.exe_id)
WHERE exe_exo_id = $exerciseId AND
a.c_id = $courseId AND
e.c_id = $courseId AND
e.session_id = $sessionId AND
status = ''";
$result = Database::query($sql);
return $result->fetchAll();
}
}

Loading…
Cancel
Save