From 68c9a3b472970f6c3da19ee98465bc78cacdb22a Mon Sep 17 00:00:00 2001 From: hchiam Date: Mon, 23 Apr 2018 21:08:30 -0400 Subject: [PATCH] final commit before submitting version 2 for review --- .../intents/1.0 Default Welcome Intent.json | 2 +- ....0 Default Welcome Intent_usersays_en.json | 90 ++++--------------- Code-Tutor/intents/1.7 sandbox.json | 6 +- .../intents/1.7 sandbox_usersays_en.json | 4 +- Code-Tutor/intents/3.7.4 sandbox - if.json | 2 +- .../3.7.4 sandbox - if_usersays_en.json | 42 +++++++-- index.js | 5 +- 7 files changed, 59 insertions(+), 92 deletions(-) diff --git a/Code-Tutor/intents/1.0 Default Welcome Intent.json b/Code-Tutor/intents/1.0 Default Welcome Intent.json index 2b8db78..461a931 100644 --- a/Code-Tutor/intents/1.0 Default Welcome Intent.json +++ b/Code-Tutor/intents/1.0 Default Welcome Intent.json @@ -61,7 +61,7 @@ "priority": 500000, "webhookUsed": false, "webhookForSlotFilling": false, - "lastUpdate": 1524527328, + "lastUpdate": 1524531900, "fallbackIntent": false, "events": [ { diff --git a/Code-Tutor/intents/1.0 Default Welcome Intent_usersays_en.json b/Code-Tutor/intents/1.0 Default Welcome Intent_usersays_en.json index 58775c7..61c8f0a 100644 --- a/Code-Tutor/intents/1.0 Default Welcome Intent_usersays_en.json +++ b/Code-Tutor/intents/1.0 Default Welcome Intent_usersays_en.json @@ -1,6 +1,6 @@ [ { - "id": "17016e26-d3fc-467f-b33a-8a4064b20660", + "id": "a813c96c-1144-467d-9fed-4a631afd88bf", "data": [ { "text": "what is this", @@ -12,7 +12,7 @@ "updated": 1524527328 }, { - "id": "1287e6be-22b2-4561-bdee-8fa9fd9c808e", + "id": "a37eff9f-3d90-42e8-af3f-fc951d18c39c", "data": [ { "text": "What do I do", @@ -24,19 +24,7 @@ "updated": 1524527328 }, { - "id": "b9d239d2-5b27-4fec-9dcf-dae6a3f9c5ad", - "data": [ - { - "text": "hi", - "userDefined": false - } - ], - "isTemplate": false, - "count": 2, - "updated": 1524527328 - }, - { - "id": "348598db-c7c6-48c1-a163-444eb0fa3c45", + "id": "d55a71f2-da14-499a-861f-35c2892f6bb7", "data": [ { "text": "teach me to program", @@ -48,7 +36,7 @@ "updated": 1524527328 }, { - "id": "eac3f7a7-3753-4b0c-bb63-672a88f1f0a3", + "id": "cdf98b49-624a-4afc-adaf-efed1b88ae24", "data": [ { "text": "what can i do", @@ -60,7 +48,7 @@ "updated": 1524527328 }, { - "id": "e4e2e33b-e629-433e-bf9f-f1fa5667adda", + "id": "943c7185-5979-4fca-b845-a0449dcad66c", "data": [ { "text": "what do you do", @@ -72,7 +60,7 @@ "updated": 1524527328 }, { - "id": "a2637368-0c32-4e5d-85c0-9eccbe8b520a", + "id": "9300e4fe-feaf-4cd1-933f-2e8279f01293", "data": [ { "text": "How do I program by talking?", @@ -84,7 +72,7 @@ "updated": 1524527328 }, { - "id": "95a3d514-62dd-4de6-82ee-22f064f0b19f", + "id": "a9b8db73-c771-479b-aecc-1b8a3173d4b8", "data": [ { "text": "How can I program by voice?", @@ -96,7 +84,7 @@ "updated": 1524527328 }, { - "id": "55c84e5b-e78a-40dc-b554-ec3495559517", + "id": "c7deb1cd-0176-4667-8e41-60e73380d3c5", "data": [ { "text": "I want to learn to program", @@ -108,7 +96,7 @@ "updated": 1524527328 }, { - "id": "b670292c-5796-4826-bdcc-62fdf46710ac", + "id": "67272d9e-c65b-49b2-b547-98a4a121b7ec", "data": [ { "text": "teach me how to code", @@ -120,7 +108,7 @@ "updated": 1524527328 }, { - "id": "d09ee55a-a7d2-4087-bf83-50bc11322f8c", + "id": "e3c684c7-1606-4af4-88f1-4654f1b338e9", "data": [ { "text": "go back to the beginning", @@ -132,7 +120,7 @@ "updated": 1524527328 }, { - "id": "651a7a2b-eada-43ad-a270-1dd555eeb37f", + "id": "30afccf7-9816-462d-9206-1972a3611963", "data": [ { "text": "let\u0027s start again", @@ -144,7 +132,7 @@ "updated": 1524527328 }, { - "id": "60f1c05b-2d30-425b-9119-28e255f615bb", + "id": "d344d238-418f-4283-b96a-f6b5c8985982", "data": [ { "text": "how do you use this?", @@ -156,7 +144,7 @@ "updated": 1524527328 }, { - "id": "5bf1ef96-f112-450c-acf8-1cc5948b2fe2", + "id": "12203eab-957d-44d9-bae9-bffc6d464331", "data": [ { "text": "what am i supposed to do", @@ -168,7 +156,7 @@ "updated": 1524527328 }, { - "id": "74113db4-6500-4b81-a5f6-a476ca0fd03c", + "id": "11ef8587-3764-4e9d-b28e-bb544c1cbfa0", "data": [ { "text": "how does this work", @@ -180,7 +168,7 @@ "updated": 1524527328 }, { - "id": "626b4ab0-43db-4885-b557-561eb30e947e", + "id": "a29c423d-c435-4779-ad94-90ff89a36f39", "data": [ { "text": "what\u0027s going on", @@ -190,53 +178,5 @@ "isTemplate": false, "count": 0, "updated": 1524527328 - }, - { - "id": "078f500e-6030-4967-ade2-5ebdf39e6a6a", - "data": [ - { - "text": "let\u0027s begin", - "userDefined": false - } - ], - "isTemplate": false, - "count": 0, - "updated": 1524527328 - }, - { - "id": "072146b9-a4a4-47ad-b2a8-a2b7b7a671f2", - "data": [ - { - "text": "let\u0027s start", - "userDefined": false - } - ], - "isTemplate": false, - "count": 0, - "updated": 1524527328 - }, - { - "id": "3c037c9b-941d-4adc-a27a-f86ad5c49e18", - "data": [ - { - "text": "hey", - "userDefined": false - } - ], - "isTemplate": false, - "count": 0, - "updated": 1524527328 - }, - { - "id": "8e1a74a4-ae7e-4cb0-a578-efb944dbfef1", - "data": [ - { - "text": "hello", - "userDefined": false - } - ], - "isTemplate": false, - "count": 1, - "updated": 1524527328 } ] \ No newline at end of file diff --git a/Code-Tutor/intents/1.7 sandbox.json b/Code-Tutor/intents/1.7 sandbox.json index 4fd91ec..5946761 100644 --- a/Code-Tutor/intents/1.7 sandbox.json +++ b/Code-Tutor/intents/1.7 sandbox.json @@ -21,8 +21,8 @@ "platform": "google", "lang": "en", "customizeAudio": true, - "ssml": "\u003cspeak\u003e\u003caudio src\u003d\"https://actions.google.com/sounds/v1/cartoon/wood_plank_flicks.ogg\"\u003e\u003c/audio\u003eIn this \"sandbox\", you have a little freedom to create any code you want. Here\u0027s examples of instructions you can say: \u003cbreak time\u003d\"1s\"/\u003e Apple equals 1. \u003cbreak time\u003d\"1s\"/\u003e Repeat 3 times. \u003cbreak time\u003d\"1s\"/\u003e Say hi. \u003cbreak time\u003d\"1s\"/\u003e If banana equals fruit. \u003cbreak time\u003d\"1s\"/\u003e When you\u0027re done, say \"run code\", and I\u0027ll follow the instructions. \u003cbreak time\u003d\"1s\"/\u003e If you need this list again, just say \"what\u0027s on the list\"\u003c/speak\u003e", - "displayText": "In this \"sandbox\", you have a little freedom to create any code you want. Here\u0027s examples of instructions you can say:\n\n* apple equals 1\n* repeat 3 times\n* say hi\n* if banana equals fruit\n\nWhen you\u0027re done, say \"run code\", and I\u0027ll follow the instructions.\n\nIf you need this list again, just say \"what\u0027s on the list?\"" + "ssml": "\u003cspeak\u003e\u003caudio src\u003d\"https://actions.google.com/sounds/v1/cartoon/wood_plank_flicks.ogg\"\u003e\u003c/audio\u003eIn this \"sandbox\", you have a little freedom to create almost any code you want. Here\u0027s examples of instructions you can say: \u003cbreak time\u003d\"1s\"/\u003e Apple equals 1. \u003cbreak time\u003d\"1s\"/\u003e Repeat 3 times. \u003cbreak time\u003d\"1s\"/\u003e Say hi. \u003cbreak time\u003d\"1s\"/\u003e If banana equals fruit. \u003cbreak time\u003d\"1s\"/\u003e When you\u0027re done, say \"run code\", and I\u0027ll follow the instructions. \u003cbreak time\u003d\"1s\"/\u003e If you need this list again, just say \"what\u0027s on the list\"\u003c/speak\u003e", + "displayText": "In this \"sandbox\", you have a little freedom to create almost any code you want. Here\u0027s examples of instructions you can say:\n\n* apple equals 1.\n* repeat 3 times.\n* say hi.\n* if banana equals fruit.\n\nWhen you\u0027re done, say \"run code\", and I\u0027ll follow the instructions.\n\nIf you need this list again, just say \"what\u0027s on the list?\"" }, { "type": 0, @@ -39,7 +39,7 @@ "priority": 500000, "webhookUsed": false, "webhookForSlotFilling": false, - "lastUpdate": 1524530252, + "lastUpdate": 1524531841, "fallbackIntent": false, "events": [] } \ No newline at end of file diff --git a/Code-Tutor/intents/1.7 sandbox_usersays_en.json b/Code-Tutor/intents/1.7 sandbox_usersays_en.json index a1151bd..e0e8676 100644 --- a/Code-Tutor/intents/1.7 sandbox_usersays_en.json +++ b/Code-Tutor/intents/1.7 sandbox_usersays_en.json @@ -1,6 +1,6 @@ [ { - "id": "6f9c9d31-301b-440c-9a21-d86cd7120a78", + "id": "882f476c-7ede-4914-bd34-278e2ce20ba2", "data": [ { "text": "sandbox", @@ -9,6 +9,6 @@ ], "isTemplate": false, "count": 0, - "updated": 1524530174 + "updated": 1524531841 } ] \ No newline at end of file diff --git a/Code-Tutor/intents/3.7.4 sandbox - if.json b/Code-Tutor/intents/3.7.4 sandbox - if.json index f4e2a86..b45b5d9 100644 --- a/Code-Tutor/intents/3.7.4 sandbox - if.json +++ b/Code-Tutor/intents/3.7.4 sandbox - if.json @@ -64,7 +64,7 @@ "priority": 500000, "webhookUsed": true, "webhookForSlotFilling": false, - "lastUpdate": 1524412508, + "lastUpdate": 1524531940, "fallbackIntent": false, "events": [] } \ No newline at end of file diff --git a/Code-Tutor/intents/3.7.4 sandbox - if_usersays_en.json b/Code-Tutor/intents/3.7.4 sandbox - if_usersays_en.json index 886942c..b41e8b3 100644 --- a/Code-Tutor/intents/3.7.4 sandbox - if_usersays_en.json +++ b/Code-Tutor/intents/3.7.4 sandbox - if_usersays_en.json @@ -1,6 +1,30 @@ [ { - "id": "6f2746f2-f089-48c7-8ece-5c4be35de3d2", + "id": "b1638575-bb65-4d87-87e4-d5ebe5e1e589", + "data": [ + { + "text": "check if @sys.any:variable equals @sys.any:value then", + "userDefined": false + } + ], + "isTemplate": true, + "count": 0, + "updated": 1524531940 + }, + { + "id": "7140a077-6ef8-4231-b4e6-d04af07f4393", + "data": [ + { + "text": "check if @sys.any:variable equals @sys.any:value", + "userDefined": false + } + ], + "isTemplate": true, + "count": 0, + "updated": 1524531940 + }, + { + "id": "587063cf-8e29-43e8-8641-d6131c971203", "data": [ { "text": "if @sys.any:variable \u003d\u003d @sys.any:value", @@ -12,7 +36,7 @@ "updated": 1524412508 }, { - "id": "ec060771-d8e2-40b7-b16f-87e5b96b1e00", + "id": "70457962-e6d7-4166-abe5-2bd5eb62c952", "data": [ { "text": "if @sys.any:variable \u003d @sys.any:value then", @@ -24,7 +48,7 @@ "updated": 1524412508 }, { - "id": "6b700e39-a7da-46b1-bf12-ffe31e9b841c", + "id": "d2d8805d-e706-4602-b513-29494a8bae64", "data": [ { "text": "if @sys.any:variable \u003d @sys.any:value", @@ -36,7 +60,7 @@ "updated": 1524412508 }, { - "id": "2c540ae4-c52b-4bde-9cba-c711946db245", + "id": "77959250-100d-4d07-b740-67ddb051140e", "data": [ { "text": "if @sys.any:variable is @sys.any:value then", @@ -48,7 +72,7 @@ "updated": 1524279451 }, { - "id": "ffa39423-198e-4249-b5c4-884c8aaf1120", + "id": "7b0d3be8-c292-4944-a0eb-5ed034b41267", "data": [ { "text": "if @sys.any:variable is @sys.any:value", @@ -60,7 +84,7 @@ "updated": 1524279451 }, { - "id": "e5ffc1c1-4f60-402d-bc58-6c622b3ee054", + "id": "8ca350cf-f391-4a6a-9496-8dbf8a89d427", "data": [ { "text": "if @sys.any:variable is equal to @sys.any:value then", @@ -72,7 +96,7 @@ "updated": 1524279451 }, { - "id": "aea5c17a-3612-4aae-9f1c-ac55b93923e0", + "id": "fdaa1e2b-949d-46a9-8bc7-8441d039afa3", "data": [ { "text": "if @sys.any:variable is equal to @sys.any:value", @@ -84,7 +108,7 @@ "updated": 1524279451 }, { - "id": "eb5fd90a-3f95-406e-bdbe-d79bb7da68c9", + "id": "d8a6f6b3-53bd-4b65-b968-9835c57e9bfb", "data": [ { "text": "if @sys.any:variable equals @sys.any:value then", @@ -96,7 +120,7 @@ "updated": 1524279451 }, { - "id": "685cdb46-39e2-4c9f-bfdb-574ab81a2ae8", + "id": "2a9adfc6-8614-45d0-b8d5-eb05e870613e", "data": [ { "text": "if @sys.any:variable equals @sys.any:value", diff --git a/index.js b/index.js index 7a45ed4..610dcdf 100644 --- a/index.js +++ b/index.js @@ -163,7 +163,7 @@ exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, resp let googleResponse = app.buildRichResponse() .addSimpleResponse("Here's your code:") .addSimpleResponse({ - speech: `${code}. That's it for the code. Now, in code, we count from 0. And because we want to repeat ${times} times, we need to stop 1 step before ${times}. Say "run code" and I'll follow the instructions.`, + speech: `${code}. That's it for the code. By the way, in code, we count from 0. And because we want to repeat ${times} times, we need to stop 1 step before ${times}. Say "run code" and I'll follow the instructions.`, displayText: code }) .addSuggestions(['run code', 'do something else']) @@ -583,6 +583,9 @@ const getOutput = (code) => { } else if (isAfterFor) { let times = parseInt(isAfterFor[2]) - parseInt(isAfterFor[1]); + if (times === undefined || times > 5 || times < 1) { + times = 5; + } if (isSaying) { let variableName = isSaying[1]; if (codeVariables.includes(variableName)) {