Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
online_quiz_question_edit_fns.inc
1 <?php
18 require_once SQ_INCLUDE_PATH.'/asset_edit/asset_edit_fns.inc';
19 
32 {
33 
34 
40  {
41  $this->Asset_Edit_Fns();
42 
43  $this->static_screens['details']['force_unlock'] = FALSE;
44 
45  }//end constructor
46 
47 
58  function paintQuestionText(&$asset, &$o, $prefix)
59  {
60  $bodycopy = $asset->getQuestionTextBodycopy();
61  $write_access = $asset->writeAccess('links') && $asset->writeAccess('attributes');
62  $use_bodycopy = !is_null($bodycopy);
63 
64  $o->openField(translate('online_quiz_question_use_question_text_bodycopy'));
65  if ($write_access) {
66  $options = Array(
67  '1' => translate('yes'),
68  '0' => translate('no'),
69  );
70 
71  combo_box($prefix.'_question_text_use_bodycopy', $options, FALSE, Array($use_bodycopy));
72  if ($use_bodycopy) {
73  echo '&nbsp;'.get_asset_tag_line($bodycopy->id, 'contents');
74  }
75  } else {
76  if ($use_bodycopy) {
77  echo translate('yes').' - '.get_asset_tag_line($bodycopy->id, 'contents');
78  } else {
79  echo translate('no');
80  }
81  }
82  $o->note(translate('online_quiz_question_use_question_text_bodycopy_note'));
83  $o->closeField();
84 
85  if (!$use_bodycopy) {
86  $o->openField('Question Text');
87  if ($write_access) {
88  text_area($prefix.'_question_text', $asset->attr('question_text'), 60, 3);
89  } else {
90  echo $asset->attr('question_text');
91  }
92  $o->closeField();
93  }
94 
95  return $write_access;
96 
97  }//end paintQuestionText()
98 
99 
110  function processQuestionText(&$asset, &$o, $prefix)
111  {
112  if ($asset->writeAccess('links') && $asset->writeAccess('attributes')) {
113  $use_bodycopy = array_get_index($_POST, $prefix.'_question_text_use_bodycopy', NULL);
114  $question_text = array_get_index($_POST, $prefix.'_question_text', NULL);
115  if (!is_null($use_bodycopy)) {
116  $GLOBALS['SQ_SYSTEM']->changeDatabaseConnection('db2');
117  $GLOBALS['SQ_SYSTEM']->doTransaction('BEGIN');
118 
119  // handle the question text
120  if (!is_null($question_text)) {
121  $asset->setAttrValue('question_text', $question_text);
122  }
123 
124  // enable/disable the bodycopy
125  if (!$asset->setQuestionTextBodycopy($use_bodycopy)) {
126  $GLOBALS['SQ_SYSTEM']->doTransaction('ROLLBACK');
127  $GLOBALS['SQ_SYSTEM']->restoreDatabaseConnection();
128  return FALSE;
129  }
130 
131  $GLOBALS['SQ_SYSTEM']->doTransaction('COMMIT');
132  $GLOBALS['SQ_SYSTEM']->restoreDatabaseConnection();
133 
134  return TRUE;
135  }
136  }
137 
138  return FALSE;
139 
140  }//end processQuestionText()
141 
142 
143 }//end class
144 ?>