HSC2011/Software/Frontend: Unterschied zwischen den Versionen

aus Metalab Wiki, dem offenen Zentrum für meta-disziplinäre Magier und technisch-kreative Enthusiasten.
Zur Navigation springenZur Suche springen
(some more words on the front end)
(moved content from "build your own")
Zeile 54: Zeile 54:
==='''Rhythm game'''===
==='''Rhythm game'''===
[http://en.wikipedia.org/wiki/Beatmania Beatmania] work-alike
[http://en.wikipedia.org/wiki/Beatmania Beatmania] work-alike
== Application Development ==
=== architectural overview ===
Each Edubuzzer app, e.g. '''Raise Your Hands''', is chiefly implemented in a
single responsible JavaScript file, e.g. <tt>raise-your-hands.js</tt>. Each one can
define a single callback, <tt>Edubuzzer.run_application</tt> which is called when
the application is started.
Inside <tt>Edubuzzer.run_application</tt> it may register other callbacks like
<tt>Edubuzzer.updated_known_logins</tt> which is called whenever a client is added
or removed, or <tt>Edubuzzer.display</tt> which is called in regular intervals.
<tt>global.js</tt> runs a poor man's event loop and schedules all pollings to the
server which result in callbacks of the active app registered being called.  An
app is activated by changing the URI <tt>#hash</tt>. The skeleton switches to an app
by simply overwriting the <tt>display</tt> function.
=== querying buzzers ===
<tt>/ygor</tt> is the base URI for the middleware endpoint. Send <tt>GET</tt> requests to
certain named queries, e.g. <tt>?name=ls_accepted_login.sql</tt>. For the full list,
see directory <tt>Ygor/sql/</tt> in the [https://github.com/Metalab/hsc2011/tree/master/software software repository]. It returns a JSON array of objects/hashes whose
keys are described in the SQL file, e.g. for above:
<code>   
    [{"rowid":42,"src":"BUZZER-DEVICE-ID","dest":"MASTER-DEVICE-ID",
        "seqnum":23,"ibutton":"SOMETHING","since":"TIMESTAMP",
        "accepted":true,"ack":false}, … ]
</code>
Refer to the table schemas in <tt>Ygor/schema/</tt> for explicit key/row names. Rely
on <tt>src</tt> for uniquely identifying a buzzer.
The most important query is <tt>ls_events.sql</tt> because it deals with the device
buttons. The first line in the file hints at the additional query parameters,
in this case <tt>loginid</tt>, i.e. the full query string is
<tt>?name=ls_events&loginid=ROWID</tt> where <tt>ROWID</tt> is a number received in earlier
different queries. Extract the button status from the <tt>eventmask</tt> field. See
<tt>docs/serialprotocol</tt> for the semantics.
For debugging purposes the middleware exposes an echo interface at base URI
<tt>/echo</tt>. The query string is ignored except for the parameter name
<tt>Response-Body</tt>. Its value is a percent encoded JSON string which
unsurprisingly is returned as response body.
For example, you want to mock:
<code>
    $.getJSON(
        Edubuzzer.middleware_endpoint+'?name=…',
        function (foo) {
            …
        }
    )
</code>
Add a [http://api.jquery.com/jQuery.getJSON/ second parameter to the <tt>getJSON</tt> call], thus:
<code>
    $.getJSON(
        Edubuzzer.middleware_mock_endpoint+'?name=…',
        'Response-Body'+encodeURIComponent('[{"rowid":123}]')
        function (foo) {
            …
        }
    )
</code>
=== instruction list ===
* decide on an app name (e.g. <tt>exampleapp</tt>)
* create a new JavaScript file with the name
* implement the <tt>run_application</tt> function and the hooks you need
** present the app UI in element <tt>#buzzers</tt>
** keep internal data under the <tt>Edubuzzer.exampleapp</tt> namespace
* add the app name/link in <tt>index.xhtml</tt>
* register the app in <tt>global.js</tt>
* add styles in <tt>edubuzzer.css</tt>


[[Kategorie:HSC2011]]
[[Kategorie:HSC2011]]
[[Kategorie:English]]
[[Kategorie:English]]

Version vom 2. Mai 2011, 19:34 Uhr

HSC2011

Teacher Frontend

The whole user visible part of the EduBuzzer software runs inside a web browser on the teacher's laptop; the files are served by Ygor, the middleware. It is implemented in JavaScript.

The teacher gets an overview of the whole setup's status (connected devices etc.) and can choose applications from a main screen.

Until screen shots are available, see the UX Design Wireframes at Interaction Design Version 0.4 to get an idea of how it looks like.

Possible Applications

Raise Your Hands

Application start

The teacher poses a question to the class. He presses the start button in the frontend. Buzzers change status (e.g. pulsing LEDs) as a sign that users can press a button to raise their hands.

During the timeout period

As soon as a user presses a button on his or her buzzer, the buzzer changes status to a different LED signal. The frontend displays each buzzer status change.

Timeout end

It ends either automatically or the teacher hits the stop button in the frontend. Buzzers change their status to show that the time is over. The computer selects a random buzzer. The selected buzzer changes status (e.g. plays sound, yellow LED flashes). The user with selected buzzer answers the teacher's question.

Evaluate answer

The teacher presses one of the following buttons in the frontend:

  • Correct answer: The buzzer changes status to reflect correct answer. The application returns to the start screen.
  • Incorrect answer and start a new timeout. The buzzer changes status to reflect wrong answer. The application returns to the start screen.
  • Incorrect answer and select a new random buzzer. This option is disabled if there aren't any buzzers left that have pressed a button. The buzzer changes status to reflect wrong answer. The new selected buzzer changes status to answer please.

Votes/Surveys

Students vote on a topic without raising your hand in front of the class which ultimately leads to a more honest voting behaviour. This application enables voting mechanisms that are hard to do with paper like multiple choice and ratings on preferred solutions as in "I'd like option A but if we don't get enough votes for that, option B would be my second favourite".

A question is displayed, there are four possible answers. The students press the button for their most preferred answer, this is their first choice. The button LED is blinking now. If the student wants to select an additional answer (second choice) he presses another button. For affirmation it also blinks, but slower. This procedure works up to four options.

When the vote is over, how many points each option gets is calculated and displayed. The first choice is worth four points, the second three etc.

Group Work/Group Games

Teams of students are chosen by a random generator. This would take the social stress off the teacher. (Student: "I don't want to be in a group with this guy." - Teacher: "The computer has chosen fairly.") Games would be possible where groups compete and if a group performs better it has to let a member go into another group. Also the opposite is possible where the best performing group gets new members.

Quiz mode (à la "Who wants to be a millionaire")

If a student doesn't know the answer he could ask the audience and the other students press the button for what they think is the right answer. The question is displayed to the classroom (beamer or similar). A countdown timer is running, meanwhile the students may press a button corresponding to the possible answers. The result is displayed as a bar chart. The teacher reveals the solution by pressing the blue button, pressing blue again advances to the next question.

Multiple Choice Tests

The teacher holds a live test where the students answer questions with multiple choice answers. (FIXME: Multiple choice tests are not very common in Europe so we need to spend research on this subject.)

Games

Werewolf

A.k.a. Mafia: The base station choses who is the wolf and the others have to find out who it is by talking to each other on a round based system.

Chase

Multiple buzzers are laid out about the class room. Students go from device to device, plug in their ibutton, and push a buzzer button to enter their solution to the quest presented at this station, then go to next station.

Rhythm game

Beatmania work-alike

Application Development

architectural overview

Each Edubuzzer app, e.g. Raise Your Hands, is chiefly implemented in a single responsible JavaScript file, e.g. raise-your-hands.js. Each one can define a single callback, Edubuzzer.run_application which is called when the application is started.

Inside Edubuzzer.run_application it may register other callbacks like Edubuzzer.updated_known_logins which is called whenever a client is added or removed, or Edubuzzer.display which is called in regular intervals.

global.js runs a poor man's event loop and schedules all pollings to the server which result in callbacks of the active app registered being called. An app is activated by changing the URI #hash. The skeleton switches to an app by simply overwriting the display function.

querying buzzers

/ygor is the base URI for the middleware endpoint. Send GET requests to certain named queries, e.g. ?name=ls_accepted_login.sql. For the full list, see directory Ygor/sql/ in the software repository. It returns a JSON array of objects/hashes whose keys are described in the SQL file, e.g. for above:

   [{"rowid":42,"src":"BUZZER-DEVICE-ID","dest":"MASTER-DEVICE-ID",
       "seqnum":23,"ibutton":"SOMETHING","since":"TIMESTAMP",
       "accepted":true,"ack":false}, … ]

Refer to the table schemas in Ygor/schema/ for explicit key/row names. Rely on src for uniquely identifying a buzzer.

The most important query is ls_events.sql because it deals with the device buttons. The first line in the file hints at the additional query parameters, in this case loginid, i.e. the full query string is ?name=ls_events&loginid=ROWID where ROWID is a number received in earlier different queries. Extract the button status from the eventmask field. See docs/serialprotocol for the semantics.

For debugging purposes the middleware exposes an echo interface at base URI /echo. The query string is ignored except for the parameter name Response-Body. Its value is a percent encoded JSON string which unsurprisingly is returned as response body.

For example, you want to mock:

   $.getJSON(
       Edubuzzer.middleware_endpoint+'?name=…',
       function (foo) {
           …
       }
   )

Add a second parameter to the getJSON call, thus:

   $.getJSON(
       Edubuzzer.middleware_mock_endpoint+'?name=…',
       'Response-Body'+encodeURIComponent('[{"rowid":123}]')
       function (foo) {
           …
       }
   )

instruction list

  • decide on an app name (e.g. exampleapp)
  • create a new JavaScript file with the name
  • implement the run_application function and the hooks you need
    • present the app UI in element #buzzers
    • keep internal data under the Edubuzzer.exampleapp namespace
  • add the app name/link in index.xhtml
  • register the app in global.js
  • add styles in edubuzzer.css