Code Duplication    Length = 18-18 lines in 2 locations

main/coursecopy/classes/CourseRestorer.class.php 2 locations

@@ 2258-2275 (lines=18) @@
2255
							// Insert the new source survey
2256
                            $new_id = Database::insert($table_sur, $params);
2257
2258
                            if ($new_id) {
2259
                                $sql = "UPDATE $table_sur SET survey_id = iid WHERE iid = $new_id";
2260
                                Database::query($sql);
2261
2262
                                $this->course->resources[RESOURCE_SURVEY][$id]->destination_id = $new_id;
2263
                                foreach ($survey->question_ids as $index => $question_id) {
2264
                                    $qid = $this->restore_survey_question(
2265
                                        $question_id,
2266
                                        $new_id
2267
                                    );
2268
                                    $sql = "UPDATE $table_que SET survey_id = $new_id
2269
                                            WHERE c_id = ".$this->destination_course_id." AND question_id = $qid";
2270
                                    Database::query($sql);
2271
                                    $sql = "UPDATE $table_ans SET survey_id = $new_id
2272
                                            WHERE c_id = ".$this->destination_course_id." AND question_id = $qid";
2273
                                    Database::query($sql);
2274
                                }
2275
                            }
2276
							break;
2277
						default:
2278
							break;
@@ 2284-2301 (lines=18) @@
2281
                    // No existing survey with the same language and the same code, we just copy the survey
2282
                    $new_id = Database::insert($table_sur, $params);
2283
2284
                    if ($new_id) {
2285
                        $sql = "UPDATE $table_sur SET survey_id = iid WHERE iid = $new_id";
2286
                        Database::query($sql);
2287
2288
                        $this->course->resources[RESOURCE_SURVEY][$id]->destination_id = $new_id;
2289
                        foreach ($survey->question_ids as $index => $question_id) {
2290
                            $qid = $this->restore_survey_question(
2291
                                $question_id,
2292
                                $new_id
2293
                            );
2294
                            $sql = "UPDATE $table_que SET survey_id = $new_id
2295
                                    WHERE c_id = ".$this->destination_course_id." AND question_id = $qid";
2296
                            Database::query($sql);
2297
                            $sql = "UPDATE $table_ans SET survey_id = $new_id
2298
                                    WHERE c_id = ".$this->destination_course_id." AND question_id = $qid";
2299
                            Database::query($sql);
2300
                        }
2301
                    }
2302
				}
2303
			}
2304
		}