# HG changeset patch # User houtin # Date 1501142307 -32400 # Node ID 192062680d0b1490f658315fd21a6f89ba32949f # Parent ed1a15e1c32d3db7ea5d1478571958acd03abf32 プログラムの改良 diff -r ed1a15e1c32d -r 192062680d0b event/oasis2017/point.sq3 diff -r ed1a15e1c32d -r 192062680d0b event/oasis2017/quiz/1-2.png Binary file event/oasis2017/quiz/1-2.png has changed diff -r ed1a15e1c32d -r 192062680d0b event/oasis2017/quiz/db/point.sq3 Binary file event/oasis2017/quiz/db/point.sq3 has changed diff -r ed1a15e1c32d -r 192062680d0b event/oasis2017/quiz/gassan.jpg Binary file event/oasis2017/quiz/gassan.jpg has changed diff -r ed1a15e1c32d -r 192062680d0b event/oasis2017/quiz/gassan_mini.jpg Binary file event/oasis2017/quiz/gassan_mini.jpg has changed diff -r ed1a15e1c32d -r 192062680d0b event/oasis2017/quiz/kantan.rb --- a/event/oasis2017/quiz/kantan.rb Thu Jul 27 14:41:25 2017 +0900 +++ b/event/oasis2017/quiz/kantan.rb Thu Jul 27 16:58:27 2017 +0900 @@ -30,9 +30,7 @@ # 1501044365/65675|unko|2017-07-26 14:43:14 +0900|qa3 -someVALUES1 = "qa1" -someVALUES2 = "qa2" -someVALUES3 = "qa3" +key = ["qa1","qa2","qa3"] #cookie≫ @@ -68,6 +66,20 @@ # cookie∫c障сc + +print(<<-EOF) + + +膂≦ + + + + + +EOF + + + ################################################################## 若句脂 playname = form_name if form_name > "" # 若name @@ -91,7 +103,7 @@ EOF exit end -printf("

%sc潟

\n", playname) +printf("

%s
c潟

\n", playname) ################################################################## @@ -110,16 +122,6 @@ number = "1" #number"1"篁e end -print(<<-EOF) - - -膂≦ - - - - - -EOF @@ -141,11 +143,11 @@ "13" => [] } -y = {"1" => "hiyori.png
" +y = {"1" => "hiyori.jpg
" } -print"\n" +#print"\n" print"
\n" @@ -174,19 +176,19 @@ printf("") print("<\p>") printf("") - db.execute("REPLACE INTO point VALUES(?,?)",id,someVALUES1) + db.execute("REPLACE INTO point VALUES(?,?)",id,key[0]) elsif number =="8" print("

") printf("") print("

") printf("") - db.execute("REPLACE INTO point VALUES(?,?)",id,someVALUES2) + db.execute("REPLACE INTO point VALUES(?,?)",id,key[1]) elsif number == "10" print("

") printf("") print("<\p>") printf("") - db.execute("REPLACE INTO point VALUES(?,?)",id,someVALUES3) + db.execute("REPLACE INTO point VALUES(?,?)",id,key[2]) end printf("") diff -r ed1a15e1c32d -r 192062680d0b event/oasis2017/quiz/quiz.csv --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/event/oasis2017/quiz/quiz.csv Thu Jul 27 16:58:27 2017 +0900 @@ -0,0 +1,10 @@ +#腮,馹,糸<ゃ若劫,御1,御2,御3,罩hВ,祉<ゃ +kantan,1,hiyori,藏翫,ュ絮怨,蕋罍絮怨,2,skipseikai1.mp4 +kantan,2,tyokai,絮,臂初絮,薐ユ儀絮,3,skipseikai4.mp4 +kantan,3,sannkyo,絮怨綺,綺,乗膊,1,skipseikai5.mp4 +futsu,1,tama,膂障羯,膤吾羯,筝羯,1,skipseikai1.mp4 +futsu,2,12,筝羯,篋羯,筝羯,2,skipseikai4.mp4 +futsu,3,shishi,絽綵号紊х絖,育紊х絖,,1,skipseikai5.mp4 +muzukashi,1,gassan,薐ユ儀絮,羚罧水臼,絮,3,skipseikai1.mp4 +muzukashi,2,maru,筝御罕,羆,藏顔羆,1,skipseikai4.mp4 +muzukashi,3,1-2,筝羯篋羯,筝羯,筝羯,1,skipseikai5.mp4 diff -r ed1a15e1c32d -r 192062680d0b event/oasis2017/quiz/quiz.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/event/oasis2017/quiz/quiz.rb Thu Jul 27 16:58:27 2017 +0900 @@ -0,0 +1,199 @@ +#!/usr/bin/env ruby +# -*- coding: utf-8 -*- +# +# 罧茯臥 [css茯炊] [篁蚊若若帥若鴻<ゃg鎧] +# 若九≪ http:/..../quiz.rb?reset + +require 'cgi' +require 'csv' +c = CGI.new(:accept_charset => 'utf-8') + +require 'sqlite3' +file = "db/point.sq3" + +# roy{c115080}% sqlite3 point.sq3 [~/public_html/mycgi/skip/quiz/db] +# SQLite version 3.8.8.2 2015-01-30 14:30:45 +# Enter ".help" for usage hints. +# sqlite> .sch +# CREATE TABLE users(id text primary key, name text, creation text); +# CREATE TABLE point(id, keyword text, FOREIGN KEY(id) REFERENCES users(id)); +# sqlite> select * from users; +# 1501044365/65675|unko|2017-07-26 14:43:14 +0900 +# sqlite> select * from point; +# 1501044365/65675|c +# sqlite> select * from users NATURAL INNER JOIN point; +# 1501044365/65675|unko|2017-07-26 14:43:14 +0900|c +# 1501044365/65675|unko|2017-07-26 14:43:14 +0900|c +# 1501044365/65675|unko|2017-07-26 14:43:14 +0900| +# 1501044365/65675|unko|2017-07-26 14:43:14 +0900|qa1 +# 1501044365/65675|unko|2017-07-26 14:43:14 +0900|qa2 +# 1501044365/65675|unko|2017-07-26 14:43:14 +0900|qa3 + +myname = File.basename($0) + +#cookie≫ +cookie_id=c.cookies["id"][0] + +form_name =c["playname"] # ュ +form_mode =c["mode"] # 馹腮 +form_qn =c["qn"] # 馹 +form_rd =c["rd"] # 茹g + +if cookie_id == nil + newid = Time.now.to_i.to_s + "/" + rand(99999).to_s + id = newid +else + id = cookie_id +end + +# idcookieх御吟 +# 紊違24荐絎expire紊違ャ +expire = (Time.now+24*3600).gmtime.strftime("%a, %d %b %Y %H:%M:%S GMT") +printf("Content-type: text/html; charset=UTF-8\n") +printf("Set-Cookie: id=%s; expires=%s\n\n", id, expire) + +db = SQLite3::Database.new(file) +db.execute("PRAGMA foreign_keys=on") +db.execute("CREATE TABLE IF NOT EXISTS " + + "users(id text primary key, name text, creation text)") +db.execute("CREATE TABLE IF NOT EXISTS " + + "point(id, keyword text, FOREIGN KEY(id) REFERENCES users(id), " + + "UNIQUE(id,keyword))") + +################################################################## 若句脂 +playname = form_name +if form_name > "" # 若name + now = Time.now.strftime("%F %T") + db.execute("REPLACE INTO users VALUES(?, ?, ?)", id, form_name, now); +else # 若namedb + dbn = db.execute("SELECT name from users WHERE id=?", id)[0] + if dbn != nil && dbn[0] + playname = dbn[0] # 若帥若鴻ゅ + end +end +if playname == "" || ARGV[0] == "reset" + print(<<-EOF) + +

ゅャ: + + + +

+ EOF + exit +end +printf("

%sc潟

\n", playname) +################################################################## + +number = c["rd"] +def outinput(value, label) + printf("", value, label) +end + +def imgsrc(img) + printf("", img, img) +end + +## 馹宴茯粋昭 +question = {} +n_question = 0 +CSV.foreach("quiz.csv", encoding: 'utf-8') do |row| + mode = row.shift # = ≪若 + next if /^#/ =~ mode # 荀冴茵鴻 + if question[mode] == nil + question[mode] = {} + end + qn = row.shift # 馹 + question[mode][qn] = row # {1 => [tama, 膂, ....]} + n_question += 1 # т +end + +puts("\n") + +if form_mode > "" + quiz_mode = form_mode +else + quiz_mode = ARGV[0] || "futsu" # kantan, futsu, muzukashi +end +if not /kantan|futsu|muzukashi/ =~ quiz_mode then + print(<<-EOF) + ERROR +

≦鴻潟若с

+ EOF + exit 0 +end + +level = {"kantan" => "膂≦", "futsu"=>"", "muzukashi"=>"c"}[quiz_mode] + +print(<<-EOF) + + +#{level} + + + + + +EOF + +print"\n" + +print"
\n" + +q = question[quiz_mode] # 3腮< + +if form_qn == nil || form_qn == "" # 馹垽絎1 + form_qn = "1" +end +ansinfo = q[form_qn] # 篁御≪茹g +# [hiyori,藏翫,ュ絮怨,蕋罍絮怨,2,skipseikai1.mp4] 絖 +image, s1, s2, s3, ans, movie = *ansinfo + +if number == ans then + print "

罩hВ!!

" + db.execute("REPLACE INTO point VALUES(?, ?)", + id, "quiz-" + quiz_mode + "-" + form_qn) # ex. quiz-kantan-1 + printf(<<-EOF, movie, quiz_mode, 1+form_qn.to_i) + +

+

+ EOF + # form_qn 1泣 hidden 篁莨若 + if form_qn.to_i < q.length # 障罨< + puts('

') + else # 鴻腟篋 + puts("

с!

") + n_right = db.execute("SELECT count(*) FROM point WHERE id=?", id)[0][0] + printf(<<-EOF, n_question, n_right.to_i) +

с!

+

%d鋇 %d閫hВ障

+ EOF + if n_question == n_right.to_i + puts("

∫!") + end + end +else + printf("

膃%d

\n", form_qn) + if /\d/ =~ number + puts("

罧綽! 筝綺!

") + end + printf("

") + imgsrc(image) + printf("

") + n=0 + for i in [s1, s2, s3] do + outinput((n+=1).to_s, i) # + puts("
") + end + printf(<<-EOF, quiz_mode, form_qn) + + +

+

+ EOF +end +print"
\n" +print "\n" +print "\n" diff -r ed1a15e1c32d -r 192062680d0b event/oasis2017/quiz/quizpg.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/event/oasis2017/quiz/quizpg.css Thu Jul 27 16:58:27 2017 +0900 @@ -0,0 +1,8 @@ +p.big{ +font-size: 30px; + + +padding: 0.5em 1em; +margin: 1em 0; +border: double 5px #4ec4d3 +} diff -r ed1a15e1c32d -r 192062680d0b event/oasis2017/quiz/shishi.jpg Binary file event/oasis2017/quiz/shishi.jpg has changed diff -r ed1a15e1c32d -r 192062680d0b event/oasis2017/quiz/shishi_mini.jpg Binary file event/oasis2017/quiz/shishi_mini.jpg has changed diff -r ed1a15e1c32d -r 192062680d0b event/oasis2017/quiz/tyokai.jpg Binary file event/oasis2017/quiz/tyokai.jpg has changed