Skip to content

Commit c613455

Browse files
committed
Now I'm showing questions
1 parent a919e2c commit c613455

File tree

6 files changed

+30
-28
lines changed

6 files changed

+30
-28
lines changed
File renamed without changes.

Files/quiz.html

+21-14
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
var xhttp = new XMLHttpRequest();
105105
xhttp.onreadystatechange = function() {
106106
if (this.readyState == 4 && this.status == 200) {
107-
if (parseInt(this.responseText) > 0) {
107+
if (parseInt(this.responseText) >= 0) {
108108
get_question();
109109
}
110110
}
@@ -113,6 +113,7 @@
113113
xhttp.send();
114114
}
115115

116+
116117
function get_question() {
117118
var xhttp = new XMLHttpRequest();
118119
xhttp.onreadystatechange = function() {
@@ -121,18 +122,19 @@
121122
xmlDoc = parser.parseFromString(this.responseText,
122123
"text/xml");
123124
document.getElementById("question_title").innerHTML =
124-
xmlDoc.getElementsByTagName("Question")[0].childNodes[1].nodeValue;
125-
var questionsID = ["A_answer", "B_answer", "B_answer", "B_answer"];
125+
xmlDoc.getElementsByTagName("Question")[0].childNodes[1].firstChild.nodeValue;
126+
127+
var questionsID = ["A_answer", "B_answer", "C_answer", "D_answer"];
126128
for (i = 0; i < 4; i++) {
127129
document.getElementById(questionsID[i]).innerHTML =
128-
xmlDoc.getElementsByTagName("Answer")[i].childNodes[1].nodeValue;
130+
xmlDoc.getElementsByTagName("Answer")[i].childNodes[1].firstChild.nodeValue;
129131
}
130132
state = "Question";
131133
changeDiv2();
132134
}
133135

134136
};
135-
xmlDoc.xhttp.open("GET", "get_question", false);
137+
xhttp.open("GET", "get_question", true);
136138
xhttp.send();
137139
}
138140

@@ -141,7 +143,7 @@
141143

142144
<body onload="setInnerHTML('get_join_number', 'join_number');">
143145
<center>
144-
<div id="part1">
146+
<div id="part1" style="display:inline">
145147
<font size="7">Now you can join the Game!<br /></font>
146148
<font size="7" id="join_number"></font>
147149
<p id="br1">
@@ -161,27 +163,32 @@
161163
<font size="4" id="number_questions">
162164
</font>
163165
</div>
164-
<p id="part3" style="display:none">
165-
<div id="question_title"></div>
166-
<table style="width:100%">
166+
<div id="part3" style="display:none">
167+
<p id="question_title">
168+
</p>
169+
<table style="width:0%">
167170
<tr>
168171
<td>
169-
<div id="A_answer"></div>
172+
<p id="A_answer">
173+
</p>
170174
</td>
171175
<td>
172-
<div id="B_answer"></div>
176+
<p id="B_answer">
177+
</p>
173178
</td>
174179
</tr>
175180
<tr>
176181
<td>
177-
<div id="C_answer"></div>
182+
<p id="C_answer">
183+
</p>
178184
</td>
179185
<td>
180-
<div id="D_answer"></div>
186+
<p id="D_answer">
187+
</p>
181188
</td>
182189
</tr>
183190
</table>
184-
</p>
191+
</div>
185192
</center>
186193
</body>
187194

Quizes/test.xml

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,26 @@
44
<Question duration="30">
55
<Text><![CDATA[
66
<font size="7">1+1</font><br />
7-
<img src="questineer-pics/test/2.jpg"/>
7+
<img src="questineer-pics/test/2.png" style="width:304px;height:228px;"/>
88
]]></Text>
99
<Answer>
1010
<Text><![CDATA[
11-
<font size = "4">1</font>
11+
<font size = "5">A: 1</font>
1212
]]></Text>
1313
</Answer>
1414
<Answer correct="1">
1515
<Text><![CDATA[
16-
<font size = "4">2</font>
16+
<font size = "5">B: 2</font>
1717
]]></Text>
1818
</Answer>
1919
<Answer>
2020
<Text><![CDATA[
21-
<font size = "4">3</font>
21+
<font size = "5">C: 3</font>
2222
]]></Text>
2323
</Answer>
2424
<Answer>
2525
<Text><![CDATA[
26-
<font size = "4">4</font>
26+
<font size = "5">D: 4</font>
2727
]]></Text>
2828
</Answer>
2929
</Question>

game.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ def set_time_change(self, new_time):
3939
self._change_timer = time.time() + new_time
4040

4141
def check_timer_change(self):
42-
print self._change_timer - time.time()
43-
print self._change_timer - time.time() < 0
4442
return self._change_timer - time.time() < 0
4543

4644

@@ -56,7 +54,6 @@ def __init__(self, quiz_name, common):
5654
join_number = random.randint(constants.MIN_PID, constants.MAX_PID)
5755
if join_number not in common.join_number.keys():
5856
break
59-
print join_number
6057
self._join_number = join_number
6158

6259
def add_player(self, new_pid, game_player):
@@ -98,7 +95,7 @@ def get_question(self):
9895
return self._parser.get_xml_question()
9996

10097
def move_to_next_question(self):
101-
self._parser.moved_to_next_question()
98+
self._parser.move_to_next_question()
10299

103100
def get_left_questions(self):
104101
return self._parser.get_left_questions()

services.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,6 @@ def __init__(self, game):
299299
self._game = game
300300

301301
def content(self):
302-
print self._game
303-
print self._game._move_to_next_page
304302
return str(self._game.get_move_to_next_page())
305303

306304

@@ -310,6 +308,7 @@ class move_to_next_question(TXTService):
310308
def __init__(self, game):
311309
super(move_to_next_question, self).__init__()
312310
self._game = game
311+
game.move_to_next_question()
313312

314313
def content(self):
315314
return str(self._game.get_left_questions())

xmlparser.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ class XMLParser(object):
88

99
def __init__(self, file_name):
1010
test_file("%s.xml" % file_name, "PyHoot\Quizes")
11-
self.file_name = file_name
1211
self._root = ElementTree.parse(
1312
"PyHoot\Quizes\%s.xml" % file_name).getroot()
1413
self.question_number = 0 # 0 Represent the starting page
@@ -24,7 +23,8 @@ def get_left_questions(self):
2423
)
2524

2625
def get_information(self):
27-
backup_root = self._root
26+
backup_root = ElementTree.parse(
27+
"PyHoot\Quizes\%s.xml" % self.file_name).getroot()
2828
for question in backup_root.findall("./Quiz/Question"):
2929
backup_root.find("./Quiz").remove(question)
3030
return ElementTree.tostring(backup_root, encoding=constants.ENCODING)
@@ -55,7 +55,6 @@ def move_to_next_question(self):
5555
def test_file(filename, base="."):
5656
"""Making sure everything is OK with the file before we start usings it
5757
"""
58-
# TODO: finish this
5958
root = ElementTree.parse(
6059
os.path.normpath(os.path.join(base, filename))
6160
)

0 commit comments

Comments
 (0)