NAVPAN CHANGES & MATH TOGGLE FOR INDV : RV
This commit is contained in:
parent
d7396137f4
commit
c138aeca33
1295
addform.html
1295
addform.html
File diff suppressed because it is too large
Load Diff
33
html2json.js
33
html2json.js
@ -17,8 +17,8 @@ function html2json() {
|
||||
questionSubTitle = document.getElementById('textQuestionSubtitle_' + element_id).querySelector('.ql-editor').innerHTML;
|
||||
}
|
||||
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 {
|
||||
"question": questionTitle,
|
||||
@ -56,8 +56,9 @@ function html2json() {
|
||||
//get choice group
|
||||
|
||||
//get default choice details
|
||||
var default_choice_math_Enabled = document.getElementById('Choicemath_' + element_id).checked;
|
||||
var choice_name = "";
|
||||
if(isMathEnabled == true)
|
||||
if(default_choice_math_Enabled == true)
|
||||
{
|
||||
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;
|
||||
}
|
||||
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_image = document.getElementById('imageInput_' + element_id).value;
|
||||
answers.push({
|
||||
"choice_name": choice_name,
|
||||
"choice_description": choice_description,
|
||||
"is_math_enabled": default_choice_math_Enabled,
|
||||
"choice_uuid": choice_group_fixed_uuid,
|
||||
"no": 'a'
|
||||
});
|
||||
|
||||
// console.log('before group');
|
||||
//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);
|
||||
$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 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 = "";
|
||||
if(isMathEnabled == true)
|
||||
if(choice_math_Enabled == true)
|
||||
{
|
||||
choice_name = document.getElementById('newchoiceTextField_math_' + groupChoiceId + '.' + individualChoiceId).value;
|
||||
}
|
||||
else
|
||||
{
|
||||
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');
|
||||
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_image = document.getElementById('newChoiceImageInput_' + groupChoiceId + '.' + individualChoiceId).value;
|
||||
|
||||
answers.push({
|
||||
"choice_name": choice_name,
|
||||
"choice_description": choice_description,
|
||||
"is_math_enabled": choice_math_Enabled,
|
||||
"choice_uuid": choice_group_dynamic_uuid,
|
||||
"no":letter
|
||||
});
|
||||
|
||||
|
||||
@ -277,6 +276,6 @@ function html2json() {
|
||||
// console.log((formData));
|
||||
// console.log(JSON.stringify(formData, null, 1));
|
||||
localStorage.setItem("json", JSON.stringify((formData)));
|
||||
// console.log(JSON.stringify(formData));
|
||||
console.log(JSON.stringify(formData));
|
||||
// console.log(OBJtoXML(({'question_paper' : formData})));
|
||||
}
|
||||
|
||||
@ -157,7 +157,7 @@ function json2nav() {
|
||||
localStorage.setItem("JSON_FOR_NAV", JSON.stringify((formData)));
|
||||
// console.log('JSON_FOR_NAV');
|
||||
// console.log('*********************************************************************************');
|
||||
console.log(JSON.stringify(formData));
|
||||
// console.log(JSON.stringify(formData));
|
||||
// console.log('*********************************************************************************');
|
||||
|
||||
// console.log(OBJtoXML(({'question_paper' : formData})));
|
||||
|
||||
136
json2html.js
136
json2html.js
@ -1,6 +1,6 @@
|
||||
function jsonToHtml(jsonData) {
|
||||
|
||||
console.log(jsonData);
|
||||
// console.log(jsonData);
|
||||
|
||||
if(jsonData == "" || jsonData == null)
|
||||
{
|
||||
@ -46,6 +46,8 @@ function jsonToHtml(jsonData) {
|
||||
jsonData.sections.forEach(function(section, index) {
|
||||
|
||||
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 sectionDescription = section.section_description;
|
||||
var sectionMarks = section.section_marks;
|
||||
@ -54,11 +56,33 @@ function jsonToHtml(jsonData) {
|
||||
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);
|
||||
|
||||
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 = "";
|
||||
if(Question.question_type)
|
||||
{
|
||||
@ -68,36 +92,50 @@ function jsonToHtml(jsonData) {
|
||||
{
|
||||
questionTypeFormets ='question_group';
|
||||
}
|
||||
var questionTitle = Question.question;
|
||||
var questionDescription = Question.question_description;
|
||||
var questionType = questionTypeFormets;
|
||||
var questionSubType = Question.question_sub_type;
|
||||
var mathEnabled = Question.is_math_enabled;
|
||||
var questionMarks = Question.marks;
|
||||
var questionUUID = Question.attributes.Id;
|
||||
var questionTitle = Question.question;
|
||||
var questionDescription = Question.question_description;
|
||||
var questionType = questionTypeFormets;
|
||||
var questionSubType = Question.question_sub_type;
|
||||
var mathEnabled = Question.is_math_enabled;
|
||||
var questionMarks = Question.marks;
|
||||
var questionUUID = Question.attributes.Id;
|
||||
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')
|
||||
{
|
||||
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')
|
||||
{
|
||||
// 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, false, questionAreaId, questionRandomNo, false, questionMarks, questionUUID, false, false, questionDisplayMarks, false);
|
||||
|
||||
groupQuestion(false, false, false, questionTitle, questionDescription, questionType, questionSubType, mathEnabled, Choice, questionAreaId, questionRandomNo, questionMarks, questionUUID, questionDisplayMarks,);
|
||||
// groupQuestion(QuestionObj);
|
||||
|
||||
Choice = Choice.slice(1);
|
||||
Choice.forEach(function(choicenames, index) {
|
||||
var choiceName = choicenames.choice_name;
|
||||
var choiceDescription = choicenames.choice_description;
|
||||
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)
|
||||
{
|
||||
|
||||
var idObj = {
|
||||
"section_question_area_id":questionAreaId,
|
||||
'question_group_obj': Question ,
|
||||
'questions_randon_id':questionRandomNo,
|
||||
};
|
||||
var idObj = {"section_question_area_id":questionAreaId, 'question_group_obj': Question, 'questions_randon_id':questionRandomNo};
|
||||
|
||||
addQuestionGroup(idObj);
|
||||
|
||||
Question.questions.forEach(function(GroupQuestions, index) {
|
||||
|
||||
const QuestionGroupRandomNo = Date.now();
|
||||
|
||||
console.log(GroupQuestions);
|
||||
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)
|
||||
}
|
||||
|
||||
var questionGroupAreaId = 'group_question_area_'+questionRandomNo;
|
||||
QuestionsForEach(GroupQuestions, questionGroupAreaId, QuestionGroupRandomNo);
|
||||
});
|
||||
}
|
||||
|
||||
@ -78,8 +78,10 @@ function json2xml() {
|
||||
for (choice in question['answers']) {
|
||||
var choiceElement = createElementWithText(doc, choicesElement, 'Choice', '', {});
|
||||
var id = createElementWithText(doc, choiceElement, 'Id', question['answers'][choice]['choice_uuid'], {});
|
||||
var no = createElementWithText(doc, choiceElement, 'No', question['answers'][choice]['choice_name'], {});
|
||||
var text = createElementWithText(doc, choiceElement, 'Text', question['answers'][choice]['choice_description'], {});
|
||||
var no = createElementWithText(doc, choiceElement, 'No', question['answers'][choice]['no'], {});
|
||||
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();
|
||||
}
|
||||
|
||||
@ -111,7 +111,7 @@ function generateSingleQuestions(ParentObjects)
|
||||
var QuestionId = question_Id.split("_")[1];
|
||||
QuestionMarkField = document.getElementById('Text_Question_Marks_Id_'+ QuestionId);
|
||||
onlyQuestionMarks = questionMarks !== undefined && questionMarks !== "" ? questionMarks : 0;
|
||||
var questionMarksINT = parseFloat(onlyQuestionMarks);
|
||||
var questionMarksINT = parseFloat(onlyQuestionMarks, 2);
|
||||
childMarks = childMarks + questionMarksINT;
|
||||
}
|
||||
else if(questionType == 'group')
|
||||
@ -119,7 +119,7 @@ function generateSingleQuestions(ParentObjects)
|
||||
var QuestionId = question_Id.split("_")[1];
|
||||
QuestionMarkField = document.getElementById('Choice_Question_Marks_Id_' + QuestionId);
|
||||
onlyQuestionMarks = questionMarks !== undefined && questionMarks !== "" ? questionMarks : 0;
|
||||
var questionMarksINT = parseFloat(onlyQuestionMarks);
|
||||
var questionMarksINT = parseFloat(onlyQuestionMarks, 2);
|
||||
childMarks = childMarks + questionMarksINT;
|
||||
}
|
||||
|
||||
@ -138,7 +138,7 @@ function generateSingleQuestions(ParentObjects)
|
||||
|
||||
var returnValue = generateGroupQuestions(QuestionGroupObjects); //function for forEach QuestionGroups and Questions
|
||||
onlyQuestionMarks = returnValue !== undefined && returnValue !== "" ? returnValue : 0;
|
||||
var questionGroupMarksINT = parseFloat(onlyQuestionMarks);
|
||||
var questionGroupMarksINT = parseFloat(onlyQuestionMarks, 2);
|
||||
childMarks = childMarks + questionGroupMarksINT;
|
||||
}
|
||||
else
|
||||
|
||||
142
nav_pane.js
142
nav_pane.js
@ -6,6 +6,7 @@ function navpane() {
|
||||
let currentlyHighlightedElement = null; // Track the currently highlighted element
|
||||
// console.log('navpane called');
|
||||
var jsonData = JSON.parse(localStorage.getItem('JSON_FOR_NAV'));
|
||||
console.log(jsonData);
|
||||
// var arr = JSON.parse( localStorage.getItem('memoriesdata') );
|
||||
// var jsonData2 = JSON.parse(jsonData);
|
||||
// console.log(typeof jsonData);
|
||||
@ -30,10 +31,16 @@ function navpane() {
|
||||
function createTree(data, container) {
|
||||
data.sections.forEach(section => {
|
||||
const sectionDiv = document.createElement('div');
|
||||
const sectionId = section.section_id;
|
||||
const sectionId = section.section_id;;
|
||||
sectionDiv.setAttribute('data-id', sectionId);
|
||||
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
|
||||
if (expandedSections.includes(sectionId)) {
|
||||
sectionDiv.classList.remove('collapsed');
|
||||
@ -80,9 +87,18 @@ function navpane() {
|
||||
|
||||
const sectionLink = document.createElement('a');
|
||||
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';
|
||||
|
||||
// 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 () {
|
||||
if (currentlyHighlightedElement !== null && currentlyHighlightedElement !== sectionLink) {
|
||||
currentlyHighlightedElement.style.fontWeight = 'normal';
|
||||
@ -96,6 +112,19 @@ function navpane() {
|
||||
}
|
||||
});
|
||||
|
||||
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') {
|
||||
section.section_title = "sampletitle";
|
||||
}
|
||||
@ -116,25 +145,83 @@ function navpane() {
|
||||
|
||||
// nodeDiv.id = nodeData.textQuestion_Id || nodeData.choice_question_id;
|
||||
const nodeDataId = nodeData.question_Id
|
||||
// console.log('nodeDataId:',nodeDataId);
|
||||
const nodeDataType = nodeData.question_type
|
||||
console.log('nodeDataType:',nodeDataType);
|
||||
|
||||
|
||||
|
||||
parentNode.appendChild(nodeDiv);
|
||||
|
||||
if (nodeData.question) {
|
||||
const bulletPoint = document.createElement('span');
|
||||
bulletPoint.style.marginRight = '10px';
|
||||
bulletPoint.style.fontSize = '23px';
|
||||
bulletPoint.style.fontWeight = 'bold';
|
||||
bulletPoint.style.color = 'darkgray';
|
||||
bulletPoint.textContent = '\u2022';
|
||||
nodeDiv.appendChild(bulletPoint);
|
||||
|
||||
var RawID = "";
|
||||
if(nodeDataType == 'text')
|
||||
{
|
||||
const bulletPoint = document.createElement('i');
|
||||
bulletPoint.className = "fa fa-text-width";
|
||||
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');
|
||||
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';
|
||||
|
||||
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 () {
|
||||
if (currentlyHighlightedElement !== null && currentlyHighlightedElement !== questionLink) {
|
||||
currentlyHighlightedElement.style.fontWeight = 'normal';
|
||||
@ -161,6 +248,14 @@ function navpane() {
|
||||
groupTitleDiv.setAttribute('data-id', groupTitleId);
|
||||
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
|
||||
if (expandedSections.includes(groupTitleId)) {
|
||||
groupTitleDiv.classList.remove('collapsed');
|
||||
@ -207,6 +302,13 @@ function navpane() {
|
||||
|
||||
const groupQuestionLink = document.createElement('a');
|
||||
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.addEventListener('click', function () {
|
||||
@ -221,6 +323,18 @@ function navpane() {
|
||||
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) {
|
||||
groupQuestionLink.innerHTML = removeParagraphTags(nodeData.group_title.substring(0, 20) + '..');
|
||||
@ -258,3 +372,11 @@ 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" });
|
||||
}
|
||||
}
|
||||
18
style.css
18
style.css
@ -3325,7 +3325,7 @@ a.main_sticky {
|
||||
|
||||
.type1-switch{
|
||||
/* margin-left: 535px; */
|
||||
text-align: right;
|
||||
text-align: left;
|
||||
width: 100%;
|
||||
position: relative;
|
||||
}
|
||||
@ -3547,7 +3547,21 @@ input:disabled {
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
14
xml2json.js
14
xml2json.js
@ -1,7 +1,7 @@
|
||||
|
||||
function xml2json(xmlData) {
|
||||
// console.clear();
|
||||
console.log('xml to json converstion');
|
||||
// console.log('xml to json converstion');
|
||||
// console.log(xmlData);
|
||||
|
||||
function getAttributesOfXMLNode(node)
|
||||
@ -54,11 +54,11 @@ function getQuestionsNodes(questionNode,type)
|
||||
{
|
||||
var tempChoiceobj = {};
|
||||
tempChoiceobj['id'] = choiceList[k].childNodes[0].firstChild.nodeValue;
|
||||
tempChoiceobj['choice_name'] = choiceList[k].childNodes[1].firstChild.nodeValue;
|
||||
tempChoiceobj['choice_description'] = (choiceList[k].childNodes[2].firstChild !== null ? choiceList[k].childNodes[2].firstChild.nodeValue : "");
|
||||
tempChoiceobj['no'] = (choiceList[k].childNodes[1].firstChild !== null ? choiceList[k].childNodes[1].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);
|
||||
questionObj['answers'].push(tempChoiceobj);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -120,8 +120,8 @@ jsonObj['sections'] = [];
|
||||
|
||||
|
||||
sectionsList = xmlDoc.getElementsByTagName("Items")[0].childNodes;
|
||||
console.log(sectionsList);
|
||||
console.log('no of sections:'+sectionsList.length);
|
||||
// console.log(sectionsList);
|
||||
// console.log('no of sections:'+sectionsList.length);
|
||||
|
||||
for (let i = 0; i < sectionsList.length ;i++) {
|
||||
|
||||
@ -164,7 +164,7 @@ jsonObj['sections'] = [];
|
||||
}
|
||||
|
||||
var jsonData = JSON.stringify(jsonObj);
|
||||
console.log('Xml to Json Conversion ');
|
||||
// console.log('Xml to Json Conversion ');
|
||||
// console.log(jsonData);
|
||||
// console.log(jsonObj);
|
||||
jsonToHtml(jsonObj);
|
||||
|
||||
@ -54,7 +54,7 @@ function getQuestionsNodes(questionNode,type)
|
||||
{
|
||||
var tempChoiceobj = {};
|
||||
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 : "");
|
||||
// console.log(tempChoiceobj);
|
||||
questionObj['answers'].push(tempChoiceobj);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user