include 'lib/FormsLib.php'; include 'lib/EnumLib.php'; $enumlib = new EnumLib(); $returnStr = $enumlib->getExamEmailStemByID($_REQUEST['id']); break; case 'updateemailstemdetails': include 'lib/FormsLib.php'; include 'lib/EnumLib.php'; $formslib = new FormsLib(); $returnStr = $formslib->setEmailStemText($_REQUEST['id'], $_REQUEST['text'], $_REQUEST['userid']); break; case 'exportexamasxmlfile': include 'lib/FormsLib.php'; include 'lib/EnumLib.php'; $enumLib = new EnumLib(); $output = $enumLib->exportAssessment($_REQUEST['id']); $overview = simplexml_load_string($enumLib->getExamInstanceOverviewByID($_REQUEST['id'])); header('Content-Disposition: attachment;filename="' . $overview->instance->name . ' export.xml"'); header('Content-Type: text/plain'); # Don't use application/force-download - it's not a real MIME type, and the Content-Disposition header is sufficient header('Content-Length: ' . strlen($output)); header('Connection: close'); print $output; break; case 'importexamfromxmlfile': include 'lib/FormsLib.php'; include 'lib/EnumLib.php'; $formslib = new FormsLib(); $returnStr = $formslib->importExamInstance($_FILES['file'], $_REQUEST['ownerID'], $_REQUEST['unit'], $_REQUEST['user']); break; case 'cloneexam':
function cloneExamInstance($id, $ownerID, $userID) { $enumLib = new EnumLib(); $examdef = simplexml_load_string($enumLib->exportAssessment($id)); $overview = simplexml_load_string($enumLib->getExamInstanceOverviewByID($id)); $overviewResult = simplexml_load_string($this->newExamInstance($examdef->overview->data->instance->name, $examdef->overview->data->instance->description, $examdef->overview->data->instance->unit_id, $examdef->overview->data->instance->scale_id, $ownerID, $userID, $examdef->feedbackemailstem->data->text)); //public function newExamInstance($name, $description, $unitid, $scaleid, $ownerID, $userID, $feedbackstem = "") if (!isset($overviewResult->error)) { // if there's no error, upload questions foreach ($examdef->questiondata->data->question as $question) { $insertQuestionResult = simplexml_load_string($this->addQuestionToInstance($overviewResult->id, $question->text, $question->type, $userID)); // if (isset($insertQuestionResult->error)) { $this->deleteInstance($overviewResult->id); return "<data><error>import failed</error></data>"; } } } else { return "<data><error>{$overviewResult->error}</error></data>"; } }