Code Duplication    Length = 25-29 lines in 2 locations

main/exercice/exercise.class.php 2 locations

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