-
Notifications
You must be signed in to change notification settings - Fork 0
/
view_question.php
executable file
·93 lines (76 loc) · 3.19 KB
/
view_question.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php // $Id: view_question.php,v 1.0 2010/05/28 09:26:00
/**
* This page prints a particular instance of decisiontree
*
* @author Andre Scherl
* @version $Id: view_question.php,v 1.0 2010/05/28 09:26:00
* @package decisiontree
*
* Copyright (C) 2011, Andre Scherl
* You should have received a copy of the GNU General Public License
* along with DASIS. If not, see <http://www.gnu.org/licenses/>.
*/
require_once("../../config.php");
require_once("lib.php");
global $DB;
$id = optional_param('id', 0, PARAM_INT); // Question ID
$did = optional_param('did', 0, PARAM_INT); // decisiontree ID
if ($id) {
if (! $question = $DB->get_record("decisiontree_questions", array("id" => $id))) {
error("Question ID is not set");
}
if (! $decisiontree = $DB->get_record("decisiontree", array("id" => $question->decisiontree_id))) {
error("Decision Tree ID in Question Record is incorrect");
}
if (! $course = $DB->get_record("course", array("id" => $decisiontree->course))) {
error("Course is misconfigured");
}
if (! $cm = get_coursemodule_from_instance("decisiontree", $decisiontree->id, $course->id)) {
error("Course Module ID was incorrect");
}
} else {
if (! $decisiontree = $DB->get_record("decisiontree", array("id" => $did))) {
print_error("Course module is incorrect");
}
if (! $course = $DB->get_record("course", array("id" => $decisiontree->course))) {
print_error("Course is misconfigured");
}
if (! $cm = get_coursemodule_from_instance("decisiontree", $decisiontree->id, $course->id)) {
print_error("Course Module ID was incorrect");
}
if (! $question = $DB->get_record("decisiontree_questions", array("root" => 1, "decisiontree_id" => $decisiontree->id))) {
redirect("edit_question.php?did={$decisiontree->id}");
print_error("No Question ID set AND no existing root question");
}
}
require_login($course->id);
add_to_log($course->id, "decisiontree", "view", "view.php?id={$cm->id}", $decisiontree->id);
/// Print the page header
$strdecisiontrees = get_string("modulenameplural", "decisiontree");
$strdecisiontree = get_string("modulename", "decisiontree");
$PAGE->set_pagelayout("standard");
echo $OUTPUT->header();
/// Print the main part of the page
require_once("answer_options_form.php");
// das muss noch eleganter mit dem header-bearbeiten-button gelöst werden
if($question->id){
print("<a href=edit_question.php?id=$question->id>Frage bearbeiten</a>");
}
if($question){
$OUTPUT->box_start();
// print answer options form (with question text)
$answerOptions = new answer_options_form("calculate_question.php");
$answerOptions->set_data(array("id" => $question->id,
"title" => $question->title,
"decisiontree_id" => $decisiontree->id));
$answerOptions->display();
$OUTPUT->box_end();
}else{
p("no question found: ");
}
if($question->root) {
$SESSION->userpath = "";
}
/// Finish the page
echo $OUTPUT->footer();
?>