<?php
/***************************************************************************
- * Copyright (C) 2003-2010 Polytechnique.org *
+ * Copyright (C) 2003-2011 Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
public static function instanceForType(Survey $survey, $type)
{
- require_once dirname(__FILE__) . '/' . $type . '.inc.php';
+ $file = dirname(__FILE__) . '/' . $type . '.inc.php';
+ if (!file_exists($file)) {
+ throw new Exception("Unknown question type \"$type\"");
+ }
+ require_once $file;
$class = 'SurveyQuestion' . $type;
return new $class($survey);
}
}
return $answer;
}
+
+ public function export()
+ {
+ $export = parent::export();
+ if (isset($export['parameters'])) {
+ foreach ($export['parameters'] as $key=>$value) {
+ $export[$key] = $value;
+ }
+ unset($export['parameters']);
+ }
+ return $export;
+ }
+
}
class SurveyQuestionGroup extends SurveyQuestion implements SurveyQuestionContainer