Some minor fixes in the test category, removing warnings/notices

skala
Julio Montoya 14 years ago
parent e9e9aa14d7
commit a0902e166b
  1. 19
      main/exercice/testcategory.class.php
  2. 31
      main/exercice/tests_category.php

@ -14,7 +14,7 @@ class Testcategory {
If you give an in_id and no in_name, you get info concerning the category of id=in_id
otherwise, you've got an category objet avec your in_id, in_name, in_descr
*/
function Testcategory($in_id=0, $in_name, $in_description="") {
function Testcategory($in_id=0, $in_name = '', $in_description="") {
if ($in_id != 0 && $in_name == "") {
$tmpobj = new Testcategory();
$tmpobj->getCategory($in_id);
@ -69,8 +69,12 @@ class Testcategory {
}
}
/** remove catagory with id=in_id from the database if no question use this category
/**
* Removes the category with id=in_id from the database if no question use this category
* @todo I'm removing the $in_id parameter because it seems that you're using $this->id instead of $in_id after confirmation delete this
* jmontoya
*/
//function removeCategory($in_id) {
function removeCategory($in_id) {
$t_cattable = Database :: get_course_table(TABLE_QUIZ_QUESTION_CATEGORY);
$v_id = Database::escape_string($this->id);
@ -102,18 +106,21 @@ class Testcategory {
}
}
/** get number of question of category id=in_id
/**
* Gets the number of question of category id=in_id
* @todo I'm removing the $in_id parameter because it seems that you're using $this->id instead of $in_id after confirmation delete this
* jmontoya
*/
function getCategoryQuestionsNumber($in_id) {
//function getCategoryQuestionsNumber($in_id) {
function getCategoryQuestionsNumber() {
$t_reltable = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY);
$in_id = Database::escape_string($this->id);
$sql = "SELECT count(*) AS nb FROM $t_reltable WHERE category_id=$in_id AND c_id=".api_get_course_int_id();
$res = Database::query($sql, __FILE__, __LINE__);
$res = Database::query($sql);
$row = Database::fetch_array($res);
return $row['nb'];
}
function display($in_color="#E0EBF5") {
echo "<textarea style='background-color:$in_color; width:60%; height:100px;'>";
print_r($this);

@ -28,7 +28,9 @@ include('question.class.php');
include('testcategory.class.php');
include('../inc/global.inc.php');
include('exercise.lib.php');
require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
//Library already added in global.inc.php
//require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
$this_section=SECTION_COURSES;
@ -41,8 +43,7 @@ $interbreadcrumb[]=array("url" => "exercice.php","name" => get_lang('Exercices')
Display::display_header(get_lang('Category'));
// Action handling: add, edit and remove
if (isset($_GET['action']) && $_GET['action'] == 'addcategory')
{
if (isset($_GET['action']) && $_GET['action'] == 'addcategory') {
add_category_form(Security::remove_XSS($_GET['action']));
}
else if (isset($_GET['action']) && $_GET['action'] == 'editcategory') {
@ -58,15 +59,10 @@ else {
Display::display_footer();
// **********************************************************************************
// ****** FUNCTIONS ********************
// **********************************************************************************
// ------------------------------------------------------------------------
// form to edit a category
// ------------------------------------------------------------------------
function edit_category_form($in_action) {
if (isset($_GET['category_id']) && is_numeric($_GET['category_id'])) {
$category_id = Security::remove_XSS($_GET['category_id']);
$objcat = new Testcategory($category_id);
@ -203,9 +199,8 @@ function add_category_form($in_action) {
}
// ------------------------------------------------------------------------
// Display add category button
// ------------------------------------------------------------------------
function display_add_category() {
echo '<div class="actions">';
echo '<a href="exercice.php?'.api_get_cidreq().'">'.Display::return_icon('back.png', get_lang('GoBackToQuestionList'),'',32).'</a>';
@ -215,19 +210,19 @@ function display_add_category() {
}
// ------------------------------------------------------------------------
// Display category list
// ------------------------------------------------------------------------
function display_categories() {
$course_id = api_get_course_int_id();
$t_cattable = Database::get_course_table(TABLE_QUIZ_QUESTION_CATEGORY);
$sql = "SELECT * FROM $t_cattable ORDER BY title";
$res = Database::query($sql, __FILE__, __LINE__);
$sql = "SELECT * FROM $t_cattable WHERE c_id = $course_id ORDER BY title";
$res = Database::query($sql);
while ($row = Database::fetch_array($res)) {
// le titre avec le nombre de questions qui sont dans cette catégorie
// le titre avec le nombre de questions qui sont dans cette cat<EFBFBD>gorie
$tmpobj = new Testcategory($row['id']);
$nb_question = $tmpobj->getCategoryQuestionsNumber();
echo '<div class="sectiontitle" id="id_cat'.$row['id'].'">';
echo "<span style='float:right'>".$nb_question.get_lang('NbCategory')."</span>";
echo "<span style='float:right'>".$nb_question.' '.get_lang('NbCategory')."</span>";
echo $row['title'];
echo '</div>';
echo '<div class="sectioncomment">';
@ -256,7 +251,7 @@ function display_categories() {
// ------------------------------------------------------------------------
function display_goback() {
echo '<div class="actions">';
echo '<a href="'.api_get_self().'">'.Display::return_icon('back.png', '', 32).' '.get_lang('BackToCategoryList').'</a>';
echo '<a href="'.api_get_self().'">'.Display::return_icon('back.png', get_lang('BackToCategoryList'), array(), 32).'</a>';
echo '</div>';
}
@ -270,5 +265,3 @@ function protectJSDialogQuote($in_txt) {
$res = str_replace('"', "\'\'", $res); // super astuce pour afficher les " dans les boite de dialogue
return $res;
}
?>
Loading…
Cancel
Save