aboutsummaryrefslogtreecommitdiff
path: root/lib/evaluation/classes/EvaluationQuestion.class.php
blob: 1ee2f9d515fbfc0bab1da0b02a7391fc1cfe9bab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<?php
# Lifter002: TODO
# Lifter007: TODO
# Lifter003: TODO
# Lifter010: TODO
/**
 * Beschreibung
 *
 * @author      Alexander Willner <mail@AlexanderWillner.de>
 * @copyright   2004 Stud.IP-Project
 * @access      public
 * @package     evaluation
 * @modulegroup evaluation_modules
 *
*/

// +--------------------------------------------------------------------------+
// This file is part of Stud.IP
// Copyright (C) 2001-2004 Stud.IP
// +--------------------------------------------------------------------------+
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or any later version.
// +--------------------------------------------------------------------------+
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
// +--------------------------------------------------------------------------+


# Include all required files ================================================ #
require_once 'lib/evaluation/evaluation.config.php';
require_once EVAL_FILE_QUESTIONDB;
require_once EVAL_FILE_OBJECT;
require_once EVAL_FILE_ANSWER;
# ====================================================== end: including files #


# Define constants ========================================================== #
/**
 * @const INSTANCEOF_EVALGROUP Is instance of an evaluationquestion object
 * @access public
 */
define ("INSTANCEOF_EVALQUESTION", "EvaluationQuestion");

/**
 * @const EVALQUESTION_TYPE_LIKERT Type of question is skala
 * @access public
 */
define ("EVALQUESTION_TYPE_LIKERT", "likertskala");

/**
 * @const EVALQUESTION_TYPE_MC Type of question is normal
 * @access public
 */
define ("EVALQUESTION_TYPE_MC", "multiplechoice");

/**
 * @const EVALQUESTION_TYPE_POL Type of question is pol
 * @access public
 */
define ("EVALQUESTION_TYPE_POL", "polskala");
# ===================================================== end: define constants #


class EvaluationQuestion extends EvaluationObject {

# Define all required variables ============================================= #
  /**
   * Type of question (skala/normal) => see EVALQUESTION_TYPE_*
   * @access private
   * @var    string   $type
   */
  var $type;

  /**
   * If set YES it is allowed to choose more than one answer
   * @access private
   * @var    string   $isMultiplechoice
   */
  var $isMultiplechoice;
# ============================================================ end: variables #

# Define constructor and destructor ========================================= #
   /**
    * Constructor
    * @access   public
    * @param    string   $objectID       The ID of an existing question
    * @param    object   $parentObject   The parent object if exists
    * @param    integer  $loadChildren   See const EVAL_LOAD_*_CHILDREN
    */
   function __construct($objectID = "", $parentObject = NULL,
                                $loadChildren = EVAL_LOAD_NO_CHILDREN) {
    /* Set default values ------------------------------------------------- */
    parent::__construct($objectID, $parentObject, $loadChildren);
    $this->instanceof       = INSTANCEOF_EVALQUESTION;

    $this->type             = EVALQUESTION_TYPE_MC;
    $this->isMultiplechoice = NO;
    $this->templateID       = YES;
    /* ------------------------------------------------------------------- */

    /* Connect to database ------------------------------------------------- */
    $this->db = new EvaluationQuestionDB ();
    if ($this->db->isError ())
      return $this->throwErrorFromClass ($this->db);
    $this->init ($objectID);
    /* --------------------------------------------------------------------- */
  }
# =========================================== end: constructor and destructor #
  

# Define public functions =================================================== #
  /**
   * Sets the type of a question
   * @access  public
   * @param   string  $type  The type of the question. ('skala','normal','pol')
   */
  function setType ($type) {
    $this->type = $type;
  }
  
  /**
   * Sets the type of a question
   * @access  public
   * @return  string  The type of the question.('likert','multiplechoice','pol')
   */
  function getType () {
    return  $this->type;
  }
  

  /**
   * Sets multiplechoice value of a question
   * @access  public
   * @param   $tinyint  The multiplechoice Value.
   */
  function setMultiplechoice ($multiplechoice) {
    $this->multiplechoice = $multiplechoice == YES ? YES : NO;
  }
  
  /**
   * Checks for multiplechoice
   * @access   public
   * @return   boolean   YES if it is an multiplechoice question
   */
  function isMultiplechoice () {
    return $this->multiplechoice == YES ? YES : NO;
  }
  
  
  /**
   * Adds a child and sets the value to pos+1
   * @access  public
   * @param   object  EvaluationObject &$child  The child object
   * @throws  error
   */
  function addChild (&$child) {
    parent::addChild ($child);
    if ($child->getValue () == 0)
        $child->setValue ($child->getPosition () + 1);
  }
# ===================================================== end: public functions #


# Define private functions ================================================== #
# ==================================================== end: private functions #

}

?>