All pastes #773617 Raw Edit

Stuff

public php v1 · immutable
·published 2007-11-14 17:48 UTC
rendered paste body
<?php	class GameshowsController extends AppController {		var $name = 'Gameshows';		var $uses = array('Assignment', 'Task', 'Answer');		var $components = array('xml');						function edit() {			$xml = $this->Task->field('task_text', array('Task.id' => 77897));			$parsed = $this->xml->import($xml, true);			//pr($this->xml->import($xml, false));			//exit;			//pr($parsed);			foreach ($parsed['data']['submodules']['submodule']['category'] as $category) {				$gameshow[] = $category;			}						$this->set('gameshow', $gameshow);		}				function multi($y = null, $x = null) {			$xml = $this->Task->field('task_text', array('Task.id' => 77897));			$parsed = $this->xml->import($xml, true);			//pr($parsed);			foreach ($parsed['data']['submodules']['submodule']['category'] as $category) {				$gameshow[] = $category;			}			$this->set('x', $x);			$this->set('y', $y);			$this->set('gameshow', $gameshow);		}				function truefalse($y = null, $x = null) {			$xml = $this->Task->field('task_text', array('Task.id' => 77897));			$parsed = $this->xml->import($xml, true);			foreach ($parsed['data']['submodules']['submodule']['category'] as $category) {				$gameshow[] = $category;			}			$this->set('x', $x);			$this->set('y', $y);			$this->set('gameshow', $gameshow);		}				function save($y = null, $x = null, $type = null) {			$xml = $this->Task->field('task_text', array('Task.id' => 77897));			$parsed = $this->xml->import($xml, true);			$newinfo = $this->data;			$multiobject = array();			$tfobject = array();						//Create MULTIple blank array...			$multiobject['sortnum'] = $y + 1;			$multiobject['value'] = null;			$multiobject['type'] = 'multi';			$multiobject['comment'] = null;			$multiobject['question']['audio'] = null;			$multiobject['question']['image'] = null;			$multiobject['question'][0] = null;			$multiobject['choices']['type'] = 'text';			$multiobject['choices']['choice'][0]['sortnum'] = 0;			$multiobject['choices']['choice'][0][0] = null;			$multiobject['choices']['choice'][1]['sortnum'] = 1;			$multiobject['choices']['choice'][1][0] = null;			$multiobject['choices']['choice'][2]['sortnum'] = 2;			$multiobject['choices']['choice'][2][0] = null;			$multiobject['choices']['choice'][3]['sortnum'] = 3;			$multiobject['choices']['choice'][3][0] = null;			$multiobject['answer'][0] = null;			$multiobject['ke']['type'] = 1;			$multiobject['ke']['value'] = null;						//Create trueFalseObject blank array			$tfobject['sortnum'] = $y + 1;			$tfobject['value'] = null;			$tfobject['type'] = 'truefalse';			$tfobject['comment'] = null;			$tfobject['question']['audio'] = null;			$tfobject['question']['image'] = null;			$tfobject['question'][0] = null;			$tfobject['answer'][0] = null;			$tfobject['ke']['type'] = 1;			$tfobject['ke']['value'] = null;						//doublecheck for 1 question categories... >.>			if (isset($parsed['data']['submodules']['submodule']['category'][$x]['quizitem']['sortnum'])) {				$placeholder = $parsed['data']['submodules']['submodule']['category'][$x]['quizitem'];				unset($parsed['data']['submodules']['submodule']['category'][$x]['quizitem']);				$parsed['data']['submodules']['submodule']['category'][$x]['quizitem'][0] = $placeholder;			}						if ($type == 'multi') {				$multiobject['choices']['choice'][0][0] = $newinfo['Answer']['Answer0'];				$multiobject['choices']['choice'][1][0] = $newinfo['Answer']['Answer1'];				$multiobject['choices']['choice'][2][0] = $newinfo['Answer']['Answer2'];				$multiobject['choices']['choice'][3][0] = $newinfo['Answer']['Answer3'];				$multiobject['answer'][0] = $newinfo['Answer']['correct'];				$multiobject['question'][0] = $newinfo['Question']['question'];				$parsed['data']['submodules']['submodule']['category'][$x]['quizitem'][$y] = $multiobject;			} elseif ($type == 'truefalse') {				$tfobject['question'][0] = $newinfo['Question']['question'];				$tfobject['answer'][0] = $newinfo['Answers']['correct'];				$parsed['data']['submodules']['submodule']['category'][$x]['quizitem'][$y][] = $tfobject;			} else {				$this->flash('This error message is appearing because you failed to select a correct question type... Please contact your system administrator', 'gameshows/edit');			}			$xml = $this->xml->export($parsed, 'iso-8859-1');			$this->Task->id = 77897;			$this->Task->save(array('task_text' => $xml, 'task_type' => 'gameshows'));			$this->flash('Question Saved Successfully!', 'gameshows/edit');		}				function delete($y = null, $x = null) {			$xml = $this->Task->field('task_text', array('Task.id' => 77897));			$parsed = $this->xml->import($xml, true);			//doublecheck for 1 question categories... >.>			if (!isset($parsed['data']['submodules']['submodule']['category'][$x]['quizitem'][0])) {				$placeholder = $parsed['data']['submodules']['submodule']['category'][$x]['quizitem'];				unset($parsed['data']['submodules']['submodule']['category'][$x]['quizitem']);				$parsed['data']['submodules']['submodule']['category'][$x]['quizitem'][0] = $placeholder;			}			unset($parsed['data']['submodules']['submodule']['category'][$x]['quizitem'][$y]);				$xml = $this->xml->export($parsed, 'iso-8859-1');			$this->Task->id = 77897;			$this->Task->save(array('task_text' => $xml, 'task_type' => 'gameshows'));			$this->flash('Question Deleted Successfully!', 'gameshows/edit');		}				function renamecat() {			$xml = $this->Task->field('task_text', array('Task.id' => 77897));			$parsed = $this->xml->import($xml, true);			//pr($parsed);			//pr($this->data);			$i = 0;			foreach ($this->data['Categorys'] as $newname) {				$parsed['data']['submodules']['submodule']['category'][$i]['name'] = $newname;				$i++;			}			$xml = $this->xml->export($parsed, 'iso-8859-1');			$this->Task->id = 77897;			$this->Task->save(array('task_text' => $xml, 'task_type' => 'gameshows'));			$this->flash('Categories Saved Successfully!', 'gameshows/edit');		}	}?>