Code Duplication    Length = 25-29 lines in 2 locations

main/exercice/exercise.class.php 2 locations

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