Skip to content

Instantly share code, notes, and snippets.

@sudoyu
Last active December 25, 2015 08:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sudoyu/baef97d14360169b8ccf to your computer and use it in GitHub Desktop.
Save sudoyu/baef97d14360169b8ccf to your computer and use it in GitHub Desktop.
package ikeametal
class QuestionController {
List ikeas = ["Vittsjö","Klubbo","Bastig","Boholmen","Grundtal","Dåtid","Samsplet","Skogaby","Adde","Nyvoll","Strandmon","Krokig","Vyssa Skont","Melltorp","Vridvinge"]
List metals = ["Akercocke","Einherjer","Sargeist","Taake","Ensiferum","Midnattsol","Turisas","Thaurorod","Sikth","Eluveitie","Månegarm","Kovenant","Korpiklaani"]
Random rand = new Random()
static Integer total = 0
static Integer correct = 0
def index() {
List joined = metals + ikeas
def picked = joined[ rand.nextInt(joined.size()) ]
render "<H1>$picked</H1> is IKEA or METAL ?" +
g.link(action:"ikea",id:picked){"<H2>IKEA</H2>"} +
g.link(action:"metal",id:picked){"<H2>METAL</H2>"} +
"( $correct / $total )"
}
def metal() {
total ++
def ans = metals.contains(params.id) ?
"<H1>Right!</H1> ${params.id} is Metal Band.<!--${++correct}-->" :
"<H1>Wrong.</H1> ${params.id} is IKEA Item."
ans += g.link(action:"index"){"<H2>Next</H2>"}+"( $correct / $total )"
render ans
}
def ikea() {
total ++
def ans = ikeas.contains(params.id) ?
"<H1>Right!</H1> ${params.id} is IKEA Item.<!--${++correct}-->" :
"<H1>Wrong.</H1> ${params.id} is Metal Band."
ans += g.link(action:"index"){"<H2>Next</H2>"}+"( $correct / $total )"
render ans
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment