|
|
|
@ -73,7 +73,6 @@ class TestCategory |
|
|
|
|
$new_id = Database::insert($table, $params); |
|
|
|
|
|
|
|
|
|
if ($new_id) { |
|
|
|
|
|
|
|
|
|
$sql = "UPDATE $table SET id = iid WHERE iid = $new_id"; |
|
|
|
|
Database::query($sql); |
|
|
|
|
|
|
|
|
@ -91,7 +90,6 @@ class TestCategory |
|
|
|
|
|
|
|
|
|
return $new_id; |
|
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -106,7 +104,6 @@ class TestCategory |
|
|
|
|
$tbl_question_rel_cat = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY); |
|
|
|
|
$id = intval($id); |
|
|
|
|
$course_id = api_get_course_int_id(); |
|
|
|
|
|
|
|
|
|
$category = $this->getCategory($id); |
|
|
|
|
|
|
|
|
|
if ($category) { |
|
|
|
@ -205,7 +202,8 @@ class TestCategory |
|
|
|
|
$categories = array(); |
|
|
|
|
if ($in_field == '') { |
|
|
|
|
$sql = "SELECT id FROM $table |
|
|
|
|
WHERE c_id=$courseId ORDER BY title ASC"; |
|
|
|
|
WHERE c_id = $courseId |
|
|
|
|
ORDER BY title ASC"; |
|
|
|
|
$res = Database::query($sql); |
|
|
|
|
while ($row = Database::fetch_array($res)) { |
|
|
|
|
$category = new TestCategory(); |
|
|
|
@ -262,7 +260,6 @@ class TestCategory |
|
|
|
|
public static function isQuestionHasCategory($questionId) |
|
|
|
|
{ |
|
|
|
|
if (TestCategory::getCategoryForQuestion($questionId) > 0) { |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -270,9 +267,11 @@ class TestCategory |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
Return the category name for question with question_id = $questionId |
|
|
|
|
In this version, a question has only 1 category. |
|
|
|
|
Return the category id, "" if none |
|
|
|
|
* Return the category name for question with question_id = $questionId |
|
|
|
|
* In this version, a question has only 1 category. |
|
|
|
|
* @param $questionId |
|
|
|
|
* @param int $courseId |
|
|
|
|
* @return string |
|
|
|
|
*/ |
|
|
|
|
public static function getCategoryNameForQuestion( |
|
|
|
|
$questionId, |
|
|
|
@ -285,7 +284,8 @@ class TestCategory |
|
|
|
|
$result = ''; |
|
|
|
|
$table = Database::get_course_table(TABLE_QUIZ_QUESTION_CATEGORY); |
|
|
|
|
$categoryId = intval($categoryId); |
|
|
|
|
$sql = "SELECT title FROM $table |
|
|
|
|
$sql = "SELECT title |
|
|
|
|
FROM $table |
|
|
|
|
WHERE id = $categoryId AND c_id = $courseId"; |
|
|
|
|
$res = Database::query($sql); |
|
|
|
|
$data = Database::fetch_array($res); |
|
|
|
@ -443,9 +443,8 @@ class TestCategory |
|
|
|
|
*/ |
|
|
|
|
public static function getNumberOfQuestionRandomByCategory($exerciseId, $in_nbrandom) |
|
|
|
|
{ |
|
|
|
|
$nbquestionresult = 0; |
|
|
|
|
$count = 0; |
|
|
|
|
$categories = TestCategory::getListOfCategoriesIDForTest($exerciseId); |
|
|
|
|
|
|
|
|
|
foreach ($categories as $category) { |
|
|
|
|
if (empty($category['id'])) { |
|
|
|
|
continue; |
|
|
|
@ -454,13 +453,13 @@ class TestCategory |
|
|
|
|
$nbQuestionInThisCat = TestCategory::getNumberOfQuestionsInCategoryForTest($exerciseId, $category['id']); |
|
|
|
|
|
|
|
|
|
if ($nbQuestionInThisCat > $in_nbrandom) { |
|
|
|
|
$nbquestionresult += $in_nbrandom; |
|
|
|
|
$count += $in_nbrandom; |
|
|
|
|
} else { |
|
|
|
|
$nbquestionresult += $nbQuestionInThisCat; |
|
|
|
|
$count += $nbQuestionInThisCat; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $nbquestionresult; |
|
|
|
|
return $count; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -674,12 +673,18 @@ class TestCategory |
|
|
|
|
$in_user_id = intval($in_user_id); |
|
|
|
|
|
|
|
|
|
$query = "SELECT DISTINCT |
|
|
|
|
marks, exe_id, user_id, ta.question_id, category_id |
|
|
|
|
FROM $tbl_track_attempt ta , $tbl_question_rel_category qrc |
|
|
|
|
marks, |
|
|
|
|
exe_id, |
|
|
|
|
user_id, |
|
|
|
|
ta.question_id, |
|
|
|
|
category_id |
|
|
|
|
FROM $tbl_track_attempt ta |
|
|
|
|
INNER JOIN $tbl_question_rel_category qrc |
|
|
|
|
ON (ta.question_id=qrc.question_id) |
|
|
|
|
WHERE |
|
|
|
|
ta.question_id=qrc.question_id AND |
|
|
|
|
qrc.category_id = $in_cat_id AND |
|
|
|
|
exe_id=$in_exe_id AND user_id=$in_user_id"; |
|
|
|
|
exe_id = $in_exe_id AND |
|
|
|
|
user_id = $in_user_id"; |
|
|
|
|
$res = Database::query($query); |
|
|
|
|
$score = ''; |
|
|
|
|
while ($data = Database::fetch_array($res)) { |
|
|
|
@ -908,7 +913,6 @@ class TestCategory |
|
|
|
|
public function returnCategoryForm(Exercise $exercise_obj) |
|
|
|
|
{ |
|
|
|
|
$categories = $this->getListOfCategoriesForTest($exercise_obj); |
|
|
|
|
|
|
|
|
|
$saved_categories = $exercise_obj->get_categories_in_exercise(); |
|
|
|
|
$return = null; |
|
|
|
|
|
|
|
|
@ -995,7 +999,8 @@ class TestCategory |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Return the id of the test category with title = $in_title |
|
|
|
|
* @param $in_title |
|
|
|
|
* @param string $title |
|
|
|
|
* @param int $courseId |
|
|
|
|
* |
|
|
|
|
* @return int is id of test category |
|
|
|
|
*/ |
|
|
|
@ -1059,9 +1064,19 @@ class TestCategory |
|
|
|
|
$courseId = intval($courseId); |
|
|
|
|
|
|
|
|
|
if (empty($sessionId)) { |
|
|
|
|
$sessionCondition = api_get_session_condition($sessionId, true, false, 'i.session_id'); |
|
|
|
|
$sessionCondition = api_get_session_condition( |
|
|
|
|
$sessionId, |
|
|
|
|
true, |
|
|
|
|
false, |
|
|
|
|
'i.session_id' |
|
|
|
|
); |
|
|
|
|
} else { |
|
|
|
|
$sessionCondition = api_get_session_condition($sessionId, true, true, 'i.session_id'); |
|
|
|
|
$sessionCondition = api_get_session_condition( |
|
|
|
|
$sessionId, |
|
|
|
|
true, |
|
|
|
|
true, |
|
|
|
|
'i.session_id' |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (empty($courseId)) { |
|
|
|
|