|
From: Chris S. <san...@us...> - 2009-06-26 15:15:28
|
Update of /cvsroot/stack/stack-dev/lib/ui/inputTypes In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv17926 Modified Files: Tag: stack_cache AnswerInputType.php Matrix.php Log Message: Index: AnswerInputType.php =================================================================== RCS file: /cvsroot/stack/stack-dev/lib/ui/inputTypes/AnswerInputType.php,v retrieving revision 1.8 retrieving revision 1.8.4.1 diff -C2 -d -r1.8 -r1.8.4.1 *** AnswerInputType.php 3 Nov 2008 16:34:45 -0000 1.8 --- AnswerInputType.php 26 Jun 2009 15:15:19 -0000 1.8.4.1 *************** *** 148,151 **** --- 148,163 ---- } + /** + * Returns an array in the form of the $_POST data, used for the question tests. + * + * @param string $value + * @access public + * @return array + */ + public function getTestPostData($value) + { + return array($this->name=>value); + } + } Index: Matrix.php =================================================================== RCS file: /cvsroot/stack/stack-dev/lib/ui/inputTypes/Matrix.php,v retrieving revision 1.3.4.1 retrieving revision 1.3.4.2 diff -C2 -d -r1.3.4.1 -r1.3.4.2 *** Matrix.php 4 Jun 2009 11:03:51 -0000 1.3.4.1 --- Matrix.php 26 Jun 2009 15:15:19 -0000 1.3.4.2 *************** *** 395,398 **** --- 395,433 ---- } + /** + * Returns an array in the form of the $_POST data, used for the question tests. + * + * @param string $value + * @access public + * @return array + */ + public function getTestPostData($value) + { + $post_data = array(); + + $cs = 'matrix_size('.$this->parameters['teacherAns'].')'; + $matrixSize = new CasString($cs); + + $mct = new MultiCasText(array('size' => $matrixSize)); + $mct->casValidate('t'); + + $size = $mct->getRawValues('size'); + + $dimensions = explode(',',$size[$cs]); + $height = trim($dimensions[0], '[]'); + $width = trim($dimensions[1], '[]'); + + for($i=0; $i < $height; $i++) { + for($j=0; $j < $width; $j++) { + $name = $this->name.'-'.$i.'-'.$j; + $default = empty($this->defaults) ? '' : $this->defaults[$i][$j]; + $post_data[$name] = $default; + } + } + + return $post_data; + } + + } ?> |