Changeset 112 for Dev/trunk/classes
- Timestamp:
- 09/19/11 16:29:02 (14 years ago)
- Location:
- Dev/trunk/classes
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk/classes/Loader.php
r85 r112 8 8 class Loader { 9 9 10 public static function load($info, $classname) { 11 $theArray = array(); 12 13 foreach ($info as $id => $title) 14 { 15 $object = new $classname($id, $title); 16 array_push($theArray, $object); 17 } 18 19 return $theArray; 20 } 21 10 22 /** 11 23 * … … 13 25 */ 14 26 public static function loadSurveys() { 15 $surveys = array(); 16 27 17 28 $surveyDBI = new SurveyCreationDatabaseInterface(null); 18 29 $surveyIDTitles = $surveyDBI->getExistingSurveys(); 19 30 20 foreach ($surveyIDTitles as $id => $title) { 21 $survey = new Survey($id, $title); 22 array_push($surveys, $survey); 23 } 24 25 return $surveys; 31 return Loader::load($surveyIDTitles, "Survey"); 32 } 33 34 public static function loadApplications() { 35 $applicationDBI = new ApplicationDatabaseInterface(null); 36 $applicationTitles = $applicationDBI->getExistingApplications(); 37 38 return Loader::load($applicationTitles, "Application"); 39 } 40 41 public static function loadSessions() { 42 $sessionDBI = new SessionCreationDatabaseInterface(null); 43 $sessionTitles = $sessionDBI->getExistingSessions(); 44 45 return Loader::load($sessionTitles, "Session"); 46 } 47 48 public static function loadQuestions() { 49 $questionDBI = new QuestionCreationDatabaseInterface(); 50 $questionCodesAndTitles = $questionDBI->getExistingQuestions(); 51 52 return Loader::load($questionCodesAndTitles, "Question"); 26 53 } 27 54 28 public static function load Applications()29 {30 $ applications = array();55 public static function loadFullQuestions() { 56 $questionDBI = new QuestionCreationDatabaseInterface(); 57 $questionCodesAndTitles = $questionDBI->getExistingQuestions(); 31 58 32 $applicationDBI = new ApplicationDatabaseInterface(null); 33 $applicationTitles = $applicationDBI->getExistingApplications(); 59 $questions = array(); 34 60 35 foreach ($ applicationTitles as $id=> $title) {36 $ application = new Application($id, $title);37 array_push($applications, $application);61 foreach ($questionCodesAndTitles as $code => $title) { 62 $info = $questionDBI->getQuestionInfo($code); 63 38 64 } 39 40 return $applications;41 }42 43 public static function loadSessions()44 {45 $sessions = array();46 47 $sessionDBI = new SessionCreationDatabaseInterface(null);48 $sessionTitles = $sessionDBI->getExistingSessions();49 50 foreach ($sessionIDTitles as $id => $title) {51 $session = new Application($id, $title);52 array_push($sessions, $session);53 }54 55 return $sessions;56 65 } 57 66 -
Dev/trunk/classes/Question.php
r98 r112 11 11 * @author fpvanagthoven 12 12 */ 13 class Question { 14 public $id; 13 class Question { 15 14 public $code; 16 15 public $title; … … 18 17 public $description; 19 18 public $answers; // format answers['#'] 19 public $category; 20 20 21 public function __construct($ id, $code, $title, $type, $description = null)21 public function __construct($code, $title, $type = null, $description = null) 22 22 { 23 $this->id = $id;24 23 $this->code = $code; 25 24 $this->title = $title; … … 28 27 $this->answers = array(); 29 28 } 29 30 /* reminder that constructor doesn't contain category haha */ 31 public function setCategory($category) 32 { 33 $this->category = $category; 34 } 35 36 public static function getQuestion($questionInfo) 37 { 38 39 } 30 40 31 41 } -
Dev/trunk/classes/QuestionCreationDatabaseInterface.php
r110 r112 54 54 public function getQuestionInfo($qCode) 55 55 { 56 $questionInfo -array();56 $questionInfo = array(); 57 57 58 58 $questionTitleObject = $this->questionRDFReader->readQuestionTitle($qCode); … … 77 77 } 78 78 } 79 80 return $questionInfo; 79 81 } 80 82 -
Dev/trunk/classes/QuestionCreationTool.php
r108 r112 244 244 categoryBox.appendChild(categoryInput); 245 245 } 246 246 247 function clearFields() 248 { 249 clearCategory(); 250 clearCode(); 251 clearTitle(); 252 clearDescription(); 253 clearType(); 254 } 255 256 function clearCategory() 257 { 258 var categoryBox = document.getElementById("categoryBox"); 259 categoryBox.innerHTML = ""; 260 261 var questionCategorySelect = document.createElement("select"); 262 questionCategorySelect.setAttribute("name", "questionCategory"); 263 questionCategorySelect.id = "questionCategorySelect"; 264 265 var newCategoryButton = document.createElement("input"); 266 newCategoryButton.setAttribute("type", "button"); 267 newCategoryButton.setAttribute("onclick", "newCategory()"); 268 newCategoryButton.setAttribute("value", "New Category"); 269 newCategoryButton.className = "surveyButton"; 270 271 categoryBox.appendChild(questionCategorySelect); 272 categoryBox.appendChild(newCategoryButton); 273 } 274 275 function clearCode() 276 { 277 var codeInput = document.getElementById("questionCode"); 278 codeInput.value = ""; 279 } 280 281 function clearTitle() 282 { 283 var titleInput = document.getElementById("questionTitle"); 284 titleInput.value =""; 285 } 286 287 function clearDescription() 288 { 289 var descriptionInput = document.getElementById("questionDescription"); 290 descriptionInput.value = ""; 291 } 292 293 function clearType() 294 { 295 var typeSelect = document.getElementById("questionTypeSelect"); 296 typeSelect.selectedIndex = 0; 297 } 298 247 299 </script> 248 300 <?php … … 273 325 <td><label for="questionCategory">Category</label></td> 274 326 <td id="categoryBox"><!-- Select should be filled with existing categories--> 275 <select name="questionCategory">327 <select id="questionCategorySelect" name="questionCategory"> 276 328 <option value='Test Category'>Test Category</option> 277 329 </select> … … 295 347 <td><label for="questionType">Type answer</label></td> 296 348 <td id="questionType"> 297 <select name="questionType" onchange="handleType(this)">349 <select id="questionTypeSelect" name="questionType" onchange="handleType(this)"> 298 350 <option value='text' selected='selected'>Text</option> 299 351 <option value='int'>Integer</option> … … 306 358 </table> 307 359 <div id="answerSpecifications"></div> 360 <input id="clearQuestionFields" type="button" onclick="clearFields()" class="surveyButton" value="Clear" /> 308 361 <input id="saveQuestion" type="submit" class="surveyButton" value="Save" /> 309 362 </form>
Note: See TracChangeset
for help on using the changeset viewer.