Minor - Format code, remove unused $form->addGroup

pull/2487/head
jmontoyaa 9 years ago
parent 5e765870e2
commit 67a5aa7cfe
  1. 99
      main/exercise/admin.php
  2. 10
      main/exercise/matching.class.php
  3. 14
      main/exercise/question_admin.inc.php

@ -4,46 +4,46 @@
use ChamiloSession as Session;
/**
* Exercise administration
* This script allows to manage (create, modify) an exercise and its questions
* Exercise administration
* This script allows to manage (create, modify) an exercise and its questions
*
* Following scripts are includes for a best code understanding :
* Following scripts are includes for a best code understanding :
*
* - exercise.class.php : for the creation of an Exercise object
* - question.class.php : for the creation of a Question object
* - answer.class.php : for the creation of an Answer object
* - exercise.lib.php : functions used in the exercise tool
* - exercise_admin.inc.php : management of the exercise
* - question_admin.inc.php : management of a question (statement & answers)
* - statement_admin.inc.php : management of a statement
* - question_list_admin.inc.php : management of the question list
* - exercise.class.php : for the creation of an Exercise object
* - question.class.php : for the creation of a Question object
* - answer.class.php : for the creation of an Answer object
* - exercise.lib.php : functions used in the exercise tool
* - exercise_admin.inc.php : management of the exercise
* - question_admin.inc.php : management of a question (statement & answers)
* - statement_admin.inc.php : management of a statement
* - question_list_admin.inc.php : management of the question list
*
* Main variables used in this script :
* Main variables used in this script :
*
* - $is_allowedToEdit : set to 1 if the user is allowed to manage the exercise
* - $objExercise : exercise object
* - $objQuestion : question object
* - $objAnswer : answer object
* - $aType : array with answer types
* - $exerciseId : the exercise ID
* - $picturePath : the path of question pictures
* - $newQuestion : ask to create a new question
* - $modifyQuestion : ID of the question to modify
* - $editQuestion : ID of the question to edit
* - $submitQuestion : ask to save question modifications
* - $cancelQuestion : ask to cancel question modifications
* - $deleteQuestion : ID of the question to delete
* - $moveUp : ID of the question to move up
* - $moveDown : ID of the question to move down
* - $modifyExercise : ID of the exercise to modify
* - $submitExercise : ask to save exercise modifications
* - $cancelExercise : ask to cancel exercise modifications
* - $modifyAnswers : ID of the question which we want to modify answers for
* - $cancelAnswers : ask to cancel answer modifications
* - $buttonBack : ask to go back to the previous page in answers of type "Fill in blanks"
* - $is_allowedToEdit : set to 1 if the user is allowed to manage the exercise
* - $objExercise : exercise object
* - $objQuestion : question object
* - $objAnswer : answer object
* - $aType : array with answer types
* - $exerciseId : the exercise ID
* - $picturePath : the path of question pictures
* - $newQuestion : ask to create a new question
* - $modifyQuestion : ID of the question to modify
* - $editQuestion : ID of the question to edit
* - $submitQuestion : ask to save question modifications
* - $cancelQuestion : ask to cancel question modifications
* - $deleteQuestion : ID of the question to delete
* - $moveUp : ID of the question to move up
* - $moveDown : ID of the question to move down
* - $modifyExercise : ID of the exercise to modify
* - $submitExercise : ask to save exercise modifications
* - $cancelExercise : ask to cancel exercise modifications
* - $modifyAnswers : ID of the question which we want to modify answers for
* - $cancelAnswers : ask to cancel answer modifications
* - $buttonBack : ask to go back to the previous page in answers of type "Fill in blanks"
*
* @package chamilo.exercise
* @author Olivier Brouckaert
* @package chamilo.exercise
* @author Olivier Brouckaert
* Modified by Hubert Borderiou 21-10-2011 Question by category
*/
@ -56,7 +56,6 @@ api_protect_course_script(true);
$is_allowedToEdit = api_is_allowed_to_edit(null, true, false, false);
$sessionId = api_get_session_id();
$studentViewActive = api_is_student_view_active();
if (!$is_allowedToEdit) {
api_not_allowed(true);
@ -64,15 +63,15 @@ if (!$is_allowedToEdit) {
/* stripslashes POST data */
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
foreach($_POST as $key=>$val) {
if(is_string($val)) {
$_POST[$key]=stripslashes($val);
} elseif(is_array($val)) {
foreach($val as $key2=>$val2) {
$_POST[$key][$key2]=stripslashes($val2);
foreach ($_POST as $key => $val) {
if (is_string($val)) {
$_POST[$key] = stripslashes($val);
} elseif (is_array($val)) {
foreach ($val as $key2 => $val2) {
$_POST[$key][$key2] = stripslashes($val2);
}
}
$GLOBALS[$key]=$_POST[$key];
$GLOBALS[$key] = $_POST[$key];
}
}
@ -110,7 +109,6 @@ $cancelQuestion = isset($cancelQuestion) ? $cancelQuestion : null;
/* Cleaning all incomplete attempts of the admin/teacher to avoid weird problems
when changing the exercise settings, number of questions, etc */
Event::delete_all_incomplete_attempts(
api_get_user_id(),
$exerciseId,
@ -281,8 +279,8 @@ if ($editQuestion || $modifyQuestion || $newQuestion || $modifyAnswers) {
$nameTools = get_lang('QuestionManagement');
}
if (isset($_SESSION['gradebook'])){
$gradebook= $_SESSION['gradebook'];
if (isset($_SESSION['gradebook'])) {
$gradebook = $_SESSION['gradebook'];
}
if (!empty($gradebook) && $gradebook=='view') {
@ -309,10 +307,10 @@ if (!$exerciseId && $nameTools != get_lang('ExerciseManagement')) {
// if the question is duplicated, disable the link of tool name
if ($modifyIn == 'thisExercise') {
if ($buttonBack) {
$modifyIn='allExercises';
if ($buttonBack) {
$modifyIn = 'allExercises';
} else {
$noPHP_SELF=true;
$noPHP_SELF = true;
}
}
$htmlHeadXtra[] = '<script>
@ -343,11 +341,10 @@ $template = new Template();
$templateName = $template->get_template('exercise/submit.js.tpl');
$htmlHeadXtra[] = $template->fetch($templateName);
$htmlHeadXtra[] = api_get_js('d3/jquery.xcolor.js');
$htmlHeadXtra[] = '<link rel="stylesheet" href="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'hotspot/css/hotspot.css">';
$htmlHeadXtra[] = '<script src="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'hotspot/js/hotspot.js"></script>';
Display::display_header($nameTools,'Exercise');
Display::display_header($nameTools, 'Exercise');
/*
if ($objExercise->exercise_was_added_in_lp) {
if ($objExercise->force_edit_exercise_in_lp == true) {

@ -143,27 +143,22 @@ class Matching extends Question
$form->addHtml('<tr>');
$form->addHtml("<td>$i</td>");
$form->addText("answer[$i]", null);
$form->addSelect(
"matches[$i]",
null,
$matches,
['id' => 'matches_'.$i]
);
$form->addText(
"weighting[$i]",
null,
true,
['id' => 'weighting_'.$i, 'value' => 10]
);
$form->addHtml('</tr>');
}
$form->addHtml('</tbody></table>');
$group = array();
$form->addGroup($group);
// DISPLAY OPTIONS
$html = '<table class="table table-striped table-hover">
@ -198,14 +193,13 @@ class Matching extends Question
}
$form->addHtml('</table>');
$group = array();
global $text;
global $text;
$group = array();
// setting the save button here and not in the question class.php
$group[] = $form->addButtonDelete(get_lang('DelElem'), 'lessOptions', true);
$group[] = $form->addButtonCreate(get_lang('AddElem'), 'moreOptions', true);
$group[] = $form->addButtonSave($text, 'submitQuestion', true);
$form->addGroup($group);
if (!empty($this->id)) {

@ -2,11 +2,11 @@
/* For licensing terms, see /license.txt */
/**
* This script allows to manage the statements of questions.
* It is included from the script admin.php
* @package chamilo.exercise
* @author Olivier Brouckaert
* @version $Id: question_admin.inc.php 22126 2009-07-15 22:38:39Z juliomontoya $
* This script allows to manage the statements of questions.
* It is included from the script admin.php
* @package chamilo.exercise
* @author Olivier Brouckaert
* @version $Id: question_admin.inc.php 22126 2009-07-15 22:38:39Z juliomontoya $
*/
if (isset($_GET['editQuestion'])) {
@ -49,10 +49,10 @@ if (is_object($objQuestion)) {
// FORM VALIDATION
if (isset($_POST['submitQuestion']) && $form->validate()) {
// question
// Question
$objQuestion->processCreation($form, $objExercise);
// answers
// Answers
$nb_answers = isset($nb_answers) ? $nb_answers : 0;
$objQuestion->processAnswersCreation($form, $nb_answers);

Loading…
Cancel
Save