Minor - fixing PHP warnings.

1.9.x
Julio Montoya 11 years ago
parent d555a949a4
commit 2c7e7ff431
  1. 54
      main/exercice/admin.php
  2. 51
      main/exercice/fill_blanks.class.php
  3. 4
      main/exercice/question_admin.inc.php

@ -87,36 +87,40 @@ if($_SERVER['REQUEST_METHOD'] == 'POST') {
}
}
// get vars from GET
if ( empty ( $exerciseId ) ) {
$exerciseId = intval($_GET['exerciseId']);
if (empty($exerciseId)) {
$exerciseId = isset($_GET['exerciseId']) ? intval($_GET['exerciseId']):'0';
}
if ( empty ( $newQuestion ) ) {
$newQuestion = $_GET['newQuestion'];
}
if ( empty ( $modifyAnswers ) ) {
$modifyAnswers = $_GET['modifyAnswers'];
if (empty($newQuestion)) {
$newQuestion = isset($_GET['newQuestion']) ? $_GET['newQuestion'] : 0;
}
if ( empty ( $editQuestion ) ) {
$editQuestion = $_GET['editQuestion'];
if (empty($modifyAnswers)) {
$modifyAnswers = isset($_GET['modifyAnswers']) ? $_GET['modifyAnswers'] : 0;
}
if ( empty ( $modifyQuestion ) ) {
$modifyQuestion = $_GET['modifyQuestion'];
if (empty($editQuestion)) {
$editQuestion = isset($_GET['editQuestion']) ? $_GET['editQuestion'] : 0;
}
if ( empty ( $deleteQuestion ) ) {
$deleteQuestion = $_GET['deleteQuestion'];
if (empty($modifyQuestion)) {
$modifyQuestion = isset($_GET['modifyQuestion']) ? $_GET['modifyQuestion'] : 0;
}
if ( empty ($clone_question) ) {
$clone_question = $_GET['clone_question'];
if (empty($deleteQuestion)) {
$deleteQuestion = isset($_GET['deleteQuestion']) ? $_GET['deleteQuestion'] : 0;
}
if ( empty ( $questionId ) ) {
$questionId = $_SESSION['questionId'];
$clone_question = isset($_REQUEST['clone_question']) ? $_REQUEST['clone_question'] : 0;
if (empty($questionId)) {
$questionId = isset($_SESSION['questionId']) ? $_SESSION['questionId'] : 0;
}
if ( empty ( $modifyExercise ) ) {
$modifyExercise = $_GET['modifyExercise'];
if (empty($modifyExercise)) {
$modifyExercise = isset($_GET['modifyExercise']) ? $_GET['modifyExercise'] : null;
}
//Cleaning all incomplete attempts of the admin/teacher to avoid weird problems when changing the exercise settings, number of questions, etc
$fromExercise = isset($fromExercise) ? $fromExercise : null;
$cancelExercise = isset($cancelExercise) ? $cancelExercise : null;
$cancelAnswers = isset($cancelAnswers) ? $cancelAnswers : null;
$modifyIn = isset($modifyIn) ? $modifyIn : null;
$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
delete_all_incomplete_attempts(api_get_user_id(), $exerciseId, api_get_course_id(), api_get_session_id());
@ -139,7 +143,7 @@ $aType = array(get_lang('UniqueSelect'),get_lang('MultipleSelect'),get_lang('Fil
// tables used in the exercise tool
if ($_GET['action'] == 'exportqti2' && !empty($_GET['questionId'])) {
if (!empty($_GET['action']) && $_GET['action'] == 'exportqti2' && !empty($_GET['questionId'])) {
require_once 'export/qti2/qti2_export.php';
$export = export_question($_GET['questionId'],true);
$qid = (int)$_GET['questionId'];
@ -176,9 +180,9 @@ if (!is_object($objExercise)) {
}
// doesn't select the exercise ID if we come from the question pool
if(!$fromExercise) {
if (!$fromExercise) {
// gets the right exercise ID, and if 0 creates a new exercise
if(!$exerciseId = $objExercise->selectId()) {
if (!$exerciseId = $objExercise->selectId()) {
$modifyExercise='yes';
}
}
@ -234,7 +238,7 @@ if ($cancelQuestion) {
}
}
if (isset($clone_question) && !empty($objExercise->id)) {
if (!empty($clone_question) && !empty($objExercise->id)) {
$old_question_obj = Question::read($clone_question);
$old_question_obj->question = $old_question_obj->question.' - '.get_lang('Copy');

@ -12,16 +12,15 @@
*/
/**
CLASS FillBlanks
*
* This class allows to instantiate an object of type MULTIPLE_ANSWER (MULTIPLE CHOICE, MULTIPLE ANSWER),
* This class allows to instantiate an object of type MULTIPLE_ANSWER
* (MULTIPLE CHOICE, MULTIPLE ANSWER),
* extending the class question
*
* @author Eric Marguin
* @author Julio Montoya multiple fill in blank option added
* @package chamilo.exercise
**/
class FillBlanks extends Question
{
static $typePicture = 'fill_in_blanks.gif';
@ -30,7 +29,7 @@ class FillBlanks extends Question
/**
* Constructor
*/
function FillBlanks()
public function FillBlanks()
{
parent::question();
$this -> type = FILL_IN_BLANKS;
@ -41,7 +40,8 @@ class FillBlanks extends Question
* function which redifines Question::createAnswersForm
* @param the formvalidator instance
*/
function createAnswersForm ($form) {
function createAnswersForm($form)
{
$defaults = array();
if (!empty($this->id)) {
@ -68,7 +68,7 @@ class FillBlanks extends Question
//Take the complete string except after the last '::'
$defaults['answer'] = '';
for ($i=0;$i<($sz-1);$i++) {
for ($i=0; $i<($sz-1); $i++) {
$defaults['answer'] .= $pre_array[$i];
}
$a_weightings = explode(',', $is_set_switchable[0]);
@ -76,9 +76,18 @@ class FillBlanks extends Question
$defaults['answer'] = get_lang('DefaultTextInBlanks');
}
$setValues = null;
if (isset($a_weightings) && count($a_weightings) > 0) {
foreach ($a_weightings as $i => $weighting) {
$setValues .= 'document.getElementById("weighting['.$i.']").value = "'.$weighting.'";';
}
}
// javascript
echo '<script>
function FCKeditor_OnComplete( editorInstance ) {
function FCKeditor_OnComplete(editorInstance) {
if (window.attachEvent) {
editorInstance.EditorDocument.attachEvent("onkeyup", updateBlanks) ;
} else {
@ -113,35 +122,30 @@ class FillBlanks extends Question
document.getElementById("blanks_weighting").innerHTML = fields + "</table></div></div>";
if (firstTime) {
firstTime = false;
';
if (count($a_weightings) > 0) {
foreach($a_weightings as $i => $weighting) {
echo 'document.getElementById("weighting['.$i.']").value = "'.$weighting.'";';
}
'.$setValues.'
}
echo '}
}
window.onload = updateBlanks;
</script>';
// answer
$form -> addElement ('label', null, '<br /><br />'.get_lang('TypeTextBelow').', '.get_lang('And').' '.get_lang('UseTagForBlank'));
$form -> addElement ('html_editor', 'answer', '<img src="../img/fill_field.png">','id="answer" cols="122" rows="6" onkeyup="javascript: updateBlanks(this);"', array('ToolbarSet' => 'TestQuestionDescription', 'Width' => '100%', 'Height' => '350'));
$form->addElement('label', null, '<br /><br />'.get_lang('TypeTextBelow').', '.get_lang('And').' '.get_lang('UseTagForBlank'));
$form->addElement('html_editor', 'answer', '<img src="../img/fill_field.png">','id="answer" cols="122" rows="6" onkeyup="javascript: updateBlanks(this);"', array('ToolbarSet' => 'TestQuestionDescription', 'Width' => '100%', 'Height' => '350'));
$form -> addRule ('answer',get_lang('GiveText'),'required');
$form -> addRule ('answer',get_lang('DefineBlanks'),'regex','/\[.*\]/');
$form->addRule('answer', get_lang('GiveText'),'required');
$form->addRule('answer', get_lang('DefineBlanks'),'regex','/\[.*\]/');
//added multiple answers
$form -> addElement ('checkbox','multiple_answer','', get_lang('FillInBlankSwitchable'));
$form->addElement('checkbox', 'multiple_answer','', get_lang('FillInBlankSwitchable'));
$form -> addElement('html','<div id="blanks_weighting"></div>');
$form->addElement('html', '<div id="blanks_weighting"></div>');
global $text, $class;
// setting the save button here and not in the question class.php
$form->addElement('style_submit_button','submitQuestion',$text, 'class="'.$class.'"');
$form->addElement('style_submit_button', 'submitQuestion', $text, 'class="'.$class.'"');
if (!empty($this -> id)) {
if (!empty($this->id)) {
$form -> setDefaults($defaults);
} else {
if ($this->isContent == 1) {
@ -150,10 +154,9 @@ class FillBlanks extends Question
}
}
/**
* abstract function which creates the form to create / edit the answers of the question
* @param the formvalidator instance
* @param FormValidator $form
*/
function processAnswersCreation($form)
{

@ -75,8 +75,10 @@ if (is_object($objQuestion)) {
echo '<script type="text/javascript">window.location.href="admin.php?exerciseId='.$exerciseId.'&hotspotadmin='.$objQuestion->id.'"</script>';
}
} else {
if (isset($questionName)) {
echo '<h3>'.$questionName.'</h3>';
if(!empty($pictureName)){
}
if (!empty($pictureName)) {
echo '<img src="../document/download.php?doc_url=%2Fimages%2F'.$pictureName.'" border="0">';
}
if(!empty($msgErr)) {

Loading…
Cancel
Save