Code Duplication    Length = 38-47 lines in 2 locations

main/exercice/exercise.class.php 1 location

@@ 7192-7229 (lines=38) @@
7189
                        $s.='</tr>';
7190
                    }
7191
7192
                } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION) {
7193
7194
                    // multiple answers
7195
                    $input_id = 'choice-'.$questionId.'-'.$answerId;
7196
7197
                    if (in_array($numAnswer, $user_choice_array)) {
7198
                        $attributes = array('id' => $input_id, 'checked' => 1, 'selected' => 1);
7199
                    } else {
7200
                        $attributes = array('id' => $input_id);
7201
                    }
7202
7203
                    if ($debug_mark_answer) {
7204
                        if ($answerCorrect) {
7205
                            $attributes['checked'] = 1;
7206
                            $attributes['selected'] = 1;
7207
                        }
7208
                    }
7209
7210
                    $answer = Security::remove_XSS($answer);
7211
                    $answer_input = '<input type="hidden" name="choice2['.$questionId.']" value="0" />';
7212
                    $answer_input .= '<label class="checkbox">';
7213
                    $answer_input .= Display::input('checkbox', 'choice['.$questionId.']['.$numAnswer.']', 1, $attributes);
7214
                    $answer_input .= $answer;
7215
                    $answer_input .= '</label>';
7216
7217
                    if ($show_comment) {
7218
                        $s.= '<tr>';
7219
                        $s .= '<td>';
7220
                        $s.= $answer_input;
7221
                        $s .= '</td>';
7222
                        $s .= '<td>';
7223
                        $s .= $comment;
7224
                        $s .= '</td>';
7225
                        $s.= '</tr>';
7226
                    } else {
7227
                        $s.= $answer_input;
7228
                    }
7229
                } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) {
7230
                    $s .= '<input type="hidden" name="choice2['.$questionId.']" value="0" />';
7231
7232
                    $my_choice = array();

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

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