Fix category see BT#10052

1.10.x
Julio Montoya 9 years ago
parent 8a29439ab3
commit d4cd676cc6
  1. 17
      main/exercice/upload_exercise.php

@ -181,7 +181,6 @@ function lp_upload_quiz_action_handling() {
$questionTypeList = array();
$questionTypeIndex = array();
$categoryList = array();
$categoryIndex = array();
// Reading all the first column items sequentially to create breakpoints
for ($i = 1; $i <= $data->sheets[0]['numRows']; $i++) {
@ -204,8 +203,6 @@ function lp_upload_quiz_action_handling() {
$noNegativeScoreIndex[] = $i;
} elseif ($data->sheets[0]['cells'][$i][1] == 'QuestionType') {
$questionTypeIndex[] = $i;
} elseif ($data->sheets[0]['cells'][$i][1] == 'Category') {
$categoryIndex[] = $i;
}
}
@ -249,6 +246,10 @@ function lp_upload_quiz_action_handling() {
if (isset($myData[1]) && $myData[1] == 'QuestionType') {
$questionTypeList[$k] = $myData[3];
}
if (isset($myData[1]) && $myData[1] == 'Category') {
$categoryList[$k] = $myData[2];
}
}
if (!isset($questionTypeList[$k])) {
@ -272,10 +273,6 @@ function lp_upload_quiz_action_handling() {
//a complete line where 1st column is 'EnrichQuestion'
$question_description[$m] = $column_data;
$m++;
} elseif (in_array($i, $categoryIndex)) {
//a complete line where 1st column is 'Category'
$categoryList[$n] = $column_data;
$n++;
} elseif (in_array($i, $noNegativeScoreIndex)) {
//a complete line where 1st column is 'NoNegativeScore'
$noNegativeScoreList[$z - 1] = $column_data;
@ -346,9 +343,9 @@ function lp_upload_quiz_action_handling() {
$description = isset($question_description[$i][2]) ? $question_description[$i][2] : '';
$categoryId = null;
if (isset($categoryList[$i]) && isset($categoryList[$i][2]) && !empty($categoryList[$i][2])) {
$categoryName = $categoryList[$i][2];
$categoryId = TestCategory::get_category_id_for_title($categoryName, $courseId);
if (isset($categoryList[$i]) && !empty($categoryList[$i])) {
$categoryName = $categoryList[$i];
$categoryId = Testcategory::get_category_id_for_title($categoryName, $courseId);
if (empty($categoryId)) {
$category = new TestCategory(null, $categoryName, '');
$categoryId = $category->addCategoryInBDD();

Loading…
Cancel
Save