diff --git a/projects/questionset-editor-library/src/lib/components/editor/editor.component.spec.data.ts b/projects/questionset-editor-library/src/lib/components/editor/editor.component.spec.data.ts
index 02a6e56d..84c6b0e3 100644
--- a/projects/questionset-editor-library/src/lib/components/editor/editor.component.spec.data.ts
+++ b/projects/questionset-editor-library/src/lib/components/editor/editor.component.spec.data.ts
@@ -319,7 +319,12 @@ export const toolbarConfig_question = {
done_btn_label: 'Done'
};
-export const nativeElement = `
`;
+export const nativeElement = `- Untitled QuestionSet
+
+
+
`;
export const getCategoryDefinitionResponse = {
id: 'api.object.category.definition.read',
@@ -1688,6 +1693,7 @@ export const treeNodeData = {
board: 'CBSE',
status: 'Draft',
showEvidence: 'No',
+ serverMode: true
},
root: false,
},
diff --git a/projects/questionset-editor-library/src/lib/components/editor/editor.component.spec.ts b/projects/questionset-editor-library/src/lib/components/editor/editor.component.spec.ts
index 205553b0..7d5009d8 100755
--- a/projects/questionset-editor-library/src/lib/components/editor/editor.component.spec.ts
+++ b/projects/questionset-editor-library/src/lib/components/editor/editor.component.spec.ts
@@ -36,12 +36,14 @@ describe('EditorComponent', () => {
let component: EditorComponent;
let fixture: ComponentFixture;
let toasterService;
+ let editorService: EditorService;
+ let treeService: TreeService;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule, FormsModule, ReactiveFormsModule, RouterTestingModule],
declarations: [EditorComponent, TelemetryInteractDirective],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
- providers: [EditorTelemetryService, EditorService, ToasterService,
+ providers: [EditorTelemetryService, EditorService, ToasterService, TreeService,
{ provide: ConfigService, useValue: configStub }
]
})
@@ -52,6 +54,8 @@ describe('EditorComponent', () => {
fixture = TestBed.createComponent(EditorComponent);
component = fixture.componentInstance;
toasterService = TestBed.inject(ToasterService);
+ editorService = TestBed.inject(EditorService);
+ treeService = TestBed.inject(TreeService);
// tslint:disable-next-line:no-string-literal
editorConfig.context['targetFWIds'] = ['nit_k12'];
// tslint:disable-next-line:no-string-literal
@@ -752,18 +756,23 @@ describe('EditorComponent', () => {
it('#showQuestionLibraryComponentPage() should set #addQuestionFromLibraryButtonLoader to false and call #saveContent()',
() => {
- const editorService = TestBed.inject(EditorService);
- const treeService = TestBed.inject(TreeService);
editorService.templateList = ['Subjective Question'];
component.collectionId = 'do_12345';
component.organisationFramework = 'nit_k12';
component.editorConfig = editorConfig_question;
component.questionlibraryInput.searchFormConfig = categoryDefinition.result.objectCategoryDefinition.forms.searchConfig;
- component.questionComponentInput.metadataFormConfig = categoryDefinition.result.objectCategoryDefinition.forms.childMetadata;
- spyOn(treeService, 'getActiveNode').and.returnValue({data: {metadata: {}}});
- spyOn(editorService, 'getContentChildrens').and.returnValue([{}, {}]);
+ component.questionlibraryInput.metadataFormConfig = categoryDefinition.result.objectCategoryDefinition.forms.childMetadata;
+ treeService.treeNativeElement = nativeElement;
+ spyOn(treeService, 'getActiveNode').and.returnValue({data: {metadata: {}}});
+ editorService.contentsCount = 0;
+ spyOn(editorService, 'getContentChildrens').and.returnValue([]);
spyOn(editorService, 'checkIfContentsCanbeAdded').and.returnValue(true);
- spyOn(treeService, 'getEval').and.returnValue({mode: "server"});
+
+
+ const serverMode = {data: {metadata: {serverMode: true}}};
+ spyOn(treeService, 'getFirstChild').and.callFake(()=> serverMode);
+ let result = treeService.getEval();
+
spyOn(component, 'saveContent').and.callFake(() => {
return Promise.resolve('success');
});
@@ -773,7 +782,9 @@ describe('EditorComponent', () => {
expect(treeService.getActiveNode).toHaveBeenCalled();
expect(component.buttonLoaders.addQuestionFromLibraryButtonLoader).toBeFalsy();
expect(component.questionlibraryInput).toBeDefined();
- expect(treeService.getEval).toHaveBeenCalled();
+ expect(editorService.getContentChildrens).toHaveBeenCalled();
+ expect(treeService.getFirstChild).toHaveBeenCalled();
+ expect(result).toBe(true)
expect(component.pageId).toEqual('question_library');
});
});
diff --git a/projects/questionset-editor-library/src/lib/components/editor/editor.component.ts b/projects/questionset-editor-library/src/lib/components/editor/editor.component.ts
index 1bb29525..8ed478d0 100755
--- a/projects/questionset-editor-library/src/lib/components/editor/editor.component.ts
+++ b/projects/questionset-editor-library/src/lib/components/editor/editor.component.ts
@@ -545,14 +545,16 @@ export class EditorComponent implements OnInit, OnDestroy, AfterViewInit {
},
targetPrimaryCategories: questionCategory,
collectionId: this.collectionId,
- existingcontentCounts: this.editorService.getContentChildrens().length,
collection: activeNode?.data?.metadata,
framework: this.organisationFramework,
editorConfig: this.editorConfig,
searchFormConfig: this.questionlibraryInput.searchFormConfig,
metadataFormConfig: this.questionlibraryInput.metadataFormConfig
};
- this.questionlibraryInput.collection.eval = this.treeService.getEval();
+ if(this.treeService.getEval()) {
+ this.questionlibraryInput.collection.evalMode = "server"
+ }
+ this.questionlibraryInput.existingcontentCounts = this.editorService.getContentChildrens().length
this.pageId = 'question_library';
console.log(this.questionlibraryInput);
}).catch(((error: string) => {
diff --git a/projects/questionset-editor-library/src/lib/components/meta-form/meta-form.component.spec.data.ts b/projects/questionset-editor-library/src/lib/components/meta-form/meta-form.component.spec.data.ts
index 7a89be09..e59340e6 100644
--- a/projects/questionset-editor-library/src/lib/components/meta-form/meta-form.component.spec.data.ts
+++ b/projects/questionset-editor-library/src/lib/components/meta-form/meta-form.component.spec.data.ts
@@ -335,7 +335,7 @@ export const mockData = {
code: 'showTimer',
},
{
- code: 'mode'
+ code: 'serverMode'
}
]
}
@@ -418,9 +418,7 @@ export const mockData = {
createdBy: '5a587cc1-e018-4859-a0a8-e842650b9d64',
compatibilityLevel: 5,
navigationMode: 'non-linear',
- eval: {
- mode: 'server'
- },
+ serverMode: true,
timeLimits: {
questionSet: {
min: 0,
diff --git a/projects/questionset-editor-library/src/lib/components/meta-form/meta-form.component.ts b/projects/questionset-editor-library/src/lib/components/meta-form/meta-form.component.ts
index 82be9d82..c14901d0 100644
--- a/projects/questionset-editor-library/src/lib/components/meta-form/meta-form.component.ts
+++ b/projects/questionset-editor-library/src/lib/components/meta-form/meta-form.component.ts
@@ -213,8 +213,9 @@ export class MetaFormComponent implements OnChanges, OnDestroy {
if (field.code === 'allowECM') {
field.default = _.get(metaDataFields, 'recordedBy') !== 'Self' ? 'Yes' : 'No' ;
}
- if (field.code === 'mode') {
- field.default = _.get(metaDataFields, 'eval.mode')
+ if (field.code === 'serverMode') {
+ field.default = _.get(metaDataFields, 'evalMode') == this.configService.editorConfig.evalMode || _.get(metaDataFields, 'serverMode') === true;
+
}
if (field.code === 'instances') {
field.default = !_.isEmpty(metaDataFields, 'instances') ? _.get(metaDataFields, 'instances.label') : '' ;
diff --git a/projects/questionset-editor-library/src/lib/components/question/question.component.spec.data.ts b/projects/questionset-editor-library/src/lib/components/question/question.component.spec.data.ts
index 5a980b03..7375c41a 100644
--- a/projects/questionset-editor-library/src/lib/components/question/question.component.spec.data.ts
+++ b/projects/questionset-editor-library/src/lib/components/question/question.component.spec.data.ts
@@ -2991,6 +2991,9 @@ export const mockTreeService = {
return {
data: {
id: "do_11330103476396851218",
+ metadata: {
+ evalMode: 'server'
+ }
},
getParent: () => {
return {
diff --git a/projects/questionset-editor-library/src/lib/components/question/question.component.ts b/projects/questionset-editor-library/src/lib/components/question/question.component.ts
index 98fc2724..237ea799 100644
--- a/projects/questionset-editor-library/src/lib/components/question/question.component.ts
+++ b/projects/questionset-editor-library/src/lib/components/question/question.component.ts
@@ -1007,7 +1007,11 @@ export class QuestionComponent implements OnInit, AfterViewInit, OnDestroy {
this.editorService.data = {};
this.editorService.selectedSection = selectedUnitId;
let metaData = this.getQuestionMetadata();
- metaData.eval = activeNode?.data.metadata?.eval || data?.data?.eval;
+
+ const evalMode = data?.data?.evalMode || data?.data?.metadata?.evalMode || activeNode?.data.metadata?.evalMode;
+ if(evalMode){
+ metaData.evalMode = evalMode;
+ }
this.setQuestionTypeValues(metaData);
return {
nodesModified: {
diff --git a/projects/questionset-editor-library/src/lib/services/config/editor.config.json b/projects/questionset-editor-library/src/lib/services/config/editor.config.json
index aff695dd..a99302a0 100644
--- a/projects/questionset-editor-library/src/lib/services/config/editor.config.json
+++ b/projects/questionset-editor-library/src/lib/services/config/editor.config.json
@@ -21,11 +21,7 @@
"readQuestionFields": "body,primaryCategory,mimeType,qType,answer,templateId,responseDeclaration,interactionTypes,interactions,name,solutions,editorState,media,remarks,evidence,hints,instructions,outcomeDeclaration,",
"omitFalseyProperties":["topic", "topicsIds", "targetTopicIds", "keywords"],
"evaluableQuestionSet": "PIAA Question Set",
- "server":{"mode":"server"},
- "client":{"mode":"client"},
- "editorModeCheck":"server",
- "serverSearch": "{\"mode\":\"server\"}",
- "clientSearch": "{\"mode\":\"client\"}",
+ "evalMode": "server",
"questionSet": {
"maxQuestionsLimit": 500
},
diff --git a/projects/questionset-editor-library/src/lib/services/editor/editor.service.spec.ts b/projects/questionset-editor-library/src/lib/services/editor/editor.service.spec.ts
index 1bc37871..c5947858 100755
--- a/projects/questionset-editor-library/src/lib/services/editor/editor.service.spec.ts
+++ b/projects/questionset-editor-library/src/lib/services/editor/editor.service.spec.ts
@@ -465,22 +465,36 @@ describe('EditorService', () => {
it('#getCollectionHierarchy should call when no section id and parent', () => {
treeService.treeCache.nodesModified = treeData.treeNode;
- treeService.treeNativeElement = nativeElement;
+ // treeService.treeNativeElement = nativeElement;
+ // treeService.setTreeElement(nativeElement);
+ spyOn(treeService, 'setTreeElement').and.returnValue(nativeElement)
spyOn(editorService, 'getCollectionHierarchy').and.callThrough();
+ spyOn(editorService.treeService, 'getFirstChild').and.callFake(() => treeData.treeNode.data);
spyOn(editorService, 'getUpdatedNodeMetaData').and.callFake(() => { return treeService.treeCache.nodesModified });
- spyOn(treeService, 'getFirstChild').and.callFake(() => {
- return { data: { metadata: { identifier: '0123' } } };
- });
hierarchyRootNodeData.folder = false;
editorService.getHierarchyObj(hierarchyRootNodeData);
editorService.getCollectionHierarchy();
+ // expect(treeService.treeNativeElement).toEqual(nativeElement);
expect(editorService.getCollectionHierarchy).toHaveBeenCalled();
});
it('#getUpdatedNodeMetaData should return root nodesModified data', () => {
- treeService.treeCache.nodesModified = treeData.treeNode;
+ treeService.treeCache.nodesModified = {"da0ac2f0-1ea3-464a-bc03-f62b71415837": {root: false, metadata: {}}};
treeService.treeNativeElement = nativeElement;
- spyOn(treeService, 'getFirstChild').and.callFake(()=> treeData.treeNode.data);
+ spyOn(treeService, 'getFirstChild').and.callFake(() => {
+ return { data: { metadata: { identifier: '0123', evalMode: 'server' } } };
+ });
+ spyOn(editorService, 'getUpdatedNodeMetaData').and.callThrough();
+ editorService.getUpdatedNodeMetaData();
+ expect(editorService.getUpdatedNodeMetaData).toHaveBeenCalled();
+ });
+
+ it('#getUpdatedNodeMetaData should delete serverMode property', () => {
+ treeService.treeCache.nodesModified = {"da0ac2f0-1ea3-464a-bc03-f62b71415837": {root: true, metadata: {serverMode: true}}};
+ treeService.treeNativeElement = nativeElement;
+ spyOn(treeService, 'getFirstChild').and.callFake(() => {
+ return { data: { metadata: { identifier: '0123', evalMode: 'server' } } };
+ });
spyOn(editorService, 'getUpdatedNodeMetaData').and.callThrough();
editorService.getUpdatedNodeMetaData();
expect(editorService.getUpdatedNodeMetaData).toHaveBeenCalled();
diff --git a/projects/questionset-editor-library/src/lib/services/editor/editor.service.ts b/projects/questionset-editor-library/src/lib/services/editor/editor.service.ts
index bec63929..528c2f10 100755
--- a/projects/questionset-editor-library/src/lib/services/editor/editor.service.ts
+++ b/projects/questionset-editor-library/src/lib/services/editor/editor.service.ts
@@ -402,15 +402,14 @@ export class EditorService {
return node.root;
});
const parentNode = this.treeService.getFirstChild().data;
-
_.forEach(this.treeService.treeCache.nodesModified, (node, nodeId)=>{
- if(!node.root && parentNode?.eval || parentNode?.metadata?.eval){
- this.treeService.treeCache.nodesModified[nodeId].metadata.eval = parentNode.eval || parentNode?.metadata?.eval;
+ if(!node.root && parentNode?.evalMode || parentNode?.metadata?.evalMode){
+ this.treeService.treeCache.nodesModified[nodeId].metadata.evalMode = parentNode?.evalMode || parentNode?.metadata?.evalMode;
}
})
- if(this.treeService.treeCache.nodesModified[parentNodeId]?.metadata.hasOwnProperty('mode')) {
- delete this.treeService.treeCache.nodesModified[parentNodeId]?.metadata?.mode
+ if(this.treeService.treeCache.nodesModified[parentNodeId]?.metadata.hasOwnProperty('serverMode')) {
+ delete this.treeService.treeCache.nodesModified[parentNodeId]?.metadata?.serverMode
}
return this.treeService.treeCache.nodesModified;
}
diff --git a/projects/questionset-editor-library/src/lib/services/tree/tree.service.spec.data.ts b/projects/questionset-editor-library/src/lib/services/tree/tree.service.spec.data.ts
index 150ba8e7..51ddd204 100644
--- a/projects/questionset-editor-library/src/lib/services/tree/tree.service.spec.data.ts
+++ b/projects/questionset-editor-library/src/lib/services/tree/tree.service.spec.data.ts
@@ -6,6 +6,7 @@ export const treeNode = {
"keywords": [
"test"
],
+ "serverMode": true,
"subject": [
"History"
],
@@ -63,7 +64,7 @@ export const treeNode = {
"medium": [
"English"
],
- "mode": "server",
+ "evalMode": "server",
"createdOn": "2021-04-22T14:23:40.169+0000",
"contentDisposition": "inline",
"additionalCategories": [
@@ -124,9 +125,6 @@ export const treeCache = {
"min": 0
}
},
- "eval": {
- "mode": "server"
- },
"description": "desc",
"board": "General Nursing Midwifery",
"medium": [
@@ -161,9 +159,6 @@ export const treeCache = {
"max": 0,
"min": 0
}
- },
- "eval": {
- "mode": "client"
}
},
"isNew": true
diff --git a/projects/questionset-editor-library/src/lib/services/tree/tree.service.spec.ts b/projects/questionset-editor-library/src/lib/services/tree/tree.service.spec.ts
index 65e8e6ab..d805894b 100755
--- a/projects/questionset-editor-library/src/lib/services/tree/tree.service.spec.ts
+++ b/projects/questionset-editor-library/src/lib/services/tree/tree.service.spec.ts
@@ -69,13 +69,13 @@ describe('TreeService', () => {
spyOn(treeService, 'getActiveNode').and.callFake(()=> treeNode);
treeService.updateTreeNodeMetadata(treeNode,undefined,'Observation', 'QuestionSet');
})
-
+
it('should call updateEvaluable for root element', ()=> {
treeService.treeCache = treeCache;
- treeService.treeNativeElement = nativeElement;
- spyOn(treeService, 'getFirstChild').and.callFake(()=> treeNode);
+ const serverMode = {data: {metadata: {serverMode: true}}};
spyOn(treeService, 'updateFirstChild').and.callFake(() => {});
+ spyOn(treeService,'getFirstChild').and.callFake(() => serverMode);
treeService.updateEvaluable('do_113263678834016256111');
expect(treeService.getFirstChild).toHaveBeenCalled();
@@ -89,10 +89,23 @@ describe('TreeService', () => {
treeService.updateEvaluable('da0ac2f0-1ea3-464a-bc03-f62b71415837');
expect(treeService.getFirstChild).toHaveBeenCalled();
});
+
it('should call getEval method', () => {
- spyOn(treeService, 'getFirstChild').and.callFake(()=> treeNode);
- treeService.getEval();
+ const serverMode = {data: {metadata: {serverMode: true}}};
+ spyOn(treeService, 'getFirstChild').and.callFake(()=> serverMode);
+ let result = treeService.getEval();
+ expect(treeService.getFirstChild).toHaveBeenCalled();
+ expect(result).toBe(true)
+ });
+
+ it('should call overrideEvaluable method', () => {
+ // const serverMode = {data: {metadata: {serverMode: true}}};
+ treeService.treeCache = treeCache;
+ const serverMode = {data: {metadata: {serverMode: true}}};
+ spyOn(treeService, 'getFirstChild').and.callFake(()=> serverMode);
+ treeService.overrideEvaluable('da0ac2f0-1ea3-464a-bc03-f62b71415837')
+ spyOn(treeService, 'overrideEvaluable');
expect(treeService.getFirstChild).toHaveBeenCalled();
});
diff --git a/projects/questionset-editor-library/src/lib/services/tree/tree.service.ts b/projects/questionset-editor-library/src/lib/services/tree/tree.service.ts
index 5672b08f..0b92388a 100755
--- a/projects/questionset-editor-library/src/lib/services/tree/tree.service.ts
+++ b/projects/questionset-editor-library/src/lib/services/tree/tree.service.ts
@@ -253,35 +253,41 @@ export class TreeService {
}
updateEvaluable(nodeId){
- this.treeCache.nodesModified[nodeId].metadata.eval = this.treeCache.nodesModified[nodeId].metadata.primaryCategory === this.configService.editorConfig.evaluableQuestionSet ?
- this.configService.editorConfig.server:this.configService.editorConfig.client;
+ if(this.treeCache.nodesModified[nodeId].metadata.primaryCategory === this.configService.editorConfig.evaluableQuestionSet) {
+ this.treeCache.nodesModified[nodeId].metadata.evalMode = this.configService.editorConfig.evalMode
+ }
if(!this.treeCache.nodesModified[nodeId].root){
- this.treeCache.nodesModified[nodeId].metadata.eval = this.getFirstChild().data.primaryCategory === this.configService.editorConfig.evaluableQuestionSet?
- this.configService.editorConfig.server:this.configService.editorConfig.client;
+ if(this.getFirstChild().data.primaryCategory === this.configService.editorConfig.evaluableQuestionSet) {
+ this.treeCache.nodesModified[nodeId].metadata.evalMode = this.configService.editorConfig.evalMode;
+ }
this.overrideEvaluable(nodeId);
} else {
- if(this.getFirstChild().data?.metadata.mode) {
- this.treeCache.nodesModified[nodeId].metadata.eval = this.getFirstChild().data.metadata.mode === this.configService.editorConfig.editorModeCheck ?
- this.configService.editorConfig.server:this.configService.editorConfig.client;
+ const firstChild = this.getFirstChild().data?.metadata;
+ if(firstChild?.serverMode) {
+ this.treeCache.nodesModified[nodeId].metadata.evalMode = this.configService.editorConfig.evalMode;
+ this.updateFirstChild(this.treeCache.nodesModified[nodeId].metadata.evalMode)
+ } else if(!firstChild?.serverMode) {
+ delete this.treeCache.nodesModified[nodeId].metadata.evalMode;
+ delete $(this.treeNativeElement).fancytree('getRootNode').getFirstChild()?.data?.evalMode
}
- this.updateFirstChild(this.treeCache.nodesModified[nodeId].metadata.eval)
}
}
updateFirstChild(evalMode:any) {
- $(this.treeNativeElement).fancytree('getRootNode').getFirstChild().data.eval = evalMode;
+ $(this.treeNativeElement).fancytree('getRootNode').getFirstChild().data.evalMode = evalMode;
}
getEval() {
- return this.getFirstChild().data?.eval?.mode === this.configService.editorConfig.server.mode ||
- this.getFirstChild().data.metadata?.eval?.mode === this.configService.editorConfig.server.mode ? this.configService.editorConfig.serverSearch : this.configService.editorConfig.clientSearch
+ if(this.getFirstChild().data?.serverMode || this.getFirstChild().data?.metadata?.serverMode) {
+ return true
+ }
+ return false
}
overrideEvaluable(nodeId){
const firstNode = this.getFirstChild()
- if(this.getFirstChild().data.metadata.mode) {
- this.treeCache.nodesModified[nodeId].metadata.eval = firstNode.data.metadata.mode === this.configService.editorConfig.editorModeCheck ?
- this.configService.editorConfig.server:this.configService.editorConfig.client;
+ if(this.getFirstChild().data?.metadata?.serverMode && firstNode.data?.metadata?.serverMode) {
+ this.treeCache.nodesModified[nodeId].metadata.evalMode = this.configService.editorConfig.evalMode
}
}