Feature #5715
Select several categories by question
Description
In the question form, we can select the category. However, there should be a possibility to select several categories in one shot, with a multiple select.
Implement the multiple select and make sure the classes/methods behind it enable picking several categories at the same time.
This should go into Chamilo 1.9.4 as it shouldn't require any database change.
Associated revisions
Adding autoincrement id in table "c_quiz_question_rel_category" to supporting several categories per question see #5715
History
Updated by Julio Montoya about 8 years ago
- Target version changed from 1.9.4 to 2.0
The table:
mysql> describe c_quiz_question_rel_category; +-------------+---------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------+---------+------+-----+---------+-------+ | c_id | int(11) | NO | PRI | NULL | | | question_id | int(11) | NO | PRI | NULL | | | category_id | int(11) | NO | | NULL | | +-------------+---------+------+-----+---------+-------+ 3 rows in set (0.00 sec)
Needs an id in order to allow multiple categories.
I'm moving this to 1.10
I also suggest to move this to 1.10 in order to leave the exercise code as stable as possible at least for the 1.9.x series
Updated by Julio Montoya about 8 years ago
- Status changed from Assigned to Needs testing
- % Done changed from 0 to 50
Updated by Yannick Warnier about 8 years ago
Julio A. Montoya wrote:
I also suggest to move this to 1.10 in order to leave the exercise code as stable as possible at least for the 1.9.x series
Good for me.
Updated by Hubert Borderiou about 8 years ago
How does it work if you have a test using random question by categories and if a question own of 2 categories ?
Question 1 : 1+1=? [category Math]
Question 2 : mc²=? [category PHYSIC]
Question 3 : c=300000km/s ; c²=? [category MATH] [category PHYSIC]
If I create a test random by category with 1 question of each category, I'll have 1 MATH question and 1 PHYSIC question. It is important not to have a test with twice question 3.
Updated by Yannick Warnier about 8 years ago
Julio, the unique ID was not really necessary, was it? Is that for the ORM or something like that?
Updated by Yannick Warnier about 8 years ago
If you have a test with random categories and one question belongs to 2 categories, then the first ocurrence of this question puts the question ID in an "exceptions" array which ensures it will only be found in the first category where it had to appear. There no other way I can think of.
Updated by Julio Montoya about 8 years ago
Yannick Warnier wrote:
Julio, the unique ID was not really necessary, was it? Is that for the ORM or something like that?
yes it was necessary, mysql prompted me errors when trying to insert several categories for a question the problem was in the primary key.
Updated by Yannick Warnier about 8 years ago
Julio A. Montoya wrote:
It seems strange to me, as the combination of category+question should be unique by itself, so it shouldn't be a problem for the primary key.Yannick Warnier wrote:
Julio, the unique ID was not really necessary, was it? Is that for the ORM or something like that?
yes it was necessary, mysql prompted me errors when trying to insert several categories for a question the problem was in the primary key.
Like:
Category | Question |
3 | 5 |
3 | 6 |
4 | 5 |
5 | 5 |
-> there's never a problem with question 5 being part of categories 3,4 and 5 at the same time, or is there???
Updated by Yannick Warnier about 8 years ago
This being said, I don't mind. At all. It just seemed strange to me.
Updated by Julio Montoya about 8 years ago
- Assignee deleted (
Julio Montoya)
Yannick Warnier wrote:
This being said, I don't mind. At all. It just seemed strange to me.
This was the old structure:
$sql = "CREATE TABLE `".$table_quiz_question_rel_category . "` (
$add_to_all_tables
question_id int NOT NULL,
category_id int NOT NULL,
PRIMARY KEY (c_id,question_id)
)" . $charset_clause;
Database::query($sql);
So according to this you can't have 2 keys with the same "c_id" and "question_id" that was the reason it failed before.
Merging from 1.9.x + allowing multiple categories per question see #5715