Examples
Introduction
The content that your user sees depends on the payload that you initialize the Socratease library with. This article lists a few common use cases.
In the examples below, we will only show what the Payload must be like. Refer the Quickstart article for boilerplate code, and other options.
Recall that for all Socratease related pages, you will have a single entry point. If you are hosting Socratease on yoursite.com/learning (see Definitions), for all URLs like yoursite.com/learning/*, you will return a static HTML page
Content Creation
Requirement
You want a user with [email protected] to see the screen where they can add quizzes, create courses, etc
Code
const payload = {
username: "[email protected]",
user_details: {first_name: "Creator", role: "ca"}
};Explanation
- We need the username because we need to keep track of who created the content. (If username isn't created, Socratease will create a random user depending on your Non-Logged in Users in .init() and Unauthenticated and Unauthorized requests settings).
- Because you are initialising the user with role=ca, Socratease will automatically redirect the user to /cms/home. Here the user can see their existing content, or create new content.
Accessing Existing Content
Requirement
A content creator has created a quiz. In its settings, the creator has said that only logged-in users can access it. Its relative url is, /units/abcd You want a user with [email protected] to take this quiz.
Code
const payload = {
username: "[email protected]",
user_details: {first_name: "Student"}
};Explanation
Because only logged-in users can access the test, username is required. You don't need to specify path here because, by default, the SDK loads window.location.pathname anyway.
Creating a Cohort
Requirements
An instructor needs to be logged in to show a page where they can create cohorts and see their existing cohorts. The instructor has already been added to an Organization
Code
const payload = {
username: "[email protected]",
user_details: {first_name: "Student", role: "instructor"}
};Explanation
Because only logged-in users can access the test, username is required. You don't need to specify path here because, by default, the SDK loads window.location.pathname anyway.