/** * function actionEdit: * processes subaction and calls getQuizEditForm function which renders edit interface */ public function actionEdit() { // dataSource: the $dataSource argument to get*Form() functions specifies where to persist data for the form from. // if a submit was in progress, and the submit was successful, we set dataSource to db. // else, we set dataSource to POST, because we need to present the user's entered values, rather than existing values // so that he/she may make changes and submit again, with least hassle. if (isset($_GET['subaction'])) { switch ($_GET['subaction']) { case 'addsections': if (!$this->isValidId($_POST['txtSectionCount'])) { displayerror('Error. No count specified.'); } else { $count = escape($_POST['txtSectionCount']); if (addSections($this->moduleComponentId, $count) !== false) { displayinfo('Section(s) added successfully.'); } } break; case 'editsection': $dataSource = 'db'; if (!$this->isValidId($_GET['sectionid'])) { displayerror('Error. Invalid section id specified.'); } elseif (isset($_POST['btnSubmit'])) { $dataSource = 'POST'; if (submitSectionEditForm($this->moduleComponentId, intval($_GET['sectionid']))) { displayinfo('Section properties saved successfully.'); $dataSource = 'db'; } } return getSectionEditForm($this->moduleComponentId, intval($_GET['sectionid']), $dataSource); break; case 'deletesection': if (!$this->isValidId($_POST['hdnSectionId'])) { displayerror('Error. Invalid section id specified.'); } elseif (deleteSection($this->moduleComponentId, intval($_POST['hdnSectionId']))) { displayinfo('The specified section was successfully deleted.'); } break; case 'movesection': if (!$this->isValidId($_GET['sectionid'])) { displayerror('Error. Invalid section id specified.'); } elseif (!isset($_GET['direction']) || $_GET['direction'] != 'up' && $_GET['direction'] != 'down') { displayerror('Error. No or invalid direction specified. Could not move section.'); } elseif (moveSection($this->moduleComponentId, intval($_GET['sectionid']))) { displayinfo('The specified section was successfully moved.'); } break; case 'addquestions': if (!$this->isValidId($_GET['sectionid'])) { displayerror('Error. No or invalid section id specified. Could not add question.'); } elseif (!$this->isValidId($_POST['txtQuestionCount'])) { displayerror('Error. No or invalid count specified. Could not add question.'); } else { $count = intval($_POST['txtQuestionCount']); $insertIds = addQuestions($this->moduleComponentId, intval($_GET['sectionid']), $count); if ($insertIds !== false) { displayinfo('New question(s) added successfully.'); } } break; case 'editquestion': $dataSource = 'db'; if (!$this->isValidId($_GET['sectionid']) || !$this->isValidId($_GET['questionid'])) { displayerror('Error. Invalid section or question specified.'); } elseif (isset($_POST['btnSubmit'])) { $dataSource = 'POST'; if (submitQuestionEditForm($this->moduleComponentId, intval($_GET['sectionid']), intval($_GET['questionid']))) { displayinfo('Question properties saved successfully.'); $dataSource = 'db'; } } return getQuestionEditForm($this->moduleComponentId, intval($_GET['sectionid']), intval($_GET['questionid']), $dataSource); break; case 'deletequestion': if (!$this->isValidId($_POST['hdnSectionId']) || !$this->isValidId($_POST['hdnQuestionId'])) { displayerror('Error. Invalid section or question specified.'); } elseif (deleteQuestion($this->moduleComponentId, intval($_POST['hdnSectionId']), intval($_POST['hdnQuestionId']))) { displayinfo('Question successfully deleted.'); } break; case 'movequestion': if (!$this->isValidId($_GET['sectionid'])) { displayerror('Error. Invalid section id specified.'); } elseif (!$this->isValidId($_GET['questionid'])) { displayerror('Error. Invalid question id specified.'); } elseif (!isset($_GET['direction']) || $_GET['direction'] != 'up' && $_GET['direction'] != 'down') { displayerror('Error. No or invalid direction specified. Could not move section.'); } elseif (moveQuestion($this->moduleComponentId, intval($_GET['sectionid']), intval($_GET['questionid']), $_GET['direction'])) { displayinfo('The specified question was successfully moved.'); } break; } } if (isset($_POST['btnSetWeightMarks'])) { if (setWeightMark(intval($_POST['quizId']), intval($_POST['weight']), intval($_POST['pos']), intval($_POST['neg']))) { displayinfo('Weight - Marks saved.'); } else { displayerror('Error in changing weight mark'); } } $dataSource = 'db'; if (isset($_POST['btnSubmit'])) { $dataSource = 'POST'; if (submitQuizEditForm($this->moduleComponentId)) { $dataSource = 'db'; } } return getQuizEditForm($this->moduleComponentId, $dataSource); }
changeContent($cid, 0, $sectionid, $option); break; case 'cancel': cancelContent($option); break; case 'orderup': orderContent($cid[0], -1, $option); break; case 'orderdown': orderContent($cid[0], 1, $option); break; case 'showarchive': viewArchive($sectionid, $option); break; case 'movesect': moveSection($cid, $sectionid, $option); break; case 'movesectsave': moveSectionSave($cid, $sectionid, $option); break; case 'copy': copyItem($cid, $sectionid, $option); break; case 'copysave': copyItemSave($cid, $sectionid, $option); break; case 'resethits': resetHits(); break; case 'accesspublic': accessMenu($cid[0], 0, $option, $client);