- Timestamp:
- 07/26/11 17:19:26 (14 years ago)
- Location:
- Dev/trunk
- Files:
-
- 4 added
- 1 deleted
- 3 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 ?> -
Dev/trunk/mainmenu.php
r50 r56 1 <?php require 'classes/master.php'; //should be at top of every page 1 <?php 2 require 'classes/master.php'; //should be at top of every page 2 3 3 if(isset($_POST['login'])) 4 { 5 if($_POST['username'] == '') 6 die("Please log in!"); 7 else 8 { 9 $userDBI = new UserDatabaseInterface(); 10 $user_exists = $userDBI->checkUserName($_POST['username']); 11 if($user_exists) 12 { 13 $correct_password = $userDBI->checkUserPassword($_POST); 14 if(!$correct_password) 15 die("The password you entered is not correct!"); 16 } 17 else 18 die("Unknown user name"); 19 } 4 if (isset($_POST['login'])) { 5 if ($_POST['username'] == '') 6 die("Please log in!"); 7 else { 8 $userDBI = new UserDatabaseInterface(); 9 $user_exists = $userDBI->checkUserName($_POST['username']); 10 if ($user_exists) { 11 $correct_password = $userDBI->checkUserPassword($_POST); 12 if (!$correct_password) 13 die("The password you entered is not correct!"); 14 } 15 else 16 die("Unknown user name"); 17 } 20 18 } 21 19 … … 43 41 <body> 44 42 <div id="header"> 45 46 47 43 <?php new Logo(); ?> 44 </div> 45 48 46 <div id="wrapper"> 49 47 50 48 <div id="content"> 51 49 <div id="menu"> 52 <?php 53 SurveyButton::newSurveyButton(); 54 SurveyButton::loadSurveyButton($surveys); 50 <?php 51 Session::createSessionButton(); 52 Application::createApplicationButton(); 53 Survey::newSurveyButton(); 54 Survey::loadSurveyButton($surveys); 55 55 ?> 56 56 </div> -
Dev/trunk/surveycreation.php
r52 r56 38 38 <head> 39 39 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 40 <title>Survey </title>40 <title>Survey Creation</title> 41 41 <link rel="stylesheet" type="text/css" href="css/style.css" /> 42 42 </head>
Note: See TracChangeset
for help on using the changeset viewer.