Skip to content

Commit

Permalink
Merge branch 'release-6.1.0' of https://github.com/Sunbird-inQuiry/ed…
Browse files Browse the repository at this point in the history
…itor into exam-validation
  • Loading branch information
pavankumar0408 committed Aug 25, 2023
2 parents c1a0f11 + b9a7067 commit 290d165
Show file tree
Hide file tree
Showing 12 changed files with 75 additions and 53 deletions.
4 changes: 2 additions & 2 deletions projects/questionset-editor-library/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@project-sunbird/sunbird-questionset-editor",
"version": "6.1.0-beta.4",
"name": "compass-collection-editor",
"version": "0.0.1",
"dependencies": {
"tslib": "^2.0.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ export class MetaFormComponent implements OnChanges, OnDestroy {
data.appIcon = this.appIcon;
}
this.toolbarEmitter.emit({ button: 'onFormValueChange', data });
delete data.selectedQuestionType;
this.treeService.updateNode(data);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1155,13 +1155,13 @@ describe("QuestionComponent", () => {
it('#getAnswerHtml() should return answer html', () => {
spyOn(component, 'getAnswerHtml').and.callThrough();
const answerHtml = component.getAnswerHtml('<p>Sample Answer</p>');
expect(answerHtml).toBe('<div class=\'anwser-body\'><p>Sample Answer</p></div>');
expect(answerHtml).toBe('<div class=\'answer-body\'><p>Sample Answer</p></div>');
});

it('#getAnswerWrapperHtml() should return answer html', () => {
spyOn(component, 'getAnswerWrapperHtml').and.callThrough();
const answerWrappedHtml = component.getAnswerWrapperHtml('<div class=\'anwser-body\'><p>Sample Answer</p></div>');
expect(answerWrappedHtml).toBe('<div class=\'anwser-container\'><div class=\'anwser-body\'><p>Sample Answer</p></div></div>');
const answerWrappedHtml = component.getAnswerWrapperHtml('<div class=\'answer-body\'><p>Sample Answer</p></div>');
expect(answerWrappedHtml).toBe('<div class=\'answer-container\'><div class=\'answer-body\'><p>Sample Answer</p></div></div>');
});

it('#getInteractionValues() should return correct answer object', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,14 +186,14 @@ export class QuestionComponent implements OnInit, AfterViewInit, OnDestroy {

initialize() {
this.editorService.fetchCollectionHierarchy(this.questionSetId).subscribe((response) => {
this.questionSetHierarchy = _.get(response, 'result.questionSet');
this.questionSetHierarchy = _.get(response, 'result.questionset');
const parentId = this.editorService.parentIdentifier ? this.editorService.parentIdentifier : this.questionId;
//only for observation,survey,observation with rubrics
if (!_.isUndefined(parentId) && !_.isUndefined(this.editorService.editorConfig.config.renderTaxonomy)) {
this.getParentQuestionOptions(parentId);
const sectionData = this.treeService.getNodeById(parentId);
const children = _.get(response, 'result.questionSet.children');
this.sectionPrimaryCategory = _.get(response, 'result.questionSet.primaryCategory');
const children = _.get(response, 'result.questionset.children');
this.sectionPrimaryCategory = _.get(response, 'result.questionset.primaryCategory');
this.selectedSectionId = _.get(sectionData, 'data.metadata.parent');
this.getBranchingLogic(children);
}
Expand Down Expand Up @@ -836,13 +836,13 @@ export class QuestionComponent implements OnInit, AfterViewInit, OnDestroy {
}

getAnswerHtml(optionLabel) {
const answerHtml = '<div class=\'anwser-body\'>{answer}</div>';
const answerHtml = '<div class=\'answer-body\'>{answer}</div>';
const optionHtml = answerHtml.replace('{answer}', optionLabel);
return optionHtml;
}

getAnswerWrapperHtml(concatenatedAnswers) {
const answerTemplate = '<div class=\'anwser-container\'>{answers}</div>';
const answerTemplate = '<div class=\'answer-container\'>{answers}</div>';
const answer = answerTemplate.replace('{answers}', concatenatedAnswers);
return answer;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,8 @@
.handle-zoom {
overflow: hidden;
position: relative;
}

lib-questionset-editor .image-viewer__close {
line-height: 45px !important;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"QuestionSet": "questionSet",
"QuestionSet": "questionset",
"Collection": "content",
"Question": "question",
"additionalCategories": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"DEFAULT_PARAMS_FIELDS": "instructions,outcomeDeclaration"
},
"Question": {
"LIST":"question/v1/list",
"READ":"question/v1/read/",
"LIST":"question/v2/list",
"READ":"question/v2/read/",
"CREATE": "question/v2/create",
"UPDATE": "question/v2/update/",
"REVIEW" : "question/v2/review/",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DataService } from './../data/data.service';
import { editorConfig, BranchingLogicData, treeNodeData, rootNodeData, hierarchyRootNodeData } from './../../components/editor/editor.component.spec.data';
import { editorConfig, BranchingLogicData, treeNodeData, rootNodeData, hierarchyRootNodeData, nativeElement } from './../../components/editor/editor.component.spec.data';
import { TestBed } from '@angular/core/testing';
import { EditorService } from './editor.service';
import { HttpClientModule, HttpClient } from '@angular/common/http';
Expand All @@ -12,9 +12,12 @@ import { of } from 'rxjs';
import { PublicDataService } from '../public-data/public-data.service';
import { ToasterService } from '../../services/toaster/toaster.service';
import { TreeService } from '../tree/tree.service';
import * as treeData from '../../services/tree/tree.service.spec.data';
import * as mockData from './editor.service.spec.data';
import { map } from 'rxjs/operators';
import * as _ from 'lodash-es';
import 'jquery.fancytree';
declare var $: any;

describe('EditorService', () => {
let editorService: EditorService;
Expand Down Expand Up @@ -527,7 +530,10 @@ describe('EditorService', () => {
});

it('#getCollectionHierarchy should call', () => {
treeService.treeCache.nodesModified = treeData.treeNode;
treeService.treeNativeElement = nativeElement;
spyOn(editorService, 'getCollectionHierarchy').and.callThrough();
spyOn(editorService, 'getUpdatedNodeMetaData').and.callFake(() => { return treeService.treeCache.nodesModified });
spyOn(treeService, 'getFirstChild').and.callFake(() => {
return { data: { metadata: { identifier: '0123' } } };
});
Expand All @@ -539,7 +545,10 @@ describe('EditorService', () => {
});

it('#getCollectionHierarchy should call when folder false', () => {
treeService.treeCache.nodesModified = treeData.treeNode;
treeService.treeNativeElement = nativeElement;
spyOn(editorService, 'getCollectionHierarchy').and.callThrough();
spyOn(editorService, 'getUpdatedNodeMetaData').and.callFake(() => { return treeService.treeCache.nodesModified });
spyOn(treeService, 'getFirstChild').and.callFake(() => {
return { data: { metadata: { identifier: '0123' } } };
});
Expand All @@ -551,7 +560,10 @@ describe('EditorService', () => {
});

it('#getCollectionHierarchy should call when no section id and parent', () => {
treeService.treeCache.nodesModified = treeData.treeNode;
treeService.treeNativeElement = nativeElement;
spyOn(editorService, 'getCollectionHierarchy').and.callThrough();
spyOn(editorService, 'getUpdatedNodeMetaData').and.callFake(() => { return treeService.treeCache.nodesModified });
spyOn(treeService, 'getFirstChild').and.callFake(() => {
return { data: { metadata: { identifier: '0123' } } };
});
Expand All @@ -561,6 +573,17 @@ describe('EditorService', () => {
expect(editorService.getCollectionHierarchy).toHaveBeenCalled();
});

it('#getUpdatedNodeMetaData should return root nodesModified data', () => {
treeService.treeCache.nodesModified = treeData.treeNode;
treeService.treeNativeElement = nativeElement;
// $(nativeElement).fancytree('getRootNode');
// spyOn($(nativeElement), 'fancytree').withArgs('getRootNode').and.callFake(() => {});
spyOn(treeService, 'getFirstChild').and.callFake(()=> treeData.treeNode.data.metadata);
spyOn(editorService, 'getUpdatedNodeMetaData').and.callThrough();
editorService.getUpdatedNodeMetaData();
expect(editorService.getUpdatedNodeMetaData).toHaveBeenCalled();
});

it('#_toFlatObjFromHierarchy should call', () => {
spyOn(editorService, '_toFlatObjFromHierarchy').and.callThrough();
spyOn(treeService, 'getFirstChild').and.callFake(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { editorConfig, nativeElement } from './../../components/editor/editor.co
import { TestBed, inject } from '@angular/core/testing';
import { TreeService } from './tree.service';
import { HttpClientModule, HttpClient } from '@angular/common/http';
import { treeNode } from './tree.service.spec.data';
import { treeNode, treeCache } from './tree.service.spec.data';

describe('TreeService', () => {
let treeService: TreeService;
Expand Down Expand Up @@ -70,6 +70,26 @@ describe('TreeService', () => {
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);
spyOn(treeService, 'updateFirstChild').and.callFake(() => {});

treeService.updateEvaluable('do_113263678834016256111');
expect(treeService.getFirstChild).toHaveBeenCalled();
expect(treeService.updateFirstChild).toHaveBeenCalled();
});

it('should call updateEvaluable for non root element', ()=> {
treeService.treeCache = treeCache;

spyOn(treeService, 'getFirstChild').and.callFake(()=> treeNode);
treeService.updateEvaluable('da0ac2f0-1ea3-464a-bc03-f62b71415837');
expect(treeService.getFirstChild).toHaveBeenCalled();
});

// it("#updateTreeNodeMetadata() should call #setTreeCache() with primaryCategory", ()=> {
// spyOn(treeService, 'updateTreeNodeMetadata').and.callThrough();
// spyOn(treeService, 'getActiveNode').and.callFake(()=> treeNode);
Expand Down
42 changes: 8 additions & 34 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ const BASE_URL = 'https://compass-dev.tarento.com/';

const API_AUTH_TOKEN = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiI0WEFsdFpGMFFhc1JDYlFnVXB4b2RvU2tLRUZyWmdpdCJ9.mXD7cSvv3Le6o_32lJplDck2D0IIMHnv0uJKq98YVwk";

const PORTAL_COOKIES= "connect.sid=s%3AsherXnbJZVk9PSaDZZKS067kYwg5wkPT.VXctObnTeEzMd%2F6qDRVMcPxg1TiDo2wxjfUaTKUQRJc"
const PORTAL_COOKIES= "connect.sid=s%3AVt7WVGstPSBHDO7OPQ93GYfgYMuQg_0D.qPKlYxL4DJvsNRpLRMwB%2B6MPpvSxXsLo6SX9OcDGm7Q"

const USER_TOKEN = "eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICI5YnBaRzhRQWF1SnZodUl2a2VqM2RVU2g3MUMzLTlvc21TdlhNeFBrbENRIn0.eyJqdGkiOiI1NzIyMWU1OC1lZTM0LTRkZWYtOGQzMS1hMjE0NDI5ZThjMTEiLCJleH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dW50IiwibWFuYWdlLWFjY291bnQtbGlua3MiLCJ2aWV3LXByb2ZpbGUiXX19LCJzY29wZSI6IiIsIm5hbWUiOiJDb21wYXNzcmdBZG1pbjEiLCJwcmVmZXJyZWRfdXNlcm5hbWUiOiJjb21wYXNzYWRtaW4xIiwiZ2l2ZW5fbmFtZSI6IkNvbXBhc3NyZ0FkbWluMSIsImZhbWlseV9uYW1lIjoiIiwiZW1haWwiOiJjbyoqKioqKioqKioqQHlvcG1haWwuY29tIn0.pT_UiKNpCW-8-a_S7dVyjKcSZnZ2Lrt7tk6Kh2jt8Rs0cqXE-L0Jec84IbGKCB2n-_yr1hdEuHMyEsmYZ4zNeUuVFoDSyRutesk-j_tbzfj8K5f3lmrcKHUf-qPKHIJJIFbtOCwTo6eJOAwFKPlqnBgdDhDAgdpOHTBwBpNAl3TYxO_fYOog7YAwCGTKAyOtRD28lcdd_mVi6nQUdbzbFtGcH3QzzmvpQts2IDCH_uq1Vhlw3zP272qNGv4iQnd34qapijbX7XSXFOVtMW5FD31j7KGN_VArpT9xQffsThUQdi-Lg6v0dmXi7aY7LcwKhhHamKH-my1unRfk9fZSEA";



Expand Down Expand Up @@ -43,34 +43,7 @@ app.all(['/api/framework/v1/read/*',
return proxyReqOpts;
}
}));
// app.use('/action/questionset/v2/*', proxy(BASE_URL, {
// https: true,
// limit: '30mb',
// proxyReqPathResolver: function (req) {
// console.log("pavan1", req.originalUrl);
// let originalUrl;
// if(!req.originalUrl.split("/").includes('update')) {
// originalUrl = req.originalUrl.replace('/action/', '/api/');
// } else {
// originalUrl = req.originalUrl;
// }
// console.log("pavan2", originalUrl);
// originalUrl = originalUrl.replace('/v2/','/v1/');
// console.log("pavan3", originalUrl);
// console.log('proxyReqPathResolver question', originalUrl, require('url').parse(originalUrl).path);
// return require('url').parse(originalUrl).path;
// },
// proxyReqOptDecorator: function (proxyReqOpts, srcReq) {
// console.log('proxyReqOptDecorator 3')
// // you can update headers
// proxyReqOpts.headers['Content-Type'] = 'application/json';
// proxyReqOpts.headers['user-id'] = 'content-editor';
// proxyReqOpts.headers['Cookie'] = PORTAL_COOKIES;
// proxyReqOpts.headers['authorization'] = `Bearer ${API_AUTH_TOKEN}`;
// proxyReqOpts.headers['x-authenticated-user-token'] = USER_TOKEN;
// return proxyReqOpts;
// }
// }));

app.use(['/action/questionset/v2/*',
'/action/question/v2/*',
'/action/collection/v1/*',
Expand All @@ -80,7 +53,6 @@ app.use(['/action/questionset/v2/*',
https: true,
limit: '30mb',
proxyReqPathResolver: function (req) {
console.log("adda", req.originalUrl);
let originalUrl = req.originalUrl.replace('/action/', '/api/')
console.log('proxyReqPathResolver questionset', originalUrl, require('url').parse(originalUrl).path);
return require('url').parse(originalUrl).path;
Expand All @@ -97,12 +69,12 @@ app.use(['/action/questionset/v2/*',
}
}));

app.use(['/action/composite/v3/search'
], proxy(BASE_URL, {
app.use(['*/action/composite/v3/search'
], proxy(BASE_URL, {
https: true,
limit: '30mb',
proxyReqPathResolver: function (req) {
let originalUrl = req.originalUrl.replace('/action/composite/v3/', '/api/composite/v1/')
let originalUrl = req.originalUrl.replace('/action/action/composite/v3/', '/api/composite/v1/')
console.log('proxyReqPathResolver questionset', originalUrl, require('url').parse(originalUrl).path);
return require('url').parse(originalUrl).path;
},
Expand Down Expand Up @@ -154,6 +126,8 @@ app.use(['/api','/assets','/action'], proxy(BASE_URL, {
proxyReqOpts.headers['Content-Type'] = 'application/json';
proxyReqOpts.headers['user-id'] = 'content-editor';
proxyReqOpts.headers['Cookie'] = PORTAL_COOKIES;
proxyReqOpts.headers['authorization'] = `Bearer ${API_AUTH_TOKEN}`;
proxyReqOpts.headers['x-authenticated-user-token'] = USER_TOKEN;
return proxyReqOpts;
}
}));
Expand Down
6 changes: 3 additions & 3 deletions src/app/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ export const questionSetEditorConfig = {
fullName: 'Test User',
firstName: 'Test',
lastName: 'User',
orgIds: ['01309282781705830427']
orgIds: ['0138325860604395527']
},
identifier: 'do_113856505592119296113', //do_1138559490270085121125
identifier: 'do_113867262426406912171', //do_113866448761913344127
authToken: ' ',
sid: 'iYO2K6dOSdA0rwq7NeT1TDzS-dbqduvV',
did: '7e85b4967aebd6704ba1f604f20056b6',
uid: 'bf020396-0d7b-436f-ae9f-869c6780fc45',
channel: '01309282781705830427',
channel: '0138325860604395527',
pdata: {
id: 'dev.dock.portal',
ver: '2.8.0',
Expand Down
2 changes: 1 addition & 1 deletion web-component/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@project-sunbird/sunbird-questionset-editor-web-component",
"version": "2.1.0-beta.4",
"version": "2.1.0-beta.6",
"description": "The web component package for the sunbird questionset editor",
"main": "sunbird-questionset-editor.js",
"scripts": {
Expand Down

0 comments on commit 290d165

Please sign in to comment.