type
stringclasses
7 values
content
stringlengths
4
9.55k
repo
stringlengths
7
96
path
stringlengths
4
178
language
stringclasses
1 value
FunctionDeclaration
export function getOverrideWindowBottomBtn(bc: IBuilderConfig) { const {overrides} = mergeComponents(bc.topbtn, { "Override Cancel Button": getCancelBtnConfig(bc), "Override Save Button": getSaveBtnConfig(bc, 1), }); return [overrides["Override Save Button"], overrides["Override Cancel Button"]]; }
honyrikS/core-frontend
packages/@essence/essence-constructor-classes/src/Grid/utils/getGridBtnsConfig.ts
TypeScript
ArrowFunction
(bc: IBuilderConfig): IBuilderConfig => ({ [VAR_RECORD_CN_ORDER]: 1e6, [VAR_RECORD_DISPLAYED]: "static:f7e324760ede4c88b4f11f0af26c9e97", [VAR_RECORD_MASTER_ID]: bc[VAR_RECORD_PAGE_OBJECT_ID], [VAR_RECORD_PAGE_OBJECT_ID]: `${bc[VAR_RECORD_PAGE_OBJECT_ID]}-remove`, [VAR_RECORD_PARENT_ID]: bc[VAR_RECORD_PAGE_OBJECT_ID], confirmquestion: "static:0cd0fc9bff2641f68f0f9712395f7b82", handler: "removeSelectedRecordAction", iconfont: "trash-o", onlyicon: true, reqsel: true, type: "BTN", uitype: "11", })
honyrikS/core-frontend
packages/@essence/essence-constructor-classes/src/Grid/utils/getGridBtnsConfig.ts
TypeScript
ArrowFunction
(bc: IBuilderConfig): IBuilderConfig => ({ [VAR_RECORD_CN_ORDER]: 1e6, [VAR_RECORD_DISPLAYED]: "static:627518f4034947aa9989507c5688cfff", [VAR_RECORD_MASTER_ID]: bc[VAR_RECORD_PAGE_OBJECT_ID], [VAR_RECORD_PAGE_OBJECT_ID]: `${bc[VAR_RECORD_PAGE_OBJECT_ID]}-audit`, [VAR_RECORD_PARENT_ID]: bc[VAR_RECORD_PAGE_OBJECT_ID], iconfont: "info", iconfontname: "fa", onlyicon: true, readonly: false, reqsel: true, type: "AUDIT_INFO", uitype: "11", })
honyrikS/core-frontend
packages/@essence/essence-constructor-classes/src/Grid/utils/getGridBtnsConfig.ts
TypeScript
ArrowFunction
(bc: IBuilderConfig): IBuilderConfig => ({ [VAR_RECORD_CN_ORDER]: 1e6, [VAR_RECORD_DISPLAYED]: "static:33c9b02a9140428d9747299b9a767abb", [VAR_RECORD_MASTER_ID]: bc[VAR_RECORD_PAGE_OBJECT_ID], [VAR_RECORD_PAGE_OBJECT_ID]: `${bc[VAR_RECORD_PAGE_OBJECT_ID]}-refresh`, [VAR_RECORD_PARENT_ID]: bc[VAR_RECORD_PAGE_OBJECT_ID], handler: "onRefresh", iconfont: "refresh", iconfontname: "fa", onlyicon: true, readonly: false, type: "BTN", uitype: "11", })
honyrikS/core-frontend
packages/@essence/essence-constructor-classes/src/Grid/utils/getGridBtnsConfig.ts
TypeScript
ArrowFunction
(bc: IBuilderConfig): IBuilderConfig => ({ [VAR_RECORD_CN_ORDER]: 1e6, [VAR_RECORD_DISPLAYED]: "static:7578080854a84cc3b4faad62d4499a4b", [VAR_RECORD_MASTER_ID]: bc[VAR_RECORD_PAGE_OBJECT_ID], [VAR_RECORD_PAGE_OBJECT_ID]: `${bc[VAR_RECORD_PAGE_OBJECT_ID]}-excel`, [VAR_RECORD_PARENT_ID]: bc[VAR_RECORD_PAGE_OBJECT_ID], ckwindow: "btnexcel", disabledemptymaster: true, extraplugingate: "PrintJasperServer", handler: "onCreateChildWindowMaster", iconfont: "table", iconfontname: "fa", onlyicon: true, readonly: false, type: "BTN", uitype: "11", })
honyrikS/core-frontend
packages/@essence/essence-constructor-classes/src/Grid/utils/getGridBtnsConfig.ts
TypeScript
ArrowFunction
(bc: IBuilderConfig, layoutTheme: number): IBuilderConfig => ({ [VAR_RECORD_CN_ORDER]: 1e6, [VAR_RECORD_DISPLAYED]: "static:8a930c6b5dd440429c0f0e867ce98316", [VAR_RECORD_PAGE_OBJECT_ID]: `${bc[VAR_RECORD_PAGE_OBJECT_ID]}_gridwindow-save`, [VAR_RECORD_PARENT_ID]: `${bc[VAR_RECORD_PAGE_OBJECT_ID]}_gridwindow`, handler: "onSimpleSaveWindow", iconfont: bc.edittype === "inline" && layoutTheme === 2 ? "save" : undefined, type: "BTN", uitype: "5", })
honyrikS/core-frontend
packages/@essence/essence-constructor-classes/src/Grid/utils/getGridBtnsConfig.ts
TypeScript
ArrowFunction
(bc: IBuilderConfig, layoutTheme: number): IBuilderConfig => ({ [VAR_RECORD_CN_ORDER]: 1e6, [VAR_RECORD_DISPLAYED]: "static:64aacc431c4c4640b5f2c45def57cae9", [VAR_RECORD_PAGE_OBJECT_ID]: `${bc[VAR_RECORD_PAGE_OBJECT_ID]}_gridwindow-cancel`, [VAR_RECORD_PARENT_ID]: `${bc[VAR_RECORD_PAGE_OBJECT_ID]}_gridwindow`, confirmquestion: "static:9b475e25ae8a40b0b158543b84ba8c08", handler: "onCloseWindow", iconfont: layoutTheme === 2 ? "times" : undefined, readonly: false, type: "BTN", uitype: "6", })
honyrikS/core-frontend
packages/@essence/essence-constructor-classes/src/Grid/utils/getGridBtnsConfig.ts
TypeScript
ArrowFunction
(bc: IBuilderConfig): IBuilderConfig => ({ [VAR_RECORD_CN_ORDER]: 1e6, [VAR_RECORD_DISPLAYED]: "static:64aacc431c4c4640b5f2c45def57cae9", [VAR_RECORD_PAGE_OBJECT_ID]: `${bc[VAR_RECORD_PAGE_OBJECT_ID]}_gridwindow-cancel`, [VAR_RECORD_PARENT_ID]: `${bc[VAR_RECORD_PAGE_OBJECT_ID]}_gridwindow`, confirmquestion: "static:9b475e25ae8a40b0b158543b84ba8c08", confirmquestionposition: "top", handler: "onCloseWindow", readonly: false, type: "BTN", uitype: "6", })
honyrikS/core-frontend
packages/@essence/essence-constructor-classes/src/Grid/utils/getGridBtnsConfig.ts
TypeScript
ArrowFunction
(bc: IBuilderConfig): IBuilderConfig => ({ [VAR_RECORD_CN_ORDER]: 1e6, [VAR_RECORD_PAGE_OBJECT_ID]: `${bc[VAR_RECORD_PAGE_OBJECT_ID]}_drag-drop`, [VAR_RECORD_PARENT_ID]: `${bc[VAR_RECORD_PAGE_OBJECT_ID]}_drag-drop`, mode: "2", modeaction: "dragdrop", type: "BTN", })
honyrikS/core-frontend
packages/@essence/essence-constructor-classes/src/Grid/utils/getGridBtnsConfig.ts
TypeScript
ArrowFunction
(bc: IBuilderConfig, layoutTheme: number): IGridBtnsConfigType => { const {components, overrides} = mergeComponents(bc.topbtn, { "Override Audit Button": getBtnAuditConfig(bc), "Override Cancel Button": bc.edittype === "inline" ? getCancelInlineBtnConfig(bc, layoutTheme) : getCancelBtnConfig(bc), "Override Delete Button": getBtnDeleteConfig(bc), "Override DragDrop Button": getDragDropBtnConfig(bc), "Override Excel Button": getBtnExcelConfig(bc), "Override Refresh Button": getBtnRefreshConfig(bc), "Override Save Button": getSaveBtnConfig(bc, layoutTheme), }); const btnsCollector: IBuilderConfig[] = []; const btns: IBuilderConfig[] = []; components.forEach((component: IBuilderConfig) => { if (component.type === "BTNCOLLECTOR") { btnsCollector.push(component); } else { btns.push(component); } }); return {btns, btnsCollector, overrides}; }
honyrikS/core-frontend
packages/@essence/essence-constructor-classes/src/Grid/utils/getGridBtnsConfig.ts
TypeScript
ArrowFunction
(component: IBuilderConfig) => { if (component.type === "BTNCOLLECTOR") { btnsCollector.push(component); } else { btns.push(component); } }
honyrikS/core-frontend
packages/@essence/essence-constructor-classes/src/Grid/utils/getGridBtnsConfig.ts
TypeScript
ArrowFunction
async () => { const all = translateService.getAll(); should(Object.keys(all)).eql(['de', 'en']); }
freshfox/ffc-node
src/test/services/translate_service_test.ts
TypeScript
ArrowFunction
async () => { const text = translateService.translate('invoice'); should(text).eql('Invoice'); }
freshfox/ffc-node
src/test/services/translate_service_test.ts
TypeScript
ArrowFunction
async () => { const text = translateService.translate('invoice', null, 'de'); should(text).eql('Rechnung'); }
freshfox/ffc-node
src/test/services/translate_service_test.ts
TypeScript
ArrowFunction
async () => { const text1 = translateService.translate('invoice_with_number', {number: 2}, 'de'); should(text1).eql('Rechnung #2'); }
freshfox/ffc-node
src/test/services/translate_service_test.ts
TypeScript
ArrowFunction
async () => { checkLocalizedStrings(translateService); }
freshfox/ffc-node
src/test/services/translate_service_test.ts
TypeScript
ArrowFunction
async () => { const catalog = translateService.getAll(); catalog['de'].test = 'monkey translation'; let errorThrown = false; try { checkLocalizedStrings(translateService); } catch (err) { errorThrown = true; should(err.code).eql(0); } delete catalog['de'].test; should(errorThrown).eql(true, 'Error wasn\'t thrown'); }
freshfox/ffc-node
src/test/services/translate_service_test.ts
TypeScript
ArrowFunction
async () => { should(translateService.translate('test1')).eql('Hello \' <> " characters'); should(translateService.translate('test2', {replace: '<> \' "'})).eql('Hello <> \' "'); }
freshfox/ffc-node
src/test/services/translate_service_test.ts
TypeScript
ArrowFunction
async () => { const t2 = new TranslateService({ directory: path.resolve(__dirname, '../locales'), defaultLocale: 'en' }); const c1 = translateService.getAll(); const c2 = t2.getAll(); should(Object.keys(c1)).eql(['de', 'en']); should(Object.keys(c2)).eql(['de', 'en']); }
freshfox/ffc-node
src/test/services/translate_service_test.ts
TypeScript
ArrowFunction
(ms) => new Promise((res) => setTimeout(res, ms))
Amorites/core
packages/components/src/recycle-tree/prompt/PromptHandle.ts
TypeScript
ArrowFunction
(res) => setTimeout(res, ms)
Amorites/core
packages/components/src/recycle-tree/prompt/PromptHandle.ts
TypeScript
ArrowFunction
(ev) => { ev.stopPropagation(); }
Amorites/core
packages/components/src/recycle-tree/prompt/PromptHandle.ts
TypeScript
ArrowFunction
(ev) => { this.onChangeEmitter.fire(this.$.value); }
Amorites/core
packages/components/src/recycle-tree/prompt/PromptHandle.ts
TypeScript
ArrowFunction
async (ev) => { if (ev.key === 'Escape') { const res: IAsyncResult<boolean>[] = await this.onCancelEmitter.fireAndAwait(this.$.value); // 当有回调函数报错或返回结果为false时,终止后续操作 if (res.some((r) => r.result === false || !!r.err)) { return; } this.destroy(); } if (ev.key === 'Enter') { this.isInPendingCommitState = true; this.$.disabled = true; const res: IAsyncResult<boolean>[] = await this.onCommitEmitter.fireAndAwait(this.$.value); // 当有回调函数报错或返回结果为false时,终止后续操作 if (res.some((r) => r.result === false || !!r.err)) { this.isInPendingCommitState = false; this.$.disabled = false; this.$.focus(); return; } this.isInPendingCommitState = false; this.$.disabled = false; this.destroy(); } }
Amorites/core
packages/components/src/recycle-tree/prompt/PromptHandle.ts
TypeScript
ArrowFunction
(r) => r.result === false || !!r.err
Amorites/core
packages/components/src/recycle-tree/prompt/PromptHandle.ts
TypeScript
ArrowFunction
() => { this.onFocusEmitter.fire(this.$.value); }
Amorites/core
packages/components/src/recycle-tree/prompt/PromptHandle.ts
TypeScript
ArrowFunction
async (ev) => { // 如果Input由于`react-virtualized`被从视图中卸载,在下一帧前Input的isConnected属性不会被更新 await delay(0); // 如果Input组件不在DOM中,但也没有被手动销毁,则表示由于其不在视窗内被`react-virtualized`卸载 if (!this.$.isConnected && !this.destroyed) { return; } const res: IAsyncResult<boolean>[] = await this.onBlurEmitter.fireAndAwait(this.$.value); // 当有回调函数报错或返回结果为false时,终止后续操作 if (res.some((r) => r.result === false || !!r.err)) { return; } if (!this.isInPendingCommitState) { this.destroy(); } }
Amorites/core
packages/components/src/recycle-tree/prompt/PromptHandle.ts
TypeScript
InterfaceDeclaration
export interface PromptValidateMessage { message: string | void; type: PROMPT_VALIDATE_TYPE; }
Amorites/core
packages/components/src/recycle-tree/prompt/PromptHandle.ts
TypeScript
EnumDeclaration
export enum PROMPT_VALIDATE_TYPE { INFO = 1, ERROR = 2, WARNING = 3, }
Amorites/core
packages/components/src/recycle-tree/prompt/PromptHandle.ts
TypeScript
MethodDeclaration
public focus(): void { this.$.focus(); }
Amorites/core
packages/components/src/recycle-tree/prompt/PromptHandle.ts
TypeScript
MethodDeclaration
public setSelectionRange(start: number, end: number): void { this.$.setSelectionRange(start, end); }
Amorites/core
packages/components/src/recycle-tree/prompt/PromptHandle.ts
TypeScript
MethodDeclaration
public addClassName(classname: string): void { this.$.classList.add(classname); }
Amorites/core
packages/components/src/recycle-tree/prompt/PromptHandle.ts
TypeScript
MethodDeclaration
public removeClassName(classname: string): void { this.$.classList.remove(classname); }
Amorites/core
packages/components/src/recycle-tree/prompt/PromptHandle.ts
TypeScript
MethodDeclaration
public addAddonAfter(classname: string) { if (!this._hasAddonAfter && !this._destroyed) { this.$.parentElement?.parentElement?.appendChild(this.$addonAfter); this._hasAddonAfter = true; } const addElement = document.createElement('div'); addElement.setAttribute('class', classname); this.$addonAfter.appendChild(addElement); }
Amorites/core
packages/components/src/recycle-tree/prompt/PromptHandle.ts
TypeScript
MethodDeclaration
public removeAddonAfter() { if (this._hasAddonAfter) { this.$addonAfter.firstChild?.remove(); this.$.parentElement?.parentElement?.removeChild(this.$addonAfter); this._hasAddonAfter = false; } }
Amorites/core
packages/components/src/recycle-tree/prompt/PromptHandle.ts
TypeScript
MethodDeclaration
public addValidateMessage(validateMessage: PromptValidateMessage) { if (!this._hasValidateElement && !this._destroyed) { // 移动到与input-box同级别 this.$.parentElement?.parentElement?.parentElement?.appendChild(this.$validate); this._hasValidateElement = true; } let validateBoxClassName = 'validate-message popup '; if (validateMessage && validateMessage.type === PROMPT_VALIDATE_TYPE.ERROR) { this._validateClassName = 'validate-error'; } else if (validateMessage && validateMessage.type === PROMPT_VALIDATE_TYPE.WARNING) { this._validateClassName = 'validate-warning'; } else { this._validateClassName = 'validate-info'; } validateBoxClassName += this._validateClassName; this.$validate.classList.value = validateBoxClassName; this.$validate.innerText = validateMessage.message || ''; this.$.parentElement?.parentElement?.classList.add(this._validateClassName); }
Amorites/core
packages/components/src/recycle-tree/prompt/PromptHandle.ts
TypeScript
MethodDeclaration
public removeValidateMessage() { if (this._hasValidateElement) { this.$.parentElement?.parentElement?.parentElement?.removeChild(this.$validate); this._hasValidateElement = false; this.$.parentElement?.parentElement?.classList.remove(this._validateClassName); } }
Amorites/core
packages/components/src/recycle-tree/prompt/PromptHandle.ts
TypeScript
MethodDeclaration
public destroy(): void { if (this._destroyed) { return; } this._destroyed = true; this.$.removeEventListener('click', this.handleClick); this.$.removeEventListener('keyup', this.handleKeyup); this.$.removeEventListener('keydown', this.handleKeydown); this.$.removeEventListener('focus', this.handleFocus); this.$.removeEventListener('blur', this.handleBlur); this.removeValidateMessage(); this.removeAddonAfter(); this.$.disabled = false; this.onDestroyEmitter.fire(this.$.value); this.disposables.dispose(); }
Amorites/core
packages/components/src/recycle-tree/prompt/PromptHandle.ts
TypeScript
ArrowFunction
(result) => this.formatResult(result)
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
ArrowFunction
(attempt) => this.formatAttempt(attempt)
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
ArrowFunction
(attempt) => attempt.id
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
ArrowFunction
(attempt) => attempt.id == attemptId
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
ArrowFunction
(attempt) => this.formatAttemptResults(attempt)
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
ArrowFunction
(h5pActivity) => h5pActivity[key] == value
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
InterfaceDeclaration
/** * Augment CoreEventsData interface with events specific to this service. * * @see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation */ export interface CoreEventsData { [AddonModH5PActivitySyncProvider.AUTO_SYNCED]: AddonModH5PActivityAutoSyncData; }
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
TypeAliasDeclaration
/** * Basic data for an H5P activity, exported by Moodle class h5pactivity_summary_exporter. */ export type AddonModH5PActivityData = { id: number; // The primary key of the record. course: number; // Course id this h5p activity is part of. name: string; // The name of the activity module instance. timecreated?: number; // Timestamp of when the instance was added to the course. timemodified?: number; // Timestamp of when the instance was last modified. intro: string; // H5P activity description. introformat: number; // Intro format (1 = HTML, 0 = MOODLE, 2 = PLAIN or 4 = MARKDOWN). grade?: number; // The maximum grade for submission. displayoptions: number; // H5P Button display options. enabletracking: number; // Enable xAPI tracking. grademethod: number; // Which H5P attempt is used for grading. contenthash?: string; // Sha1 hash of file content. coursemodule: number; // Coursemodule. context: number; // Context ID. introfiles: CoreWSExternalFile[]; package: CoreWSExternalFile[]; deployedfile?: { filename?: string; // File name. filepath?: string; // File path. filesize?: number; // File size. fileurl: string; // Downloadable file url. timemodified?: number; // Time modified. mimetype?: string; // File mime type. }; };
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
TypeAliasDeclaration
/** * Params of mod_h5pactivity_get_h5pactivities_by_courses WS. */ export type AddonModH5pactivityGetByCoursesWSParams = { courseids?: number[]; // Array of course ids. };
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
TypeAliasDeclaration
/** * Data returned by mod_h5pactivity_get_h5pactivities_by_courses WS. */ export type AddonModH5pactivityGetByCoursesWSResponse = { h5pactivities: AddonModH5PActivityData[]; warnings?: CoreWSExternalWarning[]; };
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
TypeAliasDeclaration
/** * Params of mod_h5pactivity_get_h5pactivity_access_information WS. */ export type AddonModH5pactivityGetH5pactivityAccessInformationWSParams = { h5pactivityid: number; // H5p activity instance id. };
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
TypeAliasDeclaration
/** * Data returned by mod_h5pactivity_get_h5pactivity_access_information WS. */ export type AddonModH5pactivityGetH5pactivityAccessInformationWSResponse = { warnings?: CoreWSExternalWarning[]; canview?: boolean; // Whether the user has the capability mod/h5pactivity:view allowed. canaddinstance?: boolean; // Whether the user has the capability mod/h5pactivity:addinstance allowed. cansubmit?: boolean; // Whether the user has the capability mod/h5pactivity:submit allowed. canreviewattempts?: boolean; // Whether the user has the capability mod/h5pactivity:reviewattempts allowed. };
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
TypeAliasDeclaration
/** * Result of WS mod_h5pactivity_get_h5pactivity_access_information. */ export type AddonModH5PActivityAccessInfo = AddonModH5pactivityGetH5pactivityAccessInformationWSResponse;
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
TypeAliasDeclaration
/** * Params of mod_h5pactivity_get_attempts WS. */ export type AddonModH5pactivityGetAttemptsWSParams = { h5pactivityid: number; // H5p activity instance id. userids?: number[]; // User ids. };
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
TypeAliasDeclaration
/** * Data returned by mod_h5pactivity_get_attempts WS. */ export type AddonModH5pactivityGetAttemptsWSResponse = { activityid: number; // Activity course module ID. usersattempts: AddonModH5PActivityWSUserAttempts[]; // The complete users attempts list. warnings?: CoreWSExternalWarning[]; };
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
TypeAliasDeclaration
/** * Params of mod_h5pactivity_get_results WS. */ export type AddonModH5pactivityGetResultsWSParams = { h5pactivityid: number; // H5p activity instance id. attemptids?: number[]; // Attempt ids. };
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
TypeAliasDeclaration
/** * Data returned by mod_h5pactivity_get_results WS. */ export type AddonModH5pactivityGetResultsWSResponse = { activityid: number; // Activity course module ID. attempts: AddonModH5PActivityWSAttemptResults[]; // The complete attempts list. warnings?: CoreWSExternalWarning[]; };
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
TypeAliasDeclaration
/** * Attempts results with some calculated data. */ export type AddonModH5PActivityAttemptsResults = Omit<AddonModH5pactivityGetResultsWSResponse, 'attempts'> & { attempts: AddonModH5PActivityAttemptResults[]; // The complete attempts list. };
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
TypeAliasDeclaration
/** * Attempts data for a user as returned by the WS mod_h5pactivity_get_attempts. */ export type AddonModH5PActivityWSUserAttempts = { userid: number; // The user id. attempts: AddonModH5PActivityWSAttempt[]; // The complete attempts list. scored?: { // Attempts used to grade the activity. title: string; // Scored attempts title. grademethod: string; // Scored attempts title. attempts: AddonModH5PActivityWSAttempt[]; // List of the grading attempts. }; };
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
TypeAliasDeclaration
/** * Attempt data as returned by the WS mod_h5pactivity_get_attempts. */ export type AddonModH5PActivityWSAttempt = { id: number; // ID of the context. h5pactivityid: number; // ID of the H5P activity. userid: number; // ID of the user. timecreated: number; // Attempt creation. timemodified: number; // Attempt modified. attempt: number; // Attempt number. rawscore: number; // Attempt score value. maxscore: number; // Attempt max score. duration: number; // Attempt duration in seconds. completion?: number; // Attempt completion. success?: number | null; // Attempt success. scaled: number; // Attempt scaled. };
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
TypeAliasDeclaration
/** * Attempt and results data as returned by the WS mod_h5pactivity_get_results. */ export type AddonModH5PActivityWSAttemptResults = AddonModH5PActivityWSAttempt & { results?: AddonModH5PActivityWSResult[]; // The results of the attempt. };
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
TypeAliasDeclaration
/** * Attempt result data as returned by the WS mod_h5pactivity_get_results. */ export type AddonModH5PActivityWSResult = { id: number; // ID of the context. attemptid: number; // ID of the H5P attempt. subcontent: string; // Subcontent identifier. timecreated: number; // Result creation. interactiontype: string; // Interaction type. description: string; // Result description. content?: string; // Result extra content. rawscore: number; // Result score value. maxscore: number; // Result max score. duration?: number; // Result duration in seconds. completion?: number; // Result completion. success?: number | null; // Result success. optionslabel?: string; // Label used for result options. correctlabel?: string; // Label used for correct answers. answerlabel?: string; // Label used for user answers. track?: boolean; // If the result has valid track information. options?: { // The statement options. description: string; // Option description. id: number; // Option identifier. correctanswer: AddonModH5PActivityWSResultAnswer; // The option correct answer. useranswer: AddonModH5PActivityWSResultAnswer; // The option user answer. }[]; };
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
TypeAliasDeclaration
/** * Result answer as returned by the WS mod_h5pactivity_get_results. */ export type AddonModH5PActivityWSResultAnswer = { answer?: string; // Option text value. correct?: boolean; // If has to be displayed as correct. incorrect?: boolean; // If has to be displayed as incorrect. text?: boolean; // If has to be displayed as simple text. checked?: boolean; // If has to be displayed as a checked option. unchecked?: boolean; // If has to be displayed as a unchecked option. pass?: boolean; // If has to be displayed as passed. fail?: boolean; // If has to be displayed as failed. };
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
TypeAliasDeclaration
/** * User attempts data with some calculated data. */ export type AddonModH5PActivityUserAttempts = Omit<AddonModH5PActivityWSUserAttempts, 'attempts'|'scored'> & { attempts: AddonModH5PActivityAttempt[]; // The complete attempts list. scored?: { // Attempts used to grade the activity. title: string; // Scored attempts title. grademethod: string; // Scored attempts title. attempts: AddonModH5PActivityAttempt[]; // List of the grading attempts. }; };
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
TypeAliasDeclaration
/** * Attempt with some calculated data. */ export type AddonModH5PActivityAttempt = AddonModH5PActivityWSAttempt & { durationReadable?: string; // Duration in a human readable format. durationCompact?: string; // Duration in a "short" human readable format. };
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
TypeAliasDeclaration
/** * Attempt and results data with some calculated data. */ export type AddonModH5PActivityAttemptResults = AddonModH5PActivityAttempt & { results?: AddonModH5PActivityWSResult[]; // The results of the attempt. };
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
TypeAliasDeclaration
/** * Options to pass to getDeployedFile function. */ export type AddonModH5PActivityGetDeployedFileOptions = { displayOptions?: CoreH5PDisplayOptions; // Display options ignoreCache?: boolean; // Whether to ignore cache. Will fail if offline or server down. siteId?: string; // Site ID. If not defined, current site. };
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
TypeAliasDeclaration
/** * Options to pass to getAttemptResults function. */ export type AddonModH5PActivityGetAttemptResultsOptions = CoreCourseCommonModWSOptions & { userId?: number; // User ID. If not defined, user of the site. };
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
TypeAliasDeclaration
/** * Options to pass to getAttempts function. */ export type AddonModH5PActivityGetAttemptsOptions = AddonModH5PActivityGetAttemptResultsOptions;
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
TypeAliasDeclaration
/** * Params of mod_h5pactivity_view_h5pactivity WS. */ export type AddonModH5pactivityViewH5pactivityWSParams = { h5pactivityid: number; // H5P activity instance id. };
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
MethodDeclaration
/** * Format an attempt's data. * * @param attempt Attempt to format. * @return Formatted attempt. */ protected formatAttempt(attempt: AddonModH5PActivityWSAttempt): AddonModH5PActivityAttempt { const formattedAttempt: AddonModH5PActivityAttempt = attempt; formattedAttempt.timecreated = attempt.timecreated * 1000; // Convert to milliseconds. formattedAttempt.timemodified = attempt.timemodified * 1000; // Convert to milliseconds. formattedAttempt.success = formattedAttempt.success ?? null; if (!attempt.duration) { formattedAttempt.durationReadable = '-'; formattedAttempt.durationCompact = '-'; } else { formattedAttempt.durationReadable = CoreTimeUtils.formatTime(attempt.duration); formattedAttempt.durationCompact = CoreTimeUtils.formatDurationShort(attempt.duration); } return formattedAttempt; }
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
MethodDeclaration
/** * Format attempt data and results. * * @param attempt Attempt and results to format. */ protected formatAttemptResults(attempt: AddonModH5PActivityWSAttemptResults): AddonModH5PActivityAttemptResults { const formattedAttempt: AddonModH5PActivityAttemptResults = this.formatAttempt(attempt); formattedAttempt.results = formattedAttempt.results?.map((result) => this.formatResult(result)); return formattedAttempt; }
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
MethodDeclaration
/** * Format the attempts of a user. * * @param data Data to format. * @return Formatted data. */ protected formatUserAttempts(data: AddonModH5PActivityWSUserAttempts): AddonModH5PActivityUserAttempts { const formatted: AddonModH5PActivityUserAttempts = data; formatted.attempts = formatted.attempts.map((attempt) => this.formatAttempt(attempt)); if (formatted.scored) { formatted.scored.attempts = formatted.scored.attempts.map((attempt) => this.formatAttempt(attempt)); } return formatted; }
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
MethodDeclaration
/** * Format an attempt's result. * * @param result Result to format. */ protected formatResult(result: AddonModH5PActivityWSResult): AddonModH5PActivityWSResult { result.timecreated = result.timecreated * 1000; // Convert to milliseconds. return result; }
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
MethodDeclaration
/** * Get cache key for access information WS calls. * * @param id H5P activity ID. * @return Cache key. */ protected getAccessInformationCacheKey(id: number): string { return ROOT_CACHE_KEY + 'accessInfo:' + id; }
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
MethodDeclaration
/** * Get access information for a given H5P activity. * * @param id H5P activity ID. * @param options Other options. * @return Promise resolved with the data. */ async getAccessInformation(id: number, options: CoreCourseCommonModWSOptions = {}): Promise<AddonModH5PActivityAccessInfo> { const site = await CoreSites.getSite(options.siteId); const params: AddonModH5pactivityGetH5pactivityAccessInformationWSParams = { h5pactivityid: id, }; const preSets: CoreSiteWSPreSets = { cacheKey: this.getAccessInformationCacheKey(id), updateFrequency: CoreSite.FREQUENCY_OFTEN, component: AddonModH5PActivityProvider.COMPONENT, componentId: options.cmId, ...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets. }; return site.read('mod_h5pactivity_get_h5pactivity_access_information', params, preSets); }
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
MethodDeclaration
/** * Get attempt results for all user attempts. * * @param id Activity ID. * @param options Other options. * @return Promise resolved with the results of the attempt. */ async getAllAttemptsResults( id: number, options?: AddonModH5PActivityGetAttemptResultsOptions, ): Promise<AddonModH5PActivityAttemptsResults> { const userAttempts = await this.getUserAttempts(id, options); const attemptIds = userAttempts.attempts.map((attempt) => attempt.id); if (attemptIds.length) { // Get all the attempts with a single call. return this.getAttemptsResults(id, attemptIds, options); } else { // No attempts. return { activityid: id, attempts: [], warnings: [], }; } }
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
MethodDeclaration
/** * Get cache key for results WS calls. * * @param id Instance ID. * @param attemptsIds Attempts IDs. * @return Cache key. */ protected getAttemptResultsCacheKey(id: number, attemptsIds: number[]): string { return this.getAttemptResultsCommonCacheKey(id) + ':' + JSON.stringify(attemptsIds); }
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
MethodDeclaration
/** * Get common cache key for results WS calls. * * @param id Instance ID. * @return Cache key. */ protected getAttemptResultsCommonCacheKey(id: number): string { return ROOT_CACHE_KEY + 'results:' + id; }
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
MethodDeclaration
/** * Get attempt results. * * @param id Activity ID. * @param attemptId Attempt ID. * @param options Other options. * @return Promise resolved with the results of the attempt. */ async getAttemptResults( id: number, attemptId: number, options?: AddonModH5PActivityGetAttemptResultsOptions, ): Promise<AddonModH5PActivityAttemptResults> { options = options || {}; const site = await CoreSites.getSite(options.siteId); const params: AddonModH5pactivityGetResultsWSParams = { h5pactivityid: id, attemptids: [attemptId], }; const preSets: CoreSiteWSPreSets = { cacheKey: this.getAttemptResultsCacheKey(id, params.attemptids!), updateFrequency: CoreSite.FREQUENCY_SOMETIMES, component: AddonModH5PActivityProvider.COMPONENT, componentId: options.cmId, ...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets. }; try { const response = await site.read<AddonModH5pactivityGetResultsWSResponse>( 'mod_h5pactivity_get_results', params, preSets, ); if (response.warnings?.[0]) { throw new CoreWSError(response.warnings[0]); // Cannot view attempt. } return this.formatAttemptResults(response.attempts[0]); } catch (error) { if (CoreUtils.isWebServiceError(error)) { throw error; } // Check if the full list of results is cached. If so, get the results from there. const cacheOptions: AddonModH5PActivityGetAttemptResultsOptions = { ...options, // Include all the original options. readingStrategy: CoreSitesReadingStrategy.ONLY_CACHE, }; const attemptsResults = await AddonModH5PActivity.getAllAttemptsResults(id, cacheOptions); const attempt = attemptsResults.attempts.find((attempt) => attempt.id == attemptId); if (!attempt) { throw error; } return attempt; } }
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
MethodDeclaration
/** * Get attempts results. * * @param id Activity ID. * @param attemptsIds Attempts IDs. * @param options Other options. * @return Promise resolved with all the attempts. */ async getAttemptsResults( id: number, attemptsIds: number[], options?: AddonModH5PActivityGetAttemptResultsOptions, ): Promise<AddonModH5PActivityAttemptsResults> { options = options || {}; const site = await CoreSites.getSite(options.siteId); const params: AddonModH5pactivityGetResultsWSParams = { h5pactivityid: id, attemptids: attemptsIds, }; const preSets: CoreSiteWSPreSets = { cacheKey: this.getAttemptResultsCommonCacheKey(id), updateFrequency: CoreSite.FREQUENCY_SOMETIMES, component: AddonModH5PActivityProvider.COMPONENT, componentId: options.cmId, ...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets. }; const response = await site.read<AddonModH5pactivityGetResultsWSResponse>( 'mod_h5pactivity_get_results', params, preSets, ); response.attempts = response.attempts.map((attempt) => this.formatAttemptResults(attempt)); return response; }
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
MethodDeclaration
/** * Get deployed file from an H5P activity instance. * * @param h5pActivity Activity instance. * @param options Options * @return Promise resolved with the file. */ async getDeployedFile( h5pActivity: AddonModH5PActivityData, options?: AddonModH5PActivityGetDeployedFileOptions, ): Promise<CoreWSFile> { if (h5pActivity.deployedfile) { // File already deployed and still valid, use this one. return h5pActivity.deployedfile; } if (!h5pActivity.package || !h5pActivity.package[0]) { // Shouldn't happen. throw new CoreError('No H5P package found.'); } options = options || {}; // Deploy the file in the server. return CoreH5P.getTrustedH5PFile( h5pActivity.package[0].fileurl, options.displayOptions, options.ignoreCache, options.siteId, ); }
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
MethodDeclaration
/** * Get cache key for H5P activity data WS calls. * * @param courseId Course ID. * @return Cache key. */ protected getH5PActivityDataCacheKey(courseId: number): string { return ROOT_CACHE_KEY + 'h5pactivity:' + courseId; }
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
MethodDeclaration
/** * Get an H5P activity with key=value. If more than one is found, only the first will be returned. * * @param courseId Course ID. * @param key Name of the property to check. * @param value Value to search. * @param options Other options. * @return Promise resolved with the activity data. */ protected async getH5PActivityByField( courseId: number, key: string, value: unknown, options: CoreSitesCommonWSOptions = {}, ): Promise<AddonModH5PActivityData> { const site = await CoreSites.getSite(options.siteId); const params: AddonModH5pactivityGetByCoursesWSParams = { courseids: [courseId], }; const preSets: CoreSiteWSPreSets = { cacheKey: this.getH5PActivityDataCacheKey(courseId), updateFrequency: CoreSite.FREQUENCY_RARELY, component: AddonModH5PActivityProvider.COMPONENT, ...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets. }; const response = await site.read<AddonModH5pactivityGetByCoursesWSResponse>( 'mod_h5pactivity_get_h5pactivities_by_courses', params, preSets, ); const currentActivity = response.h5pactivities.find((h5pActivity) => h5pActivity[key] == value); if (currentActivity) { return currentActivity; } throw new CoreError(Translate.instant('addon.mod_h5pactivity.errorgetactivity')); }
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
MethodDeclaration
/** * Get an H5P activity by module ID. * * @param courseId Course ID. * @param cmId Course module ID. * @param options Other options. * @return Promise resolved with the activity data. */ getH5PActivity(courseId: number, cmId: number, options: CoreSitesCommonWSOptions = {}): Promise<AddonModH5PActivityData> { return this.getH5PActivityByField(courseId, 'coursemodule', cmId, options); }
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
MethodDeclaration
/** * Get an H5P activity by context ID. * * @param courseId Course ID. * @param contextId Context ID. * @param options Other options. * @return Promise resolved with the activity data. */ getH5PActivityByContextId( courseId: number, contextId: number, options: CoreSitesCommonWSOptions = {}, ): Promise<AddonModH5PActivityData> { return this.getH5PActivityByField(courseId, 'context', contextId, options); }
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
MethodDeclaration
/** * Get an H5P activity by instance ID. * * @param courseId Course ID. * @param id Instance ID. * @param options Other options. * @return Promise resolved with the activity data. */ getH5PActivityById(courseId: number, id: number, options: CoreSitesCommonWSOptions = {}): Promise<AddonModH5PActivityData> { return this.getH5PActivityByField(courseId, 'id', id, options); }
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
MethodDeclaration
/** * Get cache key for attemps WS calls. * * @param id Instance ID. * @param userIds User IDs. * @return Cache key. */ protected getUserAttemptsCacheKey(id: number, userIds: number[]): string { return this.getUserAttemptsCommonCacheKey(id) + ':' + JSON.stringify(userIds); }
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
MethodDeclaration
/** * Get common cache key for attempts WS calls. * * @param id Instance ID. * @return Cache key. */ protected getUserAttemptsCommonCacheKey(id: number): string { return ROOT_CACHE_KEY + 'attempts:' + id; }
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
MethodDeclaration
/** * Get attempts of a certain user. * * @param id Activity ID. * @param options Other options. * @return Promise resolved with the attempts of the user. */ async getUserAttempts( id: number, options: AddonModH5PActivityGetAttemptsOptions = {}, ): Promise<AddonModH5PActivityUserAttempts> { const site = await CoreSites.getSite(options.siteId); const params: AddonModH5pactivityGetAttemptsWSParams = { h5pactivityid: id, userids: [options.userId || site.getUserId()], }; const preSets: CoreSiteWSPreSets = { cacheKey: this.getUserAttemptsCacheKey(id, params.userids!), updateFrequency: CoreSite.FREQUENCY_SOMETIMES, component: AddonModH5PActivityProvider.COMPONENT, componentId: options.cmId, ...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets. }; const response = await site.read<AddonModH5pactivityGetAttemptsWSResponse>('mod_h5pactivity_get_attempts', params, preSets); if (response.warnings?.[0]) { throw new CoreWSError(response.warnings[0]); // Cannot view user attempts. } return this.formatUserAttempts(response.usersattempts[0]); }
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
MethodDeclaration
/** * Invalidates access information. * * @param id H5P activity ID. * @param siteId Site ID. If not defined, current site. * @return Promise resolved when the data is invalidated. */ async invalidateAccessInformation(id: number, siteId?: string): Promise<void> { const site = await CoreSites.getSite(siteId); await site.invalidateWsCacheForKey(this.getAccessInformationCacheKey(id)); }
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
MethodDeclaration
/** * Invalidates H5P activity data. * * @param courseId Course ID. * @param siteId Site ID. If not defined, current site. * @return Promise resolved when the data is invalidated. */ async invalidateActivityData(courseId: number, siteId?: string): Promise<void> { const site = await CoreSites.getSite(siteId); await site.invalidateWsCacheForKey(this.getH5PActivityDataCacheKey(courseId)); }
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
MethodDeclaration
/** * Invalidates all attempts results for H5P activity. * * @param id Activity ID. * @param siteId Site ID. If not defined, current site. * @return Promise resolved when the data is invalidated. */ async invalidateAllResults(id: number, siteId?: string): Promise<void> { const site = await CoreSites.getSite(siteId); await site.invalidateWsCacheForKey(this.getAttemptResultsCommonCacheKey(id)); }
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
MethodDeclaration
/** * Invalidates results of a certain attempt for H5P activity. * * @param id Activity ID. * @param attemptId Attempt ID. * @param siteId Site ID. If not defined, current site. * @return Promise resolved when the data is invalidated. */ async invalidateAttemptResults(id: number, attemptId: number, siteId?: string): Promise<void> { const site = await CoreSites.getSite(siteId); await site.invalidateWsCacheForKey(this.getAttemptResultsCacheKey(id, [attemptId])); }
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
MethodDeclaration
/** * Invalidates all users attempts for H5P activity. * * @param id Activity ID. * @param siteId Site ID. If not defined, current site. * @return Promise resolved when the data is invalidated. */ async invalidateAllUserAttempts(id: number, siteId?: string): Promise<void> { const site = await CoreSites.getSite(siteId); await site.invalidateWsCacheForKey(this.getUserAttemptsCommonCacheKey(id)); }
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
MethodDeclaration
/** * Invalidates attempts of a certain user for H5P activity. * * @param id Activity ID. * @param userId User ID. If not defined, current user in the site. * @param siteId Site ID. If not defined, current site. * @return Promise resolved when the data is invalidated. */ async invalidateUserAttempts(id: number, userId?: number, siteId?: string): Promise<void> { const site = await CoreSites.getSite(siteId); userId = userId || site.getUserId(); await site.invalidateWsCacheForKey(this.getUserAttemptsCacheKey(id, [userId])); }
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
MethodDeclaration
/** * Delete launcher. * * @return Promise resolved when the launcher file is deleted. */ async isPluginEnabled(siteId?: string): Promise<boolean> { const site = await CoreSites.getSite(siteId); return site.wsAvailable('mod_h5pactivity_get_h5pactivities_by_courses'); }
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
MethodDeclaration
/** * Report an H5P activity as being viewed. * * @param id H5P activity ID. * @param name Name of the activity. * @param siteId Site ID. If not defined, current site. * @return Promise resolved when the WS call is successful. */ logView(id: number, name?: string, siteId?: string): Promise<void> { const params: AddonModH5pactivityViewH5pactivityWSParams = { h5pactivityid: id, }; return CoreCourseLogHelper.logSingle( 'mod_h5pactivity_view_h5pactivity', params, AddonModH5PActivityProvider.COMPONENT, id, name, 'h5pactivity', {}, siteId, ); }
Abdulig/ioamoodleapp
src/addons/mod/h5pactivity/services/h5pactivity.ts
TypeScript
FunctionDeclaration
/* type TypeGuardClass<T, K extends string> = { [ P in K]: (arg: any) => arg is T } */ export function assertType<T, C>( value: any, contextOrFn: [C, TypeGuardFn<T, C>] | TypeGuardFn<T> ): T { if (contextOrFn instanceof Function) { const hold = contextOrFn(value); if (hold === true) { return value; } else { throw new Error(`assert type for ${value} failed`); } } else { const [context, fn] = contextOrFn; const hold = fn.call(context, value); if (hold === true) { return value; } else { throw new Error(`assert type for ${value} failed`); } } }
minhloi/typescript-libs
packages/assert/src/core/assertType.ts
TypeScript
TypeAliasDeclaration
type TypeGuardFn<T, C = void> = (this: C, arg: any) => arg is T;
minhloi/typescript-libs
packages/assert/src/core/assertType.ts
TypeScript
ArrowFunction
() => { let service: ServicioVisualizarService; beforeEach(() => { TestBed.configureTestingModule({}); service = TestBed.inject(ServicioVisualizarService); }); it('should be created', () => { expect(service).toBeTruthy(); }); }
efccc0010/Vizzlan
Tienda-online/src/app/CUS13/Services/servicio-visualizar.service.spec.ts
TypeScript
ArrowFunction
() => { TestBed.configureTestingModule({}); service = TestBed.inject(ServicioVisualizarService); }
efccc0010/Vizzlan
Tienda-online/src/app/CUS13/Services/servicio-visualizar.service.spec.ts
TypeScript