Changeset 56 for Dev/trunk/classes
- Timestamp:
- 07/26/11 17:19:26 (14 years ago)
- Location:
- Dev/trunk/classes
- Files:
-
- 2 added
- 1 deleted
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk/classes/Survey.php
r35 r56 1 1 <?php 2 3 2 /* 4 3 * To change this template, choose Tools | Templates … … 12 11 */ 13 12 class Survey { 13 14 14 public $id; 15 15 public $title; 16 16 public $description; 17 17 public $questions; 18 19 public function __construct($id, $title, $description = null) 20 { 18 19 public function __construct($id, $title, $description = null) { 21 20 $this->id = $id; 22 21 $this->title = $title; … … 24 23 $this->questions = array(); 25 24 } 26 27 public static function getSurvey($info) 28 { 25 26 public static function getSurvey($info) { 29 27 $id = $info['surveyID']; 30 28 $title = $info['surveyTitle']; 31 29 $description = $info['surveyDescription']; 32 30 33 31 $survey = new Survey($id, $title, $description); 34 32 35 33 $numQ = 1; //number questions 36 while (isset($info['questionTitle' . $numQ])) 37 { 34 while (isset($info['questionTitle' . $numQ])) { 38 35 $id = $info['questionID' . $numQ]; 39 36 $title = $info['questionTitle' . $numQ]; 40 37 $type = $info['questionType' . $numQ]; 41 38 $description = $info['questionDescription' . $numQ]; 42 39 43 40 $question = new Question($id, $title, $type, $description); 44 41 45 42 $numA = 1; //number answers 46 while (isset($info['q' . $numQ . 'ans' . $numA])) 47 { 43 while (isset($info['q' . $numQ . 'ans' . $numA])) { 48 44 $answer = $info['q' . $numQ . 'ans' . $numA]; 49 45 $question->answers[$numA] = $answer; 50 46 51 47 $numA++; 52 48 } 53 54 49 50 55 51 $survey->questions[$numQ] = $question; 56 52 57 53 $numQ++; 58 54 } 59 55 60 56 return $survey; 61 57 } 62 58 59 public static function newSurveyButton() { 60 ?> 61 62 <form action="surveycreation.php" method="post"> 63 64 <input type="submit" value="Create new survey" class="surveyButton bigSurveyButton" /> 65 66 </form> 67 68 <?php 69 } 70 71 /** 72 * 73 * @param Survey $surveys An array of surveys 74 */ 75 public static function loadSurveyButton($surveys) { 76 ?> 77 <form id="loadForm" action="surveycreation.php" method="post"> 78 <input type="button" onclick="loadSurvey()" value="Load survey" class="surveyButton bigSurveyButton" /> 79 </form> 80 <br/> 81 <select id="surveysToLoad" size="1000"> 82 <?php 83 foreach ($surveys as $survey) { 84 ?><option value='<?php echo $survey->id; ?>'><?php echo $survey->title; ?></option><?php 85 } 86 ?> 87 </select> 88 <?php 89 } 90 63 91 } 64 65 92 ?>
Note: See TracChangeset
for help on using the changeset viewer.