source: Dev/trunk/classes/Loader.php @ 114

Last change on this file since 114 was 114, checked in by fpvanagthoven, 14 years ago

questions get loaded in fully

File size: 1.9 KB
RevLine 
[64]1<?php
2
3/**
4 * Helper class to load stuff
5 *
6 * @author fpvanagthoven
7 */
8class Loader {
9
[112]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
[64]22    /**
23     *
24     * @return array Array of Surveys with id and title
25     */
26    public static function loadSurveys() {
[112]27   
[83]28        $surveyDBI = new SurveyCreationDatabaseInterface(null);
[64]29        $surveyIDTitles = $surveyDBI->getExistingSurveys();
30
[112]31        return Loader::load($surveyIDTitles, "Survey");
[64]32    }
[112]33
34    public static function loadApplications() {
[78]35        $applicationDBI = new ApplicationDatabaseInterface(null);
36        $applicationTitles = $applicationDBI->getExistingApplications();
[112]37
38        return Loader::load($applicationTitles, "Application");
[78]39    }
[112]40
41    public static function loadSessions() {
[85]42        $sessionDBI = new SessionCreationDatabaseInterface(null);
[78]43        $sessionTitles = $sessionDBI->getExistingSessions();
[112]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");
53    }
54   
55    public static function loadFullQuestions() {
56        $questionDBI = new QuestionCreationDatabaseInterface();
57        $questionCodesAndTitles = $questionDBI->getExistingQuestions();
[78]58       
[112]59        $questions = array();
60       
61        foreach ($questionCodesAndTitles as $code => $title) {
62            $info = $questionDBI->getQuestionInfo($code);
[114]63            $question = Question::getQuestion($code, $info);
[112]64           
[114]65            array_push($questions, $question);
[78]66        }
[114]67       
68        return $questions;
[78]69    }
[64]70
71}
72
73?>
Note: See TracBrowser for help on using the repository browser.