Code Duplication    Length = 20-21 lines in 2 locations

main/inc/lib/MoodleImport.php 2 locations

@@ 653-673 (lines=21) @@
650
    public function processAnswers($questionList, $questionType, $questionInstance, $currentQuestion, $importedFiles)
651
    {
652
        switch ($questionType) {
653
            case 'multichoice':
654
                $objAnswer = new Answer($questionInstance->id);
655
                $questionWeighting = 0;
656
                foreach ($questionList as $slot => $answer) {
657
                    $this->processUniqueAnswer(
658
                        $objAnswer,
659
                        $answer,
660
                        $slot + 1,
661
                        $questionWeighting,
662
                        $importedFiles
663
                    );
664
                }
665
666
                // saves the answers into the data base
667
                $objAnswer->save();
668
                // sets the total weighting of the question
669
                $questionInstance->updateWeighting($questionWeighting);
670
                $questionInstance->save();
671
672
                return true;
673
                break;
674
            case 'multianswer':
675
                $objAnswer = new Answer($questionInstance->id);
676
                $coursePath = api_get_course_path();
@@ 774-793 (lines=20) @@
771
                $questionInstance->save();
772
                return true;
773
                break;
774
            case 'truefalse':
775
                $objAnswer = new Answer($questionInstance->id);
776
                $questionWeighting = 0;
777
                foreach ($questionList as $slot => $answer) {
778
                    $this->processTrueFalse(
779
                        $objAnswer,
780
                        $answer,
781
                        $slot + 1,
782
                        $questionWeighting,
783
                        $importedFiles
784
                    );
785
                }
786
787
                // saves the answers into the data base
788
                $objAnswer->save();
789
                // sets the total weighting of the question
790
                $questionInstance->updateWeighting($questionWeighting);
791
                $questionInstance->save();
792
                return false;
793
                break;
794
            default:
795
                return false;
796
                break;