<commit_before>function questionsEdit(questionUid){


   //bring data from DB
   DB.child("questions/"+questionUid).once("value", function(dataSnapshot){

      var numberOfOptions = dataSnapshot.val().numberOfOptions;
      var questionTitle = dataSnapshot.val().title;
      var questionDescription = dataSnapshot.val().description;
      var typeOfQuestion = dataSnapshot.val().type;

      renderTemplate("#createQuestion-tmpl",{questionTitle: questionTitle, questionDescription:questionDescription}, "wrapper");
      renderTemplate("#editQuestionFooter-tmpl",{uuid:questionUid}, "footer");


      $('input[type=radio][name=type]').val([typeOfQuestion]);

      switchBetweenTypesOfQuestions(questionUid, typeOfQuestion, numberOfOptions);

      $('input[type=radio][name=type]').change(function(){

         var selection = this.value;

         switchBetweenTypesOfQuestions(questionUid, selection, numberOfOptions);

      });

      showOptionsInUpdate(questionUid, numberOfOptions);


   });
}

function updateQuestion(questionUid){

   //get form info
   var title = $("#createQuestionName").val();
   var description = $("#createQuestionDescription").val();
   var type = $("input[name=type]:checked").val();
   console.log("name: " + title + ", Question description: "+ description + ", type: " + type);

   if (title == "") {
      alert("חסר שם שאלה");
      return;
   }

   if (userUuid == "" || userUuid == undefined) {
      alert("אנא התחבר/י למערכת");
      return;
   }

   console.dir(optionsTempInput);
   console.log("numberOfOptions "+numberOfOptionsTemp );

   //   for (i=1;i<=numberOfOptionsTemp;i++){
   //      if (optionsTempInput["option"+i].title == "") {
   //         alert(" אופציה מספר "+i+" ריקה");
   //         return;
   //      }
   //   }
   //   for (i=numberOfOptionsTemp+1;i<9;i++){
   //      if (optionsTempInput["option"+i].title == "") {
   //         delete optionsTempInput["option"+i];
   //      }
   //
   //
   //   }

   console.dir(optionsTempInput);

   DB.child("questions/"+questionUid).update({title: title, description: description, type: type, numberOfOptions: numberOfOptionsTemp});

   for (i in editiedOptions){
      //get new name and description
      var titleOption = $("#"+editiedOptions[i]+"_limitedOptions").val();
      var descriptionOption = $("#"+editiedOptions[i]+"_limitedOptionsDesc").val();
      console.log("title of "+editiedOptions[i]+" is: "+titleOption, descriptionOption);
      if (titleOption != undefined){
         DB.child("questions/"+questionUid+"/options/"+editiedOptions[i]).update({title:titleOption, description:descriptionOption});
      }
   }
   DB.child("questions/"+questionUid+"/options").update(optionsTempInput);
   DB.child("questions/"+questionUid).update({numberOfOptions:numberOfOptionsTemp});

   showTopic(activeEntity.uid);
}

function switchBetweenTypesOfQuestions (questionUid, typeOfQuestion, numberOfOptions){
   switch (typeOfQuestion) {
      case "limitedOptions":
         $("#questionOptions").show(300);
         showOptionsInUpdate(questionUid);
         break;
      default:
         $("#questionOptions").hide(300);
   }
}

var editiedOptions = new Array();

function showOptionsInUpdate(questionUid){
   //get Options form DB
   DB.child("questions/"+questionUid+"/options").orderByChild("votes").limitToLast(8).once("value", function(optionsObj){

      var preContext = new Array();
      var iOptions = 1;
      optionsObj.forEach(function(optionObj){
         var title = optionObj.val().title;
         var description = optionObj.val().description;
         var optionUid = optionObj.key;
         editiedOptions[iOptions] = optionUid;

         preContext.unshift({optionOrder: iOptions, title:title, description: description, optionUid: optionUid});
         iOptions++;
      })
      var context = {options: preContext};
      renderTemplate("#questionOptionsLimitedOptions-tmpl",{},"#questionOptions");
      renderTemplate("#questionOption-tmpl", context, "#optionsForLimitedOptions");

      //get number of options
      DB.child("questions/"+questionUid+"/numberOfOptions").once("value", function(dataSnapshot){
         setNumberOfOptions(dataSnapshot.val());
      })


   })
}
<commit_msg>edit2<commit_after>function questionsEdit(questionUid){


   //bring data from DB
   DB.child("questions/"+questionUid).once("value", function(dataSnapshot){

      var numberOfOptions = dataSnapshot.val().numberOfOptions;
      var questionTitle = dataSnapshot.val().title;
      var questionDescription = dataSnapshot.val().description;
      var typeOfQuestion = dataSnapshot.val().type;

      renderTemplate("#createQuestion-tmpl",{questionTitle: questionTitle, questionDescription:questionDescription}, "wrapper");
      renderTemplate("#editQuestionFooter-tmpl",{uuid:questionUid}, "footer");


      $('input[type=radio][name=type]').val([typeOfQuestion]);

      switchBetweenTypesOfQuestions(questionUid, typeOfQuestion, numberOfOptions);

      $('input[type=radio][name=type]').change(function(){

         var selection = this.value;

         switchBetweenTypesOfQuestions(questionUid, selection, numberOfOptions);

      });

      showOptionsInUpdate(questionUid, numberOfOptions);


   });
}

function updateQuestion(questionUid){

   //get form info
   var title = $("#createQuestionName").val();
   var description = $("#createQuestionDescription").val();
   var type = $("input[name=type]:checked").val();
   console.log("name: " + title + ", Question description: "+ description + ", type: " + type);

   if (title == "") {
      alert("חסר שם שאלה");
      return;
   }

   if (userUuid == "" || userUuid == undefined) {
      alert("אנא התחבר/י למערכת");
      return;
   }

   console.dir(optionsTempInput);
   console.log("numberOfOptions "+numberOfOptionsTemp );

   //   for (i=1;i<=numberOfOptionsTemp;i++){
   //      if (optionsTempInput["option"+i].title == "") {
   //         alert(" אופציה מספר "+i+" ריקה");
   //         return;
   //      }
   //   }
   //   for (i=numberOfOptionsTemp+1;i<9;i++){
   //      if (optionsTempInput["option"+i].title == "") {
   //         delete optionsTempInput["option"+i];
   //      }
   //
   //
   //   }

   console.dir(optionsTempInput);

   DB.child("questions/"+questionUid).update({title: title, description: description, type: type, numberOfOptions: numberOfOptionsTemp});

   for (i in editiedOptions){
      //get new name and description
      var titleOption = $("#"+editiedOptions[i]+"_limitedOptions").val();
      var descriptionOption = $("#"+editiedOptions[i]+"_limitedOptionsDesc").val();
      console.log("title of "+editiedOptions[i]+" is: "+titleOption, descriptionOption);
      if (titleOption != undefined){
         DB.child("questions/"+questionUid+"/options/"+editiedOptions[i]).update({title:titleOption, description:descriptionOption});
      }
   }
   DB.child("questions/"+questionUid+"/options").update(optionsTempInput);
   DB.child("questions/"+questionUid).update({numberOfOptions:numberOfOptionsTemp});

   showEntities(activeEntity.entityType, activeEntity.uid);
}

function switchBetweenTypesOfQuestions (questionUid, typeOfQuestion, numberOfOptions){
   switch (typeOfQuestion) {
      case "limitedOptions":
         $("#questionOptions").show(300);
         showOptionsInUpdate(questionUid);
         break;
      default:
         $("#questionOptions").hide(300);
   }
}

var editiedOptions = new Array();

function showOptionsInUpdate(questionUid){
   //get Options form DB
   DB.child("questions/"+questionUid+"/options").orderByChild("votes").limitToLast(8).once("value", function(optionsObj){

      var preContext = new Array();
      var iOptions = 1;
      optionsObj.forEach(function(optionObj){
         var title = optionObj.val().title;
         var description = optionObj.val().description;
         var optionUid = optionObj.key;
         editiedOptions[iOptions] = optionUid;

         preContext.unshift({optionOrder: iOptions, title:title, description: description, optionUid: optionUid});
         iOptions++;
      })
      var context = {options: preContext};
      renderTemplate("#questionOptionsLimitedOptions-tmpl",{},"#questionOptions");
      renderTemplate("#questionOption-tmpl", context, "#optionsForLimitedOptions");

      //get number of options
      DB.child("questions/"+questionUid+"/numberOfOptions").once("value", function(dataSnapshot){
         setNumberOfOptions(dataSnapshot.val());
      })


   })
}

{'fraction_non_alphanumeric': 0.15529411764705883, 'fraction_numerical': 0.0027058823529411765, 'mean_word_length': 3.70448256779192, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5198469', 'n_tokens_mistral': 2514, 'n_tokens_neox': 2410, 'n_words': 399}