Exemplo n.º 1
0
function getQuestionFromJson($testId)
{
    $data = [];
    $questions = [];
    $optionId = [];
    $solution = [];
    $query = "SELECT * FROM `test_info` WHERE `test_id` = {$testId}";
    foreach (select($query) as $value) {
        $data[] = json_decode($value['json']);
    }
    foreach ($data as $key => $ids) {
        foreach ($ids as $key => $id) {
            $optionId[$key] = $id;
            $questions[$key]['question'] = getQuestionById($key);
            $questions[$key]['alternatives'] = getQuestionAlternatives($key);
            $questions[$key]['correctOption'] = getCorrectOptions($key);
            $questions[$key]['solution'] = getSolutions($key);
        }
    }
    return array($optionId, $questions);
}
    if ($_POST['course_id'] == "") {
    }
    $_SESSION['edit_course_id'] = $_POST['course_id'];
}
if (isset($_SESSION['edit_course_id'])) {
    if (isset($_GET['question']) && ($_GET['question'] > 0 && $_GET['question'] < $numQ)) {
        $index = (int) $_GET['question'];
        $counter += $index;
        $questionId = editQuestionId($_SESSION['edit_course_id'], $index);
    } else {
        $questionId = editQuestionId($_SESSION['edit_course_id'], $index);
    }
    $currentCourse = getCourse($_SESSION['edit_course_id'])[0]['name'];
    $questions = getEditQuestion($questionId);
    $options = getQuestionOptions($questionId);
    $solution = getSolutions($questionId);
    //print_array( $solution);
}
?>

<!DOCTYPE html>
<html lang="eng">
   <head>
     <title>Edit questions</title>
     <link rel="stylesheet" type="text/css" href="css/bootstrap.css">
     <script type="text/javascript" src = "js/jquery-2.1.4.min.js"></script>
     <script type="text/javascript" src="js/bootstrap.min.js"></script>
     <link rel="stylesheet" type="text/css" href="css/summernote.css">
     <script type="text/javascript" src= "js/summernote.js"></script>
     <link rel="stylesheet" type="text/css" href="css/addquestions.css">
     <link rel="stylesheet" type="text/css" href="font-awesome/css/font-awesome.css">