source: Dev/trunk/classes_old/SurveyRDFWriter.php @ 182

Last change on this file since 182 was 137, checked in by jkraaijeveld, 14 years ago

Added old classes

File size: 2.1 KB
Line 
1<?php
2
3class SurveyRDFWriter
4{
5    protected $model;
6
7    protected $resourceSurvey;
8    protected $surveyUID;
9
10    protected $filePath;
11
12    public function __construct($surveyUID)
13    {
14        // Create empty MemModel
15        $factory = new ModelFactory();
16        $this->model = $factory->getDefaultModel();
17
18        $this->surveyUID = $surveyUID; 
19        $this->filePath = 'data/surveys/';
20        if (!is_dir($this->filePath))
21            mkdir($this->filePath);     
22    }   
23
24    public function saveSurvey()
25    {   
26        $this->model->saveAs($this->filePath.'survey_'.$this->surveyUID.'.rdf','rdf');
27    }
28
29    public function createSurvey($sTitle, $sDescription)
30    {           
31        $this->resourceSurvey = new Resource(SURVEY.'/'.$this->surveyUID);
32
33        $resourceSurveyType = new Resource(SURVEY);
34        $predicateRType = new Resource(RTYPE);
35        $this->model->add(new Statement($this->resourceSurvey,$predicateRType,$resourceSurveyType));
36
37        $literalSurveyID = new Literal($this->surveyUID);
38        $predicateUniqueID = new Resource(UID);
39        $this->model->add(new Statement($this->resourceSurvey,$predicateUniqueID,$literalSurveyID));
40
41        $predicateTitle = new Resource(TITLE);         
42        $surveyTitle = new Literal($sTitle);
43        $this->model->add(new Statement($this->resourceSurvey,$predicateTitle,$surveyTitle));           
44
45        $predicateDescription = new Resource(DESCRIPTION);
46        $surveyDescription = new Literal($sDescription);
47        $this->model->add(new Statement($this->resourceSurvey,$predicateDescription,$surveyDescription));               
48    }
49
50    public function setUserData($uID)
51    {                           
52        $userID = new Literal($uID);
53
54        $predicateCreator = new Resource(CREATOR);
55        $this->model->add(new Statement($this->resourceSurvey,$predicateCreator,$userID));
56    }
57
58    public function addQuestion($qID)
59    {           
60        $questionID = new Literal($qID);
61        $predicateQuestion = new Resource(HAS_QUESTION);
62        $this->model->add(new Statement($this->resourceSurvey,$predicateQuestion,$questionID));
63    }
64}
65
66?>
Note: See TracBrowser for help on using the repository browser.