コード例 #1
0
if (!$updater_utils->has_updated('labelling_search')) {
    $select_sql = 'SELECT q_id, correct FROM questions, options WHERE questions.q_id = options.o_id AND q_type = "labelling"';
    $result = $mysqli->prepare($select_sql);
    $result->execute();
    $result->store_result();
    $result->bind_result($q_id, $correct);
    while ($result->fetch()) {
        $first_split = explode(';', $correct);
        $option_text = '';
        if (isset($first_split[11])) {
            $s_split = explode('|', $first_split[11]);
            foreach ($s_split as $ind_label) {
                $label_parts = explode('$', $ind_label);
                if (isset($label_parts[4]) and trim($label_parts[4]) != '') {
                    $option_text .= ',' . $label_parts[4];
                }
            }
            update_question($q_id, $option_text, $mysqli);
        }
    }
    $result->close();
    $updater_utils->record_update('labelling_search');
}
function update_question($q_id, $option_text, $db)
{
    $select_sql = 'UPDATE options SET option_text = ? WHERE o_id = ?';
    $result = $db->prepare($select_sql);
    $result->bind_param('si', $option_text, $q_id);
    $result->execute();
    $result->close();
}
コード例 #2
0
    $choice_4 = $_POST['choice_4'];
    //$choices=array();
    //print_r($_POST);
    if ($correct == 1) {
        $correct = $choice_1;
    }
    if ($correct == 2) {
        $correct = $choice_2;
    }
    if ($correct == 3) {
        $correct = $choice_3;
    }
    if ($correct == 4) {
        $correct = $choice_4;
    }
    update_question($content, $correct, $question_id);
    update_choice($choices_id[0], $choice_1, $question_id);
    update_choice($choices_id[1], $choice_2, $question_id);
    update_choice($choices_id[2], $choice_3, $question_id);
    update_choice($choices_id[3], $choice_4, $question_id);
    redirect_to('edit.php?edit=' . $_GET['qid']);
    //add_question($content,$correct,$choice_1,$choice_2,$choice_3,$choice_4);
    //array_push($choices, $choice1,$choice2,$choice3,$choice4);
    //print_r($choices);
}
?>

<div class="container">