Merge branch 'dev' of bitbucket.org:venbainformationtechnology/projectb into dev
This commit is contained in:
commit
66cf6b37bf
1323
addform.html
1323
addform.html
File diff suppressed because it is too large
Load Diff
35
html2json.js
35
html2json.js
@ -17,8 +17,8 @@ function html2json() {
|
|||||||
questionSubTitle = document.getElementById('textQuestionSubtitle_' + element_id).querySelector('.ql-editor').innerHTML;
|
questionSubTitle = document.getElementById('textQuestionSubtitle_' + element_id).querySelector('.ql-editor').innerHTML;
|
||||||
}
|
}
|
||||||
var questionType = document.getElementById('question_type_' + element_id).value;
|
var questionType = document.getElementById('question_type_' + element_id).value;
|
||||||
// console.log(questionType);
|
// var questionSubType = document.getElementById('longAnswer_' + element_id).checked;
|
||||||
var questionSubType = document.getElementById('longAnswer_' + element_id).checked;
|
var questionSubType = 'false';
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"question": questionTitle,
|
"question": questionTitle,
|
||||||
@ -56,8 +56,9 @@ function html2json() {
|
|||||||
//get choice group
|
//get choice group
|
||||||
|
|
||||||
//get default choice details
|
//get default choice details
|
||||||
|
var default_choice_math_Enabled = document.getElementById('Choicemath_' + element_id).checked;
|
||||||
var choice_name = "";
|
var choice_name = "";
|
||||||
if(isMathEnabled == true)
|
if(default_choice_math_Enabled == true)
|
||||||
{
|
{
|
||||||
choice_name = document.getElementById('choiceTextField_math_' + element_id).value;
|
choice_name = document.getElementById('choiceTextField_math_' + element_id).value;
|
||||||
}
|
}
|
||||||
@ -65,47 +66,45 @@ function html2json() {
|
|||||||
{
|
{
|
||||||
choice_name = document.getElementById('choiceTextField_' + element_id).querySelector('.ql-editor').innerHTML;
|
choice_name = document.getElementById('choiceTextField_' + element_id).querySelector('.ql-editor').innerHTML;
|
||||||
}
|
}
|
||||||
var choice_description = document.getElementById('commentField_' + element_id).value;
|
|
||||||
var choice_group_fixed_uuid = document.getElementById('Choice_Group_Fixed_UUID_ID_' + element_id).value;
|
var choice_group_fixed_uuid = document.getElementById('Choice_Group_Fixed_UUID_ID_' + element_id).value;
|
||||||
// var choice_image = document.getElementById('imageInput_' + element_id).value;
|
|
||||||
answers.push({
|
answers.push({
|
||||||
"choice_name": choice_name,
|
"choice_name": choice_name,
|
||||||
"choice_description": choice_description,
|
"is_math_enabled": default_choice_math_Enabled,
|
||||||
"choice_uuid": choice_group_fixed_uuid,
|
"choice_uuid": choice_group_fixed_uuid,
|
||||||
|
"no": 'a'
|
||||||
});
|
});
|
||||||
|
|
||||||
// console.log('before group');
|
// console.log('before group');
|
||||||
//get dynamically added choice detailscolor: #999;
|
//get dynamically added choice detailscolor: #999;
|
||||||
|
const alphabets = ['b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
|
||||||
var $newlyAddedChoices = $('#addChoiceArea_' + element_id);
|
var $newlyAddedChoices = $('#addChoiceArea_' + element_id);
|
||||||
$newlyAddedChoices.children().each(function(index, element) {
|
$newlyAddedChoices.children().each(function(index, element) {
|
||||||
|
|
||||||
|
var letter = alphabets[index]; //for choice field key[no] value
|
||||||
|
|
||||||
var groupChoiceId = ((element.id).split('_').slice(-1)[0]).split('.').slice(0)[0];
|
var groupChoiceId = ((element.id).split('_').slice(-1)[0]).split('.').slice(0)[0];
|
||||||
var individualChoiceId = (element.id).split('.').slice(-1)[0];
|
var individualChoiceId = (element.id).split('.').slice(-1)[0];
|
||||||
// console.log('newChoiceTextField_'+groupChoiceId+'.'+individualChoiceId);
|
console.log('newChoiceTextField_'+groupChoiceId+'.'+individualChoiceId);
|
||||||
|
|
||||||
|
var choice_math_Enabled = document.getElementById('choice_math_' + groupChoiceId + '.' + individualChoiceId).checked;
|
||||||
var choice_name = "";
|
var choice_name = "";
|
||||||
if(isMathEnabled == true)
|
if(choice_math_Enabled == true)
|
||||||
{
|
{
|
||||||
choice_name = document.getElementById('newchoiceTextField_math_' + groupChoiceId + '.' + individualChoiceId).value;
|
choice_name = document.getElementById('newchoiceTextField_math_' + groupChoiceId + '.' + individualChoiceId).value;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
choice_name = document.getElementById('newChoiceTextField_' + groupChoiceId + '.' + individualChoiceId).querySelector('.ql-editor').innerHTML;
|
choice_name = document.getElementById('newChoiceTextField_' + groupChoiceId + '.' + individualChoiceId).querySelector('.ql-editor').innerHTML;
|
||||||
// console.log('choice_name');
|
|
||||||
// console.log(choice_name)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// console.log('choice_description id in the html to json script');
|
// console.log('choice_description id in the html to json script');
|
||||||
var id = document.getElementById('newChoiceCommentField_' + groupChoiceId + '.' + individualChoiceId);
|
var id = document.getElementById('newChoiceCommentField_' + groupChoiceId + '.' + individualChoiceId);
|
||||||
// console.log(id);
|
|
||||||
var choice_description = document.getElementById('newChoiceCommentField_' + groupChoiceId + '.' + individualChoiceId).value;
|
|
||||||
var choice_group_dynamic_uuid = document.getElementById('Choice_Group_Dynamic_UUID_ID_' + groupChoiceId + '.' + individualChoiceId).value;
|
var choice_group_dynamic_uuid = document.getElementById('Choice_Group_Dynamic_UUID_ID_' + groupChoiceId + '.' + individualChoiceId).value;
|
||||||
|
|
||||||
// var choice_image = document.getElementById('newChoiceImageInput_' + groupChoiceId + '.' + individualChoiceId).value;
|
|
||||||
|
|
||||||
answers.push({
|
answers.push({
|
||||||
"choice_name": choice_name,
|
"choice_name": choice_name,
|
||||||
"choice_description": choice_description,
|
"is_math_enabled": choice_math_Enabled,
|
||||||
"choice_uuid": choice_group_dynamic_uuid,
|
"choice_uuid": choice_group_dynamic_uuid,
|
||||||
|
"no":letter
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -277,6 +276,6 @@ function html2json() {
|
|||||||
// console.log((formData));
|
// console.log((formData));
|
||||||
// console.log(JSON.stringify(formData, null, 1));
|
// console.log(JSON.stringify(formData, null, 1));
|
||||||
localStorage.setItem("json", JSON.stringify((formData)));
|
localStorage.setItem("json", JSON.stringify((formData)));
|
||||||
// console.log(JSON.stringify(formData));
|
console.log(JSON.stringify(formData));
|
||||||
// console.log(OBJtoXML(({'question_paper' : formData})));
|
// console.log(OBJtoXML(({'question_paper' : formData})));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -157,7 +157,7 @@ function json2nav() {
|
|||||||
localStorage.setItem("JSON_FOR_NAV", JSON.stringify((formData)));
|
localStorage.setItem("JSON_FOR_NAV", JSON.stringify((formData)));
|
||||||
// console.log('JSON_FOR_NAV');
|
// console.log('JSON_FOR_NAV');
|
||||||
// console.log('*********************************************************************************');
|
// console.log('*********************************************************************************');
|
||||||
console.log(JSON.stringify(formData));
|
// console.log(JSON.stringify(formData));
|
||||||
// console.log('*********************************************************************************');
|
// console.log('*********************************************************************************');
|
||||||
|
|
||||||
// console.log(OBJtoXML(({'question_paper' : formData})));
|
// console.log(OBJtoXML(({'question_paper' : formData})));
|
||||||
|
|||||||
140
json2html.js
140
json2html.js
@ -1,6 +1,6 @@
|
|||||||
function jsonToHtml(jsonData) {
|
function jsonToHtml(jsonData) {
|
||||||
|
|
||||||
console.log(jsonData);
|
// console.log(jsonData);
|
||||||
|
|
||||||
if(jsonData == "" || jsonData == null)
|
if(jsonData == "" || jsonData == null)
|
||||||
{
|
{
|
||||||
@ -46,6 +46,8 @@ function jsonToHtml(jsonData) {
|
|||||||
jsonData.sections.forEach(function(section, index) {
|
jsonData.sections.forEach(function(section, index) {
|
||||||
|
|
||||||
const random_no = Date.now();
|
const random_no = Date.now();
|
||||||
|
var questionAreaId = 'question_area_'+random_no; //Add section to this id of the question paper
|
||||||
|
|
||||||
var sectionTitle = section.section_title;
|
var sectionTitle = section.section_title;
|
||||||
var sectionDescription = section.section_description;
|
var sectionDescription = section.section_description;
|
||||||
var sectionMarks = section.section_marks;
|
var sectionMarks = section.section_marks;
|
||||||
@ -53,12 +55,34 @@ function jsonToHtml(jsonData) {
|
|||||||
var sectionDispalyMarks = section.section_display_marks;
|
var sectionDispalyMarks = section.section_display_marks;
|
||||||
var sectionAttemptAny = section.section_attempt_any;
|
var sectionAttemptAny = section.section_attempt_any;
|
||||||
|
|
||||||
|
|
||||||
|
var SectionObj = {
|
||||||
|
'random_no' :random_no,
|
||||||
|
'sectionTitle' :section.section_title,
|
||||||
|
'sectionDescription' :section.section_description,
|
||||||
|
'sectionMarks' :section.section_marks,
|
||||||
|
'sectionUUID' :section.attributes.Id,
|
||||||
|
'sectionDispalyMarks':section.section_display_marks,
|
||||||
|
'sectionAttemptAny' :section.section_attempt_any,
|
||||||
|
}
|
||||||
|
|
||||||
|
// addSection(SectionObj); //call the addSection() function and send the sectionObject to that function
|
||||||
addSection(sectionTitle, sectionDescription, random_no, sectionUUID, sectionMarks, sectionDispalyMarks, sectionAttemptAny);
|
addSection(sectionTitle, sectionDescription, random_no, sectionUUID, sectionMarks, sectionDispalyMarks, sectionAttemptAny);
|
||||||
|
|
||||||
section.questions.forEach(function(Question, index) {
|
section.questions.forEach(function(Question, index) {
|
||||||
|
|
||||||
const questionRandomNo = Date.now();
|
const questionRandomNo = Date.now();
|
||||||
|
QuestionsForEach(Question, questionAreaId, questionRandomNo)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function QuestionsForEach(Question, questionAreaId, questionRandomNo){
|
||||||
|
|
||||||
var questionTypeFormets = "";
|
var questionTypeFormets = "";
|
||||||
if(Question.question_type)
|
if(Question.question_type)
|
||||||
{
|
{
|
||||||
@ -68,36 +92,50 @@ function jsonToHtml(jsonData) {
|
|||||||
{
|
{
|
||||||
questionTypeFormets ='question_group';
|
questionTypeFormets ='question_group';
|
||||||
}
|
}
|
||||||
var questionTitle = Question.question;
|
var questionTitle = Question.question;
|
||||||
var questionDescription = Question.question_description;
|
var questionDescription = Question.question_description;
|
||||||
var questionType = questionTypeFormets;
|
var questionType = questionTypeFormets;
|
||||||
var questionSubType = Question.question_sub_type;
|
var questionSubType = Question.question_sub_type;
|
||||||
var mathEnabled = Question.is_math_enabled;
|
var mathEnabled = Question.is_math_enabled;
|
||||||
var questionMarks = Question.marks;
|
var questionMarks = Question.marks;
|
||||||
var questionUUID = Question.attributes.Id;
|
var questionUUID = Question.attributes.Id;
|
||||||
var questionDisplayMarks = Question.display_marks;
|
var questionDisplayMarks = Question.display_marks;
|
||||||
var Choice = Question.answers;
|
var Choice = Question.answers;
|
||||||
|
|
||||||
var questionAreaId = 'question_area_'+random_no;
|
|
||||||
|
var QuestionObj = {
|
||||||
|
"question_area_id" :questionAreaId,
|
||||||
|
'questionRandomNo' :questionRandomNo,
|
||||||
|
|
||||||
|
'questionTitle' :Question.question,
|
||||||
|
'questionDescription' :Question.question_description,
|
||||||
|
'questionType' :questionTypeFormets,
|
||||||
|
'questionSubType' :Question.question_sub_type,
|
||||||
|
'mathEnabled' :Question.is_math_enabled,
|
||||||
|
'questionMarks' :Question.marks,
|
||||||
|
'questionUUID' :Question.attributes.Id,
|
||||||
|
'questionDisplayMarks' :Question.display_marks,
|
||||||
|
'Choice' :Question.answers,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if(questionType == 'text')
|
if(questionType == 'text')
|
||||||
{
|
{
|
||||||
textQuestion(false, false, false, questionTitle, questionDescription, questionSubType, mathEnabled, questionAreaId, false, questionRandomNo, false, questionMarks, questionUUID, false, false, questionDisplayMarks, false);
|
textQuestion(QuestionObj)
|
||||||
|
// textQuestion(false, false, false, questionTitle, questionDescription, questionSubType, mathEnabled, questionAreaId, questionRandomNo, questionMarks, questionUUID, questionDisplayMarks);
|
||||||
}
|
}
|
||||||
else if (questionType == 'group')
|
else if (questionType == 'group')
|
||||||
{
|
{
|
||||||
// groupQuestion(false, false, false, questionTitle, questionDescription, questionSubType, mathEnabled, Choice, questionAreaId, false, questionRandomNo, false, questionMarks, questionUUID, false, false, questionDisplayMarks, false);
|
groupQuestion(false, false, false, questionTitle, questionDescription, questionType, questionSubType, mathEnabled, Choice, questionAreaId, questionRandomNo, questionMarks, questionUUID, questionDisplayMarks,);
|
||||||
groupQuestion(false, false, false, questionTitle, questionDescription, questionType, questionSubType, mathEnabled, Choice, false, questionAreaId, questionRandomNo, false, questionMarks, questionUUID, false, false, questionDisplayMarks, false);
|
// groupQuestion(QuestionObj);
|
||||||
|
|
||||||
|
|
||||||
Choice = Choice.slice(1);
|
Choice = Choice.slice(1);
|
||||||
Choice.forEach(function(choicenames, index) {
|
Choice.forEach(function(choicenames, index) {
|
||||||
var choiceName = choicenames.choice_name;
|
var choiceName = choicenames.choice_name;
|
||||||
var choiceDescription = choicenames.choice_description;
|
|
||||||
var choiceID = choicenames.id;
|
var choiceID = choicenames.id;
|
||||||
|
var choice_mathEnabled = choicenames.is_math_enabled;
|
||||||
|
|
||||||
addNewChoice(false , choiceName, choiceDescription, questionRandomNo, false, choiceID, mathEnabled);
|
addNewChoice(false , choiceName, questionRandomNo, choiceID, choice_mathEnabled);
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -108,76 +146,20 @@ function jsonToHtml(jsonData) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//function for Generate QuestionGroup
|
||||||
function generateGroupQuestion(Question, questionAreaId, questionRandomNo)
|
function generateGroupQuestion(Question, questionAreaId, questionRandomNo)
|
||||||
{
|
{
|
||||||
|
|
||||||
var idObj = {
|
var idObj = {"section_question_area_id":questionAreaId, 'question_group_obj': Question, 'questions_randon_id':questionRandomNo};
|
||||||
"section_question_area_id":questionAreaId,
|
|
||||||
'question_group_obj': Question ,
|
|
||||||
'questions_randon_id':questionRandomNo,
|
|
||||||
};
|
|
||||||
|
|
||||||
addQuestionGroup(idObj);
|
addQuestionGroup(idObj);
|
||||||
|
|
||||||
Question.questions.forEach(function(GroupQuestions, index) {
|
Question.questions.forEach(function(GroupQuestions, index) {
|
||||||
|
|
||||||
const QuestionGroupRandomNo = Date.now();
|
const QuestionGroupRandomNo = Date.now();
|
||||||
|
var questionGroupAreaId = 'group_question_area_'+questionRandomNo;
|
||||||
console.log(GroupQuestions);
|
QuestionsForEach(GroupQuestions, questionGroupAreaId, QuestionGroupRandomNo);
|
||||||
console.log("**********************************");
|
|
||||||
|
|
||||||
// question level variables
|
|
||||||
var group_question_Title = GroupQuestions.question;
|
|
||||||
var group_question_Description = GroupQuestions.question_description;
|
|
||||||
var group_question_Type = GroupQuestions.question_type;
|
|
||||||
var group_questionSubType = GroupQuestions.question_sub_type;
|
|
||||||
var mathEnabled = GroupQuestions.is_math_enabled;
|
|
||||||
var group_question_marks = GroupQuestions.marks;
|
|
||||||
var group_question_uuid = GroupQuestions.attributes.Id;
|
|
||||||
var group_question_Display_Marks = GroupQuestions.display_marks;
|
|
||||||
|
|
||||||
//
|
|
||||||
|
|
||||||
var Choice = GroupQuestions.answers;
|
|
||||||
var questionGroupId = 'group_question_area_'+questionRandomNo;
|
|
||||||
// console.log('questionGroupId :' + questionGroupId)
|
|
||||||
|
|
||||||
if(group_question_Type == 'text')
|
|
||||||
{
|
|
||||||
// console.log('child gtext' + group_question_Title)
|
|
||||||
textQuestion(false, false, false, group_question_Title, group_question_Description, group_questionSubType, mathEnabled, false, questionGroupId, false, QuestionGroupRandomNo, false, false, group_question_marks, group_question_uuid, false, group_question_Display_Marks);
|
|
||||||
|
|
||||||
}
|
|
||||||
else if(group_question_Type == 'group')
|
|
||||||
{
|
|
||||||
// console.log('child ggroup'+group_question_Title)
|
|
||||||
// groupQuestion(false, false, false, group_question_Title, group_question_Description, mathEnabled, Choice, false, questionGroupId, false, QuestionGroupRandomNo, false, false, group_question_marks, group_question_uuid, false, group_question_Display_Marks);
|
|
||||||
groupQuestion(false, false, false, group_question_Title, group_question_Description, group_question_Type, group_questionSubType, mathEnabled, Choice, false, questionGroupId, false, QuestionGroupRandomNo, false, false, group_question_marks, group_question_uuid, false, group_question_Display_Marks);
|
|
||||||
|
|
||||||
|
|
||||||
Choice = Choice.slice(1);
|
|
||||||
Choice.forEach(function(choicenames, index) {
|
|
||||||
var choiceName = choicenames.choice_name;
|
|
||||||
var choiceDescription = choicenames.choice_description;
|
|
||||||
var choiceID = choicenames.id;
|
|
||||||
|
|
||||||
addNewChoice(false , choiceName, choiceDescription, false, QuestionGroupRandomNo, choiceID, mathEnabled)
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
generateGroupQuestion(GroupQuestions, questionGroupId, QuestionGroupRandomNo);
|
|
||||||
// console.log('child group question'+group_question_Title)
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -78,8 +78,10 @@ function json2xml() {
|
|||||||
for (choice in question['answers']) {
|
for (choice in question['answers']) {
|
||||||
var choiceElement = createElementWithText(doc, choicesElement, 'Choice', '', {});
|
var choiceElement = createElementWithText(doc, choicesElement, 'Choice', '', {});
|
||||||
var id = createElementWithText(doc, choiceElement, 'Id', question['answers'][choice]['choice_uuid'], {});
|
var id = createElementWithText(doc, choiceElement, 'Id', question['answers'][choice]['choice_uuid'], {});
|
||||||
var no = createElementWithText(doc, choiceElement, 'No', question['answers'][choice]['choice_name'], {});
|
var no = createElementWithText(doc, choiceElement, 'No', question['answers'][choice]['no'], {});
|
||||||
var text = createElementWithText(doc, choiceElement, 'Text', question['answers'][choice]['choice_description'], {});
|
var text = createElementWithText(doc, choiceElement, 'Text', question['answers'][choice]['choice_name'], {});
|
||||||
|
var is_math_enabled = createElementWithText(doc, choiceElement, 'Math', (question['answers'][choice]['is_math_enabled'] === true ? 'true' : 'false'), {});
|
||||||
|
|
||||||
}
|
}
|
||||||
// choicesElement.appendChild();
|
// choicesElement.appendChild();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -111,7 +111,7 @@ function generateSingleQuestions(ParentObjects)
|
|||||||
var QuestionId = question_Id.split("_")[1];
|
var QuestionId = question_Id.split("_")[1];
|
||||||
QuestionMarkField = document.getElementById('Text_Question_Marks_Id_'+ QuestionId);
|
QuestionMarkField = document.getElementById('Text_Question_Marks_Id_'+ QuestionId);
|
||||||
onlyQuestionMarks = questionMarks !== undefined && questionMarks !== "" ? questionMarks : 0;
|
onlyQuestionMarks = questionMarks !== undefined && questionMarks !== "" ? questionMarks : 0;
|
||||||
var questionMarksINT = parseFloat(onlyQuestionMarks);
|
var questionMarksINT = parseFloat(onlyQuestionMarks, 2);
|
||||||
childMarks = childMarks + questionMarksINT;
|
childMarks = childMarks + questionMarksINT;
|
||||||
}
|
}
|
||||||
else if(questionType == 'group')
|
else if(questionType == 'group')
|
||||||
@ -119,7 +119,7 @@ function generateSingleQuestions(ParentObjects)
|
|||||||
var QuestionId = question_Id.split("_")[1];
|
var QuestionId = question_Id.split("_")[1];
|
||||||
QuestionMarkField = document.getElementById('Choice_Question_Marks_Id_' + QuestionId);
|
QuestionMarkField = document.getElementById('Choice_Question_Marks_Id_' + QuestionId);
|
||||||
onlyQuestionMarks = questionMarks !== undefined && questionMarks !== "" ? questionMarks : 0;
|
onlyQuestionMarks = questionMarks !== undefined && questionMarks !== "" ? questionMarks : 0;
|
||||||
var questionMarksINT = parseFloat(onlyQuestionMarks);
|
var questionMarksINT = parseFloat(onlyQuestionMarks, 2);
|
||||||
childMarks = childMarks + questionMarksINT;
|
childMarks = childMarks + questionMarksINT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,8 +138,8 @@ function generateSingleQuestions(ParentObjects)
|
|||||||
|
|
||||||
var returnValue = generateGroupQuestions(QuestionGroupObjects); //function for forEach QuestionGroups and Questions
|
var returnValue = generateGroupQuestions(QuestionGroupObjects); //function for forEach QuestionGroups and Questions
|
||||||
onlyQuestionMarks = returnValue !== undefined && returnValue !== "" ? returnValue : 0;
|
onlyQuestionMarks = returnValue !== undefined && returnValue !== "" ? returnValue : 0;
|
||||||
var questionGroupMarksINT = parseFloat(onlyQuestionMarks);
|
var questionGroupMarksINT = parseFloat(onlyQuestionMarks, 2);
|
||||||
childMarks = childMarks + questionGroupMarksINT;
|
childMarks = childMarks + questionGroupMarksINT;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
148
nav_pane.js
148
nav_pane.js
@ -6,6 +6,7 @@ function navpane() {
|
|||||||
let currentlyHighlightedElement = null; // Track the currently highlighted element
|
let currentlyHighlightedElement = null; // Track the currently highlighted element
|
||||||
// console.log('navpane called');
|
// console.log('navpane called');
|
||||||
var jsonData = JSON.parse(localStorage.getItem('JSON_FOR_NAV'));
|
var jsonData = JSON.parse(localStorage.getItem('JSON_FOR_NAV'));
|
||||||
|
console.log(jsonData);
|
||||||
// var arr = JSON.parse( localStorage.getItem('memoriesdata') );
|
// var arr = JSON.parse( localStorage.getItem('memoriesdata') );
|
||||||
// var jsonData2 = JSON.parse(jsonData);
|
// var jsonData2 = JSON.parse(jsonData);
|
||||||
// console.log(typeof jsonData);
|
// console.log(typeof jsonData);
|
||||||
@ -30,10 +31,16 @@ function navpane() {
|
|||||||
function createTree(data, container) {
|
function createTree(data, container) {
|
||||||
data.sections.forEach(section => {
|
data.sections.forEach(section => {
|
||||||
const sectionDiv = document.createElement('div');
|
const sectionDiv = document.createElement('div');
|
||||||
const sectionId = section.section_id;
|
const sectionId = section.section_id;;
|
||||||
sectionDiv.setAttribute('data-id', sectionId);
|
sectionDiv.setAttribute('data-id', sectionId);
|
||||||
sectionDiv.className = 'section main-heading';
|
sectionDiv.className = 'section main-heading';
|
||||||
|
|
||||||
|
var splitedSectionId = sectionId.split("_")[3];
|
||||||
|
var SectionBox_RawID = 'SectionBox_'+splitedSectionId;
|
||||||
|
var SectionBoxID = document.getElementById(SectionBox_RawID)
|
||||||
|
console.log(SectionBoxID);
|
||||||
|
|
||||||
|
|
||||||
// Check if the section should be initially expanded based on expandedSections
|
// Check if the section should be initially expanded based on expandedSections
|
||||||
if (expandedSections.includes(sectionId)) {
|
if (expandedSections.includes(sectionId)) {
|
||||||
sectionDiv.classList.remove('collapsed');
|
sectionDiv.classList.remove('collapsed');
|
||||||
@ -77,12 +84,21 @@ function navpane() {
|
|||||||
sectionArrow.classList.add('arrow-down');
|
sectionArrow.classList.add('arrow-down');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const sectionLink = document.createElement('a');
|
const sectionLink = document.createElement('a');
|
||||||
sectionLink.href = '#' + section.section_id;
|
sectionLink.href = '#' + section.section_id;
|
||||||
|
|
||||||
|
// Attach the scroll function to the hyperlinks
|
||||||
|
sectionLink.addEventListener('click', function(e) {
|
||||||
|
e.preventDefault(); // Prevent the default behavior of the link
|
||||||
|
const targetId = this.getAttribute('href').substring(1); // Get the target element's ID
|
||||||
|
scrollToElement(targetId);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
sectionLink.style.color = '#740fd6';
|
sectionLink.style.color = '#740fd6';
|
||||||
|
|
||||||
// Add a click event listener to toggle highlighting and boldness
|
//click event listener to toggle highlighting and boldness if click the Section
|
||||||
sectionLink.addEventListener('click', function () {
|
sectionLink.addEventListener('click', function () {
|
||||||
if (currentlyHighlightedElement !== null && currentlyHighlightedElement !== sectionLink) {
|
if (currentlyHighlightedElement !== null && currentlyHighlightedElement !== sectionLink) {
|
||||||
currentlyHighlightedElement.style.fontWeight = 'normal';
|
currentlyHighlightedElement.style.fontWeight = 'normal';
|
||||||
@ -95,6 +111,19 @@ function navpane() {
|
|||||||
currentlyHighlightedElement = sectionLink;
|
currentlyHighlightedElement = sectionLink;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
SectionBoxID.addEventListener('click', function() {
|
||||||
|
if (currentlyHighlightedElement !== null && currentlyHighlightedElement !== sectionLink) {
|
||||||
|
currentlyHighlightedElement.style.fontWeight = 'normal';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentlyHighlightedElement === sectionLink) {
|
||||||
|
sectionLink.style.fontWeight = sectionLink.style.fontWeight === 'bold' ? 'normal' : 'bold';
|
||||||
|
} else {
|
||||||
|
sectionLink.style.fontWeight = 'bold';
|
||||||
|
currentlyHighlightedElement = sectionLink;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if (section.section_title == null || typeof section.section_title === 'undefined') {
|
if (section.section_title == null || typeof section.section_title === 'undefined') {
|
||||||
section.section_title = "sampletitle";
|
section.section_title = "sampletitle";
|
||||||
@ -116,25 +145,83 @@ function navpane() {
|
|||||||
|
|
||||||
// nodeDiv.id = nodeData.textQuestion_Id || nodeData.choice_question_id;
|
// nodeDiv.id = nodeData.textQuestion_Id || nodeData.choice_question_id;
|
||||||
const nodeDataId = nodeData.question_Id
|
const nodeDataId = nodeData.question_Id
|
||||||
// console.log('nodeDataId:',nodeDataId);
|
const nodeDataType = nodeData.question_type
|
||||||
|
console.log('nodeDataType:',nodeDataType);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
parentNode.appendChild(nodeDiv);
|
parentNode.appendChild(nodeDiv);
|
||||||
|
|
||||||
if (nodeData.question) {
|
if (nodeData.question) {
|
||||||
const bulletPoint = document.createElement('span');
|
|
||||||
bulletPoint.style.marginRight = '10px';
|
var RawID = "";
|
||||||
bulletPoint.style.fontSize = '23px';
|
if(nodeDataType == 'text')
|
||||||
bulletPoint.style.fontWeight = 'bold';
|
{
|
||||||
bulletPoint.style.color = 'darkgray';
|
const bulletPoint = document.createElement('i');
|
||||||
bulletPoint.textContent = '\u2022';
|
bulletPoint.className = "fa fa-text-width";
|
||||||
nodeDiv.appendChild(bulletPoint);
|
bulletPoint.style.marginRight = '10px';
|
||||||
|
bulletPoint.style.fontSize = '17px';
|
||||||
|
bulletPoint.style.fontWeight = 'bold';
|
||||||
|
bulletPoint.style.color = '#00aaff';
|
||||||
|
// bulletPoint.textContent = '\u2022';
|
||||||
|
bulletPoint.setAttribute("title", "Descriptive");
|
||||||
|
nodeDiv.appendChild(bulletPoint);
|
||||||
|
|
||||||
|
var splitedId = nodeDataId.split("_")[1];
|
||||||
|
RawID = 'removeAndCloneTextQuestion_'+splitedId;
|
||||||
|
|
||||||
|
|
||||||
|
}else if(nodeDataType == 'group')
|
||||||
|
{
|
||||||
|
const bulletPoint = document.createElement('i');
|
||||||
|
bulletPoint.className = "fa fa-check-circle-o";
|
||||||
|
bulletPoint.style.marginRight = '10px';
|
||||||
|
bulletPoint.style.fontSize = '17px';
|
||||||
|
bulletPoint.style.fontWeight = 'bold';
|
||||||
|
bulletPoint.style.color = '#00aaff';
|
||||||
|
bulletPoint.setAttribute("title", "MCQ");
|
||||||
|
// bulletPoint.textContent = '\u2022';
|
||||||
|
nodeDiv.appendChild(bulletPoint);
|
||||||
|
|
||||||
|
var splitedId = nodeDataId.split("_")[1];
|
||||||
|
RawID = 'removeAndCloneQroupQuestion_'+splitedId;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
var QuestionID = document.getElementById(RawID)
|
||||||
|
console.log(QuestionID)
|
||||||
|
|
||||||
const questionLink = document.createElement('a');
|
const questionLink = document.createElement('a');
|
||||||
questionLink.href = '#' + nodeDataId;
|
questionLink.href = '#' + nodeDataId;
|
||||||
|
|
||||||
|
// Attach the scroll function to the hyperlinks
|
||||||
|
questionLink.addEventListener('click', function(e) {
|
||||||
|
e.preventDefault(); // Prevent the default behavior of the link
|
||||||
|
const targetId = this.getAttribute('href').substring(1); // Get the target element's ID
|
||||||
|
scrollToElement(targetId);
|
||||||
|
});
|
||||||
questionLink.style.color = '#740fd6';
|
questionLink.style.color = '#740fd6';
|
||||||
|
|
||||||
|
if(nodeDataType == 'text')
|
||||||
|
{
|
||||||
|
questionLink.setAttribute("title", "Descriptive");
|
||||||
|
}else if(nodeDataType == 'text'){
|
||||||
|
questionLink.setAttribute("title", "MCQ");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QuestionID.addEventListener('click', function () {
|
||||||
|
if (currentlyHighlightedElement !== null && currentlyHighlightedElement !== questionLink) {
|
||||||
|
currentlyHighlightedElement.style.fontWeight = 'normal';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentlyHighlightedElement === questionLink) {
|
||||||
|
questionLink.style.fontWeight = questionLink.style.fontWeight === 'bold' ? 'normal' : 'bold';
|
||||||
|
} else {
|
||||||
|
questionLink.style.fontWeight = 'bold';
|
||||||
|
currentlyHighlightedElement = questionLink;
|
||||||
|
}
|
||||||
|
});
|
||||||
questionLink.addEventListener('click', function () {
|
questionLink.addEventListener('click', function () {
|
||||||
if (currentlyHighlightedElement !== null && currentlyHighlightedElement !== questionLink) {
|
if (currentlyHighlightedElement !== null && currentlyHighlightedElement !== questionLink) {
|
||||||
currentlyHighlightedElement.style.fontWeight = 'normal';
|
currentlyHighlightedElement.style.fontWeight = 'normal';
|
||||||
@ -160,6 +247,14 @@ function navpane() {
|
|||||||
const groupTitleId = nodeData.question_group_id;
|
const groupTitleId = nodeData.question_group_id;
|
||||||
groupTitleDiv.setAttribute('data-id', groupTitleId);
|
groupTitleDiv.setAttribute('data-id', groupTitleId);
|
||||||
groupTitleDiv.className = 'question-group';
|
groupTitleDiv.className = 'question-group';
|
||||||
|
|
||||||
|
console.log(groupTitleId);
|
||||||
|
|
||||||
|
var splitedGroupId = groupTitleId.split("_")[3];
|
||||||
|
var SplitedGroupRawID = 'QuestionGroupButtons_'+splitedGroupId;
|
||||||
|
var GroupBoxID = document.getElementById(SplitedGroupRawID);
|
||||||
|
console.log(GroupBoxID);
|
||||||
|
|
||||||
|
|
||||||
// Check if the group should be initially expanded based on expandedSections
|
// Check if the group should be initially expanded based on expandedSections
|
||||||
if (expandedSections.includes(groupTitleId)) {
|
if (expandedSections.includes(groupTitleId)) {
|
||||||
@ -207,6 +302,13 @@ function navpane() {
|
|||||||
|
|
||||||
const groupQuestionLink = document.createElement('a');
|
const groupQuestionLink = document.createElement('a');
|
||||||
groupQuestionLink.href = '#' + groupTitleId;
|
groupQuestionLink.href = '#' + groupTitleId;
|
||||||
|
|
||||||
|
// Attach the scroll function to the hyperlinks
|
||||||
|
groupQuestionLink.addEventListener('click', function(e) {
|
||||||
|
e.preventDefault(); // Prevent the default behavior of the link
|
||||||
|
const targetId = this.getAttribute('href').substring(1); // Get the target element's ID
|
||||||
|
scrollToElement(targetId);
|
||||||
|
});
|
||||||
groupQuestionLink.style.color = '#740fd6';
|
groupQuestionLink.style.color = '#740fd6';
|
||||||
|
|
||||||
groupQuestionLink.addEventListener('click', function () {
|
groupQuestionLink.addEventListener('click', function () {
|
||||||
@ -221,6 +323,18 @@ function navpane() {
|
|||||||
currentlyHighlightedElement = groupQuestionLink;
|
currentlyHighlightedElement = groupQuestionLink;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
GroupBoxID.addEventListener('click', function () {
|
||||||
|
if (currentlyHighlightedElement !== null && currentlyHighlightedElement !== groupQuestionLink) {
|
||||||
|
currentlyHighlightedElement.style.fontWeight = 'normal';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentlyHighlightedElement === groupQuestionLink) {
|
||||||
|
groupQuestionLink.style.fontWeight = groupQuestionLink.style.fontWeight === 'bold' ? 'normal' : 'bold';
|
||||||
|
} else {
|
||||||
|
groupQuestionLink.style.fontWeight = 'bold';
|
||||||
|
currentlyHighlightedElement = groupQuestionLink;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if (nodeData.group_title.length > 20) {
|
if (nodeData.group_title.length > 20) {
|
||||||
groupQuestionLink.innerHTML = removeParagraphTags(nodeData.group_title.substring(0, 20) + '..');
|
groupQuestionLink.innerHTML = removeParagraphTags(nodeData.group_title.substring(0, 20) + '..');
|
||||||
@ -257,4 +371,12 @@ function navpane() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Function to scroll to the specified element with smooth behavior
|
||||||
|
function scrollToElement(elementId) {
|
||||||
|
const element = document.getElementById(elementId);
|
||||||
|
if (element) {
|
||||||
|
element.scrollIntoView({ behavior: "smooth", block: "center" });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
16
style.css
16
style.css
@ -3325,7 +3325,7 @@ a.main_sticky {
|
|||||||
|
|
||||||
.type1-switch{
|
.type1-switch{
|
||||||
/* margin-left: 535px; */
|
/* margin-left: 535px; */
|
||||||
text-align: right;
|
text-align: left;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
@ -3547,7 +3547,21 @@ input:disabled {
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.checkbox{
|
||||||
|
width: 14px;
|
||||||
|
height: 14px;
|
||||||
|
float: right;
|
||||||
|
margin-right: 5px;
|
||||||
|
margin-top: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.math{
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
.mathQuestions{
|
||||||
|
font-weight: 500;
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
16
xml2json.js
16
xml2json.js
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
function xml2json(xmlData) {
|
function xml2json(xmlData) {
|
||||||
// console.clear();
|
// console.clear();
|
||||||
console.log('xml to json converstion');
|
// console.log('xml to json converstion');
|
||||||
// console.log(xmlData);
|
// console.log(xmlData);
|
||||||
|
|
||||||
function getAttributesOfXMLNode(node)
|
function getAttributesOfXMLNode(node)
|
||||||
@ -32,7 +32,7 @@ function getQuestionsNodes(questionNode,type)
|
|||||||
questionObj['marks'] = (questionNode.childNodes[2].firstChild !== null ? questionNode.childNodes[2].firstChild.nodeValue : "");
|
questionObj['marks'] = (questionNode.childNodes[2].firstChild !== null ? questionNode.childNodes[2].firstChild.nodeValue : "");
|
||||||
questionObj['display_marks'] = questionNode.childNodes[3].firstChild.nodeValue;
|
questionObj['display_marks'] = questionNode.childNodes[3].firstChild.nodeValue;
|
||||||
questionObj['is_math_enabled'] = questionNode.childNodes[4].firstChild.nodeValue;
|
questionObj['is_math_enabled'] = questionNode.childNodes[4].firstChild.nodeValue;
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -54,11 +54,11 @@ function getQuestionsNodes(questionNode,type)
|
|||||||
{
|
{
|
||||||
var tempChoiceobj = {};
|
var tempChoiceobj = {};
|
||||||
tempChoiceobj['id'] = choiceList[k].childNodes[0].firstChild.nodeValue;
|
tempChoiceobj['id'] = choiceList[k].childNodes[0].firstChild.nodeValue;
|
||||||
tempChoiceobj['choice_name'] = choiceList[k].childNodes[1].firstChild.nodeValue;
|
tempChoiceobj['no'] = (choiceList[k].childNodes[1].firstChild !== null ? choiceList[k].childNodes[1].firstChild.nodeValue : "");
|
||||||
tempChoiceobj['choice_description'] = (choiceList[k].childNodes[2].firstChild !== null ? choiceList[k].childNodes[2].firstChild.nodeValue : "");
|
tempChoiceobj['choice_name'] = (choiceList[k].childNodes[2].firstChild !== null ? choiceList[k].childNodes[2].firstChild.nodeValue : "");
|
||||||
|
tempChoiceobj['is_math_enabled'] = (choiceList[k].childNodes[3].firstChild !== null ? choiceList[k].childNodes[3].firstChild.nodeValue : "");
|
||||||
// console.log(tempChoiceobj);
|
// console.log(tempChoiceobj);
|
||||||
questionObj['answers'].push(tempChoiceobj);
|
questionObj['answers'].push(tempChoiceobj);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -120,8 +120,8 @@ jsonObj['sections'] = [];
|
|||||||
|
|
||||||
|
|
||||||
sectionsList = xmlDoc.getElementsByTagName("Items")[0].childNodes;
|
sectionsList = xmlDoc.getElementsByTagName("Items")[0].childNodes;
|
||||||
console.log(sectionsList);
|
// console.log(sectionsList);
|
||||||
console.log('no of sections:'+sectionsList.length);
|
// console.log('no of sections:'+sectionsList.length);
|
||||||
|
|
||||||
for (let i = 0; i < sectionsList.length ;i++) {
|
for (let i = 0; i < sectionsList.length ;i++) {
|
||||||
|
|
||||||
@ -164,7 +164,7 @@ jsonObj['sections'] = [];
|
|||||||
}
|
}
|
||||||
|
|
||||||
var jsonData = JSON.stringify(jsonObj);
|
var jsonData = JSON.stringify(jsonObj);
|
||||||
console.log('Xml to Json Conversion ');
|
// console.log('Xml to Json Conversion ');
|
||||||
// console.log(jsonData);
|
// console.log(jsonData);
|
||||||
// console.log(jsonObj);
|
// console.log(jsonObj);
|
||||||
jsonToHtml(jsonObj);
|
jsonToHtml(jsonObj);
|
||||||
|
|||||||
@ -54,7 +54,7 @@ function getQuestionsNodes(questionNode,type)
|
|||||||
{
|
{
|
||||||
var tempChoiceobj = {};
|
var tempChoiceobj = {};
|
||||||
tempChoiceobj['id'] = choiceList[k].childNodes[0].firstChild.nodeValue;
|
tempChoiceobj['id'] = choiceList[k].childNodes[0].firstChild.nodeValue;
|
||||||
tempChoiceobj['choice_name'] = choiceList[k].childNodes[1].firstChild.nodeValue;
|
tempChoiceobj['choice_name'] = (choiceList[k].childNodes[1].firstChild !== null ? choiceList[k].childNodes[1].firstChild.nodeValue : "");
|
||||||
tempChoiceobj['choice_description'] = (choiceList[k].childNodes[2].firstChild !== null ? choiceList[k].childNodes[2].firstChild.nodeValue : "");
|
tempChoiceobj['choice_description'] = (choiceList[k].childNodes[2].firstChild !== null ? choiceList[k].childNodes[2].firstChild.nodeValue : "");
|
||||||
// console.log(tempChoiceobj);
|
// console.log(tempChoiceobj);
|
||||||
questionObj['answers'].push(tempChoiceobj);
|
questionObj['answers'].push(tempChoiceobj);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user