ABC Test:

get_results("SELECT * FROM " . $wpdb->prefix . "abctest_main WHERE id_test = " . $_GET['parentid']); ?>

test_title ?>

test_text) ?>
get_results("SELECT * FROM " . $wpdb->prefix . "abctest_options WHERE id_test = " . $_GET['parentid'] . " ORDER BY options_order ASC"); if ( count($rslt) > 0 ) { $objRS = new Resultlist(); $objRS->ReorderMode = TRUE; $objRS->addFields('options_introduction', __('Introduction','abctest_lbl'), ''); $objRS->addFields('option_a', __('Answer A','abctest_lbl'), ''); $objRS->addFields('option_b', __('Answer B','abctest_lbl'), ''); $objRS->addFields('option_c', __('Answer C','abctest_lbl'), ''); // $arrHandlers = array('gestione opzioni' => 'admin.php?page=options&parentid'); $objRS->showResults($rslt, 'id_option', 'admin.php?page=options&parentid=' . $_GET['parentid'] . '&do=edit&id=', 'admin.php?page=options&parentid=' . $_GET['parentid'] . '&do=delete&id=', $arrHandlers); } else { printf('

%s

', __('No options available for selecting the quiz!','abctest_lbl')); } ?>
'; echo ''; echo ''; echo '

'; } public static function mainform($rows, $action) { $actions = array('' => '', 'insert' => '?page=options&parentid=' . $_GET['parentid'] . '&do=insert', 'edit' => '?page=options&parentid=' . $_GET['parentid'] . '&do=update'); ?>

«

options_introduction ),'options_introduction','options_introduction', true); ?>

prefix . "abctest_options"; $fields = self::dbfields(); $rows_affected = $wpdb->insert( $table_name, $fields ); if ($rows_affected > 0) { self::$message = __('Data were entered.','abctest_lbl'); self::$msgstatus = 'updated'; } else { self::$message = __('There was an error! Can not insert data.'); self::$msgstatus = 'error'; } return $rows_affected; } public static function edit() { global $wpdb; $sql = sprintf("SELECT * FROM %sabctest_options WHERE id_option = %d", $wpdb->prefix, $_GET['id']); $rslt = $wpdb->get_results($sql); self::mainform($rslt, $_GET['do']); } public static function update() { global $wpdb; $table_name = $wpdb->prefix . "abctest_options"; $fields = self::dbfields(); $rows_affected = $wpdb->update( $table_name, $fields, array('id_option' => $_POST['irecord']), NULL, array('%d') ); if ($rows_affected > 0) { self::$message = __('The data have been updated.','abctest_lbl'); self::$msgstatus = 'updated'; } else { self::$message = __('There was an error! Can not insert data.','abctest_lbl'); self::$msgstatus = 'error'; } return $rows_affected; } public static function delete() { global $wpdb; $sql = sprintf("DELETE FROM %sabctest_options WHERE id_option = %d", $wpdb->prefix, $_GET['id']); $wpdb->query($sql); self::$message = __('The data have been deleted.','abctest_lbl'); self::$msgstatus = 'updated'; // Implementare cancellazione immagine /* $deletefile = self::$uploadfolder . $_GET['file']; if ( file_exists( $deletefile ) ) { unlink($deletefile); } */ } public static function dbfields() { $arrFields = array('id_test' => $_GET['parentid'], 'options_introduction' => $_POST['options_introduction'], 'option_a' => $_POST['option_a'], 'option_b' => $_POST['option_b'], 'option_c' => $_POST['option_c']); //'bgimage' => $_FILES['bgimage']['name'], /* $upfile = self::upload(); if ( ! empty($upfile) ) { $fup = array("bgimage" => $upfile); $arrFields = array_merge((array) $arrFields, (array) $fup); } */ return $arrFields; } public static function reorder() { global $wpdb; $table_name = $wpdb->prefix . "abctest_options"; $arrItems = $_POST['recordorder']; for ($j = 0; $j < count($arrItems); $j++ ) { $SQLupdate = " UPDATE $table_name SET options_order = " . ($j + 1) . " WHERE id_option = " . $arrItems[$j]; $wpdb->query($SQLupdate); } self::$message = __("The order of the data was stored.",'abctest_lbl'); self::$msgstatus = 'updated'; } } // end abcTestOptions ?>