Code Duplication    Length = 7-9 lines in 2 locations

main/exercice/exercise.class.php 2 locations

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