[Logicampus-cvs] logicampus/src/logicreate/lib lc_lob_test.php, 1.1, 1.2
Brought to you by:
trilexcom
From: Mark K <har...@us...> - 2007-10-05 21:35:51
|
Update of /cvsroot/logicampus/logicampus/src/logicreate/lib In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv16642/lib Modified Files: lc_lob_test.php Log Message: Adding support to make a test with multiple choice questions. Index: lc_lob_test.php =================================================================== RCS file: /cvsroot/logicampus/logicampus/src/logicreate/lib/lc_lob_test.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** lc_lob_test.php 5 Oct 2007 19:27:37 -0000 1.1 --- lc_lob_test.php 5 Oct 2007 21:35:48 -0000 1.2 *************** *** 37,51 **** } function addQuestion($qtext, $type = 'QUESTION_ESSAY', $choices = '', $answers = '') { $q = new LobTestQst(); $q->qstText = $qtext; if ( is_array($choices) ) { } ! $this->questionObjs[] = $q; } ! function getQuestionCount() { ! return count($this->questionObjs); } } --- 37,88 ---- } + function setQuestion($qidx, $qtext, $type = 'QUESTION_ESSAY', $choices = '', $answers = '') { + $q = $this->_makeQuestion($qtext, $type, $choices, $answers); + if ($qidx > -1) { + $this->questionObjs[$qidx] = $q; + } else { + $this->questionObjs[] = $q; + } + } + function addQuestion($qtext, $type = 'QUESTION_ESSAY', $choices = '', $answers = '') { + $q = $this->_makeQuestion($qtext, $type, $choices, $answers); + $this->questionObjs[] = $q; + } + + function getQuestionCount() { + return count($this->questionObjs); + } + function _makeQuestion($qtext, $type, $choices, $answers='') { $q = new LobTestQst(); + $q->qstChoices = array(); $q->qstText = $qtext; + $q->questionTypeId = constant($type); if ( is_array($choices) ) { } ! return $q; } ! ! /** ! * ! * @return bool successfully added the choice ! */ ! function addLabel($l, $correct, $qidx=-1) { ! if ($qidx == -1) { ! $qidx = $this->getQuestionCount()-1; ! } ! if ($qidx == -1) { ! return false; ! } ! $lidx = count($this->questionObjs[$qidx]->qstChoices); ! if ($lidx == -1) { ! $lidx = 0; ! } ! ! $this->questionObjs[$qidx]->qstChoices[$lidx]['label'] = $l; ! $this->questionObjs[$qidx]->qstChoices[$lidx]['correct'] = $correct; ! return true; } } |