예제 #1
0
<?php

/**
 * Delete question action
 */
// Get input data
$guid = (int) get_input('question_id');
// Make sure we actually have permission to edit
$question = get_entity($guid);
if ($question->getSubtype() == "question" && $question->canEdit()) {
    $owner = get_entity($question->getOwnerGUID());
    // delete related answers first
    $answers = get_question_answers($question);
    if ($answers && is_array($answers)) {
        foreach ($answers as $answer) {
            $answer->delete();
        }
    }
    // Delete it!
    $rowsaffected = $question->delete();
    if ($rowsaffected > 0) {
        system_message(elgg_echo("answers:question:deleted"));
    } else {
        register_error(elgg_echo("answers:question:notdeleted"));
    }
    forward("answers/owner/" . $owner->username);
}
예제 #2
0
if ($_SESSION["get_query"] != "") {
    $redirect_url = "manage-questions.php?" . $_SESSION["get_query"];
} else {
    $redirect_url = "manage-questions.php";
}
?>

<?php 
include '../includes/layouts/header.php';
$cat = get_all_category();
$id = isset($_REQUEST["question_id"]) ? $_REQUEST["question_id"] : "";
$question = get_question_by_id($id);
if (!$question) {
    redirect_to($redirect_url);
}
$answer_set = get_question_answers($id);
?>

<?php 
// Temporary hack to simulate logged in user
if (isset($_POST['submit-edit-mc-question'])) {
    // The Edit Multiple Choice Question Form was submitted
    // Validate Edit Multiple Choice Question Form inputs
    $fields_required = array("question_text", "answer1", "answer2", "answer3", "answer4");
    foreach ($fields_required as $field) {
        $value = trim($_POST[$field]);
        if (!has_presence($value)) {
            $error_messages[$field] = ucfirst($field) . " is required.";
        }
    }
    // If there were errors, redirect back to the form.
예제 #3
0
            <table class="table table-bordered table-hover table-striped tablesorter">
              <thead>
                <tr>
                  
                  <th>ID</i></th>
                  <th>Question Text <i class="fa fa-sort"></i></th>
                  <th>Category</th>
                </tr>
              </thead>
              <tbody id="user-rows">     

              <?php 
$cnt = 0;
while ($row = mysqli_fetch_assoc($questions_list)) {
    $cnt++;
    $answer_set = get_question_answers($row['question_id']);
    $disabled = $active == 0 ? ' disabled="disabled"' : '';
    $ans_html = '<div style="padding-left:40px;">';
    $checked = isset($question_data[$row['question_id']]) && $question_data[$row['question_id']] == $answer_set[0]['answer_id'] ? " checked='checked'" : "";
    $fontClass = "";
    $fontClass .= $checked != '' ? "your-ans" : "";
    $fontClass .= $active == 0 && @$answer_data[$row['question_id']] == $answer_set[0]['answer_id'] ? " correct" : "";
    $ans_html .= '<input type="radio" name="question_' . $row['question_id'] . '" value="' . $answer_set[0]['answer_id'] . '" ' . $checked . ' ' . $disabled . '> <span class="' . $fontClass . '">' . $answer_set[0]["answer_text"] . '</span><br>';
    $checked = isset($question_data[$row['question_id']]) && $question_data[$row['question_id']] == $answer_set[1]['answer_id'] ? " checked='checked'" : "";
    $fontClass = "";
    $fontClass .= $checked != '' ? "your-ans" : "";
    $fontClass .= $active == 0 && @$answer_data[$row['question_id']] == $answer_set[1]['answer_id'] ? " correct" : "";
    $ans_html .= '<input type="radio" name="question_' . $row['question_id'] . '" value="' . $answer_set[1]['answer_id'] . '" ' . $checked . '' . $disabled . '> <span class="' . $fontClass . '">' . $answer_set[1]["answer_text"] . '</span><br>';
    $checked = isset($question_data[$row['question_id']]) && $question_data[$row['question_id']] == $answer_set[2]['answer_id'] ? " checked='checked'" : "";
    $fontClass = "";
    $fontClass .= $checked != '' ? "your-ans" : "";
예제 #4
0
function get_sorted_question_answers($question)
{
    $unsorted_answers = get_question_answers($question);
    $unsorted_ratings = array();
    $unsorted_dates = array();
    foreach ($unsorted_answers as $answer) {
        $unsorted_ratings[] = answers_overall_rating($answer);
        $unsorted_dates[] = $answer->time_created;
    }
    array_multisort($unsorted_ratings, SORT_DESC, $unsorted_dates, SORT_ASC, $unsorted_answers);
    return $unsorted_answers;
}