Code Duplication    Length = 38-47 lines in 2 locations

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();

main/exercice/exercise.class.php 1 location

@@ 7209-7246 (lines=38) @@
7206
                        $s.='</tr>';
7207
                    }
7208
7209
                } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION) {
7210
7211
                    // multiple answers
7212
                    $input_id = 'choice-'.$questionId.'-'.$answerId;
7213
7214
                    if (in_array($numAnswer, $user_choice_array)) {
7215
                        $attributes = array('id' => $input_id, 'checked' => 1, 'selected' => 1);
7216
                    } else {
7217
                        $attributes = array('id' => $input_id);
7218
                    }
7219
7220
                    if ($debug_mark_answer) {
7221
                        if ($answerCorrect) {
7222
                            $attributes['checked'] = 1;
7223
                            $attributes['selected'] = 1;
7224
                        }
7225
                    }
7226
7227
                    $answer = Security::remove_XSS($answer);
7228
                    $answer_input = '<input type="hidden" name="choice2['.$questionId.']" value="0" />';
7229
                    $answer_input .= '<label class="checkbox">';
7230
                    $answer_input .= Display::input('checkbox', 'choice['.$questionId.']['.$numAnswer.']', 1, $attributes);
7231
                    $answer_input .= $answer;
7232
                    $answer_input .= '</label>';
7233
7234
                    if ($show_comment) {
7235
                        $s.= '<tr>';
7236
                        $s .= '<td>';
7237
                        $s.= $answer_input;
7238
                        $s .= '</td>';
7239
                        $s .= '<td>';
7240
                        $s .= $comment;
7241
                        $s .= '</td>';
7242
                        $s.= '</tr>';
7243
                    } else {
7244
                        $s.= $answer_input;
7245
                    }
7246
                } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) {
7247
                    $s .= '<input type="hidden" name="choice2['.$questionId.']" value="0" />';
7248
7249
                    $my_choice = array();