Skip to main content

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​

SituationscopeviewerscreenSubmission
A student opens the materiallearnstudentlearnGraded and saved. The score counts toward the course
A course manager opens the materiallearninstructorlearn (even if there is an educator screen)Graded only, not saved
A tutor views the student screenlearntutorlearnRejected (read_only_mode). result and history() belong to the student
Settings screen on the edit pageeditinstructoreditNone. Save with saveSettings()
Previewing the student · educator screen of a saved version on the edit pageeditinstructorlearn 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 pagelearninstructorlearnSimulated without the server and kept in memory only
Settings screen of an unsaved uploadeditinstructoreditNone. saveSettings() fails with draft_not_saved
  • On screens opened with an edit token (the settings screen · edit page previews), account and result are null.
  • account.anonymousId is an anonymous id used to tell learners apart. Use this value instead of learners' personal information.
  • result is per material. score is the most recent grading value, submitCount is the cumulative number of submissions, and completedAt is 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.

URLWhenSDK 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=instructorWhen the edit page previews the student · educator screen of a saved versionOpens that screen
…#preview=1When the edit page previews an unsaved uploadWorks without the server. Submissions are kept in memory only and grading is simulated
…#token=…&preview=1When the edit page previews the draft's student screen with the draft settingsOnly 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 settingsReads that version's settings and entry files. For a version that doesn't exist, init() fails with invalid_param
…#edit=1When the edit page opens the settings screen of an unsaved uploadWorks 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.