diff --git a/ChangeLog.md b/ChangeLog.md index c3b0917..61a6fb6 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +## [v0.9.2] - 2023-06-23 +### Security +- Upgraded signature to match the security standard. ## [v0.9.1] - 2019-12-23 ### Added diff --git a/LearnosityDemo/LearnosityDemo.sln b/LearnosityDemo/LearnosityDemo.sln new file mode 100644 index 0000000..16ff9fd --- /dev/null +++ b/LearnosityDemo/LearnosityDemo.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 25.0.1704.3 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LearnosityDemo", "LearnosityDemo.csproj", "{27F96458-915A-4C09-91CF-C72F2144559F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {27F96458-915A-4C09-91CF-C72F2144559F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {27F96458-915A-4C09-91CF-C72F2144559F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {27F96458-915A-4C09-91CF-C72F2144559F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {27F96458-915A-4C09-91CF-C72F2144559F}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {1FD8BD7C-CC74-4222-AE18-82F15D9DF2CE} + EndGlobalSection +EndGlobal diff --git a/LearnosityDemo/Pages/AssessAPIDemo.cshtml b/LearnosityDemo/Pages/AssessAPIDemo.cshtml new file mode 100644 index 0000000..2d6cc71 --- /dev/null +++ b/LearnosityDemo/Pages/AssessAPIDemo.cshtml @@ -0,0 +1,26 @@ +@page +@model LearnosityDemo.Pages.AssessAPIDemoModel +@{ + ViewData["Title"] = "Learnosity Example: Standalone Assessment"; + ViewData["TopJS"] = ""; + +} + +
+ + diff --git a/LearnosityDemo/Pages/AssessAPIDemo.cshtml.cs b/LearnosityDemo/Pages/AssessAPIDemo.cshtml.cs new file mode 100644 index 0000000..b11a371 --- /dev/null +++ b/LearnosityDemo/Pages/AssessAPIDemo.cshtml.cs @@ -0,0 +1,414 @@ +using System; +using System.Text; +using LearnositySDK; +using LearnositySDK.Examples; +using LearnositySDK.Request; +using LearnositySDK.Utils; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; +using Newtonsoft.Json; + +namespace LearnosityDemo.Pages +{ + public class AssessAPIDemoModel : PageModel + { + public void OnGet(string mode) + { + string uuid = Uuid.generate(); + string courseId = "mycourse"; + string questionsApiActivityJson = AssessAPIDemoModel.questionsApiActivity(uuid, courseId); + JsonObject questionsApiActivity = JsonObjectFactory.fromString(questionsApiActivityJson); + + string service = "assess"; + + JsonObject security = new JsonObject(); + security.set("consumer_key", Credentials.ConsumerKey); + security.set("user_id", "$ANONYMIZED_USER_ID"); + security.set("domain", Credentials.Domain); + + string secret = Credentials.ConsumerSecret; + + JsonObject request = new JsonObject(); + request.set("name", "Demo Activity (8 questions)"); + request.set("state", "initial"); + request.set("items", AssessAPIDemoModel.items(uuid)); + request.set("questionsApiActivity", questionsApiActivity); + + Init init = new Init(service, security, secret, request); + ViewData["InitJSON"] = init.generate(); + } + + private static JsonObject items(string uuid) + { + JsonObject items = new JsonObject(true); + + for (int i = 3; i <= 10; i++) + { + JsonObject responseIDs = new JsonObject(true); + responseIDs.set(uuid + "_Demo" + i.ToString()); + JsonObject item = new JsonObject(); + item.set("reference", "Demo" + i.ToString()); + item.set("content", ""); + item.set("workflow", new JsonObject(true)); + item.set("response_ids", responseIDs); + item.set("feature_ids", new JsonObject(true)); + items.set(item); + } + + return items; + } + + private static string questionsApiActivity(string uuid, string courseId) + { + return string.Format(@"{{ + ""type"": ""submit_practice"", + ""state"": ""initial"", + ""id"": ""assessdemo"", + ""name"": ""Assess API - Demo"", + ""course_id"": ""{1}"", + ""questions"": [ + {{ + ""type"": ""orderlist"", + ""list"": [ + ""cat"", + ""horse"", + ""pig"", + ""elephant"", + ""mouse"" + ], + ""stimulus"": ""Arrange these animals from smallest to largest
"", + ""ui_style"": ""button"", + ""validation"": {{ + ""show_partial_ui"": true, + ""partial_scoring"": true, + ""valid_score"": 1, + ""penalty_score"": 0, + ""valid_response"": [ + 4, + 0, + 2, + 1, + 3 + ], + ""pairwise"": false + }}, + ""instant_feedback"": true, + ""response_id"": ""{0}_Demo3"", + ""metadata"": {{ + ""sheet_reference"": ""Demo3"", + ""widget_reference"": ""Demo3"" + }} + }}, + {{ + ""type"": ""clozeassociation"", + ""template"": ""The United States of America was founded in {{{{response}}}}.
"", + ""possible_responses"": [ + ""1676"", + ""1776"", + ""1876"" + ], + ""feedback_attempts"": 2, + ""instant_feedback"": true, + ""validation"": {{ + ""show_partial_ui"": true, + ""partial_scoring"": true, + ""valid_score"": 1, + ""penalty_score"": 0, + ""valid_responses"": [ + [ + ""1776"" + ] + ] + }}, + ""response_id"": ""{0}_Demo4"", + ""metadata"": {{ + ""sheet_reference"": ""Demo4"", + ""widget_reference"": ""Demo4"" + }} + }}, + {{ + ""type"": ""clozetext"", + ""template"": ""What is the sum of \\\\(785 \\\\times 89\\\\)
{{{{response}}}}"", + ""is_math"": true, + ""validation"": {{ + ""show_partial_ui"": true, + ""partial_scoring"": true, + ""valid_score"": 1, + ""penalty_score"": 0, + ""valid_responses"": [ + [ + ""69865"" + ] + ] + }}, + ""instant_feedback"": true, + ""response_id"": ""{0}_Demo5"", + ""metadata"": {{ + ""sheet_reference"": ""Demo5"", + ""widget_reference"": ""Demo5"" + }} + }}, + {{ + ""type"": ""numberline"", + ""points"": [ + ""5/5"", + ""1/4"", + ""2/4"", + ""7/8"" + ], + ""is_math"": true, + ""labels"": {{ + ""points"": ""0,1,2,3,4"", + ""show_min"": true, + ""show_max"": true + }}, + ""line"": {{ + ""min"": 0, + ""max"": 4, + ""left_arrow"": true, + ""right_arrow"": true + }}, + ""stimulus"": ""Drag the points onto the numberline.
"", + ""ticks"": {{ + ""distance"": "".25"", + ""show"": true + }}, + ""validation"": {{ + ""partial_scoring"": ""true"", + ""show_partial_ui"": ""true"", + ""valid_score"": ""1"", + ""penalty_score"": ""0"", + ""threshold"": ""0"", + ""valid_responses"": [ + {{ + ""point"": ""5/5"", + ""position"": ""1"" + }}, + {{ + ""point"": ""1/4"", + ""position"": "".25"" + }}, + {{ + ""point"": ""2/4"", + ""position"": ""2"" + }}, + {{ + ""point"": ""7/8"", + ""position"": ""3.5"" + }} + ] + }}, + ""instant_feedback"": true, + ""snap_to_ticks"": true, + ""response_id"": ""{0}_Demo6"", + ""metadata"": {{ + ""sheet_reference"": ""Demo6"", + ""widget_reference"": ""Demo6"" + }} + }}, + {{ + ""type"": ""tokenhighlight"", + ""template"": ""He was told not to laugh in class.
"", + ""tokenization"": ""word"", + ""validation"": {{ + ""show_partial_ui"": true, + ""partial_scoring"": true, + ""valid_score"": 1, + ""penalty_score"": 0, + ""valid_responses"": [ + 5 + ] + }}, + ""stimulus"": ""Highlight the verb in the sentence below.
"", + ""instant_feedback"": true, + ""response_id"": ""{0}_Demo7"", + ""metadata"": {{ + ""sheet_reference"": ""Demo7"", + ""widget_reference"": ""Demo7"" + }} + }}, + {{ + ""type"": ""mcq"", + ""options"": [ + {{ + ""value"": ""0"", + ""label"": ""Berlin"" + }}, + {{ + ""value"": ""1"", + ""label"": ""Paris"" + }}, + {{ + ""value"": ""2"", + ""label"": ""London"" + }}, + {{ + ""value"": ""3"", + ""label"": ""Madrid"" + }} + ], + ""stimulus"": ""What\'s the capital of France?"", + ""stimulus_review"": ""Something Else"", + ""ui_style"": {{ + ""type"": ""block"", + ""choice_label"": ""upper-alpha"" + }}, + ""valid_responses"": [ + {{ + ""value"": ""1"", + ""score"": 1 + }} + ], + ""instant_feedback"": true, + ""response_id"": ""{0}_Demo8"", + ""metadata"": {{ + ""sheet_reference"": ""Demo8"", + ""widget_reference"": ""Demo8"" + }} + }}, + {{ + ""type"": ""clozedropdown"", + ""template"": ""“It’s all clear,’ he {{{{response}}}}. “Have you the chisel and the bags? Great Scott! Jump, Archie, jump, and I’ll swing for it!’ Sherlock {{{{response}}}} had sprung out and seized the {{{{response}}}} by the collar. The other dived down the hole, and I heard the sound of {{{{response}}}} cloth as Jones clutched at his skirts. The light flashed upon the barrel of a revolver, but Holmes’ {{{{response}}}} came down on the man’s wrist, and the pistol {{{{response}}}} upon the stone floor."", + ""possible_responses"": [ + [ + ""whispered"", + ""sprinted"", + ""joked"" + ], + [ + ""Homes"", + ""holmes"", + ""Holmes"" + ], + [ + ""acquaintance"", + ""intruder"", + ""shopkeeper"" + ], + [ + ""burning"", + ""departing"", + ""rending"", + ""broken"" + ], + [ + ""revolver"", + ""hunting crop"" + ], + [ + ""rattled"", + ""clinked"", + ""spilt"" + ] + ], + ""stimulus"": ""Fill in the blanks.
"", + ""validation"": {{ + ""show_partial_ui"": true, + ""partial_scoring"": true, + ""valid_score"": 1, + ""penalty_score"": 0, + ""valid_responses"": [ + [ + ""whispered"" + ], + [ + ""Holmes"" + ], + [ + ""intruder"" + ], + [ + ""rending"" + ], + [ + ""hunting crop"" + ], + [ + ""clinked"" + ] + ] + }}, + ""instant_feedback"": true, + ""response_id"": ""{0}_Demo9"", + ""metadata"": {{ + ""sheet_reference"": ""Demo9"", + ""widget_reference"": ""Demo9"" + }} + }}, + {{ + ""type"": ""graphplotting"", + ""axis_x"": {{ + ""ticks_distance"": 1, + ""draw_labels"": true + }}, + ""axis_y"": {{ + ""ticks_distance"": 1, + ""draw_labels"": true + }}, + ""canvas"": {{ + ""x_min"": 0, + ""x_max"": 10.2, + ""y_min"": -0.5, + ""y_max"": 10.2, + ""snap_to"": ""grid"" + }}, + ""grid"": {{ + ""x_distance"": 1, + ""y_distance"": 1 + }}, + ""toolbar"": {{ + ""tools"": [ + ""point"", + ""move"" + ], + ""default_tool"": ""point"" + }}, + ""ui_style"": {{ + ""margin"": ""10px"" + }}, + ""stimulus"": ""Plot the following points \\\\((2,5), (4,8), (8,1)\\\\).
"", + ""is_math"": true, + ""validation"": {{ + ""valid_score"": ""1"", + ""penalty_score"": ""0"", + ""valid_responses"": [ + [ + {{ + ""id"": ""lrn_1"", + ""type"": ""point"", + ""coords"": {{ + ""x"": 2, + ""y"": 5 + }} + }}, + {{ + ""id"": ""lrn_2"", + ""type"": ""point"", + ""coords"": {{ + ""x"": 4, + ""y"": 8 + }} + }}, + {{ + ""id"": ""lrn_3"", + ""type"": ""point"", + ""coords"": {{ + ""x"": 8, + ""y"": 1 + }} + }} + ] + ] + }}, + ""instant_feedback"": true, + ""response_id"": ""{0}_Demo10"", + ""metadata"": {{ + ""sheet_reference"": ""Demo10"", + ""widget_reference"": ""Demo10"" + }} + }} + ] + }}", uuid, courseId); + } + } +} diff --git a/LearnosityDemo/Pages/AuthorAPIDemo.cshtml b/LearnosityDemo/Pages/AuthorAPIDemo.cshtml new file mode 100644 index 0000000..878f4dd --- /dev/null +++ b/LearnosityDemo/Pages/AuthorAPIDemo.cshtml @@ -0,0 +1,23 @@ +@page +@model LearnosityDemo.Pages.AuthorAPIDemoModel +@{ + ViewData["Title"] = "Learnosity Example: Standalone Assessment"; + ViewData["TopJS"] = ""; + + } + + + + diff --git a/LearnosityDemo/Pages/AuthorAPIDemo.cshtml.cs b/LearnosityDemo/Pages/AuthorAPIDemo.cshtml.cs new file mode 100644 index 0000000..41df008 --- /dev/null +++ b/LearnosityDemo/Pages/AuthorAPIDemo.cshtml.cs @@ -0,0 +1,117 @@ +using System; +using System.Text; +using LearnositySDK.Request; +using LearnositySDK.Utils; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; +using Newtonsoft.Json; + +namespace LearnosityDemo.Pages +{ + public class AuthorAPIDemoModel : PageModel + { + public void OnGet(string mode) + { + // Author API contains 2 modes + // item_edit mode and item_list mode + // the below example generate initOptions for item_edit mode + // more information about item_list mode can be found in initializeItemList() function + Init init = (mode == "item_list") ? initializeItemList() : initializeItemEdit(); + ViewData["InitJSON"] = init.generate(); + } + + private static Init initializeItemEdit() + { + string service = "author"; + + JsonObject security = new JsonObject(); + security.set("consumer_key", LearnositySDK.Credentials.ConsumerKey); + security.set("domain", LearnositySDK.Credentials.Domain); + + string secret = LearnositySDK.Credentials.ConsumerSecret; + + JsonObject request = new JsonObject(); + request.set("mode", "item_edit"); + request.set("reference", Uuid.generate()); + + JsonObject config = new JsonObject(); + JsonObject config_item_edit = new JsonObject(); + JsonObject config_item_edit_widget = new JsonObject(); + config_item_edit_widget.set("delete", true); + config_item_edit_widget.set("edit", true); + config_item_edit.set("widget", config_item_edit_widget); + JsonObject config_item_edit_item = new JsonObject(); + JsonObject config_item_edit_item_tags = new JsonObject(); + JsonObject config_item_edit_item_tags_includesTagOnEdit = new JsonObject(true); + JsonObject config_item_edit_item_tags_includesTagOnEdit_tag = new JsonObject(); + config_item_edit_item_tags_includesTagOnEdit_tag.set("type", "course"); + config_item_edit_item_tags_includesTagOnEdit_tag.set("name", "commoncore"); + config_item_edit_item_tags_includesTagOnEdit.set(config_item_edit_item_tags_includesTagOnEdit_tag); + config_item_edit_item_tags.set("include_tags_on_edit", config_item_edit_item_tags_includesTagOnEdit); + config_item_edit_item.set("tags", config_item_edit_item_tags); + config_item_edit.set("item", config_item_edit_item); + config.set("item_edit", config_item_edit); + + JsonObject config_questionEditorInitOptions = new JsonObject(); + JsonObject config_questionEditorInitOptions_ui = new JsonObject(); + config_questionEditorInitOptions_ui.set("question_tiles", false); + config_questionEditorInitOptions_ui.set("documentation_link", false); + config_questionEditorInitOptions_ui.set("change_button", true); + config_questionEditorInitOptions_ui.set("source_button", false); + config_questionEditorInitOptions_ui.set("fixed_preview", true); + config_questionEditorInitOptions_ui.set("advanced_group", false); + config_questionEditorInitOptions_ui.set("search_field", false); + config_questionEditorInitOptions.set("ui", config_questionEditorInitOptions_ui); + config.set("question_editor_init_options", config_questionEditorInitOptions); + + request.set("config", config); + + JsonObject user = new JsonObject(); + user.set("id", "brianmoser"); + user.set("firstname", "Test"); + user.set("lastname", "Test"); + user.set("email", "test@test.com"); + request.set("user", user); + + return new Init(service, security, secret, request); + } + + private static Init initializeItemList() + { + string service = "author"; + + JsonObject security = new JsonObject(); + security.set("consumer_key", LearnositySDK.Credentials.ConsumerKey); + security.set("domain", LearnositySDK.Credentials.Domain); + + string secret = LearnositySDK.Credentials.ConsumerSecret; + + JsonObject request = new JsonObject(); + request.set("mode", "item_list"); + + JsonObject config = new JsonObject(); + JsonObject config_item_list = new JsonObject(); + JsonObject config_item_list_toolbar = new JsonObject(); + config_item_list_toolbar.set("add", true); + config_item_list.set("toolbar", config_item_list_toolbar); + config.set("item_list", config_item_list); + request.set("config", config); + + JsonObject tags = new JsonObject(true); + JsonObject tag = new JsonObject(); + tag.set("type", "course"); + tag.set("name", "commoncore"); + tags.set(tag); + request.set("tags", tags); + + JsonObject user = new JsonObject(); + user.set("id", "brianmoser"); + user.set("firstname", "Test"); + user.set("lastname", "Test"); + user.set("email", "test@test.com"); + request.set("user", user); + + return new Init(service, security, secret, request); + } + } +} diff --git a/LearnosityDemo/Pages/Index.cshtml b/LearnosityDemo/Pages/Index.cshtml index b78b99c..2906fb1 100644 --- a/LearnosityDemo/Pages/Index.cshtml +++ b/LearnosityDemo/Pages/Index.cshtml @@ -8,6 +8,11 @@Click to load:
+Click to load:
+Click to load:
+Click to load:
+Click to load:
+Click to load:
For instructions, see the tutorial for this project in the README file.
diff --git a/LearnosityDemo/Pages/ItemsAPIDemo.cshtml b/LearnosityDemo/Pages/ItemsAPIDemo.cshtml index 0679949..10e5d7e 100644 --- a/LearnosityDemo/Pages/ItemsAPIDemo.cshtml +++ b/LearnosityDemo/Pages/ItemsAPIDemo.cshtml @@ -2,12 +2,11 @@ @model LearnosityDemo.Pages.ItemsAPIDemoModel @{ ViewData["Title"] = "Learnosity Example: Standalone Assessment"; - ViewData["TopJS"] = ""; + ViewData["TopJS"] = ""; } - "; + +} + + + + diff --git a/LearnosityDemo/Pages/QuestioneditorAPIDemo.cshtml.cs b/LearnosityDemo/Pages/QuestioneditorAPIDemo.cshtml.cs new file mode 100644 index 0000000..ef716a6 --- /dev/null +++ b/LearnosityDemo/Pages/QuestioneditorAPIDemo.cshtml.cs @@ -0,0 +1,47 @@ +using System; +using System.Text; +using LearnositySDK; +using LearnositySDK.Examples; +using LearnositySDK.Request; +using LearnositySDK.Utils; +using Microsoft.AspNetCore.DataProtection; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; +using Newtonsoft.Json; + +namespace LearnosityDemo.Pages +{ + public class QuestioneditorAPIDemoModel : PageModel + { + public void OnGet(string mode) + { + JsonObject request = new JsonObject(); + JsonObject consumer_key = new JsonObject(); + consumer_key.set("consumer_key", LearnositySDK.Credentials.ConsumerKey); + request.set("configuration", consumer_key); + request.set("widget_conversion", true); + + JsonObject ui = new JsonObject(); + ui.set("search_field", true); + + JsonObject layout = new JsonObject(); + layout.set("global_template", "edit_preview"); + layout.set("mode", "advanced"); + ui.set("layout", layout); + request.set("ui", ui); + string service = "questions"; + + JsonObject security = new JsonObject(); + security.set("consumer_key", LearnositySDK.Credentials.ConsumerKey); + security.set("user_id", "abc"); + security.set("domain", LearnositySDK.Credentials.Domain); + + string secret = LearnositySDK.Credentials.ConsumerSecret; + + Init init = new Init(service, security, secret, request); + + ViewData["InitJSON"] = init.generate(); + } + + } +} diff --git a/LearnosityDemo/Pages/QuestionsAPIDemo.cshtml b/LearnosityDemo/Pages/QuestionsAPIDemo.cshtml new file mode 100644 index 0000000..322b627 --- /dev/null +++ b/LearnosityDemo/Pages/QuestionsAPIDemo.cshtml @@ -0,0 +1,27 @@ +@page +@model LearnosityDemo.Pages.QuestionsAPIDemoModel +@{ + ViewData["Title"] = "Learnosity Example: Standalone Assessment"; + ViewData["TopJS"] = ""; +} + + + + + diff --git a/LearnosityDemo/Pages/QuestionsAPIDemo.cshtml.cs b/LearnosityDemo/Pages/QuestionsAPIDemo.cshtml.cs new file mode 100644 index 0000000..63a24c1 --- /dev/null +++ b/LearnosityDemo/Pages/QuestionsAPIDemo.cshtml.cs @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; +using LearnositySDK.Request; +using LearnositySDK.Utils; +using Newtonsoft.Json; +using Microsoft.AspNetCore.DataProtection; + + +namespace LearnosityDemo.Pages +{ + public class QuestionsAPIDemoModel : PageModel + { + public void OnGet() + { + + // prepare all the params + string service = "questions"; + string uuid = Uuid.generate(); + string courseId = "mycourse"; + JsonObject security = new JsonObject(); + security.set("consumer_key", LearnositySDK.Credentials.ConsumerKey); + security.set("user_id", "abc"); + security.set("domain", LearnositySDK.Credentials.Domain); + string secret = LearnositySDK.Credentials.ConsumerSecret; + JsonObject request = JsonObjectFactory.fromString(QuestionsAPIDemoModel.requestJson(uuid, courseId)); + + // Instantiate Init class + Init init = new Init(service, security, secret, request); + + // Call the generate() method to retrieve a JavaScript object + ViewData["InitJSON"] = init.generate(); + } + + private static string requestJson(string uuid, string courseId) + { + return string.Format(@"{{ + ""type"": ""local_practice"", + ""sigver"": ""v2"", + ""state"": ""initial"", + ""id"": ""questionsapi-demo"", + ""name"": ""Questions API Demo"", + ""course_id"": ""{1}"", + ""questions"": [ + {{ + ""type"": ""association"", + ""response_id"": ""60001"", + ""stimulus"": ""Match the cities to the parent nation."", + ""stimulus_list"": [""London"", ""Dublin"", ""Paris"", ""Sydney""], + ""possible_responses"": [""Australia"", ""France"", ""Ireland"", ""England""], + ""instant_feedback"" : true, + ""validation"": {{ + ""valid_responses"" : [ + [""England""],[""Ireland""],[""France""],[""Australia""] + ] + }} + }}, + + ] + }}", uuid, courseId); + } + } +} diff --git a/LearnosityDemo/Pages/ReportsAPIDemo.cshtml b/LearnosityDemo/Pages/ReportsAPIDemo.cshtml new file mode 100644 index 0000000..b321b3c --- /dev/null +++ b/LearnosityDemo/Pages/ReportsAPIDemo.cshtml @@ -0,0 +1,23 @@ +@page +@model LearnosityDemo.Pages.ReportsAPIDemoModel +@{ + ViewData["Title"] = "Learnosity Example: Standalone Assessment"; + ViewData["TopJS"] = ""; + + } + + + + diff --git a/LearnosityDemo/Pages/ReportsAPIDemo.cshtml.cs b/LearnosityDemo/Pages/ReportsAPIDemo.cshtml.cs new file mode 100644 index 0000000..be72717 --- /dev/null +++ b/LearnosityDemo/Pages/ReportsAPIDemo.cshtml.cs @@ -0,0 +1,41 @@ +using System; +using System.Text; +using LearnositySDK; +using LearnositySDK.Request; +using LearnositySDK.Utils; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; +using Newtonsoft.Json; +using static System.Net.Mime.MediaTypeNames; + +namespace LearnosityDemo.Pages +{ + public class ReportsAPIDemoModel : PageModel + { + public void OnGet(string mode) + { + string service = "reports"; + + JsonObject security = new JsonObject(); + security.set("consumer_key", Credentials.ConsumerKey); + security.set("domain", Credentials.Domain); + + string secret = Credentials.ConsumerSecret; + + JsonObject report = new JsonObject(); + report.set("id", "session-detail"); + report.set("type", "session-detail-by-item"); + report.set("user_id", "906d564c-39d4-44ba-8ddc-2d44066e2ba9"); + report.set("session_id", "906d564c-39d4-44ba-8ddc-2d44066e2ba9"); + + JsonObject reports = new JsonObject(true); + reports.set(report); + + JsonObject request = new JsonObject(); + request.set("reports", reports); + + Init init = new Init(service, security, secret, request); + ViewData["initJSON"] = init.generate(); + } + } +} diff --git a/LearnosityDemo/Pages/Shared/_Layout.cshtml b/LearnosityDemo/Pages/Shared/_Layout.cshtml index 5f90469..e4d79c0 100644 --- a/LearnosityDemo/Pages/Shared/_Layout.cshtml +++ b/LearnosityDemo/Pages/Shared/_Layout.cshtml @@ -25,6 +25,21 @@