Minor - format code.

remotes/angel/1.11.x
jmontoyaa 8 years ago
parent 42758f218a
commit 63a2529d08
  1. 5
      main/exercise/aiken.php
  2. 10
      main/exercise/export/aiken/aiken_classes.php
  3. 25
      main/exercise/export/aiken/aiken_import.inc.php

@ -25,7 +25,10 @@ if (!api_is_allowed_to_edit(null, true)) {
}
// the breadcrumbs
$interbreadcrumb[] = array("url" => 'exercise.php?'.api_get_cidreq(), "name" => get_lang('Exercises'));
$interbreadcrumb[] = array(
"url" => 'exercise.php?'.api_get_cidreq(),
"name" => get_lang('Exercises'),
);
$is_allowedToEdit = api_is_allowed_to_edit(null, true);
// import file
if ((api_is_allowed_to_edit(null, true))) {

@ -15,7 +15,8 @@ if (!function_exists('mime_content_type')) {
* @param string $filename
* @return string
*/
function mime_content_type($filename) {
function mime_content_type($filename)
{
return DocumentManager::file_get_mime_type((string)$filename);
}
}
@ -30,21 +31,24 @@ class Aiken2Question extends Question
*/
function setAnswer()
{
switch($this->type)
{
switch ($this->type) {
case MCUA:
$answer = new AikenAnswerMultipleChoice($this->id);
return $answer;
default:
$answer = null;
break;
}
return $answer;
}
function createAnswersForm($form)
{
return true;
}
function processAnswersCreation($form)
{
return true;

@ -7,6 +7,7 @@
* @author César Perales <cesar.perales@gmail.com> Parse function for Aiken format
* @package chamilo.exercise
*/
/**
* Security check
*/
@ -20,9 +21,11 @@ if (count(get_included_files()) == 1)
* @param int $mode
* @return string
*/
function tempdir($dir, $prefix = 'tmp', $mode = 0777) {
if (substr($dir, -1) != '/')
function tempdir($dir, $prefix = 'tmp', $mode = 0777)
{
if (substr($dir, -1) != '/') {
$dir .= '/';
}
do {
$path = $dir.$prefix.mt_rand(0, 9999999);
@ -40,7 +43,12 @@ function aiken_display_form()
$name_tools = get_lang('ImportAikenQuiz');
$form = '<div class="actions">';
$form .= '<a href="exercise.php?show=test&'.api_get_cidreq().'">' .
Display::return_icon('back.png', get_lang('BackToExercisesList'),'',ICON_SIZE_MEDIUM).'</a>';
Display::return_icon(
'back.png',
get_lang('BackToExercisesList'),
'',
ICON_SIZE_MEDIUM
).'</a>';
$form .= '</div>';
$form_validator = new FormValidator(
'aiken_upload',
@ -66,7 +74,8 @@ function aiken_display_form()
* @param string $uploadPath
* @return bool True on success, false on failure
*/
function get_and_unzip_uploaded_exercise($baseWorkDir, $uploadPath) {
function get_and_unzip_uploaded_exercise($baseWorkDir, $uploadPath)
{
$_course = api_get_course_info();
$_user = api_get_user_info();
// Check if the file is valid (not to big and exists)
@ -74,6 +83,7 @@ function get_and_unzip_uploaded_exercise($baseWorkDir, $uploadPath) {
// upload failed
return false;
}
if (preg_match('/.zip$/i', $_FILES['userFile']['name']) && handle_uploaded_document($_course, $_FILES['userFile'], $baseWorkDir, $uploadPath, $_user['user_id'], 0, null, 1, 'overwrite', false)) {
if (!function_exists('gzopen')) {
return false;
@ -117,7 +127,6 @@ function aiken_import_exercise($file)
// unzip the uploaded file in a tmp directory
if (preg_match('/.(zip|txt)$/i', $file)) {
if (!get_and_unzip_uploaded_exercise($baseWorkDir, $uploadPath)) {
return 'ThereWasAProblemWithYourFile';
}
}
@ -155,7 +164,6 @@ function aiken_import_exercise($file)
}
if ($result !== true) {
return $result;
}
@ -236,7 +244,8 @@ function aiken_import_exercise($file)
* @return string|boolean True on success, error message on error
* @assert ('','','') === false
*/
function aiken_parse_file(&$exercise_info, $exercisePath, $file, $questionFile) {
function aiken_parse_file(&$exercise_info, $exercisePath, $file, $questionFile)
{
global $questionTempDir;
$questionTempDir = $exercisePath . '/' . $file . '/';
@ -329,6 +338,7 @@ function aiken_parse_file(&$exercise_info, $exercisePath, $file, $questionFile)
/**
* Imports the zip file
* @param array $array_file ($_FILES)
* @return bool
*/
function aiken_import_file($array_file)
{
@ -342,7 +352,6 @@ function aiken_import_file($array_file)
if ($process && $unzip == 1) {
$imported = aiken_import_exercise($array_file['name']);
if (is_numeric($imported) && !empty($imported)) {
Display::addFlash(Display::return_message(get_lang('Uploaded')));
return $imported;

Loading…
Cancel
Save