Орла
Области
Компаний
Пользователи
Галерея
Фиксированные новости
Орла
Отзывы о фирмах
Тарифы
Пользователи
Области
Банкоматы
Торговые точки
Доска объявлений
Курсы валют
Скидки
организации Орла
организации области
товары
сайты
сайты Орел
Данные
Разделы
Поиск
Поиск запросы
Статистика
Показы каталога организаций
Статистика клиенты
Пользователи
Сайты
Управление сайтом
Анкета
Аптеки
Афиша
Афиша новая
Баннеры
Бизнес >
Викторина
Голосование
Гость на сайте
Истории
Календарь событий
Каталоги >
Конкурс красоты
Конкурс аудио
Консультации
Меню
Новое на сайте
Новости >
Организации >
Программа ТВ
Публикации
Разделы сайта
Рассылка
Рестораны
Секрет фирмы >
Сервисы >
Ссылки
Тесты
Файловый менеджер
Форум
Фотогалерея
Обратная связь
Недвижимость
Новый год
Тексты
Пользователи
Юридический рейтинг
Отзывы на товары
Бан пользователей
Жалобы
Новые тесты
Коронавирус
Файловый менеджер
Имя файла
edit_question.php
Содержимое
<?php /** * Новые тесты на сайте инфоорел * @since infoorel 3.0 */ $base_url="../"; $title="Тесты"; require($base_url."inc/top.inc.php"); function getValue(array $from, $key, $defaultValue = null) { if (isset($from[$key])) { return $from[$key]; } return $defaultValue; } $question = []; $answers = []; if (isset($_GET['id'])) { $question = sqlval(' SELECT * FROM `tests_questions` WHERE id = '.(int)$_GET['id'].' '); $answers = fetchAll(' SELECT * FROM `tests_question_answer_variants` WHERE test_question_id = '.(int)$_GET['id'].' '); } if (count($_POST) > 0) { if (isset($_POST['id']) == false) { sql(' INSERT INTO tests_questions(test_id, title, text) VALUES('.$_POST['test_id'].', "'.$_POST['question_title'].'", "'.$_POST['question_text'].'") '); $id = mysql_insert_id(); } else { $sql = ''; if (isset($_POST['question_delete_photo']) && $_POST['question_delete_photo'] == 1) { $sql = 'photo=NULL,'; } sql(' update tests_questions SET test_id = '.$_POST['test_id'].', '.$sql.' title = "'.mysql_real_escape_string($_POST['question_title']).'", text = "'.mysql_real_escape_string($_POST['question_text']).'" WHERE id = '.$_POST['id'].' '); $id = $_POST['id']; } // загрузка изображения для вопроса if (isset($_FILES['question_photo']['tmp_name']) && file_exists($_FILES['question_photo']['tmp_name'])) { $photo = upload_foto_tovar($_FILES['question_photo']['tmp_name'],930,1200,1,1,$base_url."../user_foto/tests"); sql(' UPDATE tests_questions SET photo = "'.$photo.'" WHERE id = '.$id.' '); } // sql(' // DELETE tests_question_answer_variants // WHERE test_question_id = '.$id.' // '); //сохраняем список вариантов ответов foreach ($_POST['question_variants']['title'] as $key => $variant) { $title = $_POST['question_variants']['title'][$key]; $text = $_POST['question_variants']['text'][$key]; $ball = $_POST['question_variants']['ball'][$key]; $file = $_FILES['question_variants']['tmp_name']['photo'][$key]; $questionVariantId = $_POST['question_variants']['id'][$key]; $photo = null; if (file_exists($file)) { $photo = upload_foto_tovar($file,930,1200,1,1,$base_url."../user_foto/tests"); } if ($questionVariantId > 0) { if (isset($_POST['question_variants']['delete'][$questionVariantId]) && $_POST['question_variants']['delete'][$questionVariantId] == 1) { sql(' DELETE FROM tests_question_answer_variants WHERE id = '.(int)$questionVariantId.' '); } else { $sql = ''; if (isset($_POST['question_variants']['delete_photo'][$questionVariantId]) == 1) { $sql = 'photo="",'; } sql(' UPDATE `tests_question_answer_variants` SET title = "' . mysql_real_escape_string($title) . '", text = "' . mysql_real_escape_string($text) . '", ' . $sql . ' ball = "' . (int)$ball . '" WHERE id = ' . $questionVariantId . ' '); if ($photo != null) { sql(' UPDATE tests_question_answer_variants SET photo = "' . $photo . '" WHERE id = ' . $questionVariantId . ' '); } } } else { sql(' INSERT INTO `tests_question_answer_variants` (test_question_id, title, `text`, photo, ball) VALUES( "'.$id.'", "'.mysql_real_escape_string($title).'", "'.mysql_real_escape_string($text).'", "'.$photo.'", "'.(int)$ball.'" ) '); } } echo ' <script type="text/javascript"> location.href="edit_questions.php?id='.$_POST['test_id'].'" </script> '; } ?> <style type="text/css"> .input-100 { width: 100%; } .jq-variants-table { margin: 10px; width: 95%; background: #d9eaff !important; padding: 0 !important; border-collapse: collapse !important; } .jq-variants-table tr { margin: 0 !important; padding: 0 !important; } .jq-variants-table td { background: #d9eaff; border: 1px solid #1f4a80; margin: 0 !important; padding: 5px !important; vertical-align: top !important;; } </style> <form action="edit_question.php" method="post" enctype="multipart/form-data"> <?php if (isset($_GET['id'])) { ?> <input type="hidden" name="id" value="<?=$_GET['id'];?>"> <?php } ?> <input type="hidden" name="test_id" value="<?=$_GET['test_id'];?>"> <?php $answerItem = ' <tr bgcolor="#ffffff"> <td style="width: 60%"> <input type="text" value="" name="question_variants[title][]" class="input-100" placeholder="Вариант ответа"><br><br> <textarea name="question_variants[text][]" class="input-100" style="height: 100px;" placeholder="Описание ответа (если требуется)"></textarea> </td> <td><input type="file" name="question_variants[photo][]"></td> <td> <input type="number" name="question_variants[ball][]" placeholder="Балл" style="width: 75px"> <input type="hidden" name="question_variants[id][]" value=""> </td> <td> <button type="button" class="jq-variant-delete">Удалить</button> </td> </tr> '; ?> <div class="jq-questions-list"> <table width="95%" border="0" cellspacing="0" cellpadding="0" align="center" class="table_border"> <tr> <td> <table width="100%" border="0" cellspacing="1" cellpadding="2"> <tbody> <tr bgcolor="#ffffff"> <td>Название вопроса</td> <td> <input type="text" value="<?=getValue($question, 'title');?>" name="question_title" class="input-100"> </td> </tr> <tr bgcolor="#ffffff"> <td>Описание вопроса (если требуется)</td> <td> <textarea style="height: 150px; width: 100%" placeholder="Вывод этого поля зависит от конкретной верстки" name="question_text"><?=getValue($question, 'text');?></textarea> </td> </tr> <tr bgcolor="#ffffff"> <td>Изображение</td> <td> <input type="file" name="question_photo"> <?php if (isset($question['photo']) && $question['photo'] != '') { ?> <div> <img src="/user_foto/tests/<?=$question['photo'];?>" style="width: 100px"> <br> <input type="checkbox" name="question_delete_photo" value="1"> Удалить? </div> <?php } ?> </td> </tr> <tr bgcolor="#ffffff"> <td colspan="2" style="text-align: center"><strong>Ответы</strong></td> </tr> <tr bgcolor="#ffffff"> <td colspan="2"> <table class="jq-variants-table" cellpadding="0" cellspacing="0"> <tbody> <?php foreach ($answers as $answer) { ?> <tr bgcolor="#ffffff"> <td style="width: 60%"> <input type="text" value="<?=$answer['title'];?>" name="question_variants[title][]" class="input-100" placeholder="Вариант ответа"><br><br> <textarea name="question_variants[text][]" class="input-100" style="height: 100px;" placeholder="Описание ответа (если требуется)"><?=$answer['text'];?></textarea> </td> <td> <input type="file" name="question_variants[photo][]"> <?php if (isset($answer['photo']) && $answer['photo'] != '') { ?> <img src="/user_foto/tests/<?=$answer['photo'];?>" style="width: 100px"> <br> <label> <input type="checkbox" name="question_variants[delete_photo][<?=$answer['id'];?>]" value="1"> Удалить </label> <?php } ?> </td> <td> <input type="number" name="question_variants[ball][]" value="<?=$answer['ball'];?>" placeholder="Балл" style="width: 75px"> <input type="hidden" name="question_variants[id][]" value="<?=$answer['id'];?>"> </td> <td> <label> <input type="checkbox" name="question_variants[delete][<?=$answer['id'];?>]" value="1"> Удалить </label> </td> </tr> <?php } ?> </tbody> </table> </td> </tr> <tr bgcolor="#ffffff"> <td colspan="2"> <button type="button" class="jq-add-new-answer">Добавить новый ответ</button> </td> </tr> </tbody> </table> </td> </tr> </table> </div> <div style="margin-top: 20px; margin-left:50px;"> <button type="submit">Сохранить</button> </div> </form> <script type="text/template" id="answer-template-item"> <?=$answerItem;?> </script> <script type="text/javascript"> var answerItemTemplate = $('#answer-template-item').html(); var questionFinishTemplate = $('#question-result-template-item').html(); $(document).on('click', '.jq-add-new-answer', function(e) { var $container = $(this).parent().parent().parent().find('.jq-variants-table tbody'); $container.append(answerItemTemplate); }); $(document).on('click', '.jq-variant-delete', function(e) { $(this).parent().parent().remove(); }); $('.jq-add-new-question-finish').on('click', function(e) { $('.jq-question-after').before(questionFinishTemplate); }); </script> <?php require($base_url."inc/bottom.inc.php"); ?>
/admin/tests_new/
Имя
Дата
Размер
..
2026-10-02
delete.php
2017-07-06
692 байт
delete_question.php
2017-07-20
505 байт
delete_result.php
2017-07-06
347 байт
edit_question.php
2017-07-06
12 кб.
edit_questions.php
2017-07-06
3 кб.
edit_result.php
2018-02-28
5 кб.
edit_results.php
2017-07-06
4 кб.
edit_test.php
2020-02-26
7 кб.
index.php
2021-07-29
4 кб.
index.php~
2017-07-10
4 кб.
/admin/tests_new
Загрузить файлы
Файл 1
Файл 2
Файл 3