本文整理汇总了PHP中FormValidator::getSubmitValue方法的典型用法代码示例。如果您正苦于以下问题:PHP FormValidator::getSubmitValue方法的具体用法?PHP FormValidator::getSubmitValue怎么用?PHP FormValidator::getSubmitValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FormValidator
的用法示例。
在下文中一共展示了FormValidator::getSubmitValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processCreation
/**
* @param FormValidator $form
* @param null $objExercise
* @return bool
*/
public function processCreation($form, $objExercise = null)
{
$file_info = $form->getSubmitValue('imageUpload');
$_course = api_get_course_info();
parent::processCreation($form, $objExercise);
if (!empty($file_info['tmp_name'])) {
$this->uploadPicture($file_info['tmp_name'], $file_info['name']);
$documentPath = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/document';
$picturePath = $documentPath . '/images';
// fixed width ang height
if (file_exists($picturePath . '/' . $this->picture)) {
$this->resizePicture('width', 800);
$this->save();
} else {
return false;
}
}
}
示例2: processAnswersCreation
/**
* abstract function which creates the form to create/edit the answers of the question
* @param FormValidator $form
*/
function processAnswersCreation($form)
{
$this->weighting = $form->getSubmitValue('weighting');
$this->save();
}
示例3: processAnswersCreation
/**
* abstract function which creates the form to create / edit the answers of the question
* @param FormValidator $form
*/
function processAnswersCreation($form)
{
if (!self::isAnswered()) {
$table = Database::get_course_table(TABLE_QUIZ_ANSWER);
Database::delete($table, array('c_id = ? AND question_id = ?' => array($this->course['real_id'], $this->id)));
$answer = $form->getSubmitValue('answer');
$formula = $form->getSubmitValue('formula');
$lowestValues = $form->getSubmitValue('lowestValue');
$highestValues = $form->getSubmitValue('highestValue');
$answerVariations = $form->getSubmitValue('answerVariations');
$this->weighting = $form->getSubmitValue('weighting');
// Create as many answers as $answerVariations
for ($j = 0; $j < $answerVariations; $j++) {
$auxAnswer = $answer;
$auxFormula = $formula;
$nb = preg_match_all('/\\[[^\\]]*\\]/', $auxAnswer, $blanks);
if ($nb > 0) {
for ($i = 0; $i < $nb; ++$i) {
$blankItem = $blanks[0][$i];
$replace = array("[", "]");
$newBlankItem = str_replace($replace, "", $blankItem);
$newBlankItem = "[" . trim($newBlankItem) . "]";
// take random float values when one or both edge values have a decimal point
$randomValue = strpos($lowestValues[$i], '.') !== false || strpos($highestValues[$i], '.') !== false ? mt_rand($lowestValues[$i] * 100, $highestValues[$i] * 100) / 100 : mt_rand($lowestValues[$i], $highestValues[$i]);
$auxAnswer = str_replace($blankItem, $randomValue, $auxAnswer);
$auxFormula = str_replace($blankItem, $randomValue, $auxFormula);
}
$math = new EvalMath();
$result = $math->evaluate($auxFormula);
$result = number_format($result, 2, ".", "");
// Remove decimal trailing zeros
$result = rtrim($result, "0");
// If it is an integer (ends in .00) remove the decimal point
if (mb_substr($result, -1) === ".") {
$result = str_replace(".", "", $result);
}
// Attach formula
$auxAnswer .= " [" . $result . "]@@" . $formula;
}
$this->save();
$objAnswer = new Answer($this->id);
$objAnswer->createAnswer($auxAnswer, 1, '', $this->weighting, '');
$objAnswer->position = array();
$objAnswer->save();
}
}
}
示例4: processAnswersCreation
/**
* abstract function which creates the form to create/edit the answers of the question
* @param FormValidator $form
*/
public function processAnswersCreation($form)
{
$questionWeighting = $nbrGoodAnswers = 0;
$objAnswer = new Answer($this->id);
$nb_answers = $form->getSubmitValue('nb_answers');
for ($i = 1; $i <= $nb_answers; $i++) {
$answer = trim($form->getSubmitValue('answer[' . $i . ']'));
$comment = trim($form->getSubmitValue('comment[' . $i . ']'));
if ($i == 1) {
$weighting = trim($form->getSubmitValue('weighting[' . $i . ']'));
} else {
$weighting = 0;
}
$goodAnswer = trim($form->getSubmitValue('correct[' . $i . ']'));
if ($goodAnswer) {
$weighting = abs($weighting);
} else {
$weighting = abs($weighting);
// $weighting = -$weighting;
}
if ($weighting > 0) {
$questionWeighting += $weighting;
}
$objAnswer->createAnswer($answer, $goodAnswer, $comment, $weighting, $i);
}
// saves the answers into the data base
$objAnswer->save();
// sets the total weighting of the question
$this->updateWeighting($questionWeighting);
$this->save();
}
示例5: processCreation
/**
* function which process the creation of exercises
* @param FormValidator $form the formvalidator instance
*/
function processCreation($form, $type = '')
{
$values = $form->exportValues();
$this->updateTitle($form->getSubmitValue('exerciseTitle'));
$this->updateDescription($form->getSubmitValue('exerciseDescription'));
$this->updateAttempts($form->getSubmitValue('exerciseAttempts'));
$this->updateFeedbackType($form->getSubmitValue('exerciseFeedbackType'));
$this->updateType($form->getSubmitValue('exerciseType'));
$this->setRandom($form->getSubmitValue('randomQuestions'));
$this->updateRandomAnswers($form->getSubmitValue('randomAnswers'));
$this->updateResultsDisabled($form->getSubmitValue('results_disabled'));
$this->updateExpiredTime($form->getSubmitValue('enabletimercontroltotalminutes'));
$this->updatePropagateNegative($form->getSubmitValue('propagate_neg'));
$this->updateRandomByCat($form->getSubmitValue('randomByCat'));
$this->updateTextWhenFinished($form->getSubmitValue('text_when_finished'));
$this->updateDisplayCategoryName($form->getSubmitValue('display_category_name'));
$this->updateReviewAnswers($form->getSubmitValue('review_answers'));
$this->updatePassPercentage($form->getSubmitValue('pass_percentage'));
$this->updateCategories($form->getSubmitValue('category'));
$this->updateEndButton($form->getSubmitValue('end_button'));
$this->updateEmailNotificationTemplate($form->getSubmitValue('email_notification_template'));
$this->setModelType($form->getSubmitValue('model_type'));
$this->setQuestionSelectionType($form->getSubmitValue('question_selection_type'));
$this->setHideQuestionTitle($form->getSubmitValue('hide_question_title'));
var_dump($values);
$this->setScoreTypeModel($form->getSubmitValue('score_type_model'));
$this->setGlobalCategoryId($form->getSubmitValue('global_category_id'));
if ($form->getSubmitValue('activate_start_date_check') == 1) {
$start_time = $form->getSubmitValue('start_time');
$start_time['F'] = sprintf('%02d', $start_time['F']);
$start_time['i'] = sprintf('%02d', $start_time['i']);
$start_time['d'] = sprintf('%02d', $start_time['d']);
$this->start_time = $start_time['Y'] . '-' . $start_time['F'] . '-' . $start_time['d'] . ' ' . $start_time['H'] . ':' . $start_time['i'] . ':00';
} else {
$this->start_time = '0000-00-00 00:00:00';
}
if ($form->getSubmitValue('activate_end_date_check') == 1) {
$end_time = $form->getSubmitValue('end_time');
$end_time['F'] = sprintf('%02d', $end_time['F']);
$end_time['i'] = sprintf('%02d', $end_time['i']);
$end_time['d'] = sprintf('%02d', $end_time['d']);
$this->end_time = $end_time['Y'] . '-' . $end_time['F'] . '-' . $end_time['d'] . ' ' . $end_time['H'] . ':' . $end_time['i'] . ':00';
} else {
$this->end_time = '0000-00-00 00:00:00';
}
if ($form->getSubmitValue('enabletimercontrol') == 1) {
$expired_total_time = $form->getSubmitValue('enabletimercontroltotalminutes');
if ($this->expired_time == 0) {
$this->expired_time = $expired_total_time;
}
} else {
$this->expired_time = 0;
}
if ($form->getSubmitValue('randomAnswers') == 1) {
$this->random_answers = 1;
} else {
$this->random_answers = 0;
}
$this->save($type);
}
示例6: array
if (count($a_sessions) > 0) {
$actionsRight = Display::url(Display::return_icon('printer.png', get_lang('Print'), array(), 32), 'javascript: void(0);', array('onclick' => 'javascript: window.print();'));
$actionsRight .= Display::url(Display::return_icon('export_csv.png', get_lang('ExportAsCSV'), array(), 32), api_get_self() . '?export=csv');
}
$toolbar = Display::toolbarAction('toolbar-session', $content = array(0 => $actionsLeft, 1 => $actionsRight));
echo $toolbar;
echo Display::page_header(get_lang('YourSessionsList'));
} else {
$a_sessions = Tracking::get_sessions_coached_by_user($id_coach);
}
$form = new FormValidator('search_course', 'get', api_get_path(WEB_CODE_PATH) . 'mySpace/session.php');
$form->addElement('text', 'keyword', get_lang('Keyword'));
$form->addButtonSearch(get_lang('Search'));
$keyword = '';
if ($form->validate()) {
$keyword = $form->getSubmitValue('keyword');
}
$form->setDefaults(array('keyword' => $keyword));
$url = api_get_path(WEB_AJAX_PATH) . 'model.ajax.php?a=get_sessions_tracking&keyword=' . Security::remove_XSS($keyword);
$columns = array(get_lang('Title'), get_lang('Date'), get_lang('NbCoursesPerSession'), get_lang('NbStudentPerSession'), get_lang('Details'));
// Column config
$columnModel = array(array('name' => 'name', 'index' => 'name', 'width' => '255', 'align' => 'left'), array('name' => 'date', 'index' => 'date', 'width' => '150', 'align' => 'left', 'sortable' => 'false'), array('name' => 'course_per_session', 'index' => 'course_per_session', 'width' => '150', 'sortable' => 'false'), array('name' => 'student_per_session', 'index' => 'student_per_session', 'width' => '100', 'sortable' => 'false'), array('name' => 'details', 'index' => 'details', 'width' => '100', 'sortable' => 'false'));
$extraParams = array('autowidth' => 'true', 'height' => 'auto');
$js = '<script>
$(function() {
' . Display::grid_js('session_tracking', $url, $columns, $columnModel, $extraParams, array(), null, true) . '
});
</script>';
echo $js;
$form->display();
echo Display::grid_html('session_tracking');
示例7: processAnswersCreation
/**
* Function which creates the form to create/edit the answers of the question
* @param FormValidator $form
*/
public function processAnswersCreation($form)
{
$answer = $form->getSubmitValue('answer');
// Due the ckeditor transform the elements to their HTML value
//$answer = api_html_entity_decode($answer, ENT_QUOTES, $charset);
//$answer = htmlentities(api_utf8_encode($answer));
// remove the :: eventually written by the user
$answer = str_replace('::', '', $answer);
// remove starting and ending space and
$answer = api_preg_replace("/ /", " ", $answer);
// start and end separator
$blankStartSeparator = self::getStartSeparator($form->getSubmitValue('select_separator'));
$blankEndSeparator = self::getEndSeparator($form->getSubmitValue('select_separator'));
$blankStartSeparatorRegexp = self::escapeForRegexp($blankStartSeparator);
$blankEndSeparatorRegexp = self::escapeForRegexp($blankEndSeparator);
// remove spaces at the beginning and the end of text in square brackets
$answer = preg_replace_callback("/" . $blankStartSeparatorRegexp . "[^]]+" . $blankEndSeparatorRegexp . "/", function ($matches) use($blankStartSeparator, $blankEndSeparator) {
$matchingResult = $matches[0];
$matchingResult = trim($matchingResult, $blankStartSeparator);
$matchingResult = trim($matchingResult, $blankEndSeparator);
$matchingResult = trim($matchingResult);
// remove forbidden chars
$matchingResult = str_replace("/\\/", "", $matchingResult);
$matchingResult = str_replace('/"/', "", $matchingResult);
return $blankStartSeparator . $matchingResult . $blankEndSeparator;
}, $answer);
// get the blanks weightings
$nb = preg_match_all('/' . $blankStartSeparatorRegexp . '[^' . $blankStartSeparatorRegexp . ']*' . $blankEndSeparatorRegexp . '/', $answer, $blanks);
if (isset($_GET['editQuestion'])) {
$this->weighting = 0;
}
/* if we have some [tobefound] in the text
build the string to save the following in the answers table
<p>I use a [computer] and a [pen].</p>
becomes
<p>I use a [computer] and a [pen].</p>::100,50:100,50@1
++++++++-------**
--- -- --- -- -
A B (C) (D)(E)
+++++++ : required, weighting of each words
------- : optional, input width to display, 200 if not present
** : equal @1 if "Allow answers order switches" has been checked, @ otherwise
A : weighting for the word [computer]
B : weighting for the word [pen]
C : input width for the word [computer]
D : input width for the word [pen]
E : equal @1 if "Allow answers order switches" has been checked, @ otherwise
*/
if ($nb > 0) {
$answer .= '::';
// weighting
for ($i = 0; $i < $nb; ++$i) {
// enter the weighting of word $i
$answer .= $form->getSubmitValue('weighting[' . $i . ']');
// not the last word, add ","
if ($i != $nb - 1) {
$answer .= ",";
}
// calculate the global weighting for the question
$this->weighting += $form->getSubmitValue('weighting[' . $i . ']');
}
// input width
$answer .= ":";
for ($i = 0; $i < $nb; ++$i) {
// enter the width of input for word $i
$answer .= $form->getSubmitValue('sizeofinput[' . $i . ']');
// not the last word, add ","
if ($i != $nb - 1) {
$answer .= ",";
}
}
}
// write the blank separator code number
// see function getAllowedSeparator
/*
0 [...]
1 {...}
2 (...)
3 *...*
4 #...#
5 %...%
6 $...$
*/
$answer .= ":" . $form->getSubmitValue('select_separator');
// Allow answers order switches
$is_multiple = $form->getSubmitValue('multiple_answer');
$answer .= '@' . $is_multiple;
$this->save();
$objAnswer = new Answer($this->id);
$objAnswer->createAnswer($answer, 0, '', 0, 1);
$objAnswer->save();
}
示例8: processAnswersCreation
/**
* Receives the unique answer question type creation form data and creates
* or updates the answers from that question
* @param FormValidator $form
*/
public function processAnswersCreation($form)
{
$questionWeighting = $nbrGoodAnswers = 0;
$correct = $form->getSubmitValue('correct');
$objAnswer = new Answer($this->id);
$nb_answers = $form->getSubmitValue('nb_answers');
for ($i = 1; $i <= $nb_answers; $i++) {
$answer = trim($form->getSubmitValue('answer[' . $i . ']'));
$comment = trim($form->getSubmitValue('comment[' . $i . ']'));
$weighting = trim($form->getSubmitValue('weighting[' . $i . ']'));
$scenario = $form->getSubmitValue('scenario');
//$list_destination = $form -> getSubmitValue('destination'.$i);
//$destination_str = $form -> getSubmitValue('destination'.$i);
$try = $scenario['try' . $i];
$lp = $scenario['lp' . $i];
$destination = $scenario['destination' . $i];
$url = trim($scenario['url' . $i]);
/*
How we are going to parse the destination value
here we parse the destination value which is a string
1@@3@@2;4;4;@@http://www.chamilo.org
where: try_again@@lp_id@@selected_questions@@url
try_again = is 1 || 0
lp_id = id of a learning path (0 if dont select)
selected_questions= ids of questions
url= an url
$destination_str='';
foreach ($list_destination as $destination_id)
{
$destination_str.=$destination_id.';';
}*/
$goodAnswer = $correct == $i ? true : false;
if ($goodAnswer) {
$nbrGoodAnswers++;
$weighting = abs($weighting);
if ($weighting > 0) {
$questionWeighting += $weighting;
}
}
if (empty($try)) {
$try = 0;
}
if (empty($lp)) {
$lp = 0;
}
if (empty($destination)) {
$destination = 0;
}
if ($url == '') {
$url = 0;
}
//1@@1;2;@@2;4;4;@@http://www.chamilo.org
$dest = $try . '@@' . $lp . '@@' . $destination . '@@' . $url;
$objAnswer->createAnswer($answer, $goodAnswer, $comment, $weighting, $i, null, null, $dest);
}
// saves the answers into the data base
$objAnswer->save();
// sets the total weighting of the question
$this->updateWeighting($questionWeighting);
$this->save();
}
示例9: isset
* @package chamilo.gradebook
*/
use ChamiloSession as Session;
$cidReset = true;
require_once '../inc/global.inc.php';
if (api_get_setting('allow_public_certificates') != 'true') {
api_not_allowed(true, Display::return_message(get_lang('CertificatesNotPublic'), 'warning'));
}
$userId = isset($_GET['id']) ? intval($_GET['id']) : 0;
$userList = $userInfo = $courseList = $sessionList = [];
$searchForm = new FormValidator('search_form', 'post', null, null);
$searchForm->addText('firstname', get_lang('FirstName'));
$searchForm->addText('lastname', get_lang('LastName'));
$searchForm->addButtonSearch();
if ($searchForm->validate()) {
$firstname = $searchForm->getSubmitValue('firstname');
$lastname = $searchForm->getSubmitValue('lastname');
$userList = UserManager::getUserByName($firstname, $lastname);
if (empty($userList)) {
Display::addFlash(Display::return_message(get_lang('NoResults'), 'warning'));
header('Location: ' . api_get_self());
exit;
}
} elseif ($userId > 0) {
$userInfo = api_get_user_info($userId);
if (empty($userInfo)) {
Display::addFlash(Display::return_message(get_lang('NoUser'), 'warning'));
header('Location: ' . api_get_self());
exit;
}
$courseList = GradebookUtils::getUserCertificatesInCourses($userId, false);
示例10: header
$urlToRedirect .= http_build_query(['status' => BuyCoursesPlugin::SALE_STATUS_CANCELED, 'sale' => $sale['id']]);
break;
}
header("Location: {$urlToRedirect}");
exit;
}
$productTypes = $plugin->getProductTypes();
$saleStatuses = $plugin->getSaleStatuses();
$paymentTypes = $plugin->getPaymentTypes();
$selectedFilterType = '0';
$selectedStatus = isset($_GET['status']) ? $_GET['status'] : BuyCoursesPlugin::SALE_STATUS_PENDING;
$selectedSale = isset($_GET['sale']) ? intval($_GET['sale']) : 0;
$searchTerm = '';
$form = new FormValidator('search', 'get');
if ($form->validate()) {
$selectedFilterType = $form->getSubmitValue('filter_type');
$selectedStatus = $form->getSubmitValue('status');
$searchTerm = $form->getSubmitValue('user');
if ($selectedStatus === false) {
$selectedStatus = BuyCoursesPlugin::SALE_STATUS_PENDING;
}
if ($selectedFilterType === false) {
$selectedFilterType = '0';
}
}
$form->addRadio('filter_type', get_lang('Filter'), [$plugin->get_lang('ByStatus'), $plugin->get_lang('ByUser')]);
$form->addHtml('<div id="report-by-status" ' . ($selectedFilterType !== '0' ? 'style="display:none"' : '') . '>');
$form->addSelect('status', $plugin->get_lang('OrderStatus'), $saleStatuses);
$form->addHtml('</div>');
$form->addHtml('<div id="report-by-user" ' . ($selectedFilterType !== '1' ? 'style="display:none"' : '') . '>');
$form->addText('user', get_lang('UserName'), false);
示例11: isset
$help_name = isset($_GET['open']) ? Security::remove_XSS($_GET['open']) : null;
Display::display_header(get_lang('Faq'));
if (api_is_platform_admin()) {
echo ' <a href="faq.php?edit=true"><img src="' . api_get_path(WEB_IMG_PATH) . 'edit.png" /></a>';
}
echo Display::page_header(get_lang('Faq'));
$faq_file = 'faq.html';
if (!empty($_GET['edit']) && $_GET['edit'] == 'true' && api_is_platform_admin()) {
$form = new FormValidator('set_faq', 'post', 'faq.php?edit=true');
$form->addHtmlEditor('faq_content', null, false, false, array('ToolbarSet' => 'FAQ', 'Width' => '100%', 'Height' => '300'));
$form->addButtonSave(get_lang('Ok'), 'faq_submit');
$faq_content = @(string) file_get_contents(api_get_path(SYS_APP_PATH) . 'home/faq.html');
$faq_content = api_to_system_encoding($faq_content, api_detect_encoding(strip_tags($faq_content)));
$form->setDefaults(array('faq_content' => $faq_content));
if ($form->validate()) {
$content = $form->getSubmitValue('faq_content');
$fpath = api_get_path(SYS_APP_PATH) . 'home/' . $faq_file;
if (is_file($fpath) && is_writeable($fpath)) {
$fp = fopen(api_get_path(SYS_APP_PATH) . 'home/' . $faq_file, 'w');
fwrite($fp, $content);
fclose($fp);
} else {
Display::display_warning_message(get_lang('WarningFaqFileNonWriteable'));
}
echo $content;
} else {
$form->display();
}
} else {
$faq_content = @(string) file_get_contents(api_get_path(SYS_APP_PATH) . 'home/' . $faq_file);
$faq_content = api_to_system_encoding($faq_content, api_detect_encoding(strip_tags($faq_content)));
示例12: processAnswersCreation
/**
* abstract function which creates the form to create / edit the answers of the question
* @param FormValidator $form
*/
public function processAnswersCreation($form)
{
$questionWeighting = $nbrGoodAnswers = 0;
$objAnswer = new Answer($this->id);
$nb_answers = $form->getSubmitValue('nb_answers');
$options_count = $form->getSubmitValue('options_count');
$course_id = api_get_course_int_id();
$correct = array();
$options = Question::readQuestionOption($this->id, $course_id);
if (!empty($options)) {
foreach ($options as $option_data) {
$id = $option_data['id'];
unset($option_data['id']);
Question::updateQuestionOption($id, $option_data, $course_id);
}
} else {
for ($i = 1; $i <= 3; $i++) {
$last_id = Question::saveQuestionOption($this->id, $this->options[$i], $course_id, $i);
$correct[$i] = $last_id;
}
}
/* Getting quiz_question_options (true, false, doubt) because
it's possible that there are more options in the future */
$new_options = Question::readQuestionOption($this->id, $course_id);
$sorted_by_position = array();
foreach ($new_options as $item) {
$sorted_by_position[$item['position']] = $item;
}
/* Saving quiz_question.extra values that has the correct scores of
the true, false, doubt options registered in this format
XX:YY:ZZZ where XX is a float score value.*/
$extra_values = array();
for ($i = 1; $i <= 3; $i++) {
$score = trim($form->getSubmitValue('option[' . $i . ']'));
$extra_values[] = $score;
}
$this->setExtra(implode(':', $extra_values));
for ($i = 1; $i <= $nb_answers; $i++) {
$answer = trim($form->getSubmitValue('answer[' . $i . ']'));
$comment = trim($form->getSubmitValue('comment[' . $i . ']'));
$goodAnswer = trim($form->getSubmitValue('correct[' . $i . ']'));
if (empty($options)) {
//If this is the first time that the question is created when
// change the default values from the form 1 and 2 by the correct "option id" registered
$goodAnswer = $sorted_by_position[$goodAnswer]['id'];
}
$questionWeighting += $extra_values[0];
//By default 0 has the correct answers
$objAnswer->createAnswer($answer, $goodAnswer, $comment, '', $i);
}
// saves the answers into the data base
$objAnswer->save();
// sets the total weighting of the question
$this->updateWeighting($questionWeighting);
$this->save();
}
示例13: sprintf
} else {
$endDateInSeconds = $firstAccess + $duration * 24 * 60 * 60;
$last = api_convert_and_format_date($endDateInSeconds, DATE_FORMAT_SHORT);
$msg = sprintf(get_lang('FirstAccessWasXSessionDurationYEndDateWasZ'), $firstAccessString, $duration, $last);
}
}
$form->addElement('html', sprintf(get_lang('UserXSessionY'), $userInfo['complete_name'], $sessionInfo['name']));
$form->addElement('html', '<br>');
$form->addElement('html', $msg);
$form->addElement('text', 'duration', array(get_lang('ExtraDurationForUser'), null, get_lang('Days')));
$form->addElement('button', 'submit', get_lang('Send'));
if (empty($data['duration'])) {
$data['duration'] = 0;
}
$form->setDefaults($data);
$message = null;
if ($form->validate()) {
$duration = $form->getSubmitValue('duration');
// Only update if the duration is different from the default duration
if ($duration != 0) {
SessionManager::editUserSessionDuration($duration, $userId, $sessionId);
$message = Display::return_message(get_lang('ItemUpdated'), 'confirmation');
} else {
$message = Display::return_message(get_lang('DurationIsSameAsDefault'), 'warning');
}
}
// display the header
Display::display_header(get_lang('Edit'));
echo $message;
$form->display();
Display::display_footer();
示例14: processCreation
/**
* function which process the creation of questions
* @param FormValidator $form
* @param Exercise $objExercise
*/
public function processCreation($form, $objExercise = null)
{
$this->updateTitle($form->getSubmitValue('questionName'));
$this->updateDescription($form->getSubmitValue('questionDescription'));
$this->updateLevel($form->getSubmitValue('questionLevel'));
$this->updateCategory($form->getSubmitValue('questionCategory'));
//Save normal question if NOT media
if ($this->type != MEDIA_QUESTION) {
$this->save($objExercise->id);
// modify the exercise
$objExercise->addToList($this->id);
$objExercise->update_question_positions();
}
}
示例15: processAnswersCreation
/**
* abstract function which creates the form to create / edit the answers of the question
* @param FormValidator $form
*/
function processAnswersCreation($form)
{
global $charset;
$answer = $form->getSubmitValue('answer');
//remove the :: eventually written by the user
$answer = str_replace('::', '', $answer);
// get the blanks weightings
$nb = preg_match_all('/\\[[^\\]]*\\]/', $answer, $blanks);
if (isset($_GET['editQuestion'])) {
$this->weighting = 0;
}
if ($nb > 0) {
$answer .= '::';
for ($i = 0; $i < $nb; ++$i) {
$blankItem = $blanks[0][$i];
$replace = array("[", "]");
$newBlankItem = str_replace($replace, "", $blankItem);
$newBlankItem = "[" . trim($newBlankItem) . "]";
$answer = str_replace($blankItem, $newBlankItem, $answer);
$answer .= $form->getSubmitValue('weighting[' . $i . ']') . ',';
$this->weighting += $form->getSubmitValue('weighting[' . $i . ']');
}
$answer = api_substr($answer, 0, -1);
}
$is_multiple = $form->getSubmitValue('multiple_answer');
$answer .= '@' . $is_multiple;
$this->save();
$objAnswer = new answer($this->id);
$objAnswer->createAnswer($answer, 0, '', 0, '1');
$objAnswer->save();
}