Last active
June 12, 2018 23:21
-
-
Save QB/250529f4f440ce7bbb7283488a5c62ad to your computer and use it in GitHub Desktop.
ランダムに小テストを生成するプログラム。1000問ぐらい問題をプールしておいて,50題ずつランダムに小テストを生成するような使い方を想定しています。サンプルの問題を入れておいたので,動かしてみてください。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
What is JavaFX? | |
Can I use JavaFX without Java? | |
Why should I upgrade to the latest Java version? | |
For what platforms is JavaFX available? | |
Is JavaFX free to download? | |
What will I get when I download JavaFX? | |
Can I download JavaFX and copy it to another computer? | |
I am an administrator. Can I install JavaFX on all the computers at my company? | |
Can I put JavaFX on an intranet for others to download? | |
Do I need to purchase a license if I need the JavaFX Runtime for multiple users in my company? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
JavaFX is a software technology which, combined with ( ), enables the creation and deployment of modern-looking applications with rich content, audio and video. | |
No, you must have both JRE and ( ) ( ) installed on your PC in order to run JavaFX applications. | |
The latest ( ) version contains important enhancements to improve performance, stability and security of the ( ) applications that run on your machine. | |
( ) is available on Windows, Mac OS X, and ( ). | |
Yes, ( ) is free to download. | |
The ( ) ( ) is what you get when you download JavaFX. | |
Yes, you can download the ( ) ( ) on one system and copy it to another computer, provided you own both computers. | |
Yes, you may make unlimited copies for internal use for the purpose of running applications on ( )-enabled general purpose desktop computers and servers. | |
Yes, you can provide the ( ) ( ) on an Intranet for internal users to download. | |
No, you may make unlimited copies for internal use for the purpose of running applications on ( )-enabled general purpose desktop computers and servers. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
JavaFX is a software technology which, combined with Java, enables the creation and deployment of modern-looking applications with rich content, audio and video. | |
No, you must have both JRE and JavaFX Runtime installed on your PC in order to run JavaFX applications. | |
The latest JavaFX version contains important enhancements to improve performance, stability and security of the JavaFX applications that run on your machine. | |
JavaFX is available on Windows, Mac OS X, and Linux. | |
Yes, JavaFX is free to download. | |
The JavaFX Runtime is what you get when you download JavaFX. | |
Yes, you can download the JavaFX Runtime on one system and copy it to another computer, provided you own both computers. | |
Yes, you may make unlimited copies for internal use for the purpose of running applications on Java-enabled general purpose desktop computers and servers. | |
Yes, you can provide the JavaFX Runtime on an Intranet for internal users to download. | |
No, you may make unlimited copies for internal use for the purpose of running applications on Java-enabled general purpose desktop computers and servers. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ゲームモード: trueのときは小テストは生成しない | |
GAME = false | |
#小テストを生成する場合の設定 | |
# 小テストの問題数 | |
NUM = 50 | |
# 生成する小テストの個数 | |
N = 10 | |
# 設問番号をナンバリングするか | |
NUMBERING = true | |
DATA1 = "data1.txt" #問題文ファイル | |
DATA2 = "data2.txt" #穴埋め解答ファイル | |
DATA3 = "data3.txt" #模範解答ファイル | |
class QuizMaker | |
def initialize(num) | |
@num = num | |
@data1 = align(DATA1) | |
@data2 = align(DATA2) | |
@data3 = align(DATA3) | |
@length = @data1.length | |
end | |
def align(file) | |
open(file, "r:utf-8").readlines.map(&:to_s).map(&:strip) | |
end | |
def generate | |
bank = (0..@length-1).to_a.sample(@num) | |
[ bank.map.with_index {|b,i| question(b,i+1)}, | |
bank.map.with_index {|b,i| answer(b,i+1)} ] | |
end | |
def ask(n) | |
puts | |
puts "#"*30 | |
puts @data1[n] | |
ans = (@data3[n].split(/[ ,.]/) - @data2[n].split(/[ ,.]/)) | |
sent = @data3[n] + "" | |
ans.each {|word| sent.gsub!(word, "(" + " "*(word.length-2) + ")")} | |
puts sent | |
print ">> " | |
resp = gets.chomp | |
puts "*****" + (resp == ans.join(" ") ? "CORRECT" : "WRONG") + "!!*****" | |
puts @data3[n] | |
resp == ans.join(" ") | |
end | |
def question(n, i) | |
(NUMBERING ? i.to_s+"." : " ") + " #{@data1[n]}\n #{@data2[n]}\n" | |
end | |
def answer(n, i) | |
(NUMBERING ? i.to_s+"." : " ") + " #{@data1[n]}\n #{@data3[n]}\n" | |
end | |
end | |
qm = QuizMaker.new(NUM) | |
if !GAME | |
N.times do |i| | |
data = qm.generate | |
puts "#{"#"*30}\n### Q.#{i+1} is below ###\n#{"#"*30}\n\n" | |
puts data[0] | |
puts | |
puts "#{"#"*30}\n### A.#{i+1} is below ###\n#{"#"*30}\n\n" | |
puts data[1] | |
puts | |
end | |
else | |
loop do | |
print "start: "; a = gets.chomp.to_i | |
print "end: " ; b = gets.chomp.to_i | |
break if a<1 || b<1 | |
asks = (a..b).to_a | |
until asks == [] | |
wrongs = [] | |
asks.each do |n| | |
wrongs.push(n) until qm.ask(n) | |
end | |
puts | |
puts "#"*30 | |
puts "Your wrongs were #{wrongs}." | |
asks = wrongs | |
end | |
puts "Great!!" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment