Changeset 271 for Dev/branches/rest-dojo-ui
- Timestamp:
- 02/19/12 11:31:11 (13 years ago)
- Location:
- Dev/branches/rest-dojo-ui
- Files:
-
- 7 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
Dev/branches/rest-dojo-ui
-
Property
svn:mergeinfo
set to
/Dev/branches/jos-branch merged eligible
-
Property
svn:mergeinfo
set to
-
Dev/branches/rest-dojo-ui/server
-
Property
svn:ignore
set to
.testpage.php.swp
.rdfConstants.php.swp
-
Property
svn:ignore
set to
-
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
-
Property
svn:ignore
set to
-
Dev/branches/rest-dojo-ui/server/classes/models/Answer.php
r263 r271 11 11 */ 12 12 class 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 13 23 public static $filename = 'data/results/answers.rdf'; 14 24 … … 40 50 if(is_string($this->question)) 41 51 { 42 $result = Question::get(array(" code" => $this->question));52 $result = Question::get(array("uid" => $this->question)); 43 53 if(!isset($result[0])) 44 54 return false; … … 73 83 //Query the model 74 84 $results = $model->sparqlQuery($querystring); 75 85 //An answer can have multiple values, get all these values for the answer instances found. 76 86 $answers = array(); 77 87 if(!empty($results)) -
Dev/branches/rest-dojo-ui/server/classes/models/AnswerSet.php
r263 r271 80 80 public function save() 81 81 { 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. 84 83 //TODO: Decide how to fix invalid references graciously. 85 84 if(!$this->evaluate()) -
Dev/branches/rest-dojo-ui/server/classes/models/Question.php
r256 r271 10 10 */ 11 11 class 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 12 23 private static $filename = 'data/questions/questions.rdf'; 13 24 … … 18 29 public $category; 19 30 public $answers; // format answers['#'] 20 31 32 21 33 /** 22 34 * Constructor for a Question. $uid equals the corresponding code. … … 28 40 * @param type $answers 29 41 */ 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) 31 43 { 32 44 if(!isset($uid)) … … 68 80 $model->add(new Statement($resourceQuestion,$predicateUid,$questionUid)); 69 81 70 $questionQCode = new Literal($this-> uid);82 $questionQCode = new Literal($this->code); 71 83 $predicateQCode = new Resource(QCODE); 72 84 $model->add(new Statement($resourceQuestion,$predicateQCode,$questionQCode)); … … 124 136 predicates:question_category ?category ; 125 137 '. ResearchToolObject::createArguments($arguments) . ' 126 }';138 }'; 127 139 128 140 129 141 //Create the querystring 130 142 $results = $model->sparqlQuery($querystring); 131 132 143 133 144 $questions = array(); … … 144 155 145 156 /** 146 * Gets the answers belonging to the given uid.157 * Gets the preset answers belonging to the given uid. 147 158 * @param type $uid : The uid of the Question in question (haha, pun). 148 159 */ -
Dev/branches/rest-dojo-ui/server/classes/models/SurveyInstance.php
r268 r271 26 26 * @param type $answersets: A list of answersets. 27 27 */ 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) 29 29 { 30 30 if(!isset($uid)) … … 40 40 $this->presetanswers = $presetanswers; 41 41 $this->answersets = $answersets; 42 } 42 } 43 43 44 44 45 /** … … 120 121 $model->add(new Statement($resourceSI, $predicateId, $SIID)); 121 122 122 $SISurvey = new Literal($this->survey->uid);123 $SISurvey = new Resource(SURVEY . '/' . $this->survey->uid); 123 124 $predicateSurvey = new Resource(OF_SURVEY); 124 125 $model->add(new Statement($resourceSI, $predicateSurvey, $SISurvey)); … … 167 168 { 168 169 $model = ResearchToolObject::load(SurveyInstance::$filename); 169 170 170 //Build the query string 171 171 $querystring = ' … … 200 200 $presetAnswers = SurveyInstance::getPresetAnswers($model, $result['?uid']->label); 201 201 $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); 203 203 } 204 204 } -
Dev/branches/rest-dojo-ui/server/rdfConstants.php
r256 r271 25 25 define('RESULTSET', SURVEYTOOL_RESOURCES_NAMESPACE . 'resultset'); 26 26 define('APPLICATIONINSTANCE', SURVEYTOOL_RESOURCES_NAMESPACE . 'applicationinstance'); 27 define('SURVEYINSTANCE', SURVEYTOOL_RESOURCES_NAMESPACE . 'surveyinstance'); 27 28 28 29 // Predicates used for RDF triples … … 65 66 define('CREATIONDATE', SURVEYTOOL_PREDICATES_NAMESPACE . 'creationdate'); 66 67 define('OPEN', SURVEYTOOL_PREDICATES_NAMESPACE . 'open'); 68 define('OF_SURVEY', SURVEYTOOL_PREDICATES_NAMESPACE . 'of_survey'); 69 define('PRESET_ANSWER', SURVEYTOOL_PREDICATES_NAMESPACE . 'preset_answer'); 67 70 ?>
Note: See TracChangeset
for help on using the changeset viewer.