Minor - format code.

1.10.x
Julio Montoya 9 years ago
parent ae83e3bb1c
commit 4ef94dbb44
  1. 13
      main/exercice/exercise_admin.php
  2. 64
      main/exercice/multiple_answer_combination.class.php
  3. 8
      main/exercice/multiple_answer_combination_true_false.class.php
  4. 46
      main/exercice/multiple_answer_true_false.class.php
  5. 20
      main/exercice/overview.php
  6. 12
      main/inc/lib/events.lib.php
  7. 1
      main/inc/lib/exercise_show_functions.lib.php

@ -92,8 +92,6 @@ $(document).ready(function () {
});
</script>';
// INIT EXERCISE
$objExercise = new Exercise();
$course_id = api_get_course_int_id();
@ -139,17 +137,20 @@ if ($form->validate()) {
echo '<div class="actions">';
if ($objExercise->id != 0) {
echo '<a href="admin.php?'.api_get_cidReq().'&exerciseId='.$objExercise->id.'">' . Display :: return_icon('back.png', get_lang('GoBackToQuestionList'),'',ICON_SIZE_MEDIUM).'</a>';
echo '<a href="admin.php?'.api_get_cidReq().'&exerciseId='.$objExercise->id.'">' .
Display :: return_icon('back.png', get_lang('GoBackToQuestionList'), '', ICON_SIZE_MEDIUM).'</a>';
} else {
if (!empty($_GET['lp_id']) || !empty($_POST['lp_id'])){
if (!empty($_POST['lp_id'])){
$lp_id = Security::remove_XSS($_POST['lp_id']);//TODO:this remains to be implemented after press the first post
$lp_id = intval($_POST['lp_id']);//TODO:this remains to be implemented after press the first post
} else {
$lp_id = Security::remove_XSS($_GET['lp_id']);
$lp_id = intval($_GET['lp_id']);
}
echo "<a href=\"../newscorm/lp_controller.php?".api_get_cidreq()."&gradebook=&action=add_item&type=step&lp_id=".$lp_id."#resource_tab-2\">".Display::return_icon('back.png', get_lang("BackTo").' '.get_lang("LearningPaths"),'',ICON_SIZE_MEDIUM)."</a>";
} else {
echo '<a href="exercise.php">' . Display :: return_icon('back.png', get_lang('BackToExercisesList'),'',ICON_SIZE_MEDIUM).'</a>';
echo '<a href="exercise.php">' .
Display :: return_icon('back.png', get_lang('BackToExercisesList'),'',ICON_SIZE_MEDIUM).
'</a>';
}
}
echo '</div>';

@ -2,9 +2,10 @@
/* For licensing terms, see /license.txt */
/**
* Class MultipleAnswer
* Class MultipleAnswerCombination
*
* 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
@ -26,9 +27,8 @@ class MultipleAnswerCombination extends Question
}
/**
* function which redifines Question::createAnswersForm
* function which redefines Question::createAnswersForm
* @param FormValidator $form
* @param the answers number to display
*/
function createAnswersForm($form)
{
@ -135,20 +135,22 @@ class MultipleAnswerCombination extends Question
array(),
array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '100')
);
//only 1 answer the all deal ...
//$form->addElement('text', 'weighting['.$i.']',null, 'style="vertical-align:middle;margin-left: 0em;" size="5" value="10"');
$form->addHtml('</tr>');
}
$form->addElement('html', '</tbody></table>');
$form->add_multiple_required_rule($boxes_names, get_lang('ChooseAtLeastOneCheckbox'), 'multiple_required');
$form->add_multiple_required_rule(
$boxes_names,
get_lang('ChooseAtLeastOneCheckbox'),
'multiple_required'
);
//only 1 answer the all deal ...
$form->addText('weighting[1]', get_lang('Score'), false, ['value' => 10]);
global $text, $class;
global $text;
//ie6 fix
if ($obj_ex->edit_exercise_in_lp == true) {
@ -176,48 +178,49 @@ class MultipleAnswerCombination extends Question
}
/**
* abstract function which creates the form to create / edit the answers of the question
* @param the formvalidator instance
* @param the answers number to display
* abstract function which creates the form to create/edit the answers of the question
* @param FormValidator $form
*/
function processAnswersCreation($form)
public function processAnswersCreation($form)
{
$questionWeighting = $nbrGoodAnswers = 0;
$objAnswer = new Answer($this->id);
$nb_answers = $form->getSubmitValue('nb_answers');
$nb_answers = $form -> getSubmitValue('nb_answers');
for($i=1 ; $i <= $nb_answers ; $i++)
{
$answer = trim($form -> getSubmitValue('answer['.$i.']'));
$comment = trim($form -> getSubmitValue('comment['.$i.']'));
if ($i == 1)
$weighting = trim($form -> getSubmitValue('weighting['.$i.']'));
else {
for ($i = 1; $i <= $nb_answers; $i++) {
$answer = trim($form->getSubmitValue('answer['.$i.']'));
$comment = trim($form->getSubmitValue('comment['.$i.']'));
if ($i == 1) {
$weighting = trim($form->getSubmitValue('weighting['.$i.']'));
} else {
$weighting = 0;
}
$goodAnswer = trim($form -> getSubmitValue('correct['.$i.']'));
$goodAnswer = trim($form->getSubmitValue('correct['.$i.']'));
if($goodAnswer){
if ($goodAnswer) {
$weighting = abs($weighting);
} else {
$weighting = abs($weighting);
// $weighting = -$weighting;
}
if($weighting > 0)
{
if ($weighting > 0) {
$questionWeighting += $weighting;
}
$objAnswer -> createAnswer($answer,$goodAnswer,$comment,$weighting,$i);
$objAnswer->createAnswer(
$answer,
$goodAnswer,
$comment,
$weighting,
$i
);
}
// saves the answers into the data base
$objAnswer -> save();
$objAnswer->save();
// sets the total weighting of the question
$this -> updateWeighting($questionWeighting);
$this -> save();
$this->updateWeighting($questionWeighting);
$this->save();
}
function return_header($feedback_type = null, $counter = null, $score = null)
@ -230,6 +233,7 @@ class MultipleAnswerCombination extends Question
<th>'. get_lang("Answer").'</i></th>';
$header .= '<th>'.get_lang("Comment").'</th>';
$header .= '</tr>';
return $header;
}
}

@ -2,7 +2,7 @@
/* For licensing terms, see /license.txt */
/**
* Class MultipleAnswer
* Class MultipleAnswerCombinationTrueFalse
*
* This class allows to instantiate an object of type MULTIPLE_ANSWER (MULTIPLE CHOICE, MULTIPLE ANSWER),
* extending the class question
@ -24,6 +24,10 @@ class MultipleAnswerCombinationTrueFalse extends MultipleAnswerCombination
parent::__construct();
$this -> type = MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE;
$this -> isContent = $this-> getIsContent();
$this->options = array('1'=>get_lang('True'),'0' =>get_lang('False'), '2' =>get_lang('DontKnow'));
$this->options = array(
'1' => get_lang('True'),
'0' => get_lang('False'),
'2' => get_lang('DontKnow'),
);
}
}

@ -34,7 +34,7 @@ class MultipleAnswerTrueFalse extends Question
{
$nb_answers = isset($_POST['nb_answers']) ? $_POST['nb_answers'] : 4;
// The previous default value was 2. See task #1759.
$nb_answers += (isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0));
$nb_answers += isset($_POST['lessAnswers']) ? -1 : isset($_POST['moreAnswers']) ? 1 : 0;
$course_id = api_get_course_int_id();
$obj_ex = $_SESSION['objExercise'];
@ -104,14 +104,18 @@ class MultipleAnswerTrueFalse extends Question
'comment[' . $i . ']'
);
$answer_number = $form->addElement('text', 'counter[' . $i . ']', null, 'value="' . $i . '"');
$answer_number = $form->addElement(
'text',
'counter['.$i.']',
null,
'value="'.$i.'"'
);
$answer_number->freeze();
if (is_object($answer)) {
$defaults['answer[' . $i . ']'] = $answer->answer[$i];
$defaults['comment[' . $i . ']'] = $answer->comment[$i];
//$defaults['weighting['.$i.']'] = float_format($answer -> weighting[$i], 1);
$correct = $answer->correct[$i];
$defaults['correct[' . $i . ']'] = $correct;
@ -119,9 +123,7 @@ class MultipleAnswerTrueFalse extends Question
if (!empty($option_data)) {
foreach ($option_data as $id => $data) {
$form->addElement('radio', 'correct[' . $i . ']', null, null, $id);
$j++;
if ($j == 3) {
break;
}
@ -153,7 +155,11 @@ class MultipleAnswerTrueFalse extends Question
'comment[' . $i . ']',
null,
array(),
array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '100')
array(
'ToolbarSet' => 'TestProposedAnswer',
'Width' => '100%',
'Height' => '100',
)
);
}
@ -179,17 +185,17 @@ class MultipleAnswerTrueFalse extends Question
$wrongInputTemplate .= '<!-- BEGIN error --><span class="form_error">{error}</span><!-- END error -->';
$wrongInputTemplate .= '</td>';
$doubtScoreInputTempalte = '<td>' . get_lang('DoubtScore') . '<br>{element}';
$doubtScoreInputTempalte .= '<!-- BEGIN error --><span class="form_error">{error}</span><!-- END error -->';
$doubtScoreInputTempalte .= '</td>';
$doubtScoreInputTempalte .= '</tr>';
$doubtScoreInputTempalte .= '</table>';
$doubtScoreInputTempalte .= '</div>';
$doubtScoreInputTempalte .= '</div>';
$doubtScoreInputTemplate = '<td>' . get_lang('DoubtScore') . '<br>{element}';
$doubtScoreInputTemplate .= '<!-- BEGIN error --><span class="form_error">{error}</span><!-- END error -->';
$doubtScoreInputTemplate .= '</td>';
$doubtScoreInputTemplate .= '</tr>';
$doubtScoreInputTemplate .= '</table>';
$doubtScoreInputTemplate .= '</div>';
$doubtScoreInputTemplate .= '</div>';
$renderer->setElementTemplate($correctInputTemplate, 'option[1]');
$renderer->setElementTemplate($wrongInputTemplate, 'option[2]');
$renderer->setElementTemplate($doubtScoreInputTempalte, 'option[3]');
$renderer->setElementTemplate($doubtScoreInputTemplate, 'option[3]');
// 3 scores
$form->addElement('text', 'option[1]', get_lang('Correct'), array('class' => 'span1', 'value' => '1'));
@ -202,10 +208,11 @@ class MultipleAnswerTrueFalse extends Question
$form->addElement('hidden', 'options_count', 3);
//Extra values True, false, Dont known
// Extra values True, false, Dont known
if (!empty($this->extra)) {
$scores = explode(':', $this->extra);
if (!empty($scores)) {
for ($i = 1; $i <= 3; $i++) {
$defaults['option[' . $i . ']'] = $scores[$i - 1];
@ -259,7 +266,12 @@ class MultipleAnswerTrueFalse extends Question
}
} else {
for ($i=1 ; $i <= 3 ; $i++) {
$last_id = Question::saveQuestionOption($this->id, $this->options[$i], $course_id, $i);
$last_id = Question::saveQuestionOption(
$this->id,
$this->options[$i],
$course_id,
$i
);
$correct[$i] = $last_id;
}
}

@ -90,7 +90,12 @@ if (isset($_GET['preview'])) {
$extra_params = '&preview=1';
}
$exercise_stat_info = $objExercise->get_stat_track_exercise_info($learnpath_id, $learnpath_item_id, 0);
$exercise_stat_info = $objExercise->get_stat_track_exercise_info(
$learnpath_id,
$learnpath_item_id,
0
);
$attempt_list = null;
if (isset($exercise_stat_info['exe_id'])) {
$attempt_list = Event::getAllExerciseEventByExeId($exercise_stat_info['exe_id']);
@ -109,7 +114,11 @@ if (!empty($attempt_list)) {
// 2. Exercise button
// Notice we not add there the lp_item_view_id because is not already generated
$exercise_url = api_get_path(WEB_CODE_PATH).'exercice/exercise_submit.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id.'&origin='.$origin.'&learnpath_id='.$learnpath_id.'&learnpath_item_id='.$learnpath_item_id.$extra_params;
$exercise_url_button = Display::url($label, $exercise_url, array('class'=>'btn btn-success btn-large'));
$exercise_url_button = Display::url(
$label,
$exercise_url,
array('class' => 'btn btn-success btn-large')
);
//3. Checking visibility of the exercise (overwrites the exercise button)
$visible_return = $objExercise->is_visible(
@ -181,8 +190,6 @@ if (!empty($attempts)) {
);
$teacher_revised = Display::label(get_lang('Validated'), 'success');
//$attempt_link = get_lang('NoResult');
//$attempt_link = Display::return_icon('quiz_na.png', get_lang('NoResult'), array(), ICON_SIZE_SMALL);
if ($attempt_result['attempt_revised'] == 0) {
$teacher_revised = Display::label(get_lang('NotValidated'), 'info');
}
@ -214,7 +221,10 @@ if (!empty($attempts)) {
RESULT_DISABLE_SHOW_FINAL_SCORE_ONLY_WITH_CATEGORIES
)
)
|| ($objExercise->results_disabled == RESULT_DISABLE_SHOW_SCORE_ONLY && $objExercise->feedback_type == EXERCISE_FEEDBACK_TYPE_END)) {
|| (
$objExercise->results_disabled == RESULT_DISABLE_SHOW_SCORE_ONLY &&
$objExercise->feedback_type == EXERCISE_FEEDBACK_TYPE_END)
) {
$row['attempt_link'] = $attempt_link;
}
$my_attempt_array[] = $row;

@ -1285,7 +1285,8 @@ class Event
}
$sql = "SELECT * FROM $table_track_exercises
WHERE status = '' AND
WHERE
status = '' AND
exe_user_id = $user_id AND
c_id = $courseId AND
exe_exo_id = $exercise_id AND
@ -1298,14 +1299,17 @@ class Event
$list = array();
while ($row = Database::fetch_array($res, 'ASSOC')) {
//Checking if this attempt was revised by a teacher
$sql_revised = 'SELECT exe_id FROM '.$table_track_attempt_recording.' WHERE author != "" AND exe_id = '.$row['exe_id'].' LIMIT 1';
$res_revised = Database::query($sql_revised);
$sql = 'SELECT exe_id FROM '.$table_track_attempt_recording.'
WHERE author != "" AND exe_id = '.$row['exe_id'].'
LIMIT 1';
$res_revised = Database::query($sql);
$row['attempt_revised'] = 0;
if (Database::num_rows($res_revised) > 0) {
$row['attempt_revised'] = 1;
}
$list[$row['exe_id']] = $row;
$sql = "SELECT * FROM $table_track_attempt WHERE exe_id = {$row['exe_id']}";
$sql = "SELECT * FROM $table_track_attempt
WHERE exe_id = {$row['exe_id']}";
$res_question = Database::query($sql);
while ($row_q = Database::fetch_array($res_question, 'ASSOC')) {
$list[$row['exe_id']]['question_list'][$row_q['question_id']] = $row_q;

@ -236,6 +236,7 @@ class ExerciseShowFunctions
$ans,
$in_results_disabled
) {
$hide_expected_answer = false;
if ($feedback_type == 0 && $in_results_disabled == 2) {
$hide_expected_answer = true;

Loading…
Cancel
Save