Fix PHP warning, minor UI changes

1.10.x
Julio Montoya 11 years ago
parent d5b553f4f4
commit dc4fcd66b7
  1. 44
      main/exercice/exercise.class.php
  2. 4
      main/exercice/exercise_submit.php
  3. 2
      main/exercice/overview.php
  4. 2
      main/exercice/question.class.php
  5. 11
      main/inc/lib/exercise.lib.php

@ -2429,7 +2429,7 @@ class Exercise
$choice[$ind] = 1;
}
$numAnswer=$objAnswerTmp->selectAutoId($answerId);
$studentChoice=$choice[$numAnswer];
$studentChoice = isset($choice[$numAnswer]) ? $choice[$numAnswer] : null;
if ($answerCorrect == 1) {
if ($studentChoice) {
@ -2445,7 +2445,7 @@ class Exercise
}
}
} else {
$studentChoice = $choice[$numAnswer];
$studentChoice = isset($choice[$numAnswer]) ? $choice[$numAnswer] : null;
if ($answerCorrect == 1) {
if ($studentChoice) {
$real_answers[$answerId] = true;
@ -2703,11 +2703,14 @@ class Exercise
if ($from_database) {
$query = "SELECT answer, marks FROM ".$TBL_TRACK_ATTEMPT."
WHERE exe_id = '".$exeId."' AND question_id= '".$questionId."'";
$resq = Database::query($query);
$choice = Database::result($resq,0,'answer');
$resq = Database::query($query);
$data = Database::fetch_array($resq);
$choice = $data['answer'];
$choice = str_replace('\r\n', '', $choice);
$choice = stripslashes($choice);
$questionScore = Database::result($resq, 0, "marks");
$questionScore = $data['marks'];
if ($questionScore == -1) {
$totalScore+= 0;
} else {
@ -2807,7 +2810,9 @@ class Exercise
echo '<tr>';
echo '<td>'.$s_answer_label.'</td>';
echo '<td>'.$user_answer;
echo ' <b><span style="color: #008000;">'.$real_list[$i_answer_correct_answer].'</span></b> ';
if (isset($real_list[$i_answer_correct_answer])) {
echo ' <b><span style="color: #008000;">'.$real_list[$i_answer_correct_answer].'</span></b> ';
}
echo '</td>';
echo '</tr>';
}
@ -2817,12 +2822,14 @@ class Exercise
$numAnswer = $objAnswerTmp->selectAutoId($answerId);
if ($answerCorrect) {
if ($answerCorrect == $choice[$numAnswer]) {
$questionScore += $answerWeighting;
$totalScore += $answerWeighting;
$questionScore += $answerWeighting;
$totalScore += $answerWeighting;
$user_answer = '<span>'.$answer_matching[$choice[$numAnswer]].'</span>';
} else {
$user_answer = '<span style="color: #FF0000; text-decoration: line-through;">'.$answer_matching[$choice[$numAnswer]].'</span>';
if (isset($answer_matching[$choice[$numAnswer]])) {
$user_answer = '<span style="color: #FF0000; text-decoration: line-through;">'.$answer_matching[$choice[$numAnswer]].'</span>';
}
}
$matching[$numAnswer] = $choice[$numAnswer];
}
@ -3746,15 +3753,16 @@ class Exercise
$answer = $item['answer'];
$answer_type = $item['answer_type'];
if (!empty($question) && !empty($answer) && $answer_type == FREE_ANSWER ) {
$open_question_list.='<tr>
<td width="220" valign="top" bgcolor="#E5EDF8">&nbsp;&nbsp;'.get_lang('Question').'</td>
<td width="473" valign="top" bgcolor="#F3F3F3">'.$question.'</td>
</tr>
<tr>
<td width="220" valign="top" bgcolor="#E5EDF8">&nbsp;&nbsp;'.get_lang('Answer').'</td>
<td valign="top" bgcolor="#F3F3F3">'.$answer.'</td>
</tr>';
if (!empty($question) && !empty($answer) && $answer_type == FREE_ANSWER) {
$open_question_list.='
<tr>
<td width="220" valign="top" bgcolor="#E5EDF8">&nbsp;&nbsp;'.get_lang('Question').'</td>
<td width="473" valign="top" bgcolor="#F3F3F3">'.$question.'</td>
</tr>
<tr>
<td width="220" valign="top" bgcolor="#E5EDF8">&nbsp;&nbsp;'.get_lang('Answer').'</td>
<td valign="top" bgcolor="#F3F3F3">'.$answer.'</td>
</tr>';
}
}

@ -913,7 +913,7 @@ if (!empty($error)) {
$.ajax({
type:"post",
async: false,
url: "'.api_get_path(WEB_AJAX_PATH).'exercise.ajax.php?a=save_exercise_by_now",
url: "'.api_get_path(WEB_AJAX_PATH).'exercise.ajax.php?'.api_get_cidreq().'&a=save_exercise_by_now",
data: "'.$params.'&type=simple&question_id="+question_id+"&"+my_choice+"&"+hotspot+"&"+remind_list,
success: function(return_value) {
if (return_value == "ok") {
@ -978,7 +978,7 @@ if (!empty($error)) {
$.ajax({
type:"post",
async: false,
url: "'.api_get_path(WEB_AJAX_PATH).'exercise.ajax.php?a=save_exercise_by_now",
url: "'.api_get_path(WEB_AJAX_PATH).'exercise.ajax.php?'.api_get_cidreq().'&a=save_exercise_by_now",
data: "'.$params.'&type=all&"+my_choice+"&"+hotspot+"&"+free_answers+"&"+remind_list,
success: function(return_value) {
if (return_value == "ok") {

@ -167,7 +167,7 @@ if (!empty($attempts) && $visible_return['value'] == true) {
$attempt_link = Display::url(
get_lang('Show'),
$attempt_url,
array('class' => $btn_class . 'btn')
array('class' => $btn_class . 'btn btn-default')
);
$teacher_revised = Display::label(get_lang('Validated'), 'success');

@ -807,7 +807,7 @@ abstract class Question
Database::query($sql);
$id = Database::insert_id();
$sql = "UPDATE $TBL_ANSWERS SET id = id_auto WHERE iid = $id";
$sql = "UPDATE $TBL_ANSWERS SET id = id_auto WHERE id_auto = $id";
Database::query($sql);
}

@ -38,8 +38,7 @@ class ExerciseLib
$show_comment = false,
$exercise_feedback = null,
$show_answers = false
)
{
) {
// Change false to true in the following line to enable answer hinting
$debug_mark_answer = $show_answers;
@ -77,10 +76,8 @@ class ExerciseLib
}
}
if (in_array(
$answerType,
array(FREE_ANSWER, ORAL_EXPRESSION)
) && $freeze
if (in_array($answerType, array(FREE_ANSWER, ORAL_EXPRESSION)) &&
$freeze
) {
return '';
}
@ -160,7 +157,7 @@ class ExerciseLib
);
$form->addHtmlEditor("choice[" . $questionId . "]", null, false, false, $config);
$form->setDefaults(array("choice[" . $questionId . "]" => $fck_content));
$s .= $form->return_form();
$s .= $form->returnForm();
} elseif ($answerType == ORAL_EXPRESSION) {
// Add nanog
if (api_get_setting('enable_nanogong') == 'true') {

Loading…
Cancel
Save