Changeset 114 for Dev


Ignore:
Timestamp:
09/19/11 18:04:48 (14 years ago)
Author:
fpvanagthoven
Message:

questions get loaded in fully

Location:
Dev/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • Dev/trunk/classes/Loader.php

    r112 r114  
    6161        foreach ($questionCodesAndTitles as $code => $title) {
    6262            $info = $questionDBI->getQuestionInfo($code);
     63            $question = Question::getQuestion($code, $info);
    6364           
     65            array_push($questions, $question);
    6466        }
     67       
     68        return $questions;
    6569    }
    6670
  • Dev/trunk/classes/Question.php

    r112 r114  
    1919    public $category;
    2020   
    21     public function __construct($code, $title, $type = null, $description = null)
     21    public function __construct($code, $title = null, $type = null, $description = null)
    2222    {
    2323        $this->code = $code;
     
    3434    }
    3535   
    36     public static function getQuestion($questionInfo)
     36    public static function getQuestion($code, $info)
    3737    {
     38        $question = new Question($code);
     39        $question->title = $info['questionTitle'];
     40        $question->type = $info['questionType'];
     41        if(isset($info['questionDescription']))
     42            $question->description = $info['questionDescription'];
     43        $question->category = $info['questionCategory'];
    3844       
     45        $i = 1;
     46        while (isset($info['ans' . $i]))
     47        {
     48            array_push($question->answers, $info['ans' . $i]);
     49            $i++;
     50        }
     51       
     52        return $question;
    3953    }
    4054
  • Dev/trunk/classes/QuestionCreationTool.php

    r112 r114  
    77 */
    88class QuestionCreationTool {
    9 
    10     private $list;
     9    private $questions;
    1110    private $questionEditPanel;
    1211
    13     public function __construct() {
     12    public function __construct($questions) {
     13        $this->questions = $questions;
    1414        $this->javascript();
    1515        $this->displayList();
     
    295295                var typeSelect = document.getElementById("questionTypeSelect");
    296296                typeSelect.selectedIndex = 0;
     297                clearSpecifications();
    297298            }
    298299           
     
    305306        <div id="questionListWrapper">
    306307            <select id="questionsList" size="9999">
     308                <?php $this->populateList(); ?>
    307309            </select>
    308310        </div>
     
    326328                    <td id="categoryBox"><!-- Select should be filled with existing categories-->
    327329                        <select id="questionCategorySelect" name="questionCategory">
    328                             <option value='Test Category'>Test Category</option>
     330                            <option value='Uncategorized' selected='selected'>Uncategorized</option>
    329331                        </select>
    330332                        <!-- New category button -->
     
    363365        <?php
    364366    }
     367   
     368    private function populateList()
     369    {
     370        foreach ($this->questions as $question)
     371        {
     372            ?>
     373        <option value="<?php echo $question->code; ?>">
     374        <?php echo $question->code . " - " . $question->title; ?>
     375        </option>
     376        <?php
     377        }
     378    }
    365379
    366380}
  • Dev/trunk/questioncreation.php

    r112 r114  
    11<?php
    22require 'classes/master.php';
    3 
     3$questionDBI = new QuestionCreationDatabaseInterface();
    44/* If a question is saved */
    55if(isset($_POST['questionCode']))
    66{
    7     $questionDBI = new QuestionCreationDatabaseInterface();
    87    echo $questionDBI->setQuestionInfo($_POST); // save to DB
    98}
    109
    11 $questions = Loader::loadQuestions();
     10$questions = Loader::loadFullQuestions();
    1211var_dump($questions);
    13 
    14 //$dbi = new QuestionCreationDatabaseInterface();
    15 //$info = $dbi->getQuestionInfo("testcode1");
    16 
    17 //var_dump($info);
    18 
    1912?>
    2013<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
Note: See TracChangeset for help on using the changeset viewer.