Code Duplication    Length = 25-29 lines in 2 locations

main/exercise/exercise.class.php 2 locations

@@ 3320-3348 (lines=29) @@
3317
                    }
3318
                    $totalScore = $questionScore;
3319
                    break;
3320
                case MULTIPLE_ANSWER: //2
3321
                    if ($from_database) {
3322
                        $choice = array();
3323
                        $sql = "SELECT answer FROM ".$TBL_TRACK_ATTEMPT."
3324
                                WHERE exe_id = '".$exeId."' AND question_id= '".$questionId."'";
3325
                        $resultans = Database::query($sql);
3326
                        while ($row = Database::fetch_array($resultans)) {
3327
                            $ind = $row['answer'];
3328
                            $choice[$ind] = 1;
3329
                        }
3330
3331
                        $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null;
3332
                        $real_answers[$answerId] = (bool)$studentChoice;
3333
3334
                        if ($studentChoice) {
3335
                            $questionScore  +=$answerWeighting;
3336
                        }
3337
                    } else {
3338
                        $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null;
3339
                        $real_answers[$answerId] = (bool)$studentChoice;
3340
3341
                        if (isset($studentChoice)) {
3342
                            $questionScore  += $answerWeighting;
3343
                        }
3344
                    }
3345
                    $totalScore += $answerWeighting;
3346
3347
                    if ($debug) error_log("studentChoice: $studentChoice");
3348
                    break;
3349
                case GLOBAL_MULTIPLE_ANSWER:
3350
                    if ($from_database) {
3351
                        $choice = array();
@@ 3349-3373 (lines=25) @@
3346
3347
                    if ($debug) error_log("studentChoice: $studentChoice");
3348
                    break;
3349
                case GLOBAL_MULTIPLE_ANSWER:
3350
                    if ($from_database) {
3351
                        $choice = array();
3352
                        $sql = "SELECT answer FROM $TBL_TRACK_ATTEMPT
3353
                                WHERE exe_id = '".$exeId."' AND question_id= '".$questionId."'";
3354
                        $resultans = Database::query($sql);
3355
                        while ($row = Database::fetch_array($resultans)) {
3356
                            $ind = $row['answer'];
3357
                            $choice[$ind] = 1;
3358
                        }
3359
                        $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null;
3360
                        $real_answers[$answerId] = (bool)$studentChoice;
3361
                        if ($studentChoice) {
3362
                            $questionScore +=$answerWeighting;
3363
                        }
3364
                    } else {
3365
                        $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null;
3366
                        if (isset($studentChoice)) {
3367
                            $questionScore += $answerWeighting;
3368
                        }
3369
                        $real_answers[$answerId] = (bool)$studentChoice;
3370
                    }
3371
                    $totalScore += $answerWeighting;
3372
                    if ($debug) error_log("studentChoice: $studentChoice");
3373
                    break;
3374
                case MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE:
3375
                    if ($from_database) {
3376
                        $sql = "SELECT answer FROM ".$TBL_TRACK_ATTEMPT."