Code Duplication    Length = 21-22 lines in 2 locations

main/exercice/question.class.php 2 locations

@@ 893-913 (lines=21) @@
890
                );
891
892
                // If hotspot, create first answer
893
                if ($type == HOT_SPOT || $type == HOT_SPOT_ORDER) {
894
                    $TBL_ANSWERS = Database::get_course_table(
895
                        TABLE_QUIZ_ANSWER
896
                    );
897
                    $params = [
898
                        'c_id' => $c_id,
899
                        'question_id' => $this->id,
900
                        'answer' => '',
901
                        'correct' => '',
902
                        'comment' => '',
903
                        'ponderation' => 10,
904
                        'position' => 1,
905
                        'hotspot_coordinates' => '0;0|0|0',
906
                        'hotspot_type' => 'square',
907
                    ];
908
                    $id = Database::insert($TBL_ANSWERS, $params);
909
                    if ($id) {
910
                        $sql = "UPDATE $TBL_ANSWERS SET id = iid, id_auto = iid WHERE iid = $id";
911
                        Database::query($sql);
912
                    }
913
                }
914
915
                if ($type == HOT_SPOT_DELINEATION) {
916
                    $TBL_ANSWERS = Database::get_course_table(
@@ 915-936 (lines=22) @@
912
                    }
913
                }
914
915
                if ($type == HOT_SPOT_DELINEATION) {
916
                    $TBL_ANSWERS = Database::get_course_table(
917
                        TABLE_QUIZ_ANSWER
918
                    );
919
                    $params = [
920
                        'c_id' => $c_id,
921
                        'question_id' => $this->id,
922
                        'answer' => '',
923
                        'correct' => '',
924
                        'comment' => '',
925
                        'ponderation' => 10,
926
                        'position' => 1,
927
                        'hotspot_coordinates' => '0;0|0|0',
928
                        'hotspot_type' => 'delineation',
929
                    ];
930
                    $id = Database::insert($TBL_ANSWERS, $params);
931
932
                    if ($id) {
933
                        $sql = "UPDATE $TBL_ANSWERS SET id = iid, id_auto = iid WHERE iid = $id";
934
                        Database::query($sql);
935
                    }
936
                }
937
938
                if (api_get_setting('search_enabled') == 'true') {
939
                    if ($exerciseId != 0) {