Changeset 271 for Dev/branches


Ignore:
Timestamp:
02/19/12 11:31:11 (13 years ago)
Author:
hendrikvanantwerpen
Message:

Merged changes from jos-branch:268,269 to rest-dojo-ui.

Location:
Dev/branches/rest-dojo-ui
Files:
7 edited
1 copied

Legend:

Unmodified
Added
Removed
  • Dev/branches/rest-dojo-ui

  • Dev/branches/rest-dojo-ui/server

    • Property svn:ignore set to
      .testpage.php.swp
      .rdfConstants.php.swp
  • Dev/branches/rest-dojo-ui/server/classes/models

    • Property svn:ignore set to
      .SurveyInstance.php.swp
      .ApplicationInstance.php.swp
      .AnswerSet.php.swp
      .Answer.php.swp
      .Question.php.swp
  • Dev/branches/rest-dojo-ui/server/classes/models/Answer.php

    r263 r271  
    1111 */
    1212class Answer extends ResearchToolObject {
     13
     14        /**
     15         * static function create()
     16         * @param type $obj : The object which should be converted to an Answer
     17         */
     18        public static function create($obj)
     19        {
     20                return new Answer($obj->uid, $obj->question, $obj->values)
     21        }
     22
    1323        public static $filename = 'data/results/answers.rdf';
    1424
     
    4050                if(is_string($this->question))
    4151                {
    42                         $result = Question::get(array("code" => $this->question));
     52                        $result = Question::get(array("uid" => $this->question));
    4353                        if(!isset($result[0]))
    4454                                return false;
     
    7383                //Query the model
    7484                $results = $model->sparqlQuery($querystring);   
    75                 //An answer can have multiple values, get all these values for the answer instances found.
     85        //An answer can have multiple values, get all these values for the answer instances found.
    7686                $answers = array();
    7787                if(!empty($results))
  • Dev/branches/rest-dojo-ui/server/classes/models/AnswerSet.php

    r263 r271  
    8080        public function save()
    8181        {
    82                 //If evaluation fails, some references are incorrect.
    83                 //We shouldn't save in this case. Instead - let the user know. This function returns false if the evaluation has failed.
     82                //If evaluation fails, some references are incorrect. We shouldn't save in this case.
    8483                //TODO: Decide how to fix invalid references graciously.
    8584                if(!$this->evaluate())
  • Dev/branches/rest-dojo-ui/server/classes/models/Question.php

    r256 r271  
    1010 */
    1111class Question extends ResearchToolObject{   
     12
     13        /**
     14         * static function create()
     15         * @param type $obj : The object which should be converted to a Question
     16         */
     17        public static function create($obj)
     18        {
     19                return new Question($obj->uid, $obj->code, $obj->title, $obj->type, $obj->description, $obj->category, $obj->answers); 
     20        }
     21
     22
    1223        private static $filename = 'data/questions/questions.rdf';
    1324
     
    1829    public $category;
    1930    public $answers; // format answers['#']
    20    
     31
     32
    2133    /**
    2234     * Constructor for a Question. $uid equals the corresponding code.
     
    2840     * @param type $answers
    2941     */
    30     public function __construct($uid, $code = null, $title = null, $type = null, $description = null, $category = null, $answers = null)
     42        public function __construct($uid = null, $code = null, $title = null, $type = null, $description = null, $category = null, $answers = null)
    3143    {
    3244                if(!isset($uid))
     
    6880        $model->add(new Statement($resourceQuestion,$predicateUid,$questionUid));
    6981       
    70         $questionQCode = new Literal($this->uid);
     82        $questionQCode = new Literal($this->code);
    7183        $predicateQCode = new Resource(QCODE);
    7284        $model->add(new Statement($resourceQuestion,$predicateQCode,$questionQCode));
     
    124136                predicates:question_category ?category ;
    125137                                '. ResearchToolObject::createArguments($arguments) . '
    126         }';
     138                        }';
    127139
    128140               
    129141        //Create the querystring
    130142        $results = $model->sparqlQuery($querystring);
    131 
    132143       
    133144        $questions = array();
     
    144155   
    145156    /**
    146      * Gets the answers belonging to the given uid.
     157     * Gets the preset answers belonging to the given uid.
    147158     * @param type $uid : The uid of the Question in question (haha, pun).
    148159     */
  • Dev/branches/rest-dojo-ui/server/classes/models/SurveyInstance.php

    r268 r271  
    2626     * @param type $answersets: A list of answersets.
    2727     */
    28     public function __construct($uid = null, $survey = null, $starttime = null, $endtime = null, $open = false, $presetanswers = null, $answersets = null)
     28    public function __construct($uid, $survey, $starttime, $endtime, $open, $presetanswers, $answersets)
    2929    {
    3030        if(!isset($uid))
     
    4040        $this->presetanswers = $presetanswers;
    4141        $this->answersets = $answersets;
    42     }
     42        }
     43
    4344
    4445    /**
     
    120121        $model->add(new Statement($resourceSI, $predicateId, $SIID));
    121122       
    122         $SISurvey = new Literal($this->survey->uid);
     123        $SISurvey = new Resource(SURVEY . '/' . $this->survey->uid);
    123124        $predicateSurvey = new Resource(OF_SURVEY);
    124125        $model->add(new Statement($resourceSI, $predicateSurvey, $SISurvey));
     
    167168        {
    168169                $model = ResearchToolObject::load(SurveyInstance::$filename);
    169 
    170170                //Build the query string
    171171                $querystring = '
     
    200200                                $presetAnswers = SurveyInstance::getPresetAnswers($model, $result['?uid']->label);
    201201                                $answerSets = SurveyInstance::getAnswerSets($model, $result['?uid']->label);
    202                                 $sInstances[] = new SurveyInstance($result['?uid']->label, $result['?of_survey']->label, $startTime, $endTime, $open, $presetAnswers, $answerSets);
     202                                $sInstances[] = new SurveyInstance($result['?uid']->label, $result['?of_survey']->uri, $startTime, $endTime, $open, $presetAnswers, $answerSets);
    203203                        }
    204204                }
  • Dev/branches/rest-dojo-ui/server/rdfConstants.php

    r256 r271  
    2525define('RESULTSET', SURVEYTOOL_RESOURCES_NAMESPACE . 'resultset');
    2626define('APPLICATIONINSTANCE', SURVEYTOOL_RESOURCES_NAMESPACE . 'applicationinstance');
     27define('SURVEYINSTANCE', SURVEYTOOL_RESOURCES_NAMESPACE . 'surveyinstance');
    2728
    2829// Predicates used for RDF triples
     
    6566define('CREATIONDATE', SURVEYTOOL_PREDICATES_NAMESPACE . 'creationdate');
    6667define('OPEN', SURVEYTOOL_PREDICATES_NAMESPACE . 'open');
     68define('OF_SURVEY', SURVEYTOOL_PREDICATES_NAMESPACE . 'of_survey');
     69define('PRESET_ANSWER', SURVEYTOOL_PREDICATES_NAMESPACE . 'preset_answer');
    6770?>
Note: See TracChangeset for help on using the changeset viewer.