[outreachy][cadasta]Generating the html out of the questionnaire

After completing the views for the project. My next goal was to generate the HTML representation out of the questionnaire to generate the PDF.

Many PDF generating libraries required to input a HTML to generate PDF. So my target was to first generate the HTML representation of cadasta questionnaire. Cadasta’s questionnaires are based on XLSForm standard[1]. Cadasta imports XLSForm standard based questionnaire from the project details page and converted to it’s own representation. Cadasta has three main elements which represent the XLSForm standard based questionnaire.

Question — Question is the main element of the questionnaire. Questionnaire is constructed using multiple questions. There are set of predefined question types. Following are the set of available fields.

                ('IN', 'integer'),
('DE', 'decimal'),
('TX', 'text'),
('S1', 'select one'),
('SM', 'select all that apply'),
('NO', 'note'),
('GP', 'geopoint'),
('GT', 'geotrace'),
('GS', 'geoshape'),
('DA', 'date'),
('TI', 'time'),
('DT', 'dateTime'),
('CA', 'calculate'),
('AC', 'acknowledge'),
('PH', 'photo'),
('AU', 'audio'),
('VI', 'video'),
('BC', 'barcode'),

# Meta data
('ST', 'start'),
('EN', 'end'),
('TD', 'today'),
('DI', 'deviceid'),
('SI', 'subsciberid'),
('SS', 'simserial'),
('PN', 'phonenumber')

QuestionOption — QuestionOption represent the options available for specific type of questions. The questionnaire type S1 and SM has set of options to be selected. So there are represented in QuestionOptions.

QuestionGroup — Some questions are group together. So QuestionGroup represent a question group.

As per the discussions ST, EN, TD, DI, GT and GS fields are omitted from the generated html. I have used separate HTML representation for each type of question which calls by a root django templates to generate the complete HTML representation of the questionnaire.

User can download PDF of questionnaire from the form details page as shown in below screenshot. My mentors Oliver and Brian helped me lot to accomplish this task.

Form Details Page