Code Duplication    Length = 7-9 lines in 2 locations

main/exercice/exercise.class.php 2 locations

@@ 3318-3324 (lines=7) @@
3315
                                    question_id = ".$questionId;
3316
3317
                        $result = Database::query($sql);
3318
                        while ($row = Database::fetch_array($result)) {
3319
                            $ind = $row['answer'];
3320
                            $values = explode(':', $ind);
3321
                            $my_answer_id = isset($values[0]) ? $values[0] : '';
3322
                            $option = isset($values[1]) ? $values[1] : '';
3323
                            $choice[$my_answer_id] = $option;
3324
                        }
3325
                    }
3326
3327
                    $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null;
@@ 3407-3415 (lines=9) @@
3404
                        $sql = "SELECT answer FROM ".$TBL_TRACK_ATTEMPT."
3405
                                WHERE exe_id = $exeId AND question_id= ".$questionId;
3406
                        $resultans = Database::query($sql);
3407
                        while ($row = Database::fetch_array($resultans)) {
3408
                            $ind = $row['answer'];
3409
                            $result = explode(':',$ind);
3410
                            if (isset($result[0])) {
3411
                                $my_answer_id = isset($result[0]) ? $result[0] : '';
3412
                                $option = isset($result[1]) ? $result[1] : '';
3413
                                $choice[$my_answer_id] = $option;
3414
                            }
3415
                        }
3416
                        $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : '';
3417
3418
                        if ($answerCorrect == $studentChoice) {