CODE_MERAGE CHECK_QUESTION_GROUP : AADHAVAN
This commit is contained in:
commit
c5320749e6
632
addform.html
632
addform.html
@ -539,11 +539,16 @@
|
||||
|
||||
<!-- decrypt -->
|
||||
<script src="decode.js"></script>
|
||||
|
||||
<!-- Mark Calculation Script -->
|
||||
<!-- <script src="mark_calc.js"></script> -->
|
||||
|
||||
|
||||
<!-- nave pane -->
|
||||
<script src="nav_pane.js"></script>
|
||||
|
||||
<!-- Main.js its used to trigger auto save when system online -->
|
||||
|
||||
<script src="main.js"></script>
|
||||
|
||||
<script src="checkParent.js"></script>
|
||||
@ -858,7 +863,7 @@ function addSection(title = false, description = false, random_no = false, secti
|
||||
<div class="col-lg-4 col-md-4 hideondrag text" style="margin-left:215px;" >
|
||||
<div class="form_box">
|
||||
<div style="margin-left: 35px"> Attempt Any : </div>
|
||||
<input type="text" id="Section_Attempt_Any_Id_${sectionRandomID}" value="${sectionAttemptAny !== false ? sectionAttemptAny : 0}">
|
||||
<input type="text" id="Section_Attempt_Any_Id_${sectionRandomID}" value="${sectionAttemptAny !== false ? sectionAttemptAny : ""}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -866,7 +871,7 @@ function addSection(title = false, description = false, random_no = false, secti
|
||||
<div class="col-lg-4 col-md-4 hideondrag text">
|
||||
<div class="form_box" style="margin-top: -58px;">
|
||||
<div style="margin-left: 80px"> Marks : </div>
|
||||
<input type="text" id="Section_Marks_Id_${sectionRandomID}" value="${section_marks !== false ? section_marks : "0"}">
|
||||
<input type="text" id="Section_Marks_Id_${sectionRandomID}" value="${section_marks !== false ? section_marks : ""}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -877,20 +882,6 @@ function addSection(title = false, description = false, random_no = false, secti
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row" style="text-align:right; width: 100%">
|
||||
<div class="col-lg-10 col-md-12">
|
||||
<div class="button-group align-items-center">
|
||||
<div class="form-button addButton">
|
||||
<button type="submit" id="addNewButton_${sectionRandomID}">+Add New</button>
|
||||
<button type="submit" style="display: none;" onclick="addNewQuestions(event, 1)" id="textButton_${sectionRandomID}">Text</button>
|
||||
<button type="submit" style="display: none;" onclick="addNewQuestions(event, 2)" id="choiseButton_${sectionRandomID}">Choice</button>
|
||||
<button type="submit" style="display: none;" onclick="addSection()" id="sectionButton_${sectionRandomID}">Section</button>
|
||||
<button type="submit" style="display: none;" onclick="addNewGroupQuestions(event, 0)" id="groupQuestionButton_${sectionRandomID}">Question Group</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
var formContainer = document.getElementById('addNewSection');
|
||||
@ -1055,29 +1046,45 @@ function addSection(title = false, description = false, random_no = false, secti
|
||||
}
|
||||
|
||||
|
||||
|
||||
//mark calculation code for section
|
||||
// var Section_Attempt_Any_raw_Id = 'Section_Attempt_Any_Id_' + sectionRandomID;
|
||||
// var Section_Attempt_Any_Id = document.getElementById(Section_Attempt_Any_raw_Id)
|
||||
// var Section_Marks_raw_Id = 'Section_Marks_Id_' + sectionRandomID;
|
||||
|
||||
// var Section_Marks_raw_Id = 'Section_Marks_Id_' + sectionRandomID;
|
||||
// var Section_Marks_Id = document.getElementById(Section_Marks_raw_Id)
|
||||
|
||||
// console.log(Section_Marks_Id);
|
||||
// $('#'+Section_Marks_raw_Id).prop("disabled", true);
|
||||
|
||||
// $(Section_Attempt_Any_Id).keyup(function() {
|
||||
// var inputValue = $(this).val();
|
||||
|
||||
// if(inputValue == "")
|
||||
// {
|
||||
|
||||
// $(Section_Marks_Id).prop("disabled", true);
|
||||
// }
|
||||
// else{
|
||||
|
||||
// $(Section_Marks_Id).prop("disabled", false);
|
||||
|
||||
// }
|
||||
// $('#'+Section_Attempt_Any_raw_Id).keyup(function() {
|
||||
// var inputValue = $(this).val();
|
||||
|
||||
// if(inputValue == ""){
|
||||
// $('#'+Section_Marks_raw_Id).prop("disabled", true);
|
||||
// }else{
|
||||
// $('#'+Section_Marks_raw_Id).prop("disabled", false);
|
||||
|
||||
// }
|
||||
// json2nav();
|
||||
// });
|
||||
//end of mark calculation code for section
|
||||
|
||||
|
||||
|
||||
// function for calling html2json script using Mark Calculation
|
||||
var Section_Attempt_Any_raw_Id = 'Section_Attempt_Any_Id_' + sectionRandomID;
|
||||
var Section_Marks_raw_Id = 'Section_Marks_Id_' + sectionRandomID;
|
||||
$('#'+Section_Attempt_Any_raw_Id).keyup(function() {
|
||||
|
||||
json2nav()
|
||||
markCalculation()
|
||||
|
||||
});
|
||||
$('#'+Section_Marks_raw_Id).keyup(function() {
|
||||
|
||||
json2nav()
|
||||
markCalculation()
|
||||
|
||||
});
|
||||
|
||||
|
||||
json2nav();
|
||||
clearSidebarWrapper();
|
||||
@ -1183,7 +1190,7 @@ function addQuestionGroup(idObj)
|
||||
<div class="col-lg-4 col-md-4 hideondrag text" style="margin-left:215px;">
|
||||
<div class="form_box">
|
||||
<div style="margin-left: 35px;"> Attempt Any : </div>
|
||||
<input type="text" id="Question_Attempt_Any_Id_${QuestionGroup_ID}" value="${idObj.hasOwnProperty('question_group_obj') ? idObj.question_group_obj.group_attempt_any : 0}">
|
||||
<input type="text" id="Question_Attempt_Any_Id_${QuestionGroup_ID}" value="${idObj.hasOwnProperty('question_group_obj') ? idObj.question_group_obj.group_attempt_any : ''}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -1191,7 +1198,7 @@ function addQuestionGroup(idObj)
|
||||
<div class="col-lg-4 col-md-4 hideondrag text">
|
||||
<div class="form_box" style="margin-top: -55px;">
|
||||
<div style="margin-left: 80px;"> Marks : </div>
|
||||
<input type="text" id="Question_Group_Marks_Id_${QuestionGroup_ID}" value="${idObj.hasOwnProperty('question_group_obj') ? idObj.question_group_obj.group_marks : "0"}">
|
||||
<input type="text" id="Question_Group_Marks_Id_${QuestionGroup_ID}" value="${idObj.hasOwnProperty('question_group_obj') ? idObj.question_group_obj.group_marks : ""}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -1201,18 +1208,6 @@ function addQuestionGroup(idObj)
|
||||
<div class="">
|
||||
<div class="nested-sortable" id="group_question_area_${QuestionGroup_ID}"></div>
|
||||
</div>
|
||||
<div class="row " >
|
||||
<div class="col-lg-8 col-md-12">
|
||||
<div class="button-group align-items-center">
|
||||
<div class="form-button addButton">
|
||||
<button type="submit" id="addNewButtonSectionQroup_${QuestionGroup_ID}">Insert Question</button>
|
||||
<button type="submit" style="display: none;" onclick="addNewGroupQuestions(event, 1)" id="textButtonSectionQroup_${QuestionGroup_ID}">Text</button>
|
||||
<button type="submit" style="display: none;" onclick="addNewGroupQuestions(event, 2)" id="choiseButtonSectionQroup_${QuestionGroup_ID}">Choice</button>
|
||||
<button type="submit" style="display: none;" onclick="MultiLevelQuestionGroup(event)" id="QuestionGroupButton_${QuestionGroup_ID}">Question Group</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
@ -1265,13 +1260,7 @@ function addQuestionGroup(idObj)
|
||||
});
|
||||
|
||||
|
||||
var groupQuestion = 'draggedGroup_'+QuestionGroup_ID;
|
||||
$('#'+groupQuestion).click(function(){
|
||||
|
||||
// alert('draggedGroup_');
|
||||
|
||||
})
|
||||
|
||||
|
||||
var removeAndCloneTextQuestion_Raw = 'QuestionGroupButtons_'+QuestionGroup_ID;
|
||||
var AddButtons_Raw = 'AddButton_'+QuestionGroup_ID;
|
||||
$('#'+removeAndCloneTextQuestion_Raw).mouseenter(function(){
|
||||
@ -1285,7 +1274,7 @@ function addQuestionGroup(idObj)
|
||||
|
||||
var subSectionText = 'subSection_title_text_' + QuestionGroup_ID;
|
||||
var quill = new Quill('#'+subSectionText, {
|
||||
theme: 'snow', // Choose a theme (snow, bubble, etc.)
|
||||
theme: 'snow',
|
||||
modules: {
|
||||
toolbar: toolbarOptions
|
||||
},
|
||||
@ -1346,23 +1335,39 @@ function addQuestionGroup(idObj)
|
||||
}
|
||||
|
||||
|
||||
|
||||
var question_groupid = 'subSection_title_text_'+ QuestionGroup_ID;
|
||||
var inputElement = document.getElementById(question_groupid);
|
||||
inputElement.addEventListener("keyup", function(event) {
|
||||
|
||||
json2nav();
|
||||
clearSidebarWrapper();
|
||||
navpane();
|
||||
|
||||
});
|
||||
|
||||
json2nav();
|
||||
clearSidebarWrapper();
|
||||
navpane();
|
||||
|
||||
// start the find Parent count and Remove the Fivth Question Group list
|
||||
const value = localStorage.getItem('JSON_FOR_NAV')
|
||||
|
||||
var question_groupid = 'subSection_title_text_'+ QuestionGroup_ID;
|
||||
var inputElement = document.getElementById(question_groupid);
|
||||
inputElement.addEventListener("keyup", function(event) {
|
||||
|
||||
json2nav();
|
||||
clearSidebarWrapper();
|
||||
navpane();
|
||||
|
||||
});
|
||||
|
||||
// function for calling html2json using Mark Calculation
|
||||
var Question_Group_Marks_Field = 'Question_Group_Marks_Id_' + QuestionGroup_ID;
|
||||
var Question_Attempt_Any_Fields = 'Question_Attempt_Any_Id_'+ QuestionGroup_ID;
|
||||
$('#'+Question_Group_Marks_Field).keyup(function() {
|
||||
|
||||
json2nav()
|
||||
markCalculation()
|
||||
});
|
||||
$('#'+Question_Attempt_Any_Fields).keyup(function() {
|
||||
|
||||
json2nav()
|
||||
markCalculation()
|
||||
|
||||
});
|
||||
|
||||
json2nav();
|
||||
clearSidebarWrapper();
|
||||
navpane();
|
||||
|
||||
// start the find Parent count and Remove the Fivth Question Group list
|
||||
const value = localStorage.getItem('JSON_FOR_NAV')
|
||||
const parsedValue = JSON.parse(value);
|
||||
const questionGroupId =question_groupid;
|
||||
const classes = findParent(parsedValue, questionGroupId); //this line goto checkParent.js and give the Parent count
|
||||
@ -1392,20 +1397,41 @@ function addQuestionGroup(idObj)
|
||||
}
|
||||
|
||||
//Function for Create a New Choice Question in the Section and Question Group
|
||||
function groupQuestion( question_id = false, section_id = false , group_question_area_id = false, questionTitle = false, questionDescription = false, questionType = false, questionSubType = false, mathEnabled = false, Choice = false, random_no = false, questionGroupId = false, questionAreaId = false, questionRandomNo = false, QuestionGroupRandomNo = false, questionMarks = false, questionUUID = false, group_question_marks = false, group_question_uuid = false, questionDisplayMarks = false, group_question_Display_Marks = false)
|
||||
function groupQuestion( question_id = false, section_id = false , group_question_area_id = false, questionTitle = false, questionDescription = false, questionSubType = false, mathEnabled = false, Choice = false, questionAreaId = false, questionGroupId = false, questionRandomNo = false, QuestionGroupRandomNo = false, questionMarks = false, questionUUID = false, group_question_marks = false, group_question_uuid = false, questionDisplayMarks = false, group_question_Display_Marks = false)
|
||||
{
|
||||
|
||||
// console.log('===========================================================================================================================================')
|
||||
// console.log("group_question_area_id : "+group_question_area_id, 'questionGroupId : '+ questionGroupId, 'questionAreaId : '+questionAreaId)
|
||||
// console.log('===========================================================================================================================================')
|
||||
|
||||
|
||||
|
||||
// console.log(
|
||||
// 'question_id : '+question_id,
|
||||
// 'section_id : ' + section_id,
|
||||
// 'group_question_area_id : ' + group_question_area_id,
|
||||
// 'questionTitle : '+ questionTitle,
|
||||
// 'questionDescription : ' + questionDescription,
|
||||
// 'questionSubType : ' + questionSubType,
|
||||
// 'mathEnabled : ' + mathEnabled,
|
||||
// Choice,
|
||||
// 'questionAreaId : ' + questionAreaId,
|
||||
// 'questionGroupId : ' + questionGroupId,
|
||||
// 'questionRandomNo : ' + questionRandomNo,
|
||||
// 'QuestionGroupRandomNo : ' + QuestionGroupRandomNo,
|
||||
// 'questionMarks : ' + questionMarks,
|
||||
// 'questionUUID : ' + questionUUID,
|
||||
// 'group_question_marks : ' + group_question_marks,
|
||||
// 'group_question_uuid : ' + group_question_uuid,
|
||||
// 'questionDisplayMarks : ' + questionDisplayMarks,
|
||||
// 'group_question_Display_Marks : ' + group_question_Display_Marks)
|
||||
|
||||
const ChoiceGroupFixed_UUID = uuidv4();
|
||||
|
||||
var groupQuestion = "";
|
||||
const text_field_created_time = Date.now();// random number for dynamic ID - using current date time
|
||||
localStorage.setItem('questionsId', text_field_created_time);
|
||||
|
||||
var addChoiceAreaId = ""
|
||||
var addChoiceAreaId = "";
|
||||
if(questionRandomNo)
|
||||
{
|
||||
addChoiceAreaId = questionRandomNo;
|
||||
@ -1433,7 +1459,7 @@ function groupQuestion( question_id = false, section_id = false , group_question
|
||||
}
|
||||
else
|
||||
{
|
||||
marks = 0;
|
||||
marks = "";
|
||||
}
|
||||
|
||||
var UUID = "";
|
||||
@ -1513,14 +1539,14 @@ function groupQuestion( question_id = false, section_id = false , group_question
|
||||
<div class="col-lg-12 col-md-12">
|
||||
<div class="form_box">
|
||||
<label>Question:</label>
|
||||
<div class="richText" id="textQuestionName_${addChoiceAreaId}" contenteditable="true" style=" border: 2px solid #EEECFE; margin-top: 4px;">${questionType == 'group' ? questionTitle : ''}</div>
|
||||
<div class="richText" id="textQuestionName_${addChoiceAreaId}" contenteditable="true" style=" border: 2px solid #EEECFE; margin-top: 4px;">${questionTitle ? questionTitle : ''}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-12 col-md-12 hideondrag" style="margin-bottom: 50px">
|
||||
<div class="form_box">
|
||||
<label>Subtitle:</label>
|
||||
<div class="richText" id="textQuestionSubtitle_${addChoiceAreaId}" contenteditable="true" style=" border: 2px solid #EEECFE; margin-top: 4px;">${questionType == 'group' ? questionDescription : ''}</div>
|
||||
<div class="richText" id="textQuestionSubtitle_${addChoiceAreaId}" contenteditable="true" style=" border: 2px solid #EEECFE; margin-top: 4px;">${questionDescription ? questionDescription : ''}</div>
|
||||
<math-field id="textQuestionSubtitle_math_${addChoiceAreaId}" contenteditable="true">${mathEnabled == 'true' ? questionDescription : ''}</math-field>
|
||||
</div>
|
||||
</div>
|
||||
@ -1635,14 +1661,14 @@ function groupQuestion( question_id = false, section_id = false , group_question
|
||||
var choiceTextField = 'choiceTextField_'+addChoiceAreaId;
|
||||
var choicecommentFielddelete = 'newChoiceGroup_'+addChoiceAreaId;
|
||||
|
||||
var ChoiceMathSwitchId = document.getElementById(ChoiceMathSwitch)
|
||||
var ChoiceMathSwitchId = document.getElementById(ChoiceMathSwitch);
|
||||
var textQuestionSubtitle_mathId = document.getElementById(textQuestionSubtitle_math)
|
||||
var textQuestionSubtitleId = document.getElementById(textQuestionSubtitle)
|
||||
var choiceTextField_math_Id = document.getElementById(choiceTextField_math)
|
||||
var choiceTextFieldId = document.getElementById(choiceTextField)
|
||||
var choicecommentFielddeleteId = document.getElementById(choicecommentFielddelete)
|
||||
|
||||
|
||||
|
||||
if (mathEnabled === 'true')
|
||||
{
|
||||
|
||||
@ -1658,7 +1684,7 @@ function groupQuestion( question_id = false, section_id = false , group_question
|
||||
else
|
||||
{
|
||||
|
||||
ChoiceMathSwitchId.checked = false;
|
||||
$(ChoiceMathSwitchId).checked = false;
|
||||
$(textQuestionSubtitleId).show();
|
||||
$(textQuestionSubtitle_mathId).hide();
|
||||
$(choiceTextFieldId).show();
|
||||
@ -1667,7 +1693,7 @@ function groupQuestion( question_id = false, section_id = false , group_question
|
||||
|
||||
|
||||
|
||||
ChoiceMathSwitchId.addEventListener("change", function() {
|
||||
$(ChoiceMathSwitchId).change(function() {
|
||||
|
||||
if (ChoiceMathSwitchId.checked) {
|
||||
$(textQuestionSubtitle_mathId).show();
|
||||
@ -1730,19 +1756,39 @@ function groupQuestion( question_id = false, section_id = false , group_question
|
||||
var QuestionGroupAddButtons_ID = document.getElementById(QuestionGroupAddButtons_Raw)
|
||||
var removeAndCloneTextQuestion_ID = document.getElementById(removeAndCloneTextQuestion_Raw);
|
||||
|
||||
//for hide and the side button
|
||||
var questiongrouparea = "";
|
||||
if(questionAreaId !== false)
|
||||
{
|
||||
questiongrouparea = questionAreaId.split("_")[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
var questiongrouparea = 'false';
|
||||
}
|
||||
|
||||
|
||||
if(group_question_area_id !== false)
|
||||
{
|
||||
// alert('true')
|
||||
|
||||
$('#'+overallQuestionGroupAddButtons_Raw).show();
|
||||
$('#'+overallAddButtons_Raw).hide();
|
||||
|
||||
}
|
||||
else{
|
||||
|
||||
// alert('false')
|
||||
$('#'+overallQuestionGroupAddButtons_Raw).hide();
|
||||
$('#'+overallAddButtons_Raw).show();
|
||||
|
||||
if(questiongrouparea === 'group')
|
||||
{
|
||||
$('#'+overallQuestionGroupAddButtons_Raw).show();
|
||||
$('#'+overallAddButtons_Raw).hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#'+overallQuestionGroupAddButtons_Raw).hide();
|
||||
$('#'+overallAddButtons_Raw).show();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1756,7 +1802,14 @@ function groupQuestion( question_id = false, section_id = false , group_question
|
||||
}
|
||||
else
|
||||
{
|
||||
add_button_hide_and_show(AddButtons_Raw);
|
||||
if(questiongrouparea === 'group')
|
||||
{
|
||||
add_button_hide_and_show(QuestionGroupAddButtons_Raw);
|
||||
}
|
||||
else
|
||||
{
|
||||
add_button_hide_and_show(AddButtons_Raw);
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
@ -1770,101 +1823,178 @@ function groupQuestion( question_id = false, section_id = false , group_question
|
||||
var removeAndCloneTextQuestion_ID = document.getElementById(removeAndCloneTextQuestion_Raw);
|
||||
|
||||
|
||||
// $(removeAndCloneTextQuestion_ID).click(function(){
|
||||
|
||||
// // alert('choice');
|
||||
|
||||
// })
|
||||
//mark calculation in Choice Question
|
||||
|
||||
// var choiceQuestionMarkField = 'Choice_Question_Marks_Id_' + addChoiceAreaId;
|
||||
|
||||
// var sectionRandomID = localStorage.getItem('sectionId');
|
||||
// var Section_Attempt_Any_raw_Id = 'Section_Attempt_Any_Id_' + sectionRandomID;
|
||||
// var Section_Marks_raw_Id = 'Section_Marks_Id_' + sectionRandomID;
|
||||
|
||||
// var InMarkValue = $('#'+Section_Marks_raw_Id).val();
|
||||
// // alert(InMarkValue);
|
||||
|
||||
// var QuestionGroup_ID = localStorage.getItem('QuestionGroupId');
|
||||
// var Question_Attempt_Any_Fields = 'Question_Attempt_Any_Id_' + QuestionGroup_ID;
|
||||
|
||||
|
||||
var typetwoQuestionName = 'textQuestionName_' + addChoiceAreaId;
|
||||
|
||||
var quill = new Quill('#'+typetwoQuestionName, {
|
||||
theme: 'snow',
|
||||
modules: {
|
||||
toolbar: toolbarOptions
|
||||
},
|
||||
});
|
||||
|
||||
var typetwoQuestionSubtitle = 'textQuestionSubtitle_' + addChoiceAreaId;
|
||||
var quill = new Quill('#'+typetwoQuestionSubtitle, {
|
||||
theme: 'snow',
|
||||
modules: {
|
||||
toolbar: toolbarOptions
|
||||
},
|
||||
});
|
||||
|
||||
var choiceTextField = 'choiceTextField_' + addChoiceAreaId;
|
||||
var quill = new Quill('#'+choiceTextField, {
|
||||
theme: 'snow',
|
||||
modules: {
|
||||
toolbar: toolbarOptions2
|
||||
},
|
||||
placeholder: 'Enter Choice',
|
||||
});
|
||||
|
||||
var textQuestionName_Div = 'textQuestionName_' + addChoiceAreaId;
|
||||
var textQuestionNewRTEId = 'typeTwotextQuestionName_rtc_' + addChoiceAreaId;
|
||||
var textQuestionName_previousDiv = $('#'+textQuestionName_Div).prev();
|
||||
textQuestionName_previousDiv.attr("id", textQuestionNewRTEId);
|
||||
$('#'+textQuestionName_Div).click(function() {
|
||||
|
||||
rtc_hide_and_show(textQuestionNewRTEId);
|
||||
|
||||
});
|
||||
|
||||
|
||||
var textQuestionSubtitle_Div = 'textQuestionSubtitle_' + addChoiceAreaId;
|
||||
var textQuestionSubtitleNewRTEId = 'typeTwotextQuestionSubtitle_rtc_' + addChoiceAreaId;
|
||||
var textQuestionSubtitle_previousDiv = $('#'+textQuestionSubtitle_Div).prev();
|
||||
textQuestionSubtitle_previousDiv.attr("id", textQuestionSubtitleNewRTEId);
|
||||
$('#'+textQuestionSubtitle_Div).click(function() {
|
||||
|
||||
rtc_hide_and_show(textQuestionSubtitleNewRTEId);
|
||||
|
||||
});
|
||||
|
||||
var choiceTextField_Div = 'choiceTextField_' + addChoiceAreaId;
|
||||
var choiceTextNewRTEId = 'choiceTextField_rtc_' + addChoiceAreaId;
|
||||
var choiceTextField_previousDiv = $('#'+choiceTextField_Div).prev();
|
||||
choiceTextField_previousDiv.attr("id", choiceTextNewRTEId);
|
||||
$('#'+choiceTextField_Div).click(function() {
|
||||
|
||||
rtc_hide_and_show(choiceTextNewRTEId);
|
||||
|
||||
});
|
||||
$(textQuestionName_previousDiv).hide();
|
||||
$(textQuestionSubtitle_previousDiv).hide();
|
||||
$(choiceTextField_previousDiv).hide();
|
||||
// //these lines are work only the 'ChoiceQuestion()(groupQuestion)' function calls
|
||||
// var QGinputValue = $('#'+Section_Attempt_Any_raw_Id).val();
|
||||
|
||||
// if(QGinputValue == ""){
|
||||
// $('#'+choiceQuestionMarkField).prop("disabled", false);
|
||||
// // alert('enable');
|
||||
// }else{
|
||||
// $('#'+choiceQuestionMarkField).prop("disabled", true);
|
||||
// $('#'+choiceQuestionMarkField).val(InMarkValue);
|
||||
// // alert('disabled');
|
||||
// }
|
||||
// //end of the lines
|
||||
|
||||
|
||||
var DisplayMark_RawID = "Choice_Question_Display_Marks_Id_" + addChoiceAreaId;
|
||||
var DisplayMark_ID = document.getElementById(DisplayMark_RawID)
|
||||
|
||||
if(questionDisplayMarks === 'true'){
|
||||
// $('#'+Section_Attempt_Any_raw_Id).keyup(function() {
|
||||
// var inputValue = $(this).val();
|
||||
// if(inputValue == ""){
|
||||
// $('#'+choiceQuestionMarkField).prop("disabled", false);
|
||||
// // alert('enable');
|
||||
// }else{
|
||||
// $('#'+choiceQuestionMarkField).prop("disabled", true);
|
||||
// // alert('disabled');
|
||||
|
||||
DisplayMark_ID.checked = true;
|
||||
}else if(group_question_Display_Marks === 'true'){
|
||||
DisplayMark_ID.checked = true;
|
||||
}else{
|
||||
DisplayMark_ID.checked = false;
|
||||
}
|
||||
// }
|
||||
// json2nav();
|
||||
// });
|
||||
|
||||
// $('#'+Section_Marks_raw_Id).keyup(function() {
|
||||
// var MarksinputValue = $(this).val();
|
||||
|
||||
// if(MarksinputValue !== ""){
|
||||
// $('#'+choiceQuestionMarkField).val(MarksinputValue);
|
||||
// }else{
|
||||
// $('#'+choiceQuestionMarkField).val("");
|
||||
// }
|
||||
// });
|
||||
|
||||
|
||||
var choiceid = 'textQuestionName_'+ addChoiceAreaId;
|
||||
var inputElement = document.getElementById(choiceid);
|
||||
$(inputElement).keyup(function(event) {
|
||||
|
||||
json2nav();
|
||||
clearSidebarWrapper();
|
||||
navpane();
|
||||
// $('#'+Question_Attempt_Any_Fields).keyup(function() {
|
||||
// var inputValue = $(this).val();
|
||||
// if(inputValue == ""){
|
||||
// $('#'+choiceQuestionMarkField).prop("disabled", false);
|
||||
// // alert('enable')
|
||||
// }else{
|
||||
// $('#'+choiceQuestionMarkField).prop("disabled", true);
|
||||
// // alert('disabled');
|
||||
|
||||
});
|
||||
|
||||
json2nav();
|
||||
clearSidebarWrapper();
|
||||
navpane();
|
||||
}
|
||||
// }
|
||||
// json2nav();
|
||||
// });
|
||||
|
||||
//end of mark calculation in Choice Question
|
||||
|
||||
|
||||
|
||||
var typetwoQuestionName = 'textQuestionName_' + addChoiceAreaId;
|
||||
var quill = new Quill('#'+typetwoQuestionName, {
|
||||
theme: 'snow',
|
||||
modules: {
|
||||
toolbar: toolbarOptions
|
||||
},
|
||||
});
|
||||
|
||||
var typetwoQuestionSubtitle = 'textQuestionSubtitle_' + addChoiceAreaId;
|
||||
var quill = new Quill('#'+typetwoQuestionSubtitle, {
|
||||
theme: 'snow',
|
||||
modules: {
|
||||
toolbar: toolbarOptions
|
||||
},
|
||||
});
|
||||
|
||||
var choiceTextField = 'choiceTextField_' + addChoiceAreaId;
|
||||
var quill = new Quill('#'+choiceTextField, {
|
||||
theme: 'snow',
|
||||
modules: {
|
||||
toolbar: toolbarOptions2
|
||||
},
|
||||
placeholder: 'Enter Choice',
|
||||
});
|
||||
|
||||
|
||||
|
||||
var textQuestionName_Div = 'textQuestionName_' + addChoiceAreaId;
|
||||
var textQuestionNewRTEId = 'typeTwotextQuestionName_rtc_' + addChoiceAreaId;
|
||||
var textQuestionName_previousDiv = $('#'+textQuestionName_Div).prev();
|
||||
textQuestionName_previousDiv.attr("id", textQuestionNewRTEId);
|
||||
$('#'+textQuestionName_Div).click(function() {
|
||||
|
||||
rtc_hide_and_show(textQuestionNewRTEId);
|
||||
|
||||
});
|
||||
|
||||
|
||||
var textQuestionSubtitle_Div = 'textQuestionSubtitle_' + addChoiceAreaId;
|
||||
var textQuestionSubtitleNewRTEId = 'typeTwotextQuestionSubtitle_rtc_' + addChoiceAreaId;
|
||||
var textQuestionSubtitle_previousDiv = $('#'+textQuestionSubtitle_Div).prev();
|
||||
textQuestionSubtitle_previousDiv.attr("id", textQuestionSubtitleNewRTEId);
|
||||
$('#'+textQuestionSubtitle_Div).click(function() {
|
||||
|
||||
rtc_hide_and_show(textQuestionSubtitleNewRTEId);
|
||||
|
||||
});
|
||||
|
||||
var choiceTextField_Div = 'choiceTextField_' + addChoiceAreaId;
|
||||
var choiceTextNewRTEId = 'choiceTextField_rtc_' + addChoiceAreaId;
|
||||
var choiceTextField_previousDiv = $('#'+choiceTextField_Div).prev();
|
||||
choiceTextField_previousDiv.attr("id", choiceTextNewRTEId);
|
||||
$('#'+choiceTextField_Div).click(function() {
|
||||
|
||||
rtc_hide_and_show(choiceTextNewRTEId);
|
||||
|
||||
});
|
||||
$(textQuestionName_previousDiv).hide();
|
||||
$(textQuestionSubtitle_previousDiv).hide();
|
||||
$(choiceTextField_previousDiv).hide();
|
||||
|
||||
|
||||
var DisplayMark_RawID = "Choice_Question_Display_Marks_Id_" + addChoiceAreaId;
|
||||
var DisplayMark_ID = document.getElementById(DisplayMark_RawID)
|
||||
|
||||
if(questionDisplayMarks === 'true'){
|
||||
|
||||
DisplayMark_ID.checked = true;
|
||||
}else if(group_question_Display_Marks === 'true'){
|
||||
DisplayMark_ID.checked = true;
|
||||
}else{
|
||||
DisplayMark_ID.checked = false;
|
||||
}
|
||||
|
||||
|
||||
var choiceid = 'textQuestionName_'+ addChoiceAreaId;
|
||||
var inputElement = document.getElementById(choiceid);
|
||||
$(inputElement).keyup(function(event) {
|
||||
|
||||
json2nav();
|
||||
clearSidebarWrapper();
|
||||
navpane();
|
||||
|
||||
});
|
||||
|
||||
// function for calling html2json using Mark Calculation
|
||||
var choiceQuestionMarkField = 'Choice_Question_Marks_Id_' + addChoiceAreaId;
|
||||
$('#'+choiceQuestionMarkField).keyup(function() {
|
||||
|
||||
json2nav()
|
||||
markCalculation()
|
||||
|
||||
});
|
||||
|
||||
json2nav();
|
||||
clearSidebarWrapper();
|
||||
navpane();
|
||||
|
||||
|
||||
}
|
||||
|
||||
//Function for Create a New Choice Field in a Choice Question
|
||||
function addNewChoice(NewaddChoiceAreaId = false , choiceName = false, choiceDescription = false, questionRandomNo = false, QuestionGroupRandomNo = false, choiceID = false, mathEnabled= false)
|
||||
@ -2021,7 +2151,7 @@ function addNewChoice(NewaddChoiceAreaId = false , choiceName = false, choiceDes
|
||||
}
|
||||
|
||||
//Function for Create a New Text Question in the Section and Question Group
|
||||
function textQuestion(question_id = false, section_id = false, group_question_area_id = false, questionTitle = false, questionDescription = false, questionType = false, questionSubType = false, mathEnabled = false, random_no = false, questionGroupId = false, questionAreaId = false, questionRandomNo = false, QuestionGroupRandomNo = false, questionMarks = false, questionUUID = false, group_question_marks = false, group_question_uuid = false, questionDisplayMarks = false, group_question_Display_Marks = false)
|
||||
function textQuestion(question_id = false, section_id = false, group_question_area_id = false, questionTitle = false, questionDescription = false, questionSubType = false, mathEnabled = false, questionGroupId = false, questionAreaId = false, questionRandomNo = false, QuestionGroupRandomNo = false, questionMarks = false, questionUUID = false, group_question_marks = false, group_question_uuid = false, questionDisplayMarks = false, group_question_Display_Marks = false)
|
||||
{
|
||||
// console.log('===========================================================================================================================================')
|
||||
// console.log("group_question_area_id : "+group_question_area_id, 'questionGroupId : '+ questionGroupId, 'questionAreaId : '+questionAreaId)
|
||||
@ -2045,6 +2175,7 @@ function textQuestion(question_id = false, section_id = false, group_question_ar
|
||||
{
|
||||
addTextQuestionId = text_field_created_time;
|
||||
}
|
||||
localStorage.setItem('questionsId', addTextQuestionId);
|
||||
|
||||
|
||||
|
||||
@ -2059,7 +2190,7 @@ function textQuestion(question_id = false, section_id = false, group_question_ar
|
||||
}
|
||||
else
|
||||
{
|
||||
marks = 0;
|
||||
marks = "";
|
||||
}
|
||||
|
||||
|
||||
@ -2133,13 +2264,13 @@ function textQuestion(question_id = false, section_id = false, group_question_ar
|
||||
<input type="hidden" id="Text_Question_UUID_ID_${addTextQuestionId}" value="${UUID}">
|
||||
<div class="form_box">
|
||||
<label>Question:</label>
|
||||
<div type="text" class="richText" id="textQuestionName_${addTextQuestionId}" contenteditable="true" style=" border: 2px solid #EEECFE; margin-top: 4px;">${questionType == 'text' ? questionTitle : ''}</div>
|
||||
<div type="text" class="richText" id="textQuestionName_${addTextQuestionId}" contenteditable="true" style=" border: 2px solid #EEECFE; margin-top: 4px;">${questionTitle ? questionTitle : ''}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-12 col-md-12 hideondrag">
|
||||
<div class="form_box">
|
||||
<label>Subtitle:</label>
|
||||
<div class="richText" id="textQuestionSubtitle_${addTextQuestionId}" contenteditable="true" style=" border: 2px solid #EEECFE; margin-top: 4px;">${questionType == 'text' ? questionDescription : ''}</div>
|
||||
<div class="richText" id="textQuestionSubtitle_${addTextQuestionId}" contenteditable="true" style=" border: 2px solid #EEECFE; margin-top: 4px;">${questionDescription ? questionDescription : ''}</div>
|
||||
<math-field id="textQuestionSubtitle_math_${addTextQuestionId}" contenteditable="true">${mathEnabled == 'true' ? questionDescription : ''}</math-field>
|
||||
</div>
|
||||
</div>
|
||||
@ -2239,9 +2370,9 @@ function textQuestion(question_id = false, section_id = false, group_question_ar
|
||||
var textQuestionSubtitle_math = 'textQuestionSubtitle_math_' + addTextQuestionId;
|
||||
var textQuestionSubtitle = 'textQuestionSubtitle_' + addTextQuestionId;
|
||||
|
||||
var ChoiceMathSwitchId = document.getElementById(ChoiceMathSwitch)
|
||||
var textQuestionSubtitle_mathId = document.getElementById(textQuestionSubtitle_math)
|
||||
var textQuestionSubtitleId = document.getElementById(textQuestionSubtitle)
|
||||
var ChoiceMathSwitchId = document.getElementById(ChoiceMathSwitch);
|
||||
var textQuestionSubtitle_mathId = document.getElementById(textQuestionSubtitle_math);
|
||||
var textQuestionSubtitleId = document.getElementById(textQuestionSubtitle);
|
||||
|
||||
|
||||
if (mathEnabled === 'true')
|
||||
@ -2264,16 +2395,120 @@ function textQuestion(question_id = false, section_id = false, group_question_ar
|
||||
ChoiceMathSwitchId.addEventListener("change", function() {
|
||||
|
||||
if (ChoiceMathSwitchId.checked) {
|
||||
$(textQuestionSubtitle_mathId).show();
|
||||
$(textQuestionSubtitleId).hide();
|
||||
$(textQuestionSubtitle_previousDiv).hide();
|
||||
$(textQuestionSubtitle_mathId).show();
|
||||
$(textQuestionSubtitleId).hide();
|
||||
$(textQuestionSubtitle_previousDiv).hide();
|
||||
} else {
|
||||
$(textQuestionSubtitleId).show();
|
||||
$(textQuestionSubtitle_mathId).hide();
|
||||
$(textQuestionSubtitleId).show();
|
||||
$(textQuestionSubtitle_mathId).hide();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//mark calculation in TextQuestion
|
||||
|
||||
// var textQuestionMarkField = 'Text_Question_Marks_Id_'+ addTextQuestionId
|
||||
|
||||
// var sectionRandomID = localStorage.getItem('sectionId');
|
||||
// var Section_Attempt_Any_raw_Id = 'Section_Attempt_Any_Id_' + sectionRandomID;
|
||||
// var Section_Marks_raw_Id = 'Section_Marks_Id_' + sectionRandomID;
|
||||
|
||||
|
||||
|
||||
// var QuestionGroup_ID = localStorage.getItem('QuestionGroupId');
|
||||
// var Question_Attempt_Any_Fields = 'Question_Attempt_Any_Id_' + QuestionGroup_ID;
|
||||
// var Question_Group_Marks_Field = 'Question_Group_Marks_Id_' + QuestionGroup_ID;
|
||||
|
||||
|
||||
// //These lines are execute only the 'textQuestion()' function call
|
||||
// var QGinputValue = $('#'+Section_Attempt_Any_raw_Id).val();
|
||||
// var InMarkValue = $('#'+Section_Marks_raw_Id).val();
|
||||
// // alert(InMarkValue);
|
||||
|
||||
// if(QGinputValue == ""){
|
||||
// $('#'+textQuestionMarkField).prop("disabled", false);
|
||||
// // alert('text question enable');
|
||||
// }else{
|
||||
// $('#'+textQuestionMarkField).prop("disabled", true);
|
||||
// $('#'+textQuestionMarkField).val(InMarkValue);
|
||||
// // alert('text question disabled');
|
||||
// }
|
||||
// //end of the lines
|
||||
|
||||
|
||||
// // These lines are working only the Section function to change anything AtemptAny field
|
||||
// $('#'+Section_Attempt_Any_raw_Id).keyup(function() {
|
||||
// var inputValue = $(this).val();
|
||||
// var MarkValue = $('#'+Section_Marks_raw_Id).val();
|
||||
|
||||
// // alert(MarkValue);
|
||||
|
||||
// if(inputValue == "" && section_id){
|
||||
// $('#'+textQuestionMarkField).prop("disabled", false);
|
||||
// // alert('sectionRandomID text enable');
|
||||
// }else{
|
||||
// $('#'+textQuestionMarkField).prop("disabled", true);
|
||||
// // alert('sectionRandomID text disabled');
|
||||
// }
|
||||
// json2nav();
|
||||
// });
|
||||
|
||||
// $('#'+Section_Marks_raw_Id).keyup(function() {
|
||||
// var MarksinputValue = $(this).val();
|
||||
|
||||
// if(MarksinputValue !== "" && section_id){
|
||||
// $('#'+textQuestionMarkField).val(MarksinputValue);
|
||||
// }
|
||||
// });
|
||||
// //end of the line
|
||||
|
||||
|
||||
// //These lines are execute only the 'textQuestion()' function call
|
||||
// var QG_AttemptAny_inputValue = $('#'+Question_Attempt_Any_Fields).val();
|
||||
// var QG_Marks_inputValue = $('#'+Question_Group_Marks_Field).val();
|
||||
// // alert(InMarkValue);
|
||||
|
||||
// if(QG_AttemptAny_inputValue == ""){
|
||||
// $('#'+textQuestionMarkField).prop("disabled", false);
|
||||
// // alert('text question enable');
|
||||
// }else{
|
||||
// $('#'+textQuestionMarkField).prop("disabled", true);
|
||||
// $('#'+textQuestionMarkField).val(QG_Marks_inputValue);
|
||||
// // alert('text question disabled');
|
||||
// }
|
||||
// //end of the lines
|
||||
|
||||
|
||||
|
||||
// // These Function are working only the QuestionGroup to change anything AtemptAny field
|
||||
// $('#'+Question_Attempt_Any_Fields).keyup(function() {
|
||||
// var inputValue = $(this).val();
|
||||
// var QG_Marks_inputValues = $('#'+Question_Group_Marks_Field).val();
|
||||
|
||||
// if(inputValue == "" && group_question_area_id){
|
||||
// $('#'+textQuestionMarkField).prop("disabled", false);
|
||||
// // alert('QuestionGroup_ID text enable');
|
||||
// }else{
|
||||
// $('#'+textQuestionMarkField).prop("disabled", true);
|
||||
// $('#'+textQuestionMarkField).val(QG_Marks_inputValues);
|
||||
// // alert('QuestionGroup_ID text disabled');
|
||||
|
||||
// }
|
||||
// json2nav();
|
||||
// });
|
||||
|
||||
// $('#'+Question_Group_Marks_Field).keyup(function() {
|
||||
// var MarksinputValue = $(this).val();
|
||||
|
||||
// if(MarksinputValue !== "" && group_question_area_id){
|
||||
// $('#'+textQuestionMarkField).val(MarksinputValue);
|
||||
// }
|
||||
// });
|
||||
// // end of the lines
|
||||
|
||||
|
||||
//end of mark calculation in textquestion
|
||||
|
||||
|
||||
|
||||
var AddButtons_Raw = 'AddButtons_'+addTextQuestionId;
|
||||
@ -2285,11 +2520,7 @@ function textQuestion(question_id = false, section_id = false, group_question_ar
|
||||
var QuestionGroupAddButtons_ID = document.getElementById(QuestionGroupAddButtons_Raw)
|
||||
var removeAndCloneTextQuestion_ID = document.getElementById(removeAndCloneTextQuestion_Raw);
|
||||
|
||||
// console.log('group_question_area_id');
|
||||
// console.log(group_question_area_id);
|
||||
// console.log('questionTitle');
|
||||
// console.log(questionTitle);
|
||||
// if(group_question_area_id !== false )//questionGroupId
|
||||
|
||||
if(group_question_area_id !== false )//questionGroupId
|
||||
{
|
||||
// alert('three')
|
||||
@ -2303,7 +2534,7 @@ function textQuestion(question_id = false, section_id = false, group_question_ar
|
||||
// alert('four')
|
||||
// four button group
|
||||
|
||||
if(questionGroupId !== false)
|
||||
if(questionAreaId !== false)
|
||||
{
|
||||
$('#'+overallQuestionGroupAddButtons_Raw).show();
|
||||
$('#'+overallAddButtons_Raw).hide();
|
||||
@ -2324,13 +2555,20 @@ function textQuestion(question_id = false, section_id = false, group_question_ar
|
||||
$('#'+removeAndCloneTextQuestion_Raw).mouseenter(function(){
|
||||
|
||||
|
||||
if(group_question_area_id !== false || questionTitle !== false)
|
||||
if(group_question_area_id !== false)
|
||||
{
|
||||
add_button_hide_and_show(QuestionGroupAddButtons_Raw);
|
||||
}
|
||||
else
|
||||
{
|
||||
add_button_hide_and_show(AddButtons_Raw);
|
||||
{
|
||||
if(questionAreaId !== false)
|
||||
{
|
||||
add_button_hide_and_show(QuestionGroupAddButtons_Raw);
|
||||
}
|
||||
else
|
||||
{
|
||||
add_button_hide_and_show(AddButtons_Raw);
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
@ -2407,10 +2645,18 @@ function textQuestion(question_id = false, section_id = false, group_question_ar
|
||||
navpane();
|
||||
});
|
||||
|
||||
// function for calling html2json using Mark Calculation
|
||||
var textQuestionMarkField = 'Text_Question_Marks_Id_'+ addTextQuestionId
|
||||
$('#'+textQuestionMarkField).keyup(function() {
|
||||
|
||||
json2nav()
|
||||
markCalculation()
|
||||
|
||||
});
|
||||
|
||||
json2nav();
|
||||
clearSidebarWrapper();
|
||||
navpane();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
1077
addform_old.html
1077
addform_old.html
File diff suppressed because it is too large
Load Diff
@ -4,10 +4,16 @@ function json2nav() {
|
||||
$.fn.getTextQuestion = function(element_id) {
|
||||
var questionTitle = document.getElementById('textQuestionName_' + element_id).querySelector('.ql-editor').innerHTML;
|
||||
var textQuestionId = 'textQuestionName_' + element_id;
|
||||
var marks = document.getElementById('Text_Question_Marks_Id_' + element_id).value;
|
||||
// var questionType = 'Text';
|
||||
var questionType = document.getElementById('question_type_' + element_id).value;
|
||||
|
||||
|
||||
return {
|
||||
"question": questionTitle,
|
||||
"textQuestion_Id":textQuestionId
|
||||
|
||||
"question_Id":textQuestionId,
|
||||
"marks":marks,
|
||||
"question_type":questionType
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,10 +21,17 @@ function json2nav() {
|
||||
|
||||
var questionTitle = document.getElementById('textQuestionName_' + element_id).querySelector('.ql-editor').innerHTML;
|
||||
var choiceQuestionId = 'textQuestionName_' + element_id;
|
||||
var marks = document.getElementById('Choice_Question_Marks_Id_' + element_id).value;
|
||||
// var questionType = 'Group';
|
||||
var questionType = document.getElementById('question_type_' + element_id).value;
|
||||
|
||||
|
||||
|
||||
return {
|
||||
"question": questionTitle,
|
||||
"choice_question_id":choiceQuestionId
|
||||
"question_Id":choiceQuestionId,
|
||||
"marks":marks,
|
||||
"question_type":questionType
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,8 +86,14 @@ function json2nav() {
|
||||
// console.log('section_title_text_'+rand_id);
|
||||
var groupQuestion = {}
|
||||
var group_title = document.getElementById('subSection_title_text_' + rand_id);
|
||||
var group_attempt_any = document.getElementById('Question_Attempt_Any_Id_' + rand_id);
|
||||
var group_marks = document.getElementById('Question_Group_Marks_Id_' + rand_id);
|
||||
|
||||
groupQuestion['group_title'] = ((typeof group_title !== null && group_title !== 'undefined') ? (group_title !== null ? group_title.querySelector('.ql-editor').innerHTML : null) : null);
|
||||
groupQuestion['question_group_id'] = 'subSection_title_text_' + rand_id;
|
||||
groupQuestion['group_attempt_any'] = ((typeof group_attempt_any !== null && group_attempt_any !== 'undefined') ? (group_attempt_any !== null ? group_attempt_any.value : null) : null);
|
||||
groupQuestion['group_marks'] = ((typeof group_marks !== null && group_marks !== 'undefined') ? (group_marks !== null ? group_marks.value : null) : null);
|
||||
|
||||
if (group_title !== null) {
|
||||
var questionsData = $.fn.getQuestionsData(rand_id, 'group');
|
||||
groupQuestion['questions'] = questionsData;
|
||||
@ -92,11 +111,16 @@ function json2nav() {
|
||||
// console.log('section_title_text_'+rand_id);
|
||||
var section = {}
|
||||
var section_title = document.getElementById('section_title_text_' + rand_id);
|
||||
var section_marks = document.getElementById('Section_Marks_Id_' + rand_id);
|
||||
var section_attempt_any = document.getElementById('Section_Attempt_Any_Id_' + rand_id);
|
||||
// console.log('section title in nav script');
|
||||
// console.log(section_title);
|
||||
// section['section_title'] = ((section_title !== null && section_title !== 'undefined') ? (section_title !== null ? section_title.querySelector('.ql-editor').innerHTML : null) : null);
|
||||
section['section_title'] = (section_title && section_title.querySelector('.ql-editor') ? section_title.querySelector('.ql-editor').innerHTML : null);
|
||||
section['section_id'] = 'section_title_text_' + rand_id;
|
||||
section['section_attempt_any'] = ((typeof section_attempt_any !== null && section_attempt_any !== 'undefined') ? (section_attempt_any !== null ? section_attempt_any.value : null) : null);
|
||||
section['section_marks'] = ((typeof section_marks !== null && section_marks !== 'undefined') ? (section_marks !== null ? section_marks.value : null) : null);
|
||||
|
||||
if (section_title !== null) {
|
||||
var questionsData = $.fn.getQuestionsData(rand_id);
|
||||
// console.log('Section Data');
|
||||
@ -131,10 +155,10 @@ function json2nav() {
|
||||
// console.log((formData));
|
||||
// console.log(JSON.stringify(formData, null, 1));
|
||||
localStorage.setItem("JSON_FOR_NAV", JSON.stringify((formData)));
|
||||
console.log('JSON_FOR_NAV');
|
||||
console.log('*********************************************************************************');
|
||||
// console.log('JSON_FOR_NAV');
|
||||
// console.log('*********************************************************************************');
|
||||
console.log(JSON.stringify(formData));
|
||||
console.log('*********************************************************************************');
|
||||
// console.log('*********************************************************************************');
|
||||
|
||||
// console.log(OBJtoXML(({'question_paper' : formData})));
|
||||
}
|
||||
|
||||
23
json2html.js
23
json2html.js
@ -1,5 +1,7 @@
|
||||
function jsonToHtml(jsonData) {
|
||||
|
||||
console.log(jsonData);
|
||||
|
||||
if(jsonData == "" || jsonData == null)
|
||||
{
|
||||
|
||||
@ -83,13 +85,15 @@ console.log(title)
|
||||
|
||||
if(questionType == 'text')
|
||||
{
|
||||
textQuestion(false, false, false, questionTitle, questionDescription, questionType, questionSubType, mathEnabled, random_no, false, questionAreaId, questionRandomNo, false, questionMarks, questionUUID, false, false, questionDisplayMarks, false);
|
||||
|
||||
textQuestion(false, false, false, questionTitle, questionDescription, questionSubType, mathEnabled, questionAreaId, false, questionRandomNo, false, questionMarks, questionUUID, false, false, questionDisplayMarks, false);
|
||||
}
|
||||
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, question_Title, 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, questionTitle, questionDescription, questionType, questionSubType, mathEnabled, Choice, random_no, false, questionAreaId, questionRandomNo, false, questionMarks, questionUUID, false, false, questionDisplayMarks, false);
|
||||
Choice = Choice.slice(1);
|
||||
Choice.forEach(function(choicenames, index) {
|
||||
var choiceName = choicenames.choice_name;
|
||||
@ -130,8 +134,9 @@ function generateGroupQuestion(Question, questionAreaId, questionRandomNo)
|
||||
|
||||
const QuestionGroupRandomNo = Date.now();
|
||||
|
||||
// console.log(GroupQuestions);
|
||||
// console.log("**********************************");
|
||||
console.log(GroupQuestions);
|
||||
console.log("**********************************");
|
||||
|
||||
// question level variables
|
||||
var group_question_Title = GroupQuestions.question;
|
||||
var group_question_Description = GroupQuestions.question_description;
|
||||
@ -146,18 +151,20 @@ function generateGroupQuestion(Question, questionAreaId, questionRandomNo)
|
||||
|
||||
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, false, group_questionSubType, mathEnabled, false, false, questionGroupId, false, QuestionGroupRandomNo, false, false, group_question_marks, group_question_uuid, false, group_question_Display_Marks);
|
||||
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, false, group_questionSubType, mathEnabled, Choice, false, 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, 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;
|
||||
|
||||
237
mark_calc.js
Normal file
237
mark_calc.js
Normal file
@ -0,0 +1,237 @@
|
||||
function markCalculation() {
|
||||
|
||||
console.clear();
|
||||
|
||||
// Get jsonData from the Localstorage
|
||||
var jsonString = localStorage.getItem('JSON_FOR_NAV');
|
||||
console.log('jsonData markCalculation');
|
||||
const jsonData = JSON.parse(jsonString);
|
||||
console.log(jsonData);
|
||||
|
||||
|
||||
//Section Level foreach
|
||||
jsonData.sections.forEach(function(section, index) {
|
||||
|
||||
const random_no = Date.now();
|
||||
var sectionMarks = section.section_marks;
|
||||
var sectionAttemptAny = section.section_attempt_any;
|
||||
var section_id = section.section_id;
|
||||
|
||||
console.log('sectionMarks : ' + sectionMarks);
|
||||
console.log('sectionAttemptAny : ' + sectionAttemptAny);
|
||||
console.log('section_id : ' + section_id);
|
||||
|
||||
//send a object for generateSingleQuestions() function using foreach and mark calc
|
||||
var QuestionObjects = {
|
||||
|
||||
'sectionData': section,
|
||||
'sectionRandomNo': random_no,
|
||||
'sectionMarks': sectionMarks,
|
||||
'sectionAttemptAny': sectionAttemptAny,
|
||||
}
|
||||
|
||||
// generateSingleQuestions(section,random_no);
|
||||
generateSingleQuestions(QuestionObjects);
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Function for Question Level foreach
|
||||
// function generateSingleQuestions(section, random_no)
|
||||
function generateSingleQuestions(QuestionObjects)
|
||||
{
|
||||
//set default value for reciveing questionObjects
|
||||
var section = false;
|
||||
var random_no = false;
|
||||
|
||||
//end of set default value for reciveing questionObjects
|
||||
|
||||
|
||||
//set values from QuestionObjects param if exists
|
||||
|
||||
if(QuestionObjects.hasOwnProperty('sectionData'))
|
||||
{
|
||||
section = QuestionObjects.sectionData;
|
||||
}
|
||||
else if(QuestionObjects.hasOwnProperty('sectionRandomNo'))
|
||||
{
|
||||
random_no = QuestionObjects.sectionRandomNo;
|
||||
}
|
||||
|
||||
//end of set values from QuestionObjects param if exists
|
||||
|
||||
|
||||
section.questions.forEach(function(Question, index) {
|
||||
|
||||
const questionRandomNo = Date.now();
|
||||
var questionTypeFormets = "";
|
||||
if(Question.question_type)
|
||||
{
|
||||
questionTypeFormets = Question.question_type;
|
||||
}
|
||||
else
|
||||
{
|
||||
questionTypeFormets ='question_group';
|
||||
}
|
||||
|
||||
//Questions Variables
|
||||
var questionType = questionTypeFormets;
|
||||
var questionMarks = Question.marks;
|
||||
var question_Id = Question.question_Id;
|
||||
|
||||
// section mark divided by section attempt any
|
||||
|
||||
var sectionMarks = QuestionObjects.sectionMarks;
|
||||
var sectionAttemptAny = QuestionObjects.sectionAttemptAny;
|
||||
var sectionMarkDivideVale = sectionMarks / sectionAttemptAny;
|
||||
|
||||
//end of section mark divided by section attempt any
|
||||
|
||||
|
||||
var questionAreaId = 'question_area_'+random_no;
|
||||
if(questionType == 'text')
|
||||
{
|
||||
//this part for Text question only
|
||||
var addTextQuestionId = question_Id.split("_")[1];
|
||||
var textQuestionMarkField = document.getElementById('Text_Question_Marks_Id_'+ addTextQuestionId);
|
||||
|
||||
if(QuestionObjects.sectionAttemptAny !== "")
|
||||
{
|
||||
textQuestionMarkField.value = sectionMarkDivideVale;
|
||||
}
|
||||
else
|
||||
{
|
||||
textQuestionMarkField.value = "";
|
||||
}
|
||||
|
||||
}
|
||||
else if (questionType == 'group')
|
||||
{
|
||||
//this part for Choice question only
|
||||
var addChoiceAreaId = question_Id.split("_")[1];
|
||||
var choiceQuestionMarkField = document.getElementById('Choice_Question_Marks_Id_' + addChoiceAreaId);
|
||||
|
||||
if(QuestionObjects.sectionAttemptAny !== "")
|
||||
{
|
||||
console.log(choiceQuestionMarkField);
|
||||
choiceQuestionMarkField.value = sectionMarkDivideVale;
|
||||
choiceQuestionMarkField.disable = true;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
choiceQuestionMarkField.value = "";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else if (questionType == 'question_group')
|
||||
{
|
||||
|
||||
//the objects contain QuestionGroup Data for send generateGroupQuestion()
|
||||
var QuestionGroupObjects = {
|
||||
|
||||
'questionGroupData': Question,
|
||||
'sectionMarks': sectionMarkDivideVale,
|
||||
'sectionAttemptAny': QuestionObjects.sectionAttemptAny,
|
||||
|
||||
}
|
||||
|
||||
generateGroupQuestion(QuestionGroupObjects); //function for forEach QuestionGroups and Questions
|
||||
|
||||
}
|
||||
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// function for QuestionGroups and QuestionGroup questions Level Foreach
|
||||
// function generateGroupQuestion(Question, questionRandomNo)
|
||||
function generateGroupQuestion(QuestionGroupObjects)
|
||||
{
|
||||
|
||||
|
||||
//set default value for reciveing questionObjects
|
||||
var Question = false;
|
||||
|
||||
//end of set default value for reciveing questionObjects
|
||||
|
||||
|
||||
//set values from QuestionObjects param if exists
|
||||
|
||||
if(QuestionGroupObjects.hasOwnProperty('questionGroupData'))
|
||||
{
|
||||
Question = QuestionGroupObjects.questionGroupData;
|
||||
}
|
||||
|
||||
//end of set values from QuestionObjects param if exists
|
||||
|
||||
|
||||
//QuestionGroup Variables
|
||||
var group_marks = Question.group_marks;
|
||||
var group_attempt_any = Question.group_attempt_any;
|
||||
var question_group_id = Question.question_group_id;
|
||||
|
||||
console.log(question_group_id);
|
||||
|
||||
|
||||
var QuestionGroup_ID = question_group_id.split("_")[3];
|
||||
var Question_Group_Marks_Field = document.getElementById('Question_Group_Marks_Id_' + QuestionGroup_ID);
|
||||
console.log(Question_Group_Marks_Field);
|
||||
|
||||
if(QuestionGroupObjects.sectionAttemptAny !== "")
|
||||
{
|
||||
// alert(QuestionGroupObjects.sectionMarks)
|
||||
Question_Group_Marks_Field.value = QuestionGroupObjects.sectionMarks;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Question_Group_Marks_Field.value = "";
|
||||
}
|
||||
|
||||
|
||||
console.log('group_marks : ' + group_marks);
|
||||
console.log('group_attempt_any : ' + group_attempt_any);
|
||||
console.log('question_group_id : ' + question_group_id);
|
||||
|
||||
// QuestionGroup question Level Foreach
|
||||
Question.questions.forEach(function(GroupQuestions, index) {
|
||||
|
||||
const QuestionGroupRandomNo = Date.now();
|
||||
|
||||
//QuestionGroup Questions Variables
|
||||
var group_question_Type = GroupQuestions.question_type;
|
||||
var group_question_marks = GroupQuestions.marks;
|
||||
var group_question_id = GroupQuestions.question_Id;
|
||||
|
||||
// var questionGroupId = 'group_question_area_'+questionRandomNo;
|
||||
|
||||
if(group_question_Type == 'text')
|
||||
{
|
||||
console.log('group_question_Type : ' + group_question_Type);
|
||||
console.log('group_question_marks : ' + group_question_marks);
|
||||
console.log('group_question_id : ' + group_question_id);
|
||||
}
|
||||
else if(group_question_Type == 'group')
|
||||
{
|
||||
console.log('group_question_Type : ' + group_question_Type);
|
||||
console.log('group_question_marks : ' + group_question_marks);
|
||||
console.log('group_question_id : ' + group_question_id);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
generateGroupQuestion(GroupQuestions, questionGroupId, QuestionGroupRandomNo); // function for 4 level QuestionGroup Handle
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
250
nav_pane.js
250
nav_pane.js
@ -1,3 +1,5 @@
|
||||
// Initialize an array to store the expanded section data-ids
|
||||
const expandedSections = [];
|
||||
function navpane() {
|
||||
// Sample JSON data
|
||||
let isHighlighted = false;
|
||||
@ -9,207 +11,225 @@ function navpane() {
|
||||
// console.log(typeof jsonData);
|
||||
// console.log('jsonData', jsonData);
|
||||
|
||||
// Function to remove <p></p> tags from HTML content
|
||||
|
||||
|
||||
function removeParagraphTags(html) {
|
||||
// console.log('html:', html);
|
||||
return html.replace(/<p>/g, '').replace(/<\/p>/g, '');
|
||||
}
|
||||
|
||||
|
||||
function createTreeWithHeading(data, container) {
|
||||
// console.log('data', data.question_paper_title);
|
||||
// Extract the treeTitle from the JSON data and remove <p></p> tags
|
||||
const treeTitle = removeParagraphTags(data.question_paper_title);
|
||||
|
||||
// Create the heading element
|
||||
const heading = document.createElement('a'); // You can use h1, h2, div, or any other suitable HTML element
|
||||
const heading = document.createElement('a');
|
||||
heading.style.color = '#740fd6';
|
||||
|
||||
const truncatedTitle = treeTitle.length > 20 ? treeTitle.substring(0, 20) + '.....' : treeTitle;
|
||||
heading.innerHTML = truncatedTitle; // Set the text content of the heading (with HTML tags removed)
|
||||
// heading.style.fontSize = 'x-large'; // Set the font size
|
||||
// heading.style.marginLeft = '26px';
|
||||
heading.innerHTML = truncatedTitle;
|
||||
container.appendChild(heading);
|
||||
|
||||
// Create the tree structure
|
||||
createTree(data, container);
|
||||
}
|
||||
|
||||
// Function to create the collapsible tree
|
||||
|
||||
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';
|
||||
// sectionDiv.id = sectionId;
|
||||
// console.log('sectionDiv', sectionDiv)
|
||||
container.appendChild(sectionDiv);
|
||||
|
||||
// Create arrow icon element
|
||||
const sectionArrow = document.createElement('span');
|
||||
sectionArrow.className = 'arrow-right';
|
||||
sectionArrow.style.cursor = 'pointer'; // Set cursor to pointer
|
||||
sectionDiv.appendChild(sectionArrow);
|
||||
|
||||
// Click event listener for the arrow icon
|
||||
sectionArrow.addEventListener('click', () => {
|
||||
contentDiv.classList.toggle('visible');
|
||||
sectionDiv.classList.toggle('collapsed');
|
||||
if (sectionDiv.classList.contains('collapsed')) {
|
||||
sectionArrow.classList.remove('arrow-right');
|
||||
sectionArrow.classList.add('arrow-down');
|
||||
} else {
|
||||
sectionArrow.classList.remove('arrow-down');
|
||||
sectionArrow.classList.add('arrow-right');
|
||||
}
|
||||
});
|
||||
|
||||
const sectionLink = document.createElement('a');
|
||||
sectionLink.href = '#' + section.section_id;
|
||||
sectionLink.style.color = '#740fd6';
|
||||
|
||||
// Add a click event listener to toggle highlighting and boldness
|
||||
sectionLink.addEventListener('click', function () {
|
||||
if (currentlyHighlightedElement !== null && currentlyHighlightedElement !== sectionLink) {
|
||||
// Remove highlight from the previously highlighted element
|
||||
currentlyHighlightedElement.style.fontWeight = 'normal';
|
||||
}
|
||||
|
||||
if (currentlyHighlightedElement === sectionLink) {
|
||||
// Toggle highlight on the current element
|
||||
sectionLink.style.fontWeight = sectionLink.style.fontWeight === 'bold' ? 'normal' : 'bold';
|
||||
} else {
|
||||
// Make the text bold
|
||||
sectionLink.style.fontWeight = 'bold';
|
||||
// Update the currently highlighted element
|
||||
currentlyHighlightedElement = sectionLink;
|
||||
}
|
||||
});
|
||||
|
||||
if (section.section_title == null || typeof section.section_title === 'undefined') {
|
||||
section.section_title = "sampletitle";
|
||||
|
||||
// Check if the section should be initially expanded based on expandedSections
|
||||
if (expandedSections.includes(sectionId)) {
|
||||
sectionDiv.classList.remove('collapsed');
|
||||
|
||||
} else {
|
||||
sectionDiv.classList.add('collapsed');
|
||||
}
|
||||
|
||||
sectionLink.innerHTML = removeParagraphTags(section.section_title);
|
||||
sectionDiv.appendChild(sectionLink);
|
||||
|
||||
container.appendChild(sectionDiv);
|
||||
|
||||
const sectionArrow = document.createElement('span');
|
||||
sectionArrow.style.cursor = 'pointer';
|
||||
sectionDiv.appendChild(sectionArrow);
|
||||
|
||||
const contentDiv = document.createElement('div');
|
||||
contentDiv.className = 'content';
|
||||
|
||||
// Update the arrow icon based on the section's initial state
|
||||
if (sectionDiv.classList.contains('collapsed')) {
|
||||
sectionArrow.className = 'arrow-right';
|
||||
} else {
|
||||
sectionArrow.className = 'arrow-down';
|
||||
contentDiv.classList.add('visible');
|
||||
}
|
||||
|
||||
sectionArrow.addEventListener('click', () => {
|
||||
contentDiv.classList.toggle('visible');
|
||||
sectionDiv.classList.toggle('collapsed');
|
||||
|
||||
// Check if the section is expanded or collapsed
|
||||
if (sectionDiv.classList.contains('collapsed')) {
|
||||
const index = expandedSections.indexOf(sectionId);
|
||||
if (index !== -1) {
|
||||
expandedSections.splice(index, 1);
|
||||
}
|
||||
sectionArrow.classList.remove('arrow-down');
|
||||
sectionArrow.classList.add('arrow-right');
|
||||
} else {
|
||||
expandedSections.push(sectionId);
|
||||
sectionArrow.classList.remove('arrow-right');
|
||||
sectionArrow.classList.add('arrow-down');
|
||||
}
|
||||
});
|
||||
|
||||
const sectionLink = document.createElement('a');
|
||||
sectionLink.href = '#' + section.section_id;
|
||||
sectionLink.style.color = '#740fd6';
|
||||
|
||||
// Add a click event listener to toggle highlighting and boldness
|
||||
sectionLink.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";
|
||||
}
|
||||
|
||||
sectionLink.innerHTML = removeParagraphTags(section.section_title);
|
||||
sectionDiv.appendChild(sectionLink);
|
||||
|
||||
section.questions.forEach(question => {
|
||||
createTreeNode(question, contentDiv);
|
||||
});
|
||||
|
||||
|
||||
container.appendChild(contentDiv);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function createTreeNode(nodeData, parentNode) {
|
||||
const nodeDiv = document.createElement('div');
|
||||
// nodeDiv.id = nodeData.textQuestion_Id || nodeData.choice_question_id;
|
||||
const nodeDataId = nodeData.textQuestion_Id || nodeData.choice_question_id;
|
||||
parentNode.appendChild(nodeDiv);
|
||||
|
||||
// nodeDiv.id = nodeData.textQuestion_Id || nodeData.choice_question_id;
|
||||
const nodeDataId = nodeData.question_Id
|
||||
console.log('nodeDataId:',nodeDataId);
|
||||
|
||||
|
||||
|
||||
parentNode.appendChild(nodeDiv);
|
||||
|
||||
if (nodeData.question) {
|
||||
// Create a bullet point element
|
||||
const bulletPoint = document.createElement('span');
|
||||
// Style the bullet point element
|
||||
bulletPoint.style.marginRight = '10px'; // Add space to the right of the bullet point
|
||||
bulletPoint.style.marginRight = '10px';
|
||||
bulletPoint.style.fontSize = '23px';
|
||||
bulletPoint.style.fontWeight = 'bold';
|
||||
bulletPoint.style.color = 'darkgray'; // Change the color of the bullet point
|
||||
bulletPoint.textContent = '\u2022'; // Unicode character for a bullet point dot
|
||||
// Append the bullet point element to the nodeDiv
|
||||
bulletPoint.style.color = 'darkgray';
|
||||
bulletPoint.textContent = '\u2022';
|
||||
nodeDiv.appendChild(bulletPoint);
|
||||
|
||||
|
||||
const questionLink = document.createElement('a');
|
||||
// console.log('nodeDiv.id:', nodeDataId);
|
||||
questionLink.href = '#' + nodeDataId;
|
||||
questionLink.style.color = '#740fd6';
|
||||
|
||||
// Add a click event listener to toggle highlighting and boldness
|
||||
|
||||
questionLink.addEventListener('click', function () {
|
||||
if (currentlyHighlightedElement !== null && currentlyHighlightedElement !== questionLink) {
|
||||
// Remove highlight from the previously highlighted element
|
||||
currentlyHighlightedElement.style.fontWeight = 'normal';
|
||||
}
|
||||
|
||||
|
||||
if (currentlyHighlightedElement === questionLink) {
|
||||
// Toggle highlight on the current element
|
||||
questionLink.style.fontWeight = questionLink.style.fontWeight === 'bold' ? 'normal' : 'bold';
|
||||
} else {
|
||||
// Make the text bold
|
||||
questionLink.style.fontWeight = 'bold';
|
||||
// Update the currently highlighted element
|
||||
currentlyHighlightedElement = questionLink;
|
||||
}
|
||||
});
|
||||
|
||||
// Check if the question text is longer than 20 characters
|
||||
|
||||
if (nodeData.question.length > 20) {
|
||||
questionLink.innerHTML = removeParagraphTags(nodeData.question.substring(0, 20) + '.....');
|
||||
} else {
|
||||
questionLink.innerHTML = removeParagraphTags(nodeData.question);
|
||||
}
|
||||
|
||||
|
||||
nodeDiv.appendChild(questionLink);
|
||||
} else if (nodeData.group_title) {
|
||||
const groupTitleDiv = document.createElement('div');
|
||||
const groupTitleId = nodeData.question_group_id;
|
||||
groupTitleDiv.setAttribute('data-id', groupTitleId);
|
||||
groupTitleDiv.className = 'question-group';
|
||||
// groupTitleDiv.id = groupTitleId;
|
||||
|
||||
// Check if the group should be initially expanded based on expandedSections
|
||||
if (expandedSections.includes(groupTitleId)) {
|
||||
groupTitleDiv.classList.remove('collapsed');
|
||||
} else {
|
||||
groupTitleDiv.classList.add('collapsed');
|
||||
}
|
||||
|
||||
parentNode.appendChild(groupTitleDiv);
|
||||
|
||||
// Create arrow icon element for group title
|
||||
|
||||
const groupTitleArrow = document.createElement('span');
|
||||
groupTitleArrow.className = 'arrow-right';
|
||||
groupTitleArrow.style.cursor = 'pointer'; // Set cursor to pointer
|
||||
groupTitleArrow.style.cursor = 'pointer';
|
||||
groupTitleDiv.appendChild(groupTitleArrow);
|
||||
|
||||
// Click event listener for the arrow icon
|
||||
const groupQuestionsDiv = document.createElement('div');
|
||||
groupQuestionsDiv.className = 'content';
|
||||
|
||||
// Update the arrow icon based on the section's initial state
|
||||
if (groupTitleDiv.classList.contains('collapsed')) {
|
||||
groupTitleArrow.className = 'arrow-right';
|
||||
} else {
|
||||
groupTitleArrow.className = 'arrow-down';
|
||||
groupQuestionsDiv.classList.add('visible');
|
||||
}
|
||||
|
||||
groupTitleArrow.addEventListener('click', () => {
|
||||
groupQuestionsDiv.classList.toggle('visible');
|
||||
groupTitleDiv.classList.toggle('collapsed');
|
||||
|
||||
// Check if the group is expanded or collapsed
|
||||
if (groupTitleDiv.classList.contains('collapsed')) {
|
||||
groupTitleArrow.classList.remove('arrow-down');
|
||||
groupTitleArrow.classList.add('arrow-down');
|
||||
} else {
|
||||
const index = expandedSections.indexOf(groupTitleId);
|
||||
if (index !== -1) {
|
||||
expandedSections.splice(index, 1);
|
||||
}
|
||||
groupTitleArrow.classList.remove('arrow-down');
|
||||
groupTitleArrow.classList.add('arrow-right');
|
||||
} else {
|
||||
expandedSections.push(groupTitleId);
|
||||
groupTitleArrow.classList.remove('arrow-right');
|
||||
groupTitleArrow.classList.add('arrow-down');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
const groupQuestionLink = document.createElement('a');
|
||||
// console.log('groupTitleDiv.id:', groupTitleId);
|
||||
groupQuestionLink.href = '#' + groupTitleId;
|
||||
groupQuestionLink.style.color = '#740fd6';
|
||||
|
||||
// Add a click event listener to toggle highlighting and boldness
|
||||
|
||||
groupQuestionLink.addEventListener('click', function () {
|
||||
if (currentlyHighlightedElement !== null && currentlyHighlightedElement !== groupQuestionLink) {
|
||||
// Remove highlight from the previously highlighted element
|
||||
currentlyHighlightedElement.style.fontWeight = 'normal';
|
||||
}
|
||||
|
||||
|
||||
if (currentlyHighlightedElement === groupQuestionLink) {
|
||||
// Toggle highlight on the current element
|
||||
groupQuestionLink.style.fontWeight = groupQuestionLink.style.fontWeight === 'bold' ? 'normal' : 'bold';
|
||||
} else {
|
||||
// Make the text bold
|
||||
groupQuestionLink.style.fontWeight = 'bold';
|
||||
// Update the currently highlighted element
|
||||
currentlyHighlightedElement = groupQuestionLink;
|
||||
}
|
||||
});
|
||||
|
||||
// Check if the group_title is longer than 20 characters
|
||||
|
||||
if (nodeData.group_title.length > 20) {
|
||||
groupQuestionLink.innerHTML = removeParagraphTags(nodeData.group_title.substring(0, 20) + '..');
|
||||
} else {
|
||||
groupQuestionLink.innerHTML = removeParagraphTags(nodeData.group_title);
|
||||
}
|
||||
groupTitleDiv.appendChild(groupQuestionLink);
|
||||
|
||||
const groupQuestionsDiv = document.createElement('div');
|
||||
groupQuestionsDiv.className = 'content';
|
||||
|
||||
|
||||
nodeData.questions.forEach(groupQuestion => {
|
||||
createTreeNode(groupQuestion, groupQuestionsDiv);
|
||||
});
|
||||
@ -217,8 +237,12 @@ function navpane() {
|
||||
}
|
||||
}
|
||||
|
||||
const questionPaperContainer = document.getElementById('questionPaper');
|
||||
var questionPaperContainer = document.getElementById('questionPaper');
|
||||
|
||||
createTreeWithHeading(jsonData, questionPaperContainer);
|
||||
localStorage.setItem("collapse", JSON.stringify((expandedSections)));
|
||||
console.log('expandedSections:',expandedSections);
|
||||
console.log('questionPaperContainer:',questionPaperContainer);
|
||||
|
||||
window.addEventListener('DOMContentLoaded', event => {
|
||||
// Toggle the side navigation
|
||||
|
||||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user