Skip to content

Commit

Permalink
exam validation changes integrated
Browse files Browse the repository at this point in the history
  • Loading branch information
pavankumar0408 committed Aug 8, 2023
1 parent b35d2a7 commit c1a0f11
Show file tree
Hide file tree
Showing 17 changed files with 23,115 additions and 324 deletions.
22,910 changes: 22,761 additions & 149 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"e2e": "ng e2e",
"build-lib": "ng build questionset-editor-library && node assets-copy.js",
"build-lib:prod": " ng build questionset-editor-library --configuration production && node assets-copy.js",
"test-coverage": "ng test questionset-editor-library --code-coverage=true --watch=false --browsers=ChromeHeadless",
"test-coverage": "ng test questionset-editor-library --code-coverage=true",
"build-web-component": "npm run build-lib:prod && ng build questionset-editor-library-wc --output-hashing none && node ./build-wc.js"
},
"private": true,
Expand All @@ -31,8 +31,8 @@
"@project-sunbird/client-services": "5.0.0",
"@project-sunbird/common-form-elements-full": "^6.0.3",
"@project-sunbird/sb-styles": "0.0.9",
"@project-sunbird/sunbird-quml-player-web-component": "2.1.0-beta.0",
"@project-sunbird/sunbird-resource-library": "6.1.0-beta.0",
"@project-sunbird/sunbird-quml-player-web-component": "file:../../Sunbird-inQuiry-player/player/project-sunbird-sunbird-quml-player-web-component-2.1.0-beta.0.tgz",
"@project-sunbird/sunbird-resource-library": "file:../../Sunbird-inQuiry-resource-library/sunbird-resource-library/project-sunbird-sunbird-resource-library-6.1.0-beta.0.tgz",
"@project-sunbird/telemetry-sdk": "0.0.29",
"@types/jquery": "^3.5.5",
"alphanum-sort": "^1.0.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,11 +335,7 @@ export const toolbarConfig_question = {
done_btn_label: 'Done'
};

export const nativeElement = `<div><ul id="ft-id-1" class="ui-fancytree fancytree-container fancytree-plain fancytree-ext-glyph fancytree-ext-dnd5 fancytree-connectors" tabindex="0" role="tree" aria-multiselectable="true"><li role="treeitem" aria-expanded="false" aria-selected="false" class="fancytree-lastsib"><span class="fancytree-node fancytree-folder fancytree-has-children fancytree-lastsib fancytree-exp-cl fancytree-ico-cf" draggable="true"><span role="button" class="fancytree-expander fa fa-caret-right"></span><span role="presentation" class="fancytree-custom-icon fa fa-book"></span><span class="fancytree-title" title="SB23410q" style="width:15em;text-overflow:ellipsis;white-space:nowrap;overflow:hidden">SB23410q</span><span class="ui dropdown sb-dotted-dropdown" autoclose="itemClick" suidropdown="" tabindex="0" style="display: none;"> <span id="contextMenu" class="p-0 w-auto"><i class="icon ellipsis vertical sb-color-black"></i></span>
<span id="contextMenuDropDown" class="menu transition hidden" suidropdownmenu="" style="">
<div id="addchild" class="item">Add Child</div>
</span>
</span></span></li></ul></div>`;
export const nativeElement = `<div><ul id="ft-id-1" class="ui-fancytree fancytree-container fancytree-plain fancytree-ext-glyph fancytree-ext-dnd5 fancytree-connectors fancytree-treefocus" tabindex="0" role="tree" aria-multiselectable="true" aria-activedescendant="ui-id-2"><li role="treeitem" aria-selected="false" class="fancytree-lastsib" id="ui-id-1" aria-expanded="true"><span class="fancytree-node fancytree-expanded fancytree-folder fancytree-has-children fancytree-lastsib fancytree-exp-el fancytree-ico-ef" draggable="true"><span class="fancytree-expander fa fa-caret-down"></span><span role="presentation" class="fancytree-custom-icon fa fa-book"></span><span class="fancytree-title" title="Untitled QuestionSet" style="width:11em;text-overflow:ellipsis;white-space:nowrap;overflow:hidden">Testing6</span></span><ul role="group" style=""><li role="treeitem" aria-selected="false" class="fancytree-lastsib" id="ui-id-2"><span class="fancytree-node fancytree-active fancytree-focused fancytree-folder fancytree-lastsib fancytree-exp-nl fancytree-ico-cf" draggable="true"><span class="fancytree-expander fa "></span><span role="presentation" class="fancytree-custom-icon fa fa-folder-o"></span><span class="fancytree-title" title="Section" style="width:11em;text-overflow:ellipsis;white-space:nowrap;overflow:hidden">Section A</span></span></li></ul></li></ul></div>`;

export const getCategoryDefinitionResponse = {
id: 'api.object.category.definition.read',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ export class EditorComponent implements OnInit, OnDestroy, AfterViewInit {
const data = _.get(questionSetResponse, _.toLower(`result.${this.objectType}`));
this.collectionTreeNodes.data.instructions = data.instructions ? data.instructions : '';
this.collectionTreeNodes.data.outcomeDeclaration = data?.outcomeDeclaration;

}
}
));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,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 === 'instances') {
field.default = !_.isEmpty(metaDataFields, 'instances') ? _.get(metaDataFields, 'instances.label') : '' ;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export class OptionsComponent implements OnInit, OnChanges {
templateId: this.templateType,
name: this.questionPrimaryCategory || 'Multiple Choice Question',
responseDeclaration: this.getResponseDeclaration(editorState),
outcomeDeclaration: this.getOutcomeDeclaration(),
outcomeDeclaration: this.getOutcomeDeclaration(),
interactionTypes: ['choice'],
interactions: this.getInteractions(editorState.options),
editorState: {
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 @@ -1003,6 +1003,7 @@ 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;
this.setQuestionTypeValues(metaData);
return {
nodesModified: {
Expand Down
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 @@ -21,6 +21,10 @@
"contentPrimaryCategories": ["Course Assessment", "eTextbook", "Explanation Content", "Learning Resource", "Practice Question Set"],
"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",
"questionSet": {
"maxQuestionsLimit": "500"
},
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/v2/list",
"READ":"question/v2/read/",
"LIST":"question/v1/list",
"READ":"question/v1/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
Expand Up @@ -11,6 +11,8 @@ import { DataService } from '../data/data.service';
import { map } from 'rxjs/operators';
import { HttpClient } from '@angular/common/http';
import { ExportToCsv } from 'export-to-csv';
import 'jquery.fancytree';
declare var $: any;
interface SelectedChildren {
label?: string;
primaryCategory?: string;
Expand Down Expand Up @@ -395,11 +397,43 @@ export class EditorService {
this.data = {};
const data = this.treeService.getFirstChild();
return {
nodesModified: this.treeService.treeCache.nodesModified,
nodesModified: this.getUpdatedNodeMetaData(),
hierarchy: instance.getHierarchyObj(data)
};
}

getUpdatedNodeMetaData() {
const parentNodeId = _.findKey(this.treeService.treeCache.nodesModified,(node)=>{
return node.root;
});
const parentNode = $(this.treeService.treeNativeElement).fancytree('getRootNode').getFirstChild().data;
if(parentNode?.objectType === 'QuestionSet' && parentNode?.metadata?.primaryCategory === 'Blueprint Question Set'){
_.forEach(this.treeService.treeCache.nodesModified, (node, nodeId)=>{
if(!node.root){
const {board, medium, gradeLevel, subject, difficultyLevel, selectedQuestionType, requiredQuestionCount} = this.treeService.treeCache.nodesModified[nodeId]?.metadata;
this.treeService.treeCache.nodesModified[nodeId].metadata.criterias = [{
board:board,
medium:medium,
gradeLevel:gradeLevel,
subject:subject,
difficultyLevel:difficultyLevel,
selectedQuestionType:selectedQuestionType,
requiredQuestionCount:requiredQuestionCount,
}]
}
})
}
_.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;
}

})
this.treeService.treeCache.nodesModified[parentNodeId]?.metadata.hasOwnProperty('mode')?
delete this.treeService.treeCache.nodesModified[parentNodeId]?.metadata?.mode:''
return this.treeService.treeCache.nodesModified;
}

getHierarchyObj(data, questionId?, selectUnitId?, parentId?) {
const instance = this;
if (data && data.data) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export const treeNode = {
"medium": [
"English"
],
"mode": "server",
"createdOn": "2021-04-22T14:23:40.169+0000",
"contentDisposition": "inline",
"additionalCategories": [
Expand Down Expand Up @@ -103,4 +104,74 @@ export const treeNode = {
getLevel: ()=> {
return 2;
}
};
};

export const treeCache = {
"nodesModified": {
"do_113263678834016256111": {
"root": true,
"objectType": "QuestionSet",
"metadata": {
"name": "Testing6",
"primaryCategory": "PIAA Question Set",
"showTimer": "No",
"requiresSubmit": "No",
"copyright": "UPHRH_TEST",
"license": "CC BY 4.0",
"attributions": [],
"timeLimits": {
"questionSet": {
"max": 0,
"min": 0
}
},
"eval": {
"mode": "server"
},
"description": "desc",
"board": "General Nursing Midwifery",
"medium": [
"Sociology"
],
"gradeLevel": [
"Describes about social groups social change control stratification and social problems"
],
"subject": [
"Sociology"
],
"difficultyLevel": [
"Interprets society"
]
},
"isNew": false
},
"da0ac2f0-1ea3-464a-bc03-f62b71415837": {
"root": false,
"objectType": "QuestionSet",
"metadata": {
"mimeType": "application/vnd.sunbird.questionset",
"code": "da0ac2f0-1ea3-464a-bc03-f62b71415837",
"name": "Section A",
"visibility": "Parent",
"primaryCategory": "Practice Question Set",
"shuffle": true,
"selectedQuestionType": "",
"attributions": [],
"timeLimits": {
"questionSet": {
"max": 0,
"min": 0
}
},
"eval": {
"mode": "client"
}
},
"isNew": true
}
},
"nodes": [
"do_113263678834016256111",
"da0ac2f0-1ea3-464a-bc03-f62b71415837"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ export class TreeService {
if (this.treeCache.nodesModified[nodeId]) {
// tslint:disable-next-line:max-line-length
this.treeCache.nodesModified[nodeId].metadata = _.assign(this.treeCache.nodesModified[nodeId].metadata, _.omit(metadata, 'objectType'));
this.updateEvaluable(nodeId);
} else {
this.treeCache.nodesModified[nodeId] = {
root: activeNode && activeNode.root ? true : false,
Expand All @@ -251,6 +252,34 @@ 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].root){
this.treeCache.nodesModified[nodeId].metadata.eval = this.getFirstChild().data.primaryCategory === this.configService.editorConfig.evaluableQuestionSet?
this.configService.editorConfig.server:this.configService.editorConfig.client;
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;
}
this.updateFirstChild(this.treeCache.nodesModified[nodeId].metadata.eval)
}
}

updateFirstChild(evalMode:any) {
$(this.treeNativeElement).fancytree('getRootNode').getFirstChild().data.eval = evalMode;
}

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;
}
}

clearTreeCache(node?) {
if (node) {
delete this.treeCache.nodesModified[node.id];
Expand Down
45 changes: 41 additions & 4 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,18 @@ var express = require('express'),
urlHelper = require('url');
const latexService = require('./latexService.js')

const BASE_URL = "dev.inquiry.sunbird.org";
const API_AUTH_TOKEN = "";
const USER_TOKEN = "";
const PORTAL_COOKIES= ""

// ENV Variables

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 USER_TOKEN = "eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICI5YnBaRzhRQWF1SnZodUl2a2VqM2RVU2g3MUMzLTlvc21TdlhNeFBrbEN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yzgKZv8zPbVVc0rdR2048qMII_JJYjq5j-37Me8hHCBDx_cBasfgmIYGY_3GkCiGCKK8-ip4Q3H2l1fm4PlzZvANATxa3hIHo1XbfoOaTiAZY5H1hQTUcx1uMqnPoqEEexWs-v0IzoAiKEgsTMMvmP108WzSViw9UL45qbfkOUlJt4R0lnAM_D2m-QaQcsAAoKrXNCl8L9UN_Wj3jtV4z0tn7Gz4cjcQB9Fk6ZqNjBjFpnkCYFaGqjoiXMg";



var app = express();
app.set('port', 3000);
Expand All @@ -35,6 +43,34 @@ 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 @@ -44,6 +80,7 @@ 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 Down
2 changes: 1 addition & 1 deletion src/app/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const questionSetEditorConfig = {
lastName: 'User',
orgIds: ['01309282781705830427']
},
identifier: 'do_2138219624805253121732',
identifier: 'do_113856505592119296113', //do_1138559490270085121125
authToken: ' ',
sid: 'iYO2K6dOSdA0rwq7NeT1TDzS-dbqduvV',
did: '7e85b4967aebd6704ba1f604f20056b6',
Expand Down
Loading

0 comments on commit c1a0f11

Please sign in to comment.