diff --git a/addform.html b/addform.html
index eefe445..02d8f44 100644
--- a/addform.html
+++ b/addform.html
@@ -1465,7 +1465,14 @@ function groupQuestion(question_id = false, section_id = false , group_question_
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 = "";
+ //set Default value
+ var addChoiceAreaId = false;
+ var marks = ""
+ var UUID = false;
+
+
+
+
if(questionRandomNo)
{
addChoiceAreaId = questionRandomNo;
@@ -1475,7 +1482,6 @@ function groupQuestion(question_id = false, section_id = false , group_question_
localStorage.setItem('ChoiceId', addChoiceAreaId);
- var marks = ""
if(questionMarks)
{
marks = questionMarks;
@@ -1485,7 +1491,6 @@ function groupQuestion(question_id = false, section_id = false , group_question_
marks = "";
}
- var UUID = "";
if(questionUUID)
{
UUID = questionUUID;
@@ -1941,11 +1946,45 @@ markCalculation();
}
//Function for Create a New Choice Field in a Choice Question
-function addNewChoice(NewaddChoiceAreaId = false , choiceName = false, questionRandomNo = false, choiceID = false, choice_mathEnabled= false)
+// function addNewChoice(NewaddChoiceAreaId = false , choiceName = false, questionRandomNo = false, choiceID = false, choice_mathEnabled= false)
+function addNewChoice(choiceObj)
{
- const Choice_Group_Dynamic_UUID = uuidv4();
+ //set the default value to false
+ var choiceName = false;
+ var choiceID = false;
+ var choice_mathEnabled = false;
+ var editChoiceAreaId = false;
+ var addChoiceAreaId = false;
+
+
+ //set values from obj param if exists
+ if(choiceObj.hasOwnProperty('addChoiceAreaId')) {
+
+ addChoiceAreaId = choiceObj.addChoiceAreaId;
+
+ }else if (choiceObj.hasOwnProperty('editChoiceAreaId')){
+
+ editChoiceAreaId = choiceObj.editChoiceAreaId;
+
+ }else if (choiceObj.hasOwnProperty('choiceName')){
+
+ choiceName = choiceObj.choiceName;
+
+ }else if (choiceObj.hasOwnProperty('choiceID')){
+
+ choiceID = choiceObj.choiceID;
+
+ }else if (choiceObj.hasOwnProperty('choice_mathEnabled')){
+
+ choice_mathEnabled = choiceObj.choice_mathEnabled;
+
+ }
+ //end of set values from obj param if exists
+
addChoice = "";
+
+ const Choice_Group_Dynamic_UUID = uuidv4();
const text_field_created_time = Date.now();
var rnd_no = Math.random();
@@ -1965,15 +2004,14 @@ function addNewChoice(NewaddChoiceAreaId = false , choiceName = false, questionR
`
- if(questionRandomNo)
+ if(editChoiceAreaId !== false)
{
- var addChoiceAreaId = 'addChoiceArea_'+questionRandomNo;
- var addChoiceAreaId2 = document.getElementById(addChoiceAreaId);
+ var addChoiceAreaId2 = document.getElementById(editChoiceAreaId);
addChoiceAreaId2.insertAdjacentHTML('beforeend', addChoice);
}
- else if(NewaddChoiceAreaId)
+ else if(addChoiceAreaId !== false)
{
- NewaddChoiceAreaId.insertAdjacentHTML('beforeend', addChoice);
+ addChoiceAreaId.insertAdjacentHTML('beforeend', addChoice);
}
@@ -1992,8 +2030,6 @@ $(newChoiceDeleteButtonId).on('click', function() {
$(newChoiceCommentFieldDeleteId).remove();
})
-
-
var newChoiceTextField = document.getElementById('newChoiceTextField_'+text_field_created_time+rnd_no);
var quill = new Quill(newChoiceTextField, {
theme: 'snow',
@@ -2073,15 +2109,6 @@ $(newChoiceDeleteButtonId).on('click', function() {
$(newchoiceTextField_math_Id).hide();
}
-
-
-
-
-
-
-
-
-
json2nav();
clearSidebarWrapper();
navpane();
@@ -2123,6 +2150,12 @@ textQuestion +=
+
+
+
+
+
+
@@ -2161,12 +2194,6 @@ textQuestion +=
-
-
-
-
-
-
@@ -2428,35 +2455,35 @@ var inputElement = document.getElementById(Textid);
function ReArrangeQuestions(e){
var currentID= e.target.parentElement.parentElement.parentElement.id;
- console.log(currentID)
+ // console.log(currentID)
var currentItemID = document.getElementById(currentID);
- console.log('currentItemID');
- console.log(currentItemID);
+ // console.log('currentItemID');
+ // console.log(currentItemID);
if (e.target.classList.contains('up-icon')) {
- console.log('FORWORD');
+ // console.log('FORWORD');
const question_ListItem = e.target.parentElement.parentElement;
- console.log('question_ListItem');
- console.log(question_ListItem);
+ // console.log('question_ListItem');
+ // console.log(question_ListItem);
const question_PrevItem = question_ListItem.previousElementSibling;
- console.log('question_PrevItem');
- console.log(question_PrevItem );
+ // console.log('question_PrevItem');
+ // console.log(question_PrevItem );
if (question_PrevItem !== null) {
currentItemID.insertBefore(question_ListItem, question_PrevItem);
}
} else if (e.target.classList.contains('down-icon')) {
- console.log('BACKWORD');
+ // console.log('BACKWORD');
const question_ListItem = e.target.parentElement.parentElement;
- console.log('question_ListItem');
- console.log(question_ListItem);
+ // console.log('question_ListItem');
+ // console.log(question_ListItem);
const question_nextItem = question_ListItem.nextElementSibling;
- console.log('question_nextItem');
- console.log(question_nextItem );
+ // console.log('question_nextItem');
+ // console.log(question_nextItem );
if (question_nextItem) {
currentItemID.insertBefore(question_nextItem, question_ListItem);
@@ -2502,6 +2529,7 @@ function ReArrangeQuestionsGroup(e){
currentItemID.insertBefore(question_nextItem, question_ListItem);
}
}
+
}
//Function for Add Group Question inside the Group QUestion Like Question
@@ -2569,7 +2597,12 @@ function ConstructAddNewChoiceID(e){
var addChoiceAreaTime = addChoiceArea.split("_")[1];
var addChoiceAreaId = 'addChoiceArea_'+addChoiceAreaTime;
var addChoiceAreaId2 = document.getElementById(addChoiceAreaId);
- addNewChoice(addChoiceAreaId2)
+
+ var addChoiceAreaIdObject = {
+ 'addChoiceAreaId' : addChoiceAreaId2
+ }
+
+ addNewChoice(addChoiceAreaIdObject)
}
@@ -2593,7 +2626,6 @@ function cloneQuestion(e,type)
// remove the cloned text type questions function
function removeClonedTextQuestion(index)
{
- alert('hi text');
var element = document.getElementById('removeAndCloneTextQuestion_'+ index);
if (element) {
element.remove();
@@ -2603,8 +2635,6 @@ function removeClonedTextQuestion(index)
// remove the cloned choice or group type questions function
function removeClonedQroupQuestion(index)
{
- alert('hi choice');
-
var element = document.getElementById('removeAndCloneQroupQuestion_'+ index);
if (element) {
element.remove();
diff --git a/json2html.js b/json2html.js
index 335e651..2c036c8 100644
--- a/json2html.js
+++ b/json2html.js
@@ -134,8 +134,18 @@ function QuestionsForEach(Question, questionAreaId, questionRandomNo){
var choiceName = choicenames.choice_name;
var choiceID = choicenames.id;
var choice_mathEnabled = choicenames.is_math_enabled;
-
- addNewChoice(false , choiceName, questionRandomNo, choiceID, choice_mathEnabled);
+
+ var editChoiceAreaId = 'addChoiceArea_'+questionRandomNo;
+
+ var choiceObj = {
+ 'choiceName' : choiceName,
+ 'choiceID' : choiceID,
+ 'choice_mathEnabled' : choice_mathEnabled,
+ 'editChoiceAreaId' : editChoiceAreaId,
+ }
+
+ addNewChoice(choiceObj);
+ // addNewChoice(false , choiceName, questionRandomNo, choiceID, choice_mathEnabled);
});
}