Code Duplication    Length = 25-29 lines in 2 locations

main/exercise/exercise.class.php 2 locations

@@ 3357-3385 (lines=29) @@
3354
                    }
3355
                    $totalScore = $questionScore;
3356
                    break;
3357
                case MULTIPLE_ANSWER: //2
3358
                    if ($from_database) {
3359
                        $choice = array();
3360
                        $sql = "SELECT answer FROM ".$TBL_TRACK_ATTEMPT."
3361
                                WHERE exe_id = '".$exeId."' AND question_id= '".$questionId."'";
3362
                        $resultans = Database::query($sql);
3363
                        while ($row = Database::fetch_array($resultans)) {
3364
                            $ind = $row['answer'];
3365
                            $choice[$ind] = 1;
3366
                        }
3367
3368
                        $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null;
3369
                        $real_answers[$answerId] = (bool)$studentChoice;
3370
3371
                        if ($studentChoice) {
3372
                            $questionScore  +=$answerWeighting;
3373
                        }
3374
                    } else {
3375
                        $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null;
3376
                        $real_answers[$answerId] = (bool)$studentChoice;
3377
3378
                        if (isset($studentChoice)) {
3379
                            $questionScore  += $answerWeighting;
3380
                        }
3381
                    }
3382
                    $totalScore += $answerWeighting;
3383
3384
                    if ($debug) error_log("studentChoice: $studentChoice");
3385
                    break;
3386
                case GLOBAL_MULTIPLE_ANSWER:
3387
                    if ($from_database) {
3388
                        $choice = array();
@@ 3386-3410 (lines=25) @@
3383
3384
                    if ($debug) error_log("studentChoice: $studentChoice");
3385
                    break;
3386
                case GLOBAL_MULTIPLE_ANSWER:
3387
                    if ($from_database) {
3388
                        $choice = array();
3389
                        $sql = "SELECT answer FROM $TBL_TRACK_ATTEMPT
3390
                                WHERE exe_id = '".$exeId."' AND question_id= '".$questionId."'";
3391
                        $resultans = Database::query($sql);
3392
                        while ($row = Database::fetch_array($resultans)) {
3393
                            $ind = $row['answer'];
3394
                            $choice[$ind] = 1;
3395
                        }
3396
                        $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null;
3397
                        $real_answers[$answerId] = (bool)$studentChoice;
3398
                        if ($studentChoice) {
3399
                            $questionScore +=$answerWeighting;
3400
                        }
3401
                    } else {
3402
                        $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null;
3403
                        if (isset($studentChoice)) {
3404
                            $questionScore += $answerWeighting;
3405
                        }
3406
                        $real_answers[$answerId] = (bool)$studentChoice;
3407
                    }
3408
                    $totalScore += $answerWeighting;
3409
                    if ($debug) error_log("studentChoice: $studentChoice");
3410
                    break;
3411
                case MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE:
3412
                    if ($from_database) {
3413
                        $sql = "SELECT answer FROM ".$TBL_TRACK_ATTEMPT."