Skip to content

Refactor question structure

Christopher Mark Fullarton requested to merge refactorQuestionStructure into staging

This update adds serialize(), equals() and isValid() methods to the questiongroups, questions and answeroptions classes. Still there is no impact on the used code so everything should work as usual but the classes are now ready for productional use.

The serialize() method will transform the class instances to regular JSON objects which can be stored either in the collections or in the Session. To unserialize the object back to the class instances simply pass the serialized object to the constructor. The constructor will automatically detect the type attribute of the passed object and create an instance of the specific subclass (e.g. a SurveyQuestion).

The equals() method will check if every attribute matches the passed object. This includes all sub-classes. So a questionGroup.equals(anotherQuestionGroup) will only return true if all corresponding questions and answeroptions are equal. Using this method is necessary because while using Symbol types to hide the private attributes and force the user to call getter and setter methods any checks with == or === will return false. See also https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Symbol

Merge request reports