Code Duplication    Length = 38-47 lines in 2 locations

main/exercice/exercise.class.php 1 location

@@ 7139-7176 (lines=38) @@
7136
                        $s.='</tr>';
7137
                    }
7138
7139
                } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION) {
7140
7141
                    // multiple answers
7142
                    $input_id = 'choice-'.$questionId.'-'.$answerId;
7143
7144
                    if (in_array($numAnswer, $user_choice_array)) {
7145
                        $attributes = array('id' => $input_id, 'checked' => 1, 'selected' => 1);
7146
                    } else {
7147
                        $attributes = array('id' => $input_id);
7148
                    }
7149
7150
                    if ($debug_mark_answer) {
7151
                        if ($answerCorrect) {
7152
                            $attributes['checked'] = 1;
7153
                            $attributes['selected'] = 1;
7154
                        }
7155
                    }
7156
7157
                    $answer = Security::remove_XSS($answer);
7158
                    $answer_input = '<input type="hidden" name="choice2['.$questionId.']" value="0" />';
7159
                    $answer_input .= '<label class="checkbox">';
7160
                    $answer_input .= Display::input('checkbox', 'choice['.$questionId.']['.$numAnswer.']', 1, $attributes);
7161
                    $answer_input .= $answer;
7162
                    $answer_input .= '</label>';
7163
7164
                    if ($show_comment) {
7165
                        $s.= '<tr>';
7166
                        $s .= '<td>';
7167
                        $s.= $answer_input;
7168
                        $s .= '</td>';
7169
                        $s .= '<td>';
7170
                        $s .= $comment;
7171
                        $s .= '</td>';
7172
                        $s.= '</tr>';
7173
                    } else {
7174
                        $s.= $answer_input;
7175
                    }
7176
                } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) {
7177
                    $s .= '<input type="hidden" name="choice2['.$questionId.']" value="0" />';
7178
7179
                    $my_choice = array();

main/inc/lib/exercise.lib.php 1 location

@@ 451-497 (lines=47) @@
448
                        }
449
                        $s .= '</tr>';
450
                    }
451
                } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION) {
452
                    // multiple answers
453
                    $input_id = 'choice-' . $questionId . '-' . $answerId;
454
455
                    if (in_array($numAnswer, $user_choice_array)) {
456
                        $attributes = array(
457
                            'id' => $input_id,
458
                            'checked' => 1,
459
                            'selected' => 1
460
                        );
461
                    } else {
462
                        $attributes = array('id' => $input_id);
463
                    }
464
465
                    if ($debug_mark_answer) {
466
                        if ($answerCorrect) {
467
                            $attributes['checked'] = 1;
468
                            $attributes['selected'] = 1;
469
                        }
470
                    }
471
472
                    $answer = Security::remove_XSS($answer, STUDENT);
473
                    $answer_input = '<input type="hidden" name="choice2[' . $questionId . ']" value="0" />';
474
                    $answer_input .= '<label class="checkbox">';
475
                    $answer_input .= Display::input(
476
                        'checkbox',
477
                        'choice[' . $questionId . '][' . $numAnswer . ']',
478
                        1,
479
                        $attributes
480
                    );
481
                    $answer_input .= $answer;
482
                    $answer_input .= '</label>';
483
484
                    if ($show_comment) {
485
                        $s .= '<tr>';
486
                        $s .= '<td>';
487
                        $s .= $answer_input;
488
                        $s .= '</td>';
489
                        $s .= '<td>';
490
                        $s .= $comment;
491
                        $s .= '</td>';
492
                        $s .= '</tr>';
493
                    } else {
494
                        $s .= $answer_input;
495
                    }
496
497
                } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) {
498
                    $s .= '<input type="hidden" name="choice2[' . $questionId . ']" value="0" />';
499
500
                    $my_choice = array();