Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
online_quiz_question_group.inc
1 <?php
18 require_once SQ_CORE_PACKAGE_PATH.'/folder/folder.inc';
19 
20 
33 {
34 
35 
44  function Online_Quiz_Question_Group($assetid=0)
45  {
46  $this->_ser_attrs = TRUE;
47  $this->Folder($assetid);
48 
49  }//end constructor
50 
51 
62  protected function _getName($short_name=FALSE, $contextid=NULL)
63  {
64  // No context specified, using the current context
65  if ($contextid === NULL) {
66  $contextid = $GLOBALS['SQ_SYSTEM']->getContextId();
67  }//end if
68 
69  // Obtain the attribute value for Name from the specified Context
70  $values = $GLOBALS['SQ_SYSTEM']->am->getAttributeValuesByName('name', $this->type(), Array($this->id), $contextid);
71  if (empty($values) === TRUE) {
72  return parent::_getName($short_name, $contextid);
73  } else {
74  return $values[$this->id];
75  }
76 
77  }//end _getName()
78 
79 
87  function _getAllowedLinks()
88  {
89  $page_links = parent::_getAllowedLinks();
90  $page_links[SQ_LINK_TYPE_2]['online_quiz_question'] = Array('card' => 'M', 'exclusive' => FALSE);
91  $page_links[SQ_LINK_TYPE_3]['online_quiz_question'] = Array('card' => 'M', 'exclusive' => FALSE);
92  $page_links[SQ_LINK_TYPE_2]['online_quiz_question_group'] = Array('card' => 'M', 'exclusive' => FALSE);
93  $page_links[SQ_LINK_TYPE_3]['online_quiz_question_group'] = Array('card' => 'M', 'exclusive' => FALSE);
94  return $page_links;
95 
96  }//end _getAllowedLinks()
97 
98 
105  function getQuestions()
106  {
107  $questions = $GLOBALS['SQ_SYSTEM']->am->getChildren($this->id, 'online_quiz_question', FALSE);
108 
109  return $questions;
110 
111  }//end getQuestions()
112 
113 
121  {
122  return $this->attr('score_categories');
123 
124  }//end getScoreCategories()
125 
126 
135  function getScoreCategoryForScore($score)
136  {
137  $score_category = NULL;
138  $score_categories = $this->getScoreCategories();
139 
140  foreach ($score_categories as $key => $current_score_category) {
141  $min_score = $current_score_category['min_score'];
142  $max_score = $current_score_category['max_score'];
143 
144  // Score categories can be open-ended or closed. Examples follow:
145  // Min score (empty), Max score = 10: Score of 10 or lower
146  // Min score = 0, Max score = 10: Any score 0 to 10 inclusive
147  // Min score = 1, Max score (empty): Score of 1 or greater
148 
149  if ((strlen($min_score) == 0) && (strlen($max_score) > 0) && ($score <= $max_score)) {
150  $score_category = $current_score_category;
151  break;
152  }
153 
154  if ((strlen($min_score) > 0) && (strlen($max_score) > 0) && ($score >= $min_score) && ($score <= $max_score)) {
155  $score_category = $current_score_category;
156  break;
157  }
158 
159  if ((strlen($min_score) > 0) && (strlen($max_score) == 0) && ($score >= $min_score)) {
160  $score_category = $current_score_category;
161  break;
162  }
163  }
164 
165  return $score_category;
166 
167  }//end getScoreCategoryForScore()
168 
169 
170 }//end class
171 ?>