write($filename, json_encode($meta)); } catch (\Exception $e) { throw new \common_Exception("Unable to write file '${filename}'."); } } /** * Read Compilation Metadata * * @param \tao_models_classes_service_StorageDirectory $compilationDirectory * @return mixed * @throws \common_Exception */ public function readCompilationMetadata(\tao_models_classes_service_StorageDirectory $compilationDirectory) { try { $data = $compilationDirectory->read(\taoQtiTest_models_classes_QtiTestService::TEST_COMPILED_META_FILENAME . '.json'); return json_decode($data, true); } catch (\Exception $e) { // Legacy compilation support. try { $filename = \taoQtiTest_models_classes_QtiTestService::TEST_COMPILED_META_FILENAME . '.php'; $data = $compilationDirectory->read($filename); $data = str_replace('', '', $data); return eval($data); } catch (\Exception $e) { throw new \common_Exception("Unable to read file '${filename}'."); } } } }