Minor - fix format code, fix php warnings

pull/3683/head
Julio Montoya 5 years ago
parent 1676bd4591
commit 02fb00f5a9
  1. 29
      main/exercise/upload_exercise.php
  2. 2
      main/inc/lib/exercise.lib.php

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
@ -9,11 +10,9 @@ use ChamiloSession as Session;
// setting the help
$help_content = 'exercise_upload';
require_once __DIR__.'/../inc/global.inc.php';
api_protect_course_script(true);
$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
$debug = false;
$origin = api_get_origin();
@ -42,15 +41,12 @@ $interbreadcrumb[] = [
'name' => get_lang('Exercises'),
];
// Display the header
Display::display_header(get_lang('ImportExcelQuiz'), 'Exercises');
// display the actions
echo '<div class="actions">';
echo lp_upload_quiz_actions();
echo '</div>';
// the main content
lp_upload_quiz_main();
function lp_upload_quiz_actions()
@ -142,7 +138,6 @@ function lp_upload_quiz_action_handling()
}
$courseId = $_course['real_id'];
// Get the extension of the document.
$path_info = pathinfo($_FILES['user_upload_quiz']['name']);
@ -162,12 +157,11 @@ function lp_upload_quiz_action_handling()
$questionTypeList = [];
$answerList = [];
$quizTitle = '';
$objPHPExcel = PHPExcel_IOFactory::load($_FILES['user_upload_quiz']['tmp_name']);
$objPHPExcel->setActiveSheetIndex(0);
$worksheet = $objPHPExcel->getActiveSheet();
$highestRow = $worksheet->getHighestRow(); // e.g. 10
$highestColumn = $worksheet->getHighestColumn(); // e.g 'F'
//$highestColumn = $worksheet->getHighestColumn(); // e.g 'F'
$correctScore = isset($_POST['correct_score']) ? $_POST['correct_score'] : null;
$incorrectScore = isset($_POST['incorrect_score']) ? $_POST['incorrect_score'] : null;
@ -218,11 +212,11 @@ function lp_upload_quiz_action_handling()
$questionTypeTitle = $worksheet->getCellByColumnAndRow(0, $answerRow);
$questionTypeExtra = $worksheet->getCellByColumnAndRow(2, $answerRow);
$title = $questionTypeTitle->getValue();
if ($title == 'QuestionType') {
if ($title === 'QuestionType') {
$questionTypeList[$numberQuestions] = $questionTypeExtra->getValue();
$continue = false;
}
if ($title == 'Question') {
if ($title === 'Question') {
$continue = false;
}
// To avoid loops
@ -263,7 +257,13 @@ function lp_upload_quiz_action_handling()
}
}
if ($quizTitle != '') {
$url = api_get_path(WEB_CODE_PATH).'exercise/upload_exercise.php?'.api_get_cidreq();
if (empty($quizTitle)) {
Display::addFlash(Display::return_message('ErrorImportingFile'), 'warning');
api_location($url);
}
// Variables
$type = 2;
$random = $active = $results = $max_attempt = $expired_time = 0;
@ -551,6 +551,7 @@ function lp_upload_quiz_action_handling()
}
}
}
Display::addFlash(Display::return_message(get_lang('FileImported')));
if (isset($_SESSION['oLP']) && isset($_GET['lp_id'])) {
$previous = $_SESSION['oLP']->select_previous_item_id();
@ -568,9 +569,9 @@ function lp_upload_quiz_action_handling()
header('Location: ../lp/lp_controller.php?'.api_get_cidreq().'&action=add_item&type=step&lp_id='.intval($_GET['lp_id']));
exit;
} else {
// header('location: exercise.php?' . api_get_cidreq());
echo '<script>window.location.href = "'.api_get_path(WEB_CODE_PATH).'exercise/admin.php?'.api_get_cidreq().'&exerciseId='.$quiz_id.'&session_id='.api_get_session_id().'"</script>';
}
$exerciseUrl = api_get_path(WEB_CODE_PATH).
'exercise/admin.php?'.api_get_cidreq().'&exerciseId='.$quiz_id.'&session_id='.api_get_session_id();
api_location($exerciseUrl);
}
}

@ -6141,7 +6141,7 @@ EOT;
if (empty($emailList)) {
continue;
}
$attempts = $attemptData['attempts'];
$attempts = isset($attemptData['attempts']) ? $attemptData['attempts'] : [];
foreach ($attempts as $attempt) {
$sendMessage = false;
if (isset($attempt['attempt']) && $attemptCountToSend !== (int) $attempt['attempt']) {

Loading…
Cancel
Save