Fix session-to-session copy of surveys - refs BT#8986

1.9.x
Angel Fernando Quiroz Campos 10 years ago
parent 83bd1d6a06
commit ae8931897c
  1. 2
      main/coursecopy/classes/CourseBuilder.class.php
  2. 10
      main/coursecopy/classes/CourseRestorer.class.php

@ -728,7 +728,7 @@ class CourseBuilder
$table_question = Database :: get_course_table(TABLE_SURVEY_QUESTION);
$course_id = api_get_course_int_id();
$sql = 'SELECT * FROM '.$table_survey.' WHERE c_id = '.$course_id.' AND session_id = 0 ';
$sql = 'SELECT * FROM '.$table_survey.' WHERE c_id = '.$course_id.' AND session_id = ' . $session_id;
$db_result = Database::query($sql);
while ($obj = Database::fetch_object($db_result)) {
$survey = new Survey($obj->survey_id, $obj->code,$obj->title,

@ -1677,8 +1677,10 @@ class CourseRestorer
/**
* Restore surveys
*/
public function restore_surveys()
public function restore_surveys($sessionId = 0)
{
$sessionId = intval($sessionId);
if ($this->course->has_resources(RESOURCE_SURVEY)) {
$table_sur = Database :: get_course_table(TABLE_SURVEY);
$table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION);
@ -1743,7 +1745,8 @@ class CourseRestorer
"invited = '0', " .
"answered = '0', " .
"invite_mail = '".self::DBUTF8escapestring($survey->invite_mail)."', " .
"reminder_mail = '".self::DBUTF8escapestring($survey->reminder_mail)."'";
"reminder_mail = '".self::DBUTF8escapestring($survey->reminder_mail)."', ".
"session_id = $sessionId";
//An existing survey exists with the same code and the same language
if (Database::num_rows($result_check) == 1) {
@ -1777,7 +1780,8 @@ class CourseRestorer
"invited = '0', " .
"answered = '0', " .
"invite_mail = '".self::DBUTF8escapestring($survey->invite_mail)."', " .
"reminder_mail = '".self::DBUTF8escapestring($survey->reminder_mail)."'";
"reminder_mail = '".self::DBUTF8escapestring($survey->reminder_mail)."', ".
"session_id = $sessionId";
//Insert the new source survey
Database::query($sql);

Loading…
Cancel
Save