Fork repo - https://github.com/Sunbird-inQuiry/editor

1git clone git@github.com:rajnishdargan/editor.git 2cd editor 3git remote add upstream git@github.com:Sunbird-inQuiry/editor.git 4git remote -v 5git fetch upstream 6git checkout -b release-8.0.0 upstream/release-8.0.0 7git fetch upstream 8git merge upstream/release-8.0.0

You got the latest code of release-8.0.0 by following above steps

Check node version

1node -v

Use node 18.19.1 or latest of 18

Install dependencies

1npm i // root folder


Open three terminals

Terminal1 (Build the library)

1ng build questionset-editor-library --watch=true

Terminal2 (Run Demo app) - Once the terminal 1 execution complete then run the terminal2

1npm run start

Terminal3

1node server.js

or

1nodemon server.js


Set the Base URL and API Key in .env file

If .env file is not present create a .env file and add the API key and Base Url as

1BASE_URL="dev.sunbirded.org" 2AUTH_API_TOKEN="--Replace with Actual API Key--" 3USER_API_TOKEN=""; // not needed

Change the questionset identifier in data.ts file to launch diffrent questionset.

https://github.com/Sunbird-inQuiry/editor/blob/release-8.0.0/src/app/data.ts#L12

Go to http://localhost:4200/

It will launch the Demo app

To launch Practise Questionset click on Quetsion Set Editor

Note - The type of Primary category or the editor get stored in localstorage to Launch the editor as per another Primary category config clear the localstore manually then Click on The flow as per need.

Questionset Editor (inQuiry default flow used in ED)

Question Editor ( Samagra use case VDN - change the config in data.ts file and Base_URL + API_KEY in .env file)

Survey , Observation, Rubrics (Sikhalokam Flow - VDN Dev)

Once you click on Question Set Editor it will launch the editor locally

For any proxy related changes make necessary changes in proxy.config.json and server.js file.


After all the Testing Related to Editor is completed build the web component and change the package version

1npm run build-web-component

Change the version in editor/projects/questionset-editor-library/package.json for angular library.

Change the version in editor/web-component/package.json for web component.


Dev Debug Help

Mock API’s by modifying server.js (note this require code changes and you need to be careful while pushing the changes in PR)

Update the server.js file as per the need of proxing the API’s locally

Here is one of the sample that can be used

1var express = require('express'), 2 http = require('http'); 3 bodyParser = require('body-parser'), 4 proxy = require('express-http-proxy'), 5 urlHelper = require('url'); 6const latexService = require('./latexService.js') 7const dotenv = require('dotenv'); 8dotenv.config(); 9 10const fwReadResponse = require('./mock-apis/frameworkRead.js') 11const channelResponse = require('./mock-apis/channelRead.js') 12 13const BASE_URL = process.env.BASE_URL || "dev.sunbirded.org"; 14const API_AUTH_TOKEN = process.env.AUTH_API_TOKEN; 15const USER_TOKEN = process.env.USER_API_TOKEN; 16const PORTAL_COOKIES= "" 17 18const ASSET = { 19 "CREATE": "/action/asset/v1/create", 20 "CONTENT_UPLOAD_URL": "/action/content/v3/upload/url/*", 21 "ASSET_UPLOAD": "/action/asset/v1/upload/*" 22} 23 24var app = express(); 25app.set('port', 3000); 26app.use(express.json()) 27app.get("/latex/convert", latexService.convert) 28app.post("/latex/convert", bodyParser.json({ limit: '1mb' }), latexService.convert); 29app.use(express.static(__dirname + '/web-component-examples/vanilla-js')); 30 31const decoratePublicRequestHeaders2 = function () { 32 return function (proxyReqOpts, srcReq) { 33 proxyReqOpts.headers['authorization'] = `Bearer ${API_AUTH_TOKEN}`; 34 proxyReqOpts.headers['x-authenticated-user-token'] = USER_TOKEN; 35 return proxyReqOpts; 36 } 37}; 38 39 40var publicRequestHeaders = { 41 "authorization": `Bearer ${API_AUTH_TOKEN}`, 42 "x-channel-id": "0137541424673095687" 43}; 44 45var contentTypeHeaders = { 46 'content-type': "application/json" 47} 48 49const customDecorateReqHeaders = function () { 50 return function (proxyReqOpts, srcReq) { 51 proxyReqOpts.headers = Object.assign({}, proxyReqOpts.headers, publicRequestHeaders); 52 return proxyReqOpts; 53 } 54} 55 56const decoratePublicRequestHeaders = function () { 57 return function (proxyReqOpts, srcReq) { 58 proxyReqOpts.headers = Object.assign({}, proxyReqOpts.headers, publicRequestHeaders, contentTypeHeaders); 59 return proxyReqOpts; 60 } 61} 62 63app.get('/api/framework/v1/read/*', function (req, res) { 64 res.send(fwReadResponse.frameworkRead); 65}) 66 67app.get('/api/channel/v1/read/*', function (req, res) { 68 res.send(channelResponse.channelRead); 69}) 70 71app.all(['/api/question/v2/list'], proxy(BASE_URL, { 72 https: true, 73 limit: '30mb', 74 proxyReqPathResolver: function (req) { 75 let originalUrl = req.originalUrl.replace('/api/', '/learner/') 76 console.log('proxyReqPathResolver questionset', originalUrl, require('url').parse(originalUrl).path); 77 return require('url').parse(originalUrl).path; 78 }, 79 proxyReqOptDecorator: decoratePublicRequestHeaders() 80})); 81 82app.use(['/action/questionset/v2/*', 83 '/action/question/v2/*', 84 '/action/collection/v1/*', 85 '/action/object/category/definition/v1/*', 86 '/action/collection/v1/*' 87 ], proxy(BASE_URL, { 88 https: true, 89 limit: '30mb', 90 proxyReqPathResolver: function (req) { 91 let originalUrl = req.originalUrl.replace('/action/', '/api/') 92 console.log('proxyReqPathResolver questionset', originalUrl, require('url').parse(originalUrl).path); 93 return require('url').parse(originalUrl).path; 94 }, 95 proxyReqOptDecorator: decoratePublicRequestHeaders() 96})); 97 98app.use(['/action/composite/v3/search', 99 ], proxy(BASE_URL, { 100 https: true, 101 limit: '30mb', 102 proxyReqPathResolver: function (req) { 103 let originalUrl = req.originalUrl.replace('/action/composite/v3/', '/api/composite/v1/') 104 console.log('proxyReqPathResolver questionset', originalUrl, require('url').parse(originalUrl).path); 105 return require('url').parse(originalUrl).path; 106 }, 107 proxyReqOptDecorator: decoratePublicRequestHeaders() 108})); 109 110app.use(['/action/program/v1/*', 111 '/action/question/v2/bulkUpload', 112 '/action/question/v2/bulkUploadStatus', 113 '/action/asset/v1' 114 ], proxy(BASE_URL, { 115 https: true, 116 limit: '30mb', 117 proxyReqPathResolver: function (req) { 118 let originalUrl = req.originalUrl.replace('/action/', '/api/') 119 console.log('proxyReqPathResolver questionset', originalUrl, require('url').parse(originalUrl).path); 120 return require('url').parse(originalUrl).path; 121 }, 122 proxyReqOptDecorator: decoratePublicRequestHeaders() 123})); 124 125app.use(['/action', '/assets'], proxy(BASE_URL, { 126 https: true, 127 limit: '30mb', 128 proxyReqPathResolver: function(req) { 129 console.log('proxyReqPathResolver ', urlHelper.parse(req.url).path); 130 return urlHelper.parse(req.url).path; 131 }, 132 proxyReqOptDecorator: decoratePublicRequestHeaders() 133})); 134 135app.use(['/assets/public/*'], proxy(BASE_URL, { 136 https: true, 137 proxyReqPathResolver: function(req) { 138 return require('url').parse(`https://${BASE_URL}` + req.originalUrl).path 139 } 140})); 141 142http.createServer(app).listen(app.get('port'), 3000);

Unzip mock-api folder in root folder

run the node server.js again after making any changes in server.js