Code Duplication    Length = 18-18 lines in 2 locations

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

@@ 2321-2338 (lines=18) @@
2318
							// Insert the new source survey
2319
                            $new_id = Database::insert($table_sur, $params);
2320
2321
                            if ($new_id) {
2322
                                $sql = "UPDATE $table_sur SET survey_id = iid WHERE iid = $new_id";
2323
                                Database::query($sql);
2324
2325
                                $this->course->resources[RESOURCE_SURVEY][$id]->destination_id = $new_id;
2326
                                foreach ($survey->question_ids as $index => $question_id) {
2327
                                    $qid = $this->restore_survey_question(
2328
                                        $question_id,
2329
                                        $new_id
2330
                                    );
2331
                                    $sql = "UPDATE $table_que SET survey_id = $new_id
2332
                                            WHERE c_id = ".$this->destination_course_id." AND question_id = $qid";
2333
                                    Database::query($sql);
2334
                                    $sql = "UPDATE $table_ans SET survey_id = $new_id
2335
                                            WHERE c_id = ".$this->destination_course_id." AND question_id = $qid";
2336
                                    Database::query($sql);
2337
                                }
2338
                            }
2339
							break;
2340
						default:
2341
							break;
@@ 2347-2364 (lines=18) @@
2344
                    // No existing survey with the same language and the same code, we just copy the survey
2345
                    $new_id = Database::insert($table_sur, $params);
2346
2347
                    if ($new_id) {
2348
                        $sql = "UPDATE $table_sur SET survey_id = iid WHERE iid = $new_id";
2349
                        Database::query($sql);
2350
2351
                        $this->course->resources[RESOURCE_SURVEY][$id]->destination_id = $new_id;
2352
                        foreach ($survey->question_ids as $index => $question_id) {
2353
                            $qid = $this->restore_survey_question(
2354
                                $question_id,
2355
                                $new_id
2356
                            );
2357
                            $sql = "UPDATE $table_que SET survey_id = $new_id
2358
                                    WHERE c_id = ".$this->destination_course_id." AND question_id = $qid";
2359
                            Database::query($sql);
2360
                            $sql = "UPDATE $table_ans SET survey_id = $new_id
2361
                                    WHERE c_id = ".$this->destination_course_id." AND question_id = $qid";
2362
                            Database::query($sql);
2363
                        }
2364
                    }
2365
				}
2366
			}
2367
		}