質問編集履歴
6
test
CHANGED
File without changes
|
test
CHANGED
@@ -19,483 +19,3 @@
|
|
19
19
|
もしくは一般的なクイズサイトで正答数を記録している方法や、そういった事を紹介しているサイトなどがあれば
|
20
20
|
|
21
21
|
教えていただけると助かります。
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
```php
|
28
|
-
|
29
|
-
```
|
30
|
-
|
31
|
-
<?php
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
session_start();
|
36
|
-
|
37
|
-
//2回目以降の処理------------------------------------------------------
|
38
|
-
|
39
|
-
if($_SERVER["REQUEST_METHOD"]=="POST"){
|
40
|
-
|
41
|
-
// 訪問回数カウント用の変数$countにカウント値を格納----------------------------------------------------------
|
42
|
-
|
43
|
-
$count = $_SESSION["count"];
|
44
|
-
|
45
|
-
$count++; // カウント値+1
|
46
|
-
|
47
|
-
$_SESSION["count"] = $count;// 有効期限なしのクッキーを設定
|
48
|
-
|
49
|
-
}else{
|
50
|
-
|
51
|
-
$_SESSION["count"] = $count = 1;//
|
52
|
-
|
53
|
-
}
|
54
|
-
|
55
|
-
if($count >= 6){
|
56
|
-
|
57
|
-
$_SESSION["count"] = 0;//カウントをリセット
|
58
|
-
|
59
|
-
header("location: result.php");
|
60
|
-
|
61
|
-
echo "全問終了リザルトへ";//予定ではresultページに遷移
|
62
|
-
|
63
|
-
}
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
include('../setdb/selectTable.php');
|
68
|
-
|
69
|
-
$_SESSION["right"] = $right;//正解を格納
|
70
|
-
|
71
|
-
?>
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
<!DOCTYPE html>
|
76
|
-
|
77
|
-
<html lang="ja">
|
78
|
-
|
79
|
-
<head>
|
80
|
-
|
81
|
-
<meta charset="UTF-8">
|
82
|
-
|
83
|
-
<title>ボックスの例</title>
|
84
|
-
|
85
|
-
<link rel="stylesheet" href="../css/gameScreen.css">
|
86
|
-
|
87
|
-
<link href="https://fonts.googleapis.com/css?family=M+PLUS+Rounded+1c" rel="stylesheet">
|
88
|
-
|
89
|
-
<script src="../js/three.min.js"></script>
|
90
|
-
|
91
|
-
<script src="../js/jquery-3.3.1.min.js"></script>
|
92
|
-
|
93
|
-
<audio id="overSound" preload="auto"><!-- 音声の読み込み -->
|
94
|
-
|
95
|
-
<source src="../music/cursor1.mp3" type="audio/mp3">
|
96
|
-
|
97
|
-
</audio>
|
98
|
-
|
99
|
-
<script>
|
100
|
-
|
101
|
-
//===回答後の処理=====================================================
|
102
|
-
|
103
|
-
$(document).ready(function(){
|
104
|
-
|
105
|
-
var form = $( 'form' );
|
106
|
-
|
107
|
-
//選択肢の画像クリックした場合
|
108
|
-
|
109
|
-
$(".ans").click(function (e) {
|
110
|
-
|
111
|
-
//クリックされた画像のnameの値を代入
|
112
|
-
|
113
|
-
var ansName = $(this).attr("name");
|
114
|
-
|
115
|
-
// フォームの値を設定
|
116
|
-
|
117
|
-
if(ansName == "<?php echo $_SESSION["right"]; ?>"){
|
118
|
-
|
119
|
-
//正解の表示
|
120
|
-
|
121
|
-
$('#success').css('z-index','4');
|
122
|
-
|
123
|
-
}else{
|
124
|
-
|
125
|
-
//不正解の表示
|
126
|
-
|
127
|
-
$('#miss').css('z-index','4');
|
128
|
-
|
129
|
-
}
|
130
|
-
|
131
|
-
// ------- 一旦 submit を止める success missの表示時間 -------------------------------------------------------------
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
e.preventDefault();
|
136
|
-
|
137
|
-
// submit を遅らせて実行
|
138
|
-
|
139
|
-
setTimeout( function() {
|
140
|
-
|
141
|
-
form.off( 'submit' );
|
142
|
-
|
143
|
-
form.submit();
|
144
|
-
|
145
|
-
//正解不正解の表示時間
|
146
|
-
|
147
|
-
}, 750 );
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
//正解数をカウント---------------------------result画面で削除------------
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
//正解までの時間をカウント
|
156
|
-
|
157
|
-
});
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
});
|
162
|
-
|
163
|
-
</script>
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
<script>
|
168
|
-
|
169
|
-
//選択肢にカーソル合わせた時に効果音を再生----------------------
|
170
|
-
|
171
|
-
$(function(){
|
172
|
-
|
173
|
-
$('.mouseon').mouseover(function(){
|
174
|
-
|
175
|
-
document.getElementById("overSound").currentTime = 0;
|
176
|
-
|
177
|
-
document.getElementById("overSound").play();
|
178
|
-
|
179
|
-
});
|
180
|
-
|
181
|
-
});
|
182
|
-
|
183
|
-
</script>
|
184
|
-
|
185
|
-
<script>
|
186
|
-
|
187
|
-
//画像の読み込み---------------------------------
|
188
|
-
|
189
|
-
var wrong1 = "<?php echo $wrong1; ?>";
|
190
|
-
|
191
|
-
var wrong2 = "<?php echo $wrong2; ?>";
|
192
|
-
|
193
|
-
var wrong3 = "<?php echo $wrong3; ?>";
|
194
|
-
|
195
|
-
var wrong4 = "<?php echo $wrong4; ?>";
|
196
|
-
|
197
|
-
var wrong5 = "<?php echo $wrong5; ?>";
|
198
|
-
|
199
|
-
var wrong6 = "<?php echo $wrong6; ?>";
|
200
|
-
|
201
|
-
console.log(wrong1);
|
202
|
-
|
203
|
-
</script>
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
<script>
|
208
|
-
|
209
|
-
// ページの読み込みを待つ
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
window.addEventListener('load', init);
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
function init() {
|
218
|
-
|
219
|
-
//============ 表示サイズを指定 ======================
|
220
|
-
|
221
|
-
const width = 480;
|
222
|
-
|
223
|
-
const height = 480;
|
224
|
-
|
225
|
-
// レンダラーを作成
|
226
|
-
|
227
|
-
const renderer = new THREE.WebGLRenderer({
|
228
|
-
|
229
|
-
canvas: document.querySelector('#myCanvas')
|
230
|
-
|
231
|
-
});
|
232
|
-
|
233
|
-
renderer.setSize(width, height);
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
//============ シーンを作成 ===========================
|
238
|
-
|
239
|
-
const scene = new THREE.Scene();
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
//============ カメラを作成 ===========================
|
244
|
-
|
245
|
-
const camera = new THREE.PerspectiveCamera(45, width / height);
|
246
|
-
|
247
|
-
camera.position.set(0, -50, +800);//x,y
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
//=============== モデリング ===========================
|
252
|
-
|
253
|
-
//立方体を作成
|
254
|
-
|
255
|
-
const geometry = new THREE.BoxBufferGeometry( 200, 200, 200 );
|
256
|
-
|
257
|
-
// const geometry = new THREE.BoxGeometry( 200, 200, 200, 1, 1, 1);
|
258
|
-
|
259
|
-
//cube = new THREE.CubeGeometry(1, 1, 1);
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
// 球体を作成
|
264
|
-
|
265
|
-
//const geometry = new THREE.SphereGeometry(300, 30, 30);
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
// 画像を読み込む テクスチャ1個に対して1回ずつlorderを呼ぶ必要がある このやり方は問題ない
|
270
|
-
|
271
|
-
//ここで読み込むデータをデータベースから取得したランダムなものに変える
|
272
|
-
|
273
|
-
var loader = new THREE.TextureLoader();
|
274
|
-
|
275
|
-
console.log(wrong1);
|
276
|
-
|
277
|
-
var texture1 = loader.load("../imgs/" + wrong1);
|
278
|
-
|
279
|
-
var texture2 = loader.load("../imgs/" + wrong2);
|
280
|
-
|
281
|
-
var texture3 = loader.load("../imgs/" + wrong3);
|
282
|
-
|
283
|
-
var texture4 = loader.load("../imgs/" + wrong4);
|
284
|
-
|
285
|
-
var texture5 = loader.load("../imgs/" + wrong5);
|
286
|
-
|
287
|
-
var texture6 = loader.load("../imgs/" + wrong6);
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
// マテリアルにテクスチャーを設定
|
292
|
-
|
293
|
-
/*const material = new THREE.MeshStandardMaterial({
|
294
|
-
|
295
|
-
map: texture1
|
296
|
-
|
297
|
-
});*/
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
const materials =
|
302
|
-
|
303
|
-
[
|
304
|
-
|
305
|
-
new THREE.MeshStandardMaterial({ map: texture1}),
|
306
|
-
|
307
|
-
new THREE.MeshStandardMaterial({ map: texture2}),
|
308
|
-
|
309
|
-
new THREE.MeshStandardMaterial({ map: texture3}),
|
310
|
-
|
311
|
-
new THREE.MeshStandardMaterial({ map: texture4}),
|
312
|
-
|
313
|
-
new THREE.MeshStandardMaterial({ map: texture5}),
|
314
|
-
|
315
|
-
new THREE.MeshStandardMaterial({ map: texture6}),
|
316
|
-
|
317
|
-
] ;
|
318
|
-
|
319
|
-
// メッシュを作成 テクスチャにあたる配列をそのまま第二引数に渡せる
|
320
|
-
|
321
|
-
const mesh = new THREE.Mesh(geometry, materials);
|
322
|
-
|
323
|
-
// 3D空間にメッシュを追加
|
324
|
-
|
325
|
-
scene.add(mesh);
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
//================ 光源の設定 ===============================
|
330
|
-
|
331
|
-
// ①平行光源
|
332
|
-
|
333
|
-
const directionalLight = new THREE.DirectionalLight(0xFFFFFF);
|
334
|
-
|
335
|
-
directionalLight.position.set(1, 1, 1);
|
336
|
-
|
337
|
-
// ②環境光源を作成
|
338
|
-
|
339
|
-
// new THREE.AmbientLight(色, 光の強さ)
|
340
|
-
|
341
|
-
const light = new THREE.AmbientLight(0xFFFFFF, 1.0);
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
// シーンに追加
|
346
|
-
|
347
|
-
scene.add(directionalLight, light);
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
//================ 動作 ====================================
|
354
|
-
|
355
|
-
tick();
|
356
|
-
|
357
|
-
// 毎フレーム時に実行されるループイベントです
|
358
|
-
|
359
|
-
function tick() {
|
360
|
-
|
361
|
-
// レンダリング
|
362
|
-
|
363
|
-
mesh.rotation.y += 0.01;
|
364
|
-
|
365
|
-
mesh.rotation.x += 0.02;
|
366
|
-
|
367
|
-
renderer.render(scene, camera);
|
368
|
-
|
369
|
-
requestAnimationFrame(tick);
|
370
|
-
|
371
|
-
}
|
372
|
-
|
373
|
-
}
|
374
|
-
|
375
|
-
</script>
|
376
|
-
|
377
|
-
<!--------------------------------------------------------------------------ここまで画面の読み込み----->
|
378
|
-
|
379
|
-
</head>
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
<body>
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
<div class="box1 ">使われていない画像を選べ!</div>
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
<div class="boxcenter">
|
394
|
-
|
395
|
-
<!-- 残り問題数 ------------------------------------------------------------->
|
396
|
-
|
397
|
-
<div class="box2">
|
398
|
-
|
399
|
-
Question <br>
|
400
|
-
|
401
|
-
<?php echo $count;?>/5
|
402
|
-
|
403
|
-
</div>
|
404
|
-
|
405
|
-
<!-- 残り問題数 ------------------------------------------------------------->
|
406
|
-
|
407
|
-
<div class="box3">
|
408
|
-
|
409
|
-
<canvas id="myCanvas"></canvas>
|
410
|
-
|
411
|
-
</div>
|
412
|
-
|
413
|
-
<!-- タイマー -------------------------------------------------------------------------------------->
|
414
|
-
|
415
|
-
<div class="box4" >
|
416
|
-
|
417
|
-
<div id="timer">00:00.000</div>
|
418
|
-
|
419
|
-
<div class="controls">
|
420
|
-
|
421
|
-
<button id="min">Min</button>
|
422
|
-
|
423
|
-
<button id="min">Sec</button>
|
424
|
-
|
425
|
-
<button id="min">Reset</button>
|
426
|
-
|
427
|
-
<button id="min">Start</button>
|
428
|
-
|
429
|
-
</div>
|
430
|
-
|
431
|
-
</div>
|
432
|
-
|
433
|
-
<!----------------------------------------------------------------------------------- タイマー -->
|
434
|
-
|
435
|
-
</div>
|
436
|
-
|
437
|
-
<div class="box5">
|
438
|
-
|
439
|
-
<?php
|
440
|
-
|
441
|
-
//画像をランダムに並べるための配列を作成
|
442
|
-
|
443
|
-
$randomImg=array($wrong1, $wrong2, $wrong3, $wrong4, $wrong5, $wrong6, $right);
|
444
|
-
|
445
|
-
shuffle($randomImg);
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
?>
|
450
|
-
|
451
|
-
<form action='<?= $_SERVER["SCRIPT_NAME"] ?>' method="post">
|
452
|
-
|
453
|
-
<!-- jQuery 用のクラスを付与 -->
|
454
|
-
|
455
|
-
<input type="image" src="../imgs/<?php echo $randomImg[0];?>" name="<?php echo $randomImg[0];?>" alt="" width="10%" class="ans mouseon">
|
456
|
-
|
457
|
-
<input type="image" src="../imgs/<?php echo $randomImg[1];?>" name="<?php echo $randomImg[1];?>" alt="" width="10%" class="ans mouseon" >
|
458
|
-
|
459
|
-
<input type="image" src="../imgs/<?php echo $randomImg[2];?>" name="<?php echo $randomImg[2];?>" alt="" width="10%" class="ans mouseon" >
|
460
|
-
|
461
|
-
<input type="image" src="../imgs/<?php echo $randomImg[3];?>" name="<?php echo $randomImg[3];?>" alt="" width="10%" class="ans mouseon" >
|
462
|
-
|
463
|
-
<input type="image" src="../imgs/<?php echo $randomImg[4];?>" name="<?php echo $randomImg[4];?>" alt="" width="10%" class="ans mouseon" >
|
464
|
-
|
465
|
-
<input type="image" src="../imgs/<?php echo $randomImg[5];?>" name="<?php echo $randomImg[5];?>" alt="" width="10%" class="ans mouseon" >
|
466
|
-
|
467
|
-
<input type="image" src="../imgs/<?php echo $randomImg[6];?>" name="<?php echo $randomImg[6];?>" alt="" width="10%" class="ans mouseon" >
|
468
|
-
|
469
|
-
</form>
|
470
|
-
|
471
|
-
</div>
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
<p id="success" class="effect1">success</p>
|
476
|
-
|
477
|
-
<p id="miss" class="effect1">miss </p>
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
</body>
|
484
|
-
|
485
|
-
</html>
|
486
|
-
|
487
|
-
```
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
### 試したこと
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
javascriptでセッションに情報を記録する方法を試しましたがうまくいきません。
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
### 使用ツール
|
500
|
-
|
501
|
-
eclopse xampp mariadb GoogleChrome php javascript jQuery html css
|
5
test
CHANGED
File without changes
|
test
CHANGED
File without changes
|
4
全文を記載するべき、とご指摘を受けたので修正しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -28,81 +28,461 @@
|
|
28
28
|
|
29
29
|
```
|
30
30
|
|
31
|
+
<?php
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
session_start();
|
36
|
+
|
37
|
+
//2回目以降の処理------------------------------------------------------
|
38
|
+
|
39
|
+
if($_SERVER["REQUEST_METHOD"]=="POST"){
|
40
|
+
|
41
|
+
// 訪問回数カウント用の変数$countにカウント値を格納----------------------------------------------------------
|
42
|
+
|
43
|
+
$count = $_SESSION["count"];
|
44
|
+
|
45
|
+
$count++; // カウント値+1
|
46
|
+
|
47
|
+
$_SESSION["count"] = $count;// 有効期限なしのクッキーを設定
|
48
|
+
|
49
|
+
}else{
|
50
|
+
|
51
|
+
$_SESSION["count"] = $count = 1;//
|
52
|
+
|
53
|
+
}
|
54
|
+
|
55
|
+
if($count >= 6){
|
56
|
+
|
57
|
+
$_SESSION["count"] = 0;//カウントをリセット
|
58
|
+
|
59
|
+
header("location: result.php");
|
60
|
+
|
61
|
+
echo "全問終了リザルトへ";//予定ではresultページに遷移
|
62
|
+
|
63
|
+
}
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
include('../setdb/selectTable.php');
|
68
|
+
|
69
|
+
$_SESSION["right"] = $right;//正解を格納
|
70
|
+
|
71
|
+
?>
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
<!DOCTYPE html>
|
76
|
+
|
77
|
+
<html lang="ja">
|
78
|
+
|
79
|
+
<head>
|
80
|
+
|
81
|
+
<meta charset="UTF-8">
|
82
|
+
|
83
|
+
<title>ボックスの例</title>
|
84
|
+
|
85
|
+
<link rel="stylesheet" href="../css/gameScreen.css">
|
86
|
+
|
87
|
+
<link href="https://fonts.googleapis.com/css?family=M+PLUS+Rounded+1c" rel="stylesheet">
|
88
|
+
|
89
|
+
<script src="../js/three.min.js"></script>
|
90
|
+
|
91
|
+
<script src="../js/jquery-3.3.1.min.js"></script>
|
92
|
+
|
93
|
+
<audio id="overSound" preload="auto"><!-- 音声の読み込み -->
|
94
|
+
|
95
|
+
<source src="../music/cursor1.mp3" type="audio/mp3">
|
96
|
+
|
97
|
+
</audio>
|
98
|
+
|
99
|
+
<script>
|
100
|
+
|
101
|
+
//===回答後の処理=====================================================
|
102
|
+
|
103
|
+
$(document).ready(function(){
|
104
|
+
|
105
|
+
var form = $( 'form' );
|
106
|
+
|
107
|
+
//選択肢の画像クリックした場合
|
108
|
+
|
109
|
+
$(".ans").click(function (e) {
|
110
|
+
|
111
|
+
//クリックされた画像のnameの値を代入
|
112
|
+
|
113
|
+
var ansName = $(this).attr("name");
|
114
|
+
|
115
|
+
// フォームの値を設定
|
116
|
+
|
117
|
+
if(ansName == "<?php echo $_SESSION["right"]; ?>"){
|
118
|
+
|
119
|
+
//正解の表示
|
120
|
+
|
121
|
+
$('#success').css('z-index','4');
|
122
|
+
|
123
|
+
}else{
|
124
|
+
|
125
|
+
//不正解の表示
|
126
|
+
|
127
|
+
$('#miss').css('z-index','4');
|
128
|
+
|
129
|
+
}
|
130
|
+
|
131
|
+
// ------- 一旦 submit を止める success missの表示時間 -------------------------------------------------------------
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
e.preventDefault();
|
136
|
+
|
137
|
+
// submit を遅らせて実行
|
138
|
+
|
139
|
+
setTimeout( function() {
|
140
|
+
|
141
|
+
form.off( 'submit' );
|
142
|
+
|
143
|
+
form.submit();
|
144
|
+
|
145
|
+
//正解不正解の表示時間
|
146
|
+
|
147
|
+
}, 750 );
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
//正解数をカウント---------------------------result画面で削除------------
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
//正解までの時間をカウント
|
156
|
+
|
157
|
+
});
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
});
|
162
|
+
|
163
|
+
</script>
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
<script>
|
168
|
+
|
169
|
+
//選択肢にカーソル合わせた時に効果音を再生----------------------
|
170
|
+
|
171
|
+
$(function(){
|
172
|
+
|
173
|
+
$('.mouseon').mouseover(function(){
|
174
|
+
|
175
|
+
document.getElementById("overSound").currentTime = 0;
|
176
|
+
|
177
|
+
document.getElementById("overSound").play();
|
178
|
+
|
179
|
+
});
|
180
|
+
|
181
|
+
});
|
182
|
+
|
183
|
+
</script>
|
184
|
+
|
31
185
|
<script>
|
32
186
|
|
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
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
187
|
+
//画像の読み込み---------------------------------
|
188
|
+
|
189
|
+
var wrong1 = "<?php echo $wrong1; ?>";
|
190
|
+
|
191
|
+
var wrong2 = "<?php echo $wrong2; ?>";
|
192
|
+
|
193
|
+
var wrong3 = "<?php echo $wrong3; ?>";
|
194
|
+
|
195
|
+
var wrong4 = "<?php echo $wrong4; ?>";
|
196
|
+
|
197
|
+
var wrong5 = "<?php echo $wrong5; ?>";
|
198
|
+
|
199
|
+
var wrong6 = "<?php echo $wrong6; ?>";
|
200
|
+
|
201
|
+
console.log(wrong1);
|
202
|
+
|
203
|
+
</script>
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
<script>
|
208
|
+
|
209
|
+
// ページの読み込みを待つ
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
window.addEventListener('load', init);
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
function init() {
|
218
|
+
|
219
|
+
//============ 表示サイズを指定 ======================
|
220
|
+
|
221
|
+
const width = 480;
|
222
|
+
|
223
|
+
const height = 480;
|
224
|
+
|
225
|
+
// レンダラーを作成
|
226
|
+
|
227
|
+
const renderer = new THREE.WebGLRenderer({
|
228
|
+
|
229
|
+
canvas: document.querySelector('#myCanvas')
|
230
|
+
|
231
|
+
});
|
232
|
+
|
233
|
+
renderer.setSize(width, height);
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
//============ シーンを作成 ===========================
|
238
|
+
|
239
|
+
const scene = new THREE.Scene();
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
//============ カメラを作成 ===========================
|
244
|
+
|
245
|
+
const camera = new THREE.PerspectiveCamera(45, width / height);
|
246
|
+
|
247
|
+
camera.position.set(0, -50, +800);//x,y
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
//=============== モデリング ===========================
|
252
|
+
|
253
|
+
//立方体を作成
|
254
|
+
|
255
|
+
const geometry = new THREE.BoxBufferGeometry( 200, 200, 200 );
|
256
|
+
|
257
|
+
// const geometry = new THREE.BoxGeometry( 200, 200, 200, 1, 1, 1);
|
258
|
+
|
259
|
+
//cube = new THREE.CubeGeometry(1, 1, 1);
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
// 球体を作成
|
264
|
+
|
265
|
+
//const geometry = new THREE.SphereGeometry(300, 30, 30);
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
// 画像を読み込む テクスチャ1個に対して1回ずつlorderを呼ぶ必要がある このやり方は問題ない
|
270
|
+
|
271
|
+
//ここで読み込むデータをデータベースから取得したランダムなものに変える
|
272
|
+
|
273
|
+
var loader = new THREE.TextureLoader();
|
274
|
+
|
275
|
+
console.log(wrong1);
|
276
|
+
|
277
|
+
var texture1 = loader.load("../imgs/" + wrong1);
|
278
|
+
|
279
|
+
var texture2 = loader.load("../imgs/" + wrong2);
|
280
|
+
|
281
|
+
var texture3 = loader.load("../imgs/" + wrong3);
|
282
|
+
|
283
|
+
var texture4 = loader.load("../imgs/" + wrong4);
|
284
|
+
|
285
|
+
var texture5 = loader.load("../imgs/" + wrong5);
|
286
|
+
|
287
|
+
var texture6 = loader.load("../imgs/" + wrong6);
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
// マテリアルにテクスチャーを設定
|
292
|
+
|
293
|
+
/*const material = new THREE.MeshStandardMaterial({
|
294
|
+
|
295
|
+
map: texture1
|
296
|
+
|
297
|
+
});*/
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
const materials =
|
302
|
+
|
303
|
+
[
|
304
|
+
|
305
|
+
new THREE.MeshStandardMaterial({ map: texture1}),
|
306
|
+
|
307
|
+
new THREE.MeshStandardMaterial({ map: texture2}),
|
308
|
+
|
309
|
+
new THREE.MeshStandardMaterial({ map: texture3}),
|
310
|
+
|
311
|
+
new THREE.MeshStandardMaterial({ map: texture4}),
|
312
|
+
|
313
|
+
new THREE.MeshStandardMaterial({ map: texture5}),
|
314
|
+
|
315
|
+
new THREE.MeshStandardMaterial({ map: texture6}),
|
316
|
+
|
317
|
+
] ;
|
318
|
+
|
319
|
+
// メッシュを作成 テクスチャにあたる配列をそのまま第二引数に渡せる
|
320
|
+
|
321
|
+
const mesh = new THREE.Mesh(geometry, materials);
|
322
|
+
|
323
|
+
// 3D空間にメッシュを追加
|
324
|
+
|
325
|
+
scene.add(mesh);
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
//================ 光源の設定 ===============================
|
330
|
+
|
331
|
+
// ①平行光源
|
332
|
+
|
333
|
+
const directionalLight = new THREE.DirectionalLight(0xFFFFFF);
|
334
|
+
|
335
|
+
directionalLight.position.set(1, 1, 1);
|
336
|
+
|
337
|
+
// ②環境光源を作成
|
338
|
+
|
339
|
+
// new THREE.AmbientLight(色, 光の強さ)
|
340
|
+
|
341
|
+
const light = new THREE.AmbientLight(0xFFFFFF, 1.0);
|
342
|
+
|
343
|
+
|
344
|
+
|
345
|
+
// シーンに追加
|
346
|
+
|
347
|
+
scene.add(directionalLight, light);
|
348
|
+
|
349
|
+
|
350
|
+
|
351
|
+
|
352
|
+
|
353
|
+
//================ 動作 ====================================
|
354
|
+
|
355
|
+
tick();
|
356
|
+
|
357
|
+
// 毎フレーム時に実行されるループイベントです
|
358
|
+
|
359
|
+
function tick() {
|
360
|
+
|
361
|
+
// レンダリング
|
362
|
+
|
363
|
+
mesh.rotation.y += 0.01;
|
364
|
+
|
365
|
+
mesh.rotation.x += 0.02;
|
366
|
+
|
367
|
+
renderer.render(scene, camera);
|
368
|
+
|
369
|
+
requestAnimationFrame(tick);
|
370
|
+
|
371
|
+
}
|
372
|
+
|
373
|
+
}
|
374
|
+
|
375
|
+
</script>
|
376
|
+
|
377
|
+
<!--------------------------------------------------------------------------ここまで画面の読み込み----->
|
378
|
+
|
379
|
+
</head>
|
380
|
+
|
381
|
+
|
382
|
+
|
383
|
+
|
384
|
+
|
385
|
+
<body>
|
386
|
+
|
387
|
+
|
388
|
+
|
389
|
+
<div class="box1 ">使われていない画像を選べ!</div>
|
390
|
+
|
391
|
+
|
392
|
+
|
393
|
+
<div class="boxcenter">
|
394
|
+
|
395
|
+
<!-- 残り問題数 ------------------------------------------------------------->
|
396
|
+
|
397
|
+
<div class="box2">
|
398
|
+
|
399
|
+
Question <br>
|
400
|
+
|
401
|
+
<?php echo $count;?>/5
|
402
|
+
|
403
|
+
</div>
|
404
|
+
|
405
|
+
<!-- 残り問題数 ------------------------------------------------------------->
|
406
|
+
|
407
|
+
<div class="box3">
|
408
|
+
|
409
|
+
<canvas id="myCanvas"></canvas>
|
410
|
+
|
411
|
+
</div>
|
412
|
+
|
413
|
+
<!-- タイマー -------------------------------------------------------------------------------------->
|
414
|
+
|
415
|
+
<div class="box4" >
|
416
|
+
|
417
|
+
<div id="timer">00:00.000</div>
|
418
|
+
|
419
|
+
<div class="controls">
|
420
|
+
|
421
|
+
<button id="min">Min</button>
|
422
|
+
|
423
|
+
<button id="min">Sec</button>
|
424
|
+
|
425
|
+
<button id="min">Reset</button>
|
426
|
+
|
427
|
+
<button id="min">Start</button>
|
428
|
+
|
429
|
+
</div>
|
430
|
+
|
431
|
+
</div>
|
432
|
+
|
433
|
+
<!----------------------------------------------------------------------------------- タイマー -->
|
434
|
+
|
435
|
+
</div>
|
436
|
+
|
437
|
+
<div class="box5">
|
438
|
+
|
439
|
+
<?php
|
440
|
+
|
441
|
+
//画像をランダムに並べるための配列を作成
|
442
|
+
|
443
|
+
$randomImg=array($wrong1, $wrong2, $wrong3, $wrong4, $wrong5, $wrong6, $right);
|
444
|
+
|
445
|
+
shuffle($randomImg);
|
446
|
+
|
447
|
+
|
448
|
+
|
449
|
+
?>
|
450
|
+
|
451
|
+
<form action='<?= $_SERVER["SCRIPT_NAME"] ?>' method="post">
|
452
|
+
|
453
|
+
<!-- jQuery 用のクラスを付与 -->
|
454
|
+
|
455
|
+
<input type="image" src="../imgs/<?php echo $randomImg[0];?>" name="<?php echo $randomImg[0];?>" alt="" width="10%" class="ans mouseon">
|
456
|
+
|
457
|
+
<input type="image" src="../imgs/<?php echo $randomImg[1];?>" name="<?php echo $randomImg[1];?>" alt="" width="10%" class="ans mouseon" >
|
458
|
+
|
459
|
+
<input type="image" src="../imgs/<?php echo $randomImg[2];?>" name="<?php echo $randomImg[2];?>" alt="" width="10%" class="ans mouseon" >
|
460
|
+
|
461
|
+
<input type="image" src="../imgs/<?php echo $randomImg[3];?>" name="<?php echo $randomImg[3];?>" alt="" width="10%" class="ans mouseon" >
|
462
|
+
|
463
|
+
<input type="image" src="../imgs/<?php echo $randomImg[4];?>" name="<?php echo $randomImg[4];?>" alt="" width="10%" class="ans mouseon" >
|
464
|
+
|
465
|
+
<input type="image" src="../imgs/<?php echo $randomImg[5];?>" name="<?php echo $randomImg[5];?>" alt="" width="10%" class="ans mouseon" >
|
466
|
+
|
467
|
+
<input type="image" src="../imgs/<?php echo $randomImg[6];?>" name="<?php echo $randomImg[6];?>" alt="" width="10%" class="ans mouseon" >
|
468
|
+
|
469
|
+
</form>
|
470
|
+
|
471
|
+
</div>
|
472
|
+
|
473
|
+
|
474
|
+
|
475
|
+
<p id="success" class="effect1">success</p>
|
476
|
+
|
477
|
+
<p id="miss" class="effect1">miss </p>
|
478
|
+
|
479
|
+
|
480
|
+
|
481
|
+
|
482
|
+
|
483
|
+
</body>
|
484
|
+
|
485
|
+
</html>
|
106
486
|
|
107
487
|
```
|
108
488
|
|
3
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,7 +1,3 @@
|
|
1
|
-
```php
|
2
|
-
|
3
|
-
|
4
|
-
|
5
1
|
クイズサイトを作成しています。
|
6
2
|
|
7
3
|
phpで作っているサイトで、データベースからの問題の読み込みと、選択肢からの正解の判定まではうまくいったのですが、
|
@@ -28,9 +24,7 @@
|
|
28
24
|
|
29
25
|
|
30
26
|
|
31
|
-
```
|
27
|
+
```php
|
32
|
-
|
33
|
-
該当部分のコード
|
34
28
|
|
35
29
|
```
|
36
30
|
|
2
test
CHANGED
File without changes
|
test
CHANGED
File without changes
|
1
文字が改行されておらず読みくいため
test
CHANGED
File without changes
|
test
CHANGED
@@ -4,17 +4,25 @@
|
|
4
4
|
|
5
5
|
クイズサイトを作成しています。
|
6
6
|
|
7
|
-
phpで作っているサイトで、データベースからの問題の読み込みと、選択肢からの正解の判定まではうまくいったのですが、
|
7
|
+
phpで作っているサイトで、データベースからの問題の読み込みと、選択肢からの正解の判定まではうまくいったのですが、
|
8
|
+
|
9
|
+
正解数の記録がうまくいきません。
|
8
10
|
|
9
11
|
|
10
12
|
|
11
|
-
できればSESSIONに正解数を記録したいのですが、正解か不正解かの判定部分をjqueryで行っているためphpで記録できず、
|
13
|
+
できればSESSIONに正解数を記録したいのですが、正解か不正解かの判定部分をjqueryで行っているためphpで記録できず、
|
14
|
+
|
15
|
+
javascript用のセッションの記録方法を試したのですが、結果画面に遷移するとセッションの読み出し部分が「Notice:
|
16
|
+
|
17
|
+
Undefined variable: _SESSION in......」という表示になってしまいます。
|
12
18
|
|
13
19
|
|
14
20
|
|
15
21
|
javascriptの記述の中でsessionに情報を記録する方法、またはそれと同様の事が行える方法があれば教えてください。
|
16
22
|
|
17
|
-
もしくは一般的なクイズサイトで正答数を記録している方法や、そういった事を紹介しているサイトなどがあれば
|
23
|
+
もしくは一般的なクイズサイトで正答数を記録している方法や、そういった事を紹介しているサイトなどがあれば
|
24
|
+
|
25
|
+
教えていただけると助かります。
|
18
26
|
|
19
27
|
|
20
28
|
|