Minor - format code.

1.9.x
Julio Montoya 12 years ago
parent 0daf812ba3
commit e365bcde56
  1. 8
      main/exercice/admin.php
  2. 77
      main/exercice/export/qti2/qti2_classes.php
  3. 66
      main/exercice/question.class.php

@ -125,7 +125,7 @@ $cancelQuestion = isset($cancelQuestion) ? $cancelQuestion : null;
delete_all_incomplete_attempts(api_get_user_id(), $exerciseId, api_get_course_id(), api_get_session_id());
// get from session
$objExercise = $_SESSION['objExercise'];
$objExercise = isset($_SESSION['objExercise']) ? $_SESSION['objExercise'] : null;
$objQuestion = $_SESSION['objQuestion'];
$objAnswer = $_SESSION['objAnswer'];
@ -264,9 +264,9 @@ if ($cancelAnswers) {
$editQuestion=$modifyAnswers;
unset($modifyAnswers);
}
$nameTools = null;
// modifies the query string that is used in the link of tool name
if($editQuestion || $modifyQuestion || $newQuestion || $modifyAnswers) {
if ($editQuestion || $modifyQuestion || $newQuestion || $modifyAnswers) {
$nameTools = get_lang('QuestionManagement');
}
@ -523,7 +523,7 @@ if (!$newQuestion && !$modifyQuestion && !$editQuestion && !isset($_GET['hotspot
}
// if we are in question authoring, display warning to user is feedback not shown at the end of the test -ref #6619
// this test to displau only message in the question authoring page and not in the question list page too
// this test to display only message in the question authoring page and not in the question list page too
// if (is_object($objQuestion) && $objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_EXAM && ($newQuestion || $modifyQuestion || $editQuestion)) {
if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_EXAM) {
Display::display_normal_message(get_lang("TestFeedbackNotShown"));

@ -42,39 +42,41 @@ class Ims2Question extends Question
*/
function setAnswer()
{
switch($this->type)
{
switch($this->type) {
case MCUA :
$answer = new ImsAnswerMultipleChoice($this->id);
return $answer;
return $answer;
case MCMA :
$answer = new ImsAnswerMultipleChoice($this->id);
return $answer;
return $answer;
case TF :
$answer = new ImsAnswerMultipleChoice($this->id);
return $answer;
return $answer;
case FIB :
$answer = new ImsAnswerFillInBlanks($this->id);
return $answer;
return $answer;
case MATCHING :
$answer = new ImsAnswerMatching($this->id);
return $answer;
return $answer;
case FREE_ANSWER :
$answer = new ImsAnswerFree($this->id);
return $answer;
$answer = new ImsAnswerFree($this->id);
return $answer;
case HOT_SPOT :
$answer = new ImsAnswerHotspot($this->id);
return $answer;
$answer = new ImsAnswerHotspot($this->id);
return $answer;
default :
$answer = null;
break;
}
return $answer;
}
function createAnswersForm($form)
{
return true;
}
function processAnswersCreation($form)
{
return true;
@ -97,11 +99,8 @@ class ImsAnswerMultipleChoice extends Answer
$out .= ' <prompt> ' . $questionStatment . ' </prompt>'. "\n";
if (is_array($this->answerList)) {
foreach ($this->answerList as $current_answer) {
$out .= ' <simpleChoice identifier="answer_' . $current_answer['id'] . '" fixed="false">' . $current_answer['answer'];
if (isset($current_answer['comment']) && $current_answer['comment'] != '')
{
if (isset($current_answer['comment']) && $current_answer['comment'] != '') {
$out .= '<feedbackInline identifier="answer_' . $current_answer['id'] . '">' . $current_answer['comment'] . '</feedbackInline>';
}
$out .= '</simpleChoice>'. "\n";
@ -128,8 +127,7 @@ class ImsAnswerMultipleChoice extends Answer
$out .= ' <correctResponse>'. "\n";
if (is_array($this->answerList)) {
foreach($this->answerList as $current_answer) {
if ($current_answer['correct'])
{
if ($current_answer['correct']) {
$out .= ' <value>answer_'. $current_answer['id'] .'</value>'. "\n";
}
}
@ -140,16 +138,13 @@ class ImsAnswerMultipleChoice extends Answer
$out .= ' <mapping>'. "\n";
if (is_array($this->answerList)) {
foreach($this->answerList as $current_answer)
{
if (isset($current_answer['grade']))
{
$out .= ' <mapEntry mapKey="answer_'. $current_answer['id'] .'" mappedValue="'.$current_answer['grade'].'" />'. "\n";
foreach($this->answerList as $current_answer) {
if (isset($current_answer['grade'])) {
$out .= ' <mapEntry mapKey="answer_'. $current_answer['id'] .'" mappedValue="'.$current_answer['grade'].'" />'. "\n";
}
}
}
$out .= ' </mapping>'. "\n";
$out .= ' </responseDeclaration>'. "\n";
return $out;
@ -233,7 +228,6 @@ class ImsAnswerFillInBlanks extends Answer
//}
return $out;
}
/**
@ -241,13 +235,12 @@ class ImsAnswerFillInBlanks extends Answer
*/
function imsExportResponsesDeclaration($questionIdent)
{
$this->answerList = $this->getAnswersList(true);
$this->gradeList = $this->getGradesList();
$out = '';
if (is_array($this->answerList)) {
foreach ($this->answerList as $answerKey=>$answer) {
$answerKey = $answer['id'];
$answer = $answer['answer'];
$out .= ' <responseDeclaration identifier="fill_' . $answerKey . '" cardinality="single" baseType="identifier">' . "\n";
@ -273,8 +266,7 @@ class ImsAnswerFillInBlanks extends Answer
*/
$out .= ' </correctResponse>'. "\n";
if (isset($this->gradeList[$answerKey]))
{
if (isset($this->gradeList[$answerKey])) {
$out .= ' <mapping>'. "\n";
$out .= ' <mapEntry mapKey="'.$answer.'" mappedValue="'.$this->gradeList[$answerKey].'"/>'. "\n";
$out .= ' </mapping>'. "\n";
@ -311,8 +303,7 @@ class ImsAnswerMatching extends Answer
$out .= ' <simpleMatchSet>'. "\n";
if (is_array($this->leftList)) {
foreach ($this->leftList as $leftKey=>$leftElement)
{
foreach ($this->leftList as $leftKey=>$leftElement) {
$out .= ' <simpleAssociableChoice identifier="left_'.$leftKey.'" >'. $leftElement['answer'] .'</simpleAssociableChoice>'. "\n";
}
}
@ -326,14 +317,12 @@ class ImsAnswerMatching extends Answer
$i = 0;
if (is_array($this->rightList)) {
foreach($this->rightList as $rightKey=>$rightElement)
{
foreach($this->rightList as $rightKey=>$rightElement) {
$out .= ' <simpleAssociableChoice identifier="right_'.$i.'" >'. $rightElement['answer'] .'</simpleAssociableChoice>'. "\n";
$i++;
}
}
$out .= ' </simpleMatchSet>'. "\n";
$out .= '</matchInteraction>'. "\n";
return $out;
@ -350,13 +339,10 @@ class ImsAnswerMatching extends Answer
$gradeArray = array();
if (is_array($this->leftList)) {
foreach ($this->leftList as $leftKey=>$leftElement)
{
foreach ($this->leftList as $leftKey=>$leftElement) {
$i=0;
foreach ($this->rightList as $rightKey=>$rightElement)
{
if( ($leftElement['match'] == $rightElement['code']))
{
foreach ($this->rightList as $rightKey=>$rightElement) {
if (($leftElement['match'] == $rightElement['code'])) {
$out .= ' <value>left_' . $leftKey . ' right_'.$i.'</value>'. "\n";
$gradeArray['left_' . $leftKey . ' right_'.$i] = $leftElement['grade'];
@ -368,8 +354,7 @@ class ImsAnswerMatching extends Answer
$out .= ' </correctResponse>'. "\n";
$out .= ' <mapping>' . "\n";
if (is_array($gradeArray)) {
foreach ($gradeArray as $gradeKey=>$grade)
{
foreach ($gradeArray as $gradeKey=>$grade) {
$out .= ' <mapEntry mapKey="'.$gradeKey.'" mappedValue="'.$grade.'"/>' . "\n";
}
}
@ -406,8 +391,7 @@ class ImsAnswerHotspot extends Answer
$text .= ' <prompt>'.$questionDesc.'</prompt>'."\n";
$text .= ' <object type="'.$mimetype.'" width="250" height="230" data="'.$questionMedia.'">-</object>'."\n";
if (is_array($this->answerList)) {
foreach ($this->answerList as $key=>$answer)
{
foreach ($this->answerList as $key=>$answer) {
$key = $answer['id'];
$answerTxt = $answer['answer'];
$len = api_strlen($answerTxt);
@ -442,7 +426,6 @@ class ImsAnswerHotspot extends Answer
$text .= ' </graphicOrderInteraction>'."\n";
$out = $text;
return $out;
}
@ -452,7 +435,6 @@ class ImsAnswerHotspot extends Answer
*/
function imsExportResponsesDeclaration($questionIdent)
{
$this->answerList = $this->getAnswersList(true);
$this->gradeList = $this->getGradesList();
$out = '';
@ -460,12 +442,10 @@ class ImsAnswerHotspot extends Answer
$out .= ' <correctResponse>'. "\n";
if (is_array($this->answerList)) {
foreach ($this->answerList as $answerKey=>$answer)
{
foreach ($this->answerList as $answerKey=>$answer) {
$answerKey = $answer['id'];
$answer = $answer['answer'];
$out .= ' <value>'.$answerKey.'</value>'. "\n";
}
}
$out .= ' </correctResponse>'. "\n";
@ -497,4 +477,3 @@ class ImsAnswerFree extends Answer
return '';
}
}
?>

@ -45,47 +45,47 @@ define('FIB', 3);
*/
abstract class Question
{
public $id;
public $question;
public $description;
public $weighting;
public $position;
public $type;
public $level;
public $picture;
public $exerciseList; // array with the list of exercises which this question is in
public $id;
public $question;
public $description;
public $weighting;
public $position;
public $type;
public $level;
public $picture;
public $exerciseList; // array with the list of exercises which this question is in
public $category_list;
public $parent_id;
public $category;
public $isContent;
public $category;
public $isContent;
public $course;
public static $typePicture = 'new_question.png';
public static $explanationLangVar = '';
public static $typePicture = 'new_question.png';
public static $explanationLangVar = '';
public $question_table_class = 'table table-striped';
public static $questionTypes =
array(
UNIQUE_ANSWER => array('unique_answer.class.php' , 'UniqueAnswer'),
MULTIPLE_ANSWER => array('multiple_answer.class.php' , 'MultipleAnswer'),
FILL_IN_BLANKS => array('fill_blanks.class.php' , 'FillBlanks'),
MATCHING => array('matching.class.php' , 'Matching'),
FREE_ANSWER => array('freeanswer.class.php' , 'FreeAnswer'),
ORAL_EXPRESSION => array('oral_expression.class.php' , 'OralExpression'),
HOT_SPOT => array('hotspot.class.php' , 'HotSpot'),
HOT_SPOT_DELINEATION => array('hotspot.class.php' , 'HotspotDelineation'),
MULTIPLE_ANSWER_COMBINATION => array('multiple_answer_combination.class.php', 'MultipleAnswerCombination'),
UNIQUE_ANSWER_NO_OPTION => array('unique_answer_no_option.class.php', 'UniqueAnswerNoOption'),
MULTIPLE_ANSWER_TRUE_FALSE => array('multiple_answer_true_false.class.php', 'MultipleAnswerTrueFalse'),
MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE => array('multiple_answer_combination_true_false.class.php', 'MultipleAnswerCombinationTrueFalse'),
GLOBAL_MULTIPLE_ANSWER => array('global_multiple_answer.class.php' , 'GlobalMultipleAnswer'),
//MEDIA_QUESTION => array('media_question.class.php' , 'MediaQuestion')
);
public static $questionTypes = array(
UNIQUE_ANSWER => array('unique_answer.class.php' , 'UniqueAnswer'),
MULTIPLE_ANSWER => array('multiple_answer.class.php' , 'MultipleAnswer'),
FILL_IN_BLANKS => array('fill_blanks.class.php' , 'FillBlanks'),
MATCHING => array('matching.class.php' , 'Matching'),
FREE_ANSWER => array('freeanswer.class.php' , 'FreeAnswer'),
ORAL_EXPRESSION => array('oral_expression.class.php' , 'OralExpression'),
HOT_SPOT => array('hotspot.class.php' , 'HotSpot'),
HOT_SPOT_DELINEATION => array('hotspot.class.php' , 'HotspotDelineation'),
MULTIPLE_ANSWER_COMBINATION => array('multiple_answer_combination.class.php', 'MultipleAnswerCombination'),
UNIQUE_ANSWER_NO_OPTION => array('unique_answer_no_option.class.php', 'UniqueAnswerNoOption'),
MULTIPLE_ANSWER_TRUE_FALSE => array('multiple_answer_true_false.class.php', 'MultipleAnswerTrueFalse'),
MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE => array('multiple_answer_combination_true_false.class.php', 'MultipleAnswerCombinationTrueFalse'),
GLOBAL_MULTIPLE_ANSWER => array('global_multiple_answer.class.php' , 'GlobalMultipleAnswer'),
//MEDIA_QUESTION => array('media_question.class.php' , 'MediaQuestion')
);
/**
* constructor of the class
*
* @author - Olivier Brouckaert
*/
public function Question() {
public function Question()
{
$this->id=0;
$this->question='';
$this->description='';
@ -1303,8 +1303,8 @@ abstract class Question
/**
* function which process the creation of questions
* @param FormValidator $form the formvalidator instance
* @param Exercise $objExercise the Exercise instance
* @param FormValidator $form
* @param Exercise $objExercise
*/
function processCreation ($form, $objExercise = null) {
//$this->updateParentId($form->getSubmitValue('parent_id'));

Loading…
Cancel
Save