Code Duplication    Length = 18-18 lines in 2 locations

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

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