model = $factory->getDefaultModel(); if (!is_dir($this->filePath)) mkdir($this->filePath); if(file_exists($this->filePath.'questions.rdf')) $this->model->load($this->filePath.'questions.rdf'); } public function saveQuestions() { $this->model->saveAs($this->filePath.'questions.rdf','rdf'); } public function createQuestion($qTitle,$qDescription,$qType,$qCode,$qCategory,$qAnswers) { $resourceQuestion = new Resource(QUESTION.'/'.$qCode); $resourceQuestionType = new Resource(QUESTION); $predicateRType = new Resource(RTYPE); $this->model->add(new Statement($resourceQuestion,$predicateRType,$resourceQuestionType)); $predicateTitle = new Resource(TITLE); $questionTitle = new Literal($qTitle); $this->model->add(new Statement($resourceQuestion,$predicateTitle,$questionTitle)); $predicateDescription = new Resource(DESCRIPTION); $questionDescription = new Literal($qDescription); $this->model->add(new Statement($resourceQuestion,$predicateDescription,$questionDescription)); $predicateQType = new Resource(QTYPE); $resourceQuestionType = new Literal($qType); $this->model->add(new Statement($resourceQuestion,$predicateQType,$resourceQuestionType)); $predicateQCode = new Resource(QCODE); $questionQCode = new Literal($qCode); $this->model->add(new Statement($resourceQuestion,$predicateQCode,$questionQCode)); $predicateQCategory = new Resource(QCATEGORY); $questionQCategory = new Literal($qCategory); $this->model->add(new Statement($resourceQuestion,$predicateQCategory,$questionQCategory)); foreach($qAnswers as $answer) { $answerValue = new Literal($answer); $predicateAnswer = new Resource(HAS_ANSWER); $this->model->add(new Statement($resourceQuestion,$predicateAnswer,$answerValue)); } } } ?>