Ignore:
Timestamp:
08/24/11 17:52:20 (14 years ago)
Author:
basvannuland
Message:

Start with new separate question db

File:
1 edited

Legend:

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

    r62 r82  
    4848    }
    4949
    50     public function setUserData($userID)
     50    public function setUserData($uID)
    5151    {                           
    52         $resourceUser = new Resource(USER . '/' . $userID);
     52        $userID = new Literal($uID);
    5353
    5454        $predicateCreator = new Resource(CREATOR);
    55         $this->model->add(new Statement($this->resourceSurvey,$predicateCreator,$resourceUser));
     55        $this->model->add(new Statement($this->resourceSurvey,$predicateCreator,$userID));
    5656    }
    5757
    58     public function addQuestion($qTitle,$qDescription,$qType,$qID,$qAnswers)
    59     {
    60         $questionID = $qID;
    61         $resourceQuestion = new Resource(QUESTION.'/'.$questionID);
    62 
    63         $resourceQuestionType = new Resource(QUESTION);
    64         $predicateRType = new Resource(RTYPE);
    65         $this->model->add(new Statement($resourceQuestion,$predicateRType,$resourceQuestionType));
    66 
    67         $predicateUniqueID = new Resource(UID);
    68         $questionUID = new Literal($questionID);
    69         $this->model->add(new Statement($resourceQuestion,$predicateUniqueID,$questionUID));
    70 
    71         $predicateTitle = new Resource(TITLE);         
    72         $questionTitle = new Literal($qTitle);
    73         $this->model->add(new Statement($resourceQuestion,$predicateTitle,$questionTitle));     
    74 
    75         $predicateDescription = new Resource(DESCRIPTION);
    76         $questionDescription = new Literal($qDescription);
    77         $this->model->add(new Statement($resourceQuestion,$predicateDescription,$questionDescription));         
    78 
    79         $predicateQType = new Resource(QTYPE);
    80         $resourceQuestionType = new Literal($qType);
    81         $this->model->add(new Statement($resourceQuestion,$predicateQType,$resourceQuestionType));
    82 
    83             foreach($qAnswers as $answer)
    84             {           
    85                 $answerID = md5( uniqid(rand(), true) );       
    86                 $resourceAnswer = new Resource(ANSWER.'/'.$answerID);
    87 
    88                 $resourceAnswerType = new Resource(ANSWER);
    89                 $predicateRType = new Resource(RTYPE);
    90                 $this->model->add(new Statement($resourceAnswer,$predicateRType,$resourceAnswerType)); 
    91 
    92                 $predicateUniqueID = new Resource(UID);
    93                 $answerUID = new Literal($answerID);
    94                 $this->model->add(new Statement($resourceAnswer,$predicateUniqueID,$answerUID));                       
    95 
    96                 $answerTitle = new Literal($answer['Title']);
    97                 $this->model->add(new Statement($resourceAnswer,$predicateTitle,$answerTitle));
    98 
    99                 $answerDescription = new Literal($answer['Description']);
    100                 $this->model->add(new Statement($resourceAnswer,$predicateDescription,$answerDescription));
    101 
    102                 $predicateAnswer = new Resource(HAS_ANSWER);   
    103                 $this->model->add(new Statement($resourceQuestion,$predicateAnswer,$resourceAnswer));
    104             }
    105 
    106             $predicateQuestion = new Resource(HAS_QUESTION);
    107             $this->model->add(new Statement($this->resourceSurvey,$predicateQuestion,$resourceQuestion));               
    108         }
     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    }
    10964}
    11065
Note: See TracChangeset for help on using the changeset viewer.