Giter Club home page Giter Club logo

slickquiz-sparql's Introduction

SlickQuiz-SPARQL

jQueryクイズアプリ SlickQuiz で SPARQLの検索結果を利用できるようにしました。

デモ

http://uedayou.net/SlickQuiz-SPARQL/

利用データ: 横浜検定問題・解答集

使い方

config.js の endpoint に SPARQLエンドポイントを、query に SPARQLクエリを入力してください。 queryは、/* ... */ の中に記述してください。

// SPARQLエンドポイントURL
var endpoint = "http://lodcu.cs.chubu.ac.jp/SparqlEPCU/api/yokohama_quiz";
// SPARQLクエリ
var query = (function () {/*
	select distinct * where { ?uri <http://linkdata.org/property/rdf1s560i#question> ?question;
	<http://linkdata.org/property/rdf1s560i#choice1> ?choise1;
	<http://linkdata.org/property/rdf1s560i#choice2> ?choise2;
	<http://linkdata.org/property/rdf1s560i#choice3> ?choise3;
	<http://linkdata.org/property/rdf1s560i#choice4> ?choise4;
	<http://linkdata.org/property/rdf1s560i#answer> ?answer_no;
	<http://linkdata.org/property/rdf1s560i#kaisetsu> ?kaisetsu.
	bind(concat('</p>解説:',str(?kaisetsu),'</p>') as ?correct)
	bind(concat('</p>解説:',str(?kaisetsu),'</p>') as ?incorrect) } ORDER BY RAND() LIMIT 10
*/}).toString().match(/\n([\s\S]*)\n/)[1];

指定する変数に、以下のデータが入るように記述してください。

変数 説明
?question 問題文
?answer ※1 答え
?choise1
?choise2
?choise3
...※2
選択肢
?correct 正解だったときに表示するメッセージ
?incorrect 不正解だったときに表示するメッセージ
?answer_no ※1 選択肢の中の答えの番号を指定※3

※1: ?answer か ?answer_no どちらかあれば動きます。それ以外は必須
※2: 選択肢の数はいくつでもかまいません。
※3: 例えば、「1」だと「?choise1」が答えとして設定されます。

また、quizJSON 内のデータを変更することで、アプリの名前や正解率に応じたメッセージをカスタマイズできます。

var quizJSON = {
	"info": {
    	"name":    "横浜検定クイズ", // アプリの名前(index.htmlのtitleタグも変更する必要があります)
    	"main":    "<p>横浜に関するクイズ集です。</p>", // アプリの説明
    	"results": "<p>このアプリのクイズデータは、http://linkdata.org/work/rdf1s560i のデータを使用しています。</p>", // クイズ終了時のメッセージ
    	"level1":  "すばらしい!",
    	"level2":  "なかなかです",
    	"level3":  "普通です",
    	"level4":  "まだまだです",
    	"level5":  "残念でした" // no comma here
	}
};

その他の使い方は、SlickQuiz を参照してください。

ライセンス

Copyright © 2014 Hiroshi Ueda(@uedayou). Licensed under the MIT license.

slickquiz-sparql's People

Contributors

uedayou avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.