• forked:姫路検定
Import an externally hosted application
Check style

  • JavaScript
  • CSS
  • HTML
  • Images
  • Input Data
  • ReadMe
  • forked:姫路検定
  • jquery-1.7.1.min.js  
  •  
  • history

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
94
95
96
97
98
99
100
 
/*
This is a Example program to retrieve and display the data. 
Press the Run button on the right of the screen (described the behavior of the Example program below). 
Please create a new application rewrite this program work. 
*/
var max = 12;
var category_q_num = 4;
var count = 0;
var correct_num = 0;
var all_q_data;
var q_data;
 
Array.prototype.shuffle = function() {
    var i = this.length;
    while(i){
        var j = Math.floor(Math.random()*i);
        var t = this[--i];
        this[i] = this[j];
        this[j] = t;
    }
    return this;
}
 
function initialize(){  
    // 初期化
    count = 0;
    correct_num = 0;
    all_q_data = new Array();
    q_data = new Array();
    
    // データをLinkDataから取得 
    tmp_q_data = new Array();
    $.each(LinkData.getWorks(), function(workKey, workValue) {
    $.each(LinkData.getFiles(workValue), function(fileKey, fileValue) {
        $.each(LinkData.getSubjects(workValue, fileValue), function(subjKey, subjValue) {
            var tmp_data = {}
            tmp_data["id"] = subjValue;
            $.each(LinkData.getProperties(workValue, fileValue), function(propKey, propValue) {
                $.each(LinkData.getObjects(workValue, fileValue, subjValue, propValue), function(objKey, objValue) {
                    if(propValue == "http://linkdata.org/property/rdf1s560i#question"){
                        tmp_data["q"] = objValue;
                    }else if(propValue == "http://linkdata.org/property/rdf1s560i#choice1"){
                        tmp_data["c1"] = objValue;
                    }else if(propValue == "http://linkdata.org/property/rdf1s560i#choice2"){
                        tmp_data["c2"] = objValue;
                    }else if(propValue == "http://linkdata.org/property/rdf1s560i#choice3"){
                        tmp_data["c3"] = objValue;
                    }else if(propValue == "http://linkdata.org/property/rdf1s560i#choice4"){
                        tmp_data["c4"] = objValue;
                    }else if(propValue == "http://linkdata.org/property/rdf1s560i#answer"){
                        tmp_data["a"] = objValue;
                    }else if(propValue == "http://linkdata.org/property/rdf1s560i#category"){
                        tmp_data["category"] = objValue;
                    }else if(propValue == "http://linkdata.org/property/rdf1s560i#kaisetsu"){
                        tmp_data["detail"] = objValue;
                    }
                });
            });
            tmp_q_data.push(tmp_data);
        }); 
    });
    });         
    all_q_data = tmp_q_data;
    
    // TODO: カテゴリごとに出題する問題を10問選ぶ
    var data_h = new Array();
    var data_c = new Array();
    var data_l = new Array();
    all_q_data.forEach(function(e, i, a){
        if(e.category == "歴史"){
            data_h.push(e);
        }else if (e.category == "文化・スポーツ"){
            data_c.push(e);
        }else if (e.category == "生活"){
            data_l.push(e);
        }
    });
    var selected_h = random(data_h, category_q_num);
    var selected_c = random(data_c, category_q_num);
    var selected_l = random(data_l, category_q_num);
    [].push.apply(q_data, selected_h);
    [].push.apply(q_data, selected_c);
    [].push.apply(q_data, selected_l);
    q_data = q_data.shuffle();
    
    $("#contents").empty();
    var intro = "<div id='introduction'><H1>姫路検定</H1><H3>あなたの姫路力をチェック!</H3><div><div>下のボタンを押して<br/>検定をはじめましょう。</div><div class='button'><input type='submit' value='スタート' onclick='next();'/></div></div></div>";
    $("#contents").append(intro);
}
 
function next(){
                $("#contents").empty();
                if(count < max){
                    count++;
                    var tmp_q = q_data[count-1];                    
                    var q = $("<div id='question'>"); 
                    var c = $("<h1>第<span id='count'>"+count+"</span>問</h1>");
                    var h3 = $("<h3>"+tmp_q.q+"</h3>");
                    var choices = $("<div id='choices'/>"); 
                    var choice = [$("<div><input type='radio' name='answer' value='1'>"+tmp_q.c1+"</div>"),$("<div><input type='radio' name='answer' value='2'>"+tmp_q.c2+"</div>"),$("<div><input type='radio' name='answer' value='3'>"+tmp_q.c3+"</div>"),$("<div><input type='radio' name='answer' value='4'>"+tmp_q.c4+"</div>")];
jquery-1.7.1.min.js
Playing...

jquery-1.7.1.min.js