In Assigning badges to pages I covered what a script would look like that could generate a badge awarding environment. Typically you would create a UI to manage this, rather than doing it through scripts. However, here’s another approach using a spreadsheet to describe your questions and answers.
- panelsets. These are lists of collections of badges (described in the collections tab) that should be presented in response to a request for a panel set of the given id. Typically these would be badges that represented learnable topics on the page that holds the panel.
- collections. These are collections of badges (described in the badges tab) that would typically go together. A set of collections are referenced by a panelset and together are shown on a page. A collection can be referenced by multiple panelsets
- badges. These are badges that can be earned, and must appear in collection(s) to be accessible from a panelset. They refer to questionets (which appear in the questionset tab). These questionsets must be answered to qualify for a badge. A badge can appear in multiple collections.
- questionsets. These are a list of questions (described in the question tab), that would typically go together. A questionset can be associated with multiple badges
- questions. These are the questions and answers that would be combined into a questionset and associated with a badge. A question can appear in multiple questionsets
By splitting up the components in this way, questions, collections, questionsets and badges can be recombined in multiple ways depending on the topic the panelset refers to.
Creating the scriptdb
- You may not want to make this sheet public, or to publish it as a web app
- You may have multiple sheets, or a UI, all of which modify the shared scriptdb that holds your badge data.
Taking the test
The badge set below selects one of the panelsets created from the spreadsheet discussed above.
function makeMyBadgeData() { // this would be if you were populating a scriptdb in some other script mcpher.makeBadgesFromSheet(badgeManager.publicStuffDb()); // or you could use this one.. //mcpher.makeBadgesFromSheet(ScriptDb.getMyDb()); }
The code
Here is the code that generates the scriptDB data from the sheet above.
function makeMyBadgeData() { // this would be if you were populating a scriptdb in some other script mcpher.makeBadgesFromSheet(badgeManager.publicStuffDb()); // or you could use this one.. //mcpher.makeBadgesFromSheet(ScriptDb.getMyDb()); } // this stuff is for being able to publish function showMyScriptDb() { return publicStuffDb(); } function showMyScriptAppResource(s) { try { return ScriptApp.getResource(s); } catch (err) { throw err + " getting script " + s; } } function publicStuffDb() { return ScriptDb.getMyDb(); }
For help and more information join our forum, follow the blog or follow me on Twitter .