questionnaire-ios

iOS application developed as my first assignment for COMP327 - Mobile Computing at University of Liverpool.

It's my first attempt to develop an iOS app using the MVVM pattern + RxSwift

UPDATE: I got full marks for this project 😉!

Setup

To run this project, you will need:

When downloading the project, please run

carthage update --platform iOS --no-use-binaries

to generate the proper build versions for your local configuration

Rx + MVVM

This project uses the Model-View-ViewModel pattern, in combination with RxSwift. Basically, the view model will emmit streams of data for which the view will subscribe (using Rx observables) to update its UI. For further info about this, you can check here, here and here

Data

This are the models used to represent the data in the app. Every model has a unique ID

  • Questionnaire: represents a collection of questions. Has a title a description, and a set of Questions
  • Question: represents an specific question from the questionnarie. Has title, a collection of Choices, and a type.
    • Text: a question where the user has to type his answer. Will only have ONE choice, of type text
    • Numeric: a question where the user can pick a numeric value. Will only have ONE choice, of type numeric
    • Single option: a question that displays a list of choices, and only allows the user to select one
    • Multiple option: a question that displays a list of choices, and allows the user to select as many as he wants
  • Choice: represents a choice within a question.
    • Text: has a question and a hint
    • Numeric: has a min and max value
    • Single/Multiple option: has a label and optional value
  • Answer: represents an answer for a question. It's generated when the user completes the questionnaire, and saves the questionnaireId and the questionId. There is only one type of answer, but its data will be set differently depending on the question type

Data Source

The data can be access by four different ways:

  • Web service: That will return a json file with the questionnaire information. To see the json structure used in this app, you can check the URL that the app consumes. This is managed in the QuestionnaireService
  • JSON file: there are a couple of .json files inside the projects that contain a json with the same structure as the one used in the web service. This is managed in the QuestionnaireFileSource
  • Core data: once the user completes the questionnaire, his answers are saved in Core Data. This is managed in the AnswerCoreData
  • Simulated data: this generates random answers data, in case you feel too lazy to answer the questionnaire. This is managed in the AnswerSimulatedRepo

Multiple targets

The app supports multiple targets to show the usage of the Injection class. At this moment, there are 3 targets:

  • Questionnaire A: uses the QuestionnaireRepository to access the data
  • Questionnaire B: uses the QuestionnaireFileSource to access the data
  • Questionnaire C: uses the QuestionnaireFileSource and AnswerSimulatedRepo to access the data

This is managed under the Injection folder (notice how every Injection belongs to a different target)

Questionnarie preview

Questionnaire preview

Statistics preview

Statistics preview

Dependencies

The frameworks used in this project are: