Ignore:
Timestamp:
07/15/11 15:33:08 (14 years ago)
Author:
basvannuland
Message:

little work on the ontology

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Dev/trunk/classes/SurveyRDFWriter.php

    r14 r16  
    66               
    77        var $resourceSurvey;
    8         var $resourceTitle;
    9         var $resourceDescription;
    10        
    118    /**
    129    * Use SurveyRDFWriter::getInstance() instead of this
     
    2522        {
    2623               
    27                 $this->resourceSurvey = new Resource(SURVEYTOOL_NAMESPACE.'Survey');
    28                 $this->resourceTitle = new Resource(TITLE);
    29                 $this->resourceDescription = new Resource(DESCRIPTION);
     24                $this->resourceSurvey = new Resource(SURVEY);
    3025        }
    3126       
    3227        public function createSurvey($sTitle, $sDescription)
    3328        {               
     29               
     30                $predicateTitle = new Resource(TITLE);         
    3431                $surveyTitle = new Literal($sTitle);
    35                 $this->model->add(new Statement($this->resourceSurvey,$this->resourceTitle,$surveyTitle));             
     32                $this->model->add(new Statement($this->resourceSurvey,$predicateTitle,$surveyTitle));           
    3633               
     34                $predicateDescription = new Resource(DESCRIPTION);
    3735                $surveyDescription = new Literal($sDescription);
    38                 $this->model->add(new Statement($this->resourceSurvey,$this->resourceDescription,$surveyDescription)); 
     36                $this->model->add(new Statement($this->resourceSurvey,$predicateDescription,$surveyDescription));               
     37        }
     38       
     39        public function addQuestion($qTitle,$qDescription,$qType,$qAnswers)
     40        {
     41                $resourceQuestion = new Resource(QUESTION);
     42                $predicateQuestion = new Resource(HAS_QUESTION);
     43                $this->model->add(new Statement($this->resourceSurvey,$predicateQuestion,$resourceQuestion));
     44               
     45                $predicateTitle = new Resource(TITLE);         
     46                $questionTitle = new Literal($qTitle);
     47                $this->model->add(new Statement($resourceQuestion,$predicateTitle,$questionTitle));     
     48               
     49                $predicateDescription = new Resource(DESCRIPTION);
     50                $questionDescription = new Literal($qDescription);
     51                $this->model->add(new Statement($resourceQuestion,$predicateDescription,$questionDescription));         
     52               
     53                $predicateType = new Resource(TYPE);
     54                $resourceQuestionType = new Resource(QUESTION_TYPE);
     55                $this->model->add(new Statement($resourceQuestion,$predicateType,$resourceQuestionType));
     56               
     57                foreach($qAnswers as $answer)
     58                {
     59                        $resourceAnswer = new Resource(ANSWER);
     60                        $predicateAnswer = new Resource(HAS_ANSWER);   
     61                        $this->model->add(new Statement($resourceQuestion,$predicateAnswer,$resourceAnswer));
     62                       
     63                        $predicateTitle = new Resource(TITLE);
     64                        $answerTitle = new Literal($answer['Title']);
     65                        $this->model->add(new Statement($resourceAnswer,$predicateTitle,$answerTitle));
     66                       
     67                        $predicateDescription = new Resource(DESCRIPTION);
     68                        $answerDescription = new Literal($answer['Description']);
     69                        $this->model->add(new Statement($resourceAnswer,$predicateDescription,$answerDescription));
     70                       
     71                }
     72               
     73               
    3974        }
    4075       
Note: See TracChangeset for help on using the changeset viewer.