Screens and viewers
The SDK distinguishes which page opened the content (scope), who is viewing it (viewer), and which entry file is running (screen). Read these values after init() has finished.
sdk.scope; // 'learn' | 'edit' 어느 페이지가 열었나
sdk.viewer; // 'student' | 'instructor' | 'tutor' 누가 보나
sdk.screen; // 'learn' | 'instructor' | 'edit' 어떤 진입 파일이 실행 중인가
sdk.account; // { anonymousId: 'a1b2…', fullname: null }
sdk.result; // { score: 50, submitCount: 2, completedAt: null } 또는 null
sdk.isDraft; // 편집 화면의 미리보기 · 저장 전 업로드면 true
Educators also see the student screen on the learning page
On the learning page (learn-scope token), screen is always learn regardless of who is viewing. The educator screen (instructor) opens only when the educator is selected in the edit page preview.
So do not split educator-only features inside the student screen by viewer on the learning page. The student screen is the same screen for everyone; only how submissions are handled (graded · saved · rejected) differs by viewer.
Values by situation
| Situation | scope | viewer | screen | Submission |
|---|---|---|---|---|
| A student opens the material | learn | student | learn | Graded and saved. The score counts toward the course |
| A course manager opens the material | learn | instructor | learn (even if there is an educator screen) | Graded only, not saved |
| A tutor views the student screen | learn | tutor | learn | Rejected (read_only_mode). result and history() belong to the student |
| Settings screen on the edit page | edit | instructor | edit | None. Save with saveSettings() |
| Previewing the student · educator screen of a saved version on the edit page | edit | instructor | learn or instructor (learn if there is no educator screen) | Decided by the server |
| Previewing a draft · an unsaved upload · a past version on the edit page | learn | instructor | learn | Simulated without the server and kept in memory only |
| Settings screen of an unsaved upload | edit | instructor | edit | None. saveSettings() fails with draft_not_saved |
- On screens opened with an edit token (the settings screen · edit page previews),
accountandresultarenull. account.anonymousIdis an anonymous id used to tell learners apart. Use this value instead of learners' personal information.resultis per material.scoreis the most recent grading value,submitCountis the cumulative number of submissions, andcompletedAtis the time it was first completed and is never cleared. It is not reset when the educator uploads a new zip.
URLs per screen
The screen is determined by the fragment of the URL LXP uses to load the content. The content never needs to handle this value itself; init() reads it.
| URL | When | SDK behavior |
|---|---|---|
…/index.html#token=… | Learning page (student · educator · tutor, all on the student screen) | Communicates with the server |
…#token=… (edit-scope token) | When the edit page opens the settings screen (entries.edit) | settings holds the draft values, and saveSettings() saves to the draft |
…#token=…&screen=learn, …&screen=instructor | When the edit page previews the student · educator screen of a saved version | Opens that screen |
…#preview=1 | When the edit page previews an unsaved upload | Works without the server. Submissions are kept in memory only and grading is simulated |
…#token=…&preview=1 | When the edit page previews the draft's student screen with the draft settings | Only the material (draft settings) is read with the token; submissions and history stay in memory |
…#token=…&preview=1&versionId=… | When the edit page's version history previews a past version with that version's settings | Reads that version's settings and entry files. For a version that doesn't exist, init() fails with invalid_param |
…#edit=1 | When the edit page opens the settings screen of an unsaved upload | Works without the server. saveSettings() fails with draft_not_saved |
sdk.isDraft is true for #preview=1 (even with a token), an edit token + versionId, and #edit=1. In these cases, submissions and history are not kept on the server.