Code Duplication    Length = 25-29 lines in 2 locations

main/exercise/exercise.class.php 2 locations

@@ 3383-3411 (lines=29) @@
3380
                    }
3381
                    $totalScore = $questionScore;
3382
                    break;
3383
                case MULTIPLE_ANSWER: //2
3384
                    if ($from_database) {
3385
                        $choice = array();
3386
                        $sql = "SELECT answer FROM ".$TBL_TRACK_ATTEMPT."
3387
                                WHERE exe_id = '".$exeId."' AND question_id= '".$questionId."'";
3388
                        $resultans = Database::query($sql);
3389
                        while ($row = Database::fetch_array($resultans)) {
3390
                            $ind = $row['answer'];
3391
                            $choice[$ind] = 1;
3392
                        }
3393
3394
                        $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null;
3395
                        $real_answers[$answerId] = (bool) $studentChoice;
3396
3397
                        if ($studentChoice) {
3398
                            $questionScore += $answerWeighting;
3399
                        }
3400
                    } else {
3401
                        $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null;
3402
                        $real_answers[$answerId] = (bool) $studentChoice;
3403
3404
                        if (isset($studentChoice)) {
3405
                            $questionScore += $answerWeighting;
3406
                        }
3407
                    }
3408
                    $totalScore += $answerWeighting;
3409
3410
                    if ($debug) error_log("studentChoice: $studentChoice");
3411
                    break;
3412
                case GLOBAL_MULTIPLE_ANSWER:
3413
                    if ($from_database) {
3414
                        $choice = array();
@@ 3412-3436 (lines=25) @@
3409
3410
                    if ($debug) error_log("studentChoice: $studentChoice");
3411
                    break;
3412
                case GLOBAL_MULTIPLE_ANSWER:
3413
                    if ($from_database) {
3414
                        $choice = array();
3415
                        $sql = "SELECT answer FROM $TBL_TRACK_ATTEMPT
3416
                                WHERE exe_id = '".$exeId."' AND question_id= '".$questionId."'";
3417
                        $resultans = Database::query($sql);
3418
                        while ($row = Database::fetch_array($resultans)) {
3419
                            $ind = $row['answer'];
3420
                            $choice[$ind] = 1;
3421
                        }
3422
                        $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null;
3423
                        $real_answers[$answerId] = (bool) $studentChoice;
3424
                        if ($studentChoice) {
3425
                            $questionScore += $answerWeighting;
3426
                        }
3427
                    } else {
3428
                        $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null;
3429
                        if (isset($studentChoice)) {
3430
                            $questionScore += $answerWeighting;
3431
                        }
3432
                        $real_answers[$answerId] = (bool) $studentChoice;
3433
                    }
3434
                    $totalScore += $answerWeighting;
3435
                    if ($debug) error_log("studentChoice: $studentChoice");
3436
                    break;
3437
                case MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE:
3438
                    if ($from_database) {
3439
                        $sql = "SELECT answer FROM ".$TBL_TRACK_ATTEMPT."