Skip to content

Commit

Permalink
Fix category see BT#10052
Browse files Browse the repository at this point in the history
  • Loading branch information
jmontoyaa committed Dec 30, 2015
1 parent 8a29439 commit d4cd676
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions main/exercice/upload_exercise.php
Expand Up @@ -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++) {
Expand All @@ -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;
}
}

Expand Down Expand Up @@ -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])) {
Expand All @@ -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;
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit d4cd676

Please sign in to comment.