From: Simon H. <sim...@us...> - 2010-12-01 18:21:40
|
Update of /cvsroot/stack/stack-dev/lib/items In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv22401/lib/items Modified Files: Tag: item_state_separation StudentAns.php ItemOption.php Log Message: Ongoing debugging Index: ItemOption.php =================================================================== RCS file: /cvsroot/stack/stack-dev/lib/items/ItemOption.php,v retrieving revision 1.19.8.3 retrieving revision 1.19.8.4 diff -C2 -d -r1.19.8.3 -r1.19.8.4 *** ItemOption.php 28 Nov 2010 16:15:45 -0000 1.19.8.3 --- ItemOption.php 1 Dec 2010 18:21:32 -0000 1.19.8.4 *************** *** 107,116 **** $this->addOption('OptWorkedSol','list','true',array('true' => get_string('stack_True','stack',''),'false' => get_string('stack_False', 'stack','')),'',''); } ! public function __clone() { // obsolete? } ! /** * Validates every option. --- 107,117 ---- $this->addOption('OptWorkedSol','list','true',array('true' => get_string('stack_True','stack',''),'false' => get_string('stack_False', 'stack','')),'',''); } ! /* public function __clone() { // obsolete? + echo "6:17pm:";var_dump(self::$options); } ! */ /** * Validates every option. *************** *** 148,154 **** * @access public */ ! public function addOption($name, $type, $default, $value ='', $casKey = NULL, $casType = NULL) { ! $tmp = new StackOption($type, $default, $value, $casKey, $casType); $valid = $tmp->validate(); --- 149,155 ---- * @access public */ ! public function addOption($name, $type, $default, $values = NULL, $casKey = NULL, $casType = NULL) { ! $tmp = new StackOption($type, $default, $values, $casKey, $casType); $valid = $tmp->validate(); *************** *** 156,160 **** { self::$options[$name] = $tmp; // new option for ItemOption ! $this->selected[$name] = $value; // and value set for the instance } else --- 157,161 ---- { self::$options[$name] = $tmp; // new option for ItemOption ! $this->selected[$name] = $default; // and value set for the instance } else *************** *** 366,370 **** public function setSelected($name, $value) { ! if(array_key_exists($name, $this->selected)) // we have the option { $this->selected[$name] = $value; --- 367,372 ---- public function setSelected($name, $value) { ! echo "6pm:";var_dump(self::$options); ! if(array_key_exists($name, self::$options)) // we have the option { $this->selected[$name] = $value; *************** *** 401,410 **** public function getWidget($name, $size=NULL) { ! if(array_key_exists($name, $this->options)) ! { // rather kludgy way of setting Option up with correct selection $option = clone self::$options[$name]; $option->setSelected($this->selected[$name]); ! return $options->editWidget($name, $size); } else --- 403,411 ---- public function getWidget($name, $size=NULL) { ! if(array_key_exists($name, self::$options)) { // rather kludgy way of setting Option up with correct selection $option = clone self::$options[$name]; $option->setSelected($this->selected[$name]); ! return $option->editWidget($name, $size); } else *************** *** 446,467 **** */ public function copyFrom($src) { ! if(!empty($src->options)) ! { ! foreach($src->options as $optName => $option) ! { ! // check src option even exists in this ! if(array_key_exists($optName, $this->options)) { ! ! $selection = $src->selection[$optName]; ! ! // copy value over, involves checks. ! self::$options[$optName]->setSelected($src->options[$optName]->getSelected()); ! $this->selected[$optName] = $selection; ! ! } else { ! self::$errorLog->addError('Attempted to copy selection of '.$optName.' which does not exist in current item.'); ! } ! } ! } } --- 447,456 ---- */ public function copyFrom($src) { ! // assuming default options are static, we just need to copy over selection ! if(!empty($src->selected)) { ! foreach($src->selected as $key => $val) { ! $this->selected[$key] = $val; ! } ! } } Index: StudentAns.php =================================================================== RCS file: /cvsroot/stack/stack-dev/lib/items/StudentAns.php,v retrieving revision 1.42.6.2.2.1 retrieving revision 1.42.6.2.2.2 diff -C2 -d -r1.42.6.2.2.1 -r1.42.6.2.2.2 *** StudentAns.php 9 Nov 2010 16:51:37 -0000 1.42.6.2.2.1 --- StudentAns.php 1 Dec 2010 18:21:32 -0000 1.42.6.2.2.2 *************** *** 217,220 **** --- 217,221 ---- { $itemOptions = clone $itemOpts; + echo "snow:<pre>";print_r($itemOpts); $toReturn = true; foreach($this->studentAnswers as $label => $sAns) |