Arc Forumnew | comments | leaders | submitlogin
Tiny quiz app
3 points by skenney26 5235 days ago | 6 comments
I recently started working on a simple quiz app. It is far from "complete" but I thought it would be more interesting to share it rather than continue working on it alone.

So far the only page that works displays a question, a youtube video related to the question, and four possible answers. The user selects an answer and is shown whether they got it right.

The app still needs a home page and a page for adding new questions. Any feedback or new features would be appreciated.

To use the app:

get the code at http://github.com/skenney26/kwizwiz/blob/master/kwizwiz.arc

  (load "kwizwiz.arc")

  (asv)
go to http://localhost:8080/q

Because the default app only comes with 4 questions it is possible that the same question will randomly load 2 times in a row.



3 points by akkartik 5234 days ago | link

Nice! I'd forgotten about deftem, should use it more.

I like ret and mapair. But not how you are overloading between.

And how the heck is param avoiding infinite recursion?

I suspect you can make shuffle+choices shorter by using rand-choice+pull.

-----

2 points by fallintothis 5234 days ago | link

It might be worth noting that ret was unnecessary in this case.

  (mac ret (var val . body)
   `(let ,var ,val ,@body ,var))
   
  (def question (url q a b c d)
    (let id (++ question-id*)
      (ret new (inst 'question
                     'id id 'url (video-url url)
                     'q q 'a a 'b b 'c c 'd d)
        (= (questions* id) new))))
could just be

  (def question (url q a b c d)
    (let id (++ question-id*)
      (= (questions* id)
         (inst 'question
               'id id 'url (video-url url)
               'q q 'a a 'b b 'c c 'd d))))
ret would certainly be useful in general, of course.

-----

3 points by skenney26 5234 days ago | link

I like your rewrite of 'question.

I agree that 'ret would be more useful in other areas than here. In arc.arc 'best, 'summing, 'sum, 'listtab, 'copy, 'inst, 'w/table, 'memtable, and 'evtil all use this idiom of creating a local variable with 'let and then returning it.

-----

1 point by skenney26 5234 days ago | link

Thanks for the feedback. I'll take a look at how rand-choice and pull can improve shuffle and choices.

I use between alot with numbers and would like a similar utility for strings, but I understand its confusing that the arguments to between work exclusively with strings but inclusively with numbers.

param is just mapping over a paired list. Infinite recursion shouldn't be a problem.

-----

2 points by akkartik 5234 days ago | link

There's a call to param inside param's body. Isn't it the same fn? Ah, it's just the tag macro's private language.

between with a string == substring between delimiters. between without a string == pick a random number in a range. Is that right? It's not just about exclusive/inclusive, that's pretty different semantics.

-----

1 point by skenney26 5234 days ago | link

I meant that the return value of the string version doesn't include the delimiters (between "ab" "ef" "abcdef"), while when something like (between 3 7) is called, the return value could also be 3 or 7.

Maybe it would make more sense to modify rand so that it could return numbers in a range if given 2 arguments.

-----