diff --git a/main/exercice/question.class.php b/main/exercice/question.class.php index d1b871b3e7..fdfe4fd44d 100644 --- a/main/exercice/question.class.php +++ b/main/exercice/question.class.php @@ -1,4 +1,4 @@ -id=mysql_insert_id(); + $this->id=Database::get_last_insert_id(); api_item_property_update($_course, TOOL_QUIZ, $this->id,'QuizQuestionAdded',$_user['user_id']); @@ -919,8 +919,7 @@ abstract class Question * @author - Olivier Brouckaert * @return - integer - ID of the new question */ - function duplicate() - { + function duplicate() { global $TBL_QUESTIONS, $picturePath; $question=addslashes($this->question); @@ -932,8 +931,7 @@ abstract class Question $sql="INSERT INTO $TBL_QUESTIONS(question,description,ponderation,position,type) VALUES('".Database::escape_string($question)."','".Database::escape_string($description)."','".Database::escape_string($weighting)."','".Database::escape_string($position)."','".Database::escape_string($type)."')"; api_sql_query($sql,__FILE__,__LINE__); - $id=mysql_insert_id(); - + $id=Database::get_last_insert_id(); // duplicates the picture $this->exportPicture($id); @@ -946,22 +944,16 @@ abstract class Question * @return an instance of a Question subclass (or of Questionc class by default) */ static function getInstance ($type) { - - list($file_name,$class_name) = self::$questionTypes[$type]; - - include_once ($file_name); - - - if(class_exists($class_name)) - { - return new $class_name(); + if (!is_null($type)) { + list($file_name,$class_name) = self::$questionTypes[$type]; + include_once($file_name); + if (class_exists($class_name)) { + return new $class_name(); + } else { + echo 'Can\'t instanciate class '.$class_name.' of type '.$type; + return null; + } } - else - { - echo 'Can\'t instanciate class '.$class_name.' of type '.$type; - return null; - } - } /** diff --git a/main/exercice/question_pool.php b/main/exercice/question_pool.php index d044824f81..6ec9f9ce31 100644 --- a/main/exercice/question_pool.php +++ b/main/exercice/question_pool.php @@ -1,4 +1,4 @@ -',$row['question'],''; echo '
',
+ echo '
',
'
';