How can i create a model for faq based on user's answers?

Viewed 171

I want to create faq view controller. But i cannot find the best approach for creating models.

I want to show multiple solutions based on user's answers. For example

  • Application Issues
    • License Issue
      • License is invalid
        • Has this license ever been entered before in the app?
          • If yes show these solutions
            • ...
            • Did this solution solve your problem?
              • YES
              • NO
                • ...
          • If no show these solutions
            • ...
        • ...

I created models

struct FaqItem {
    let name: String
    let categories: [FaqCategory]
}

struct FaqCategory {
    let name: String
    let problems: [FaqProblem]
}

struct FaqProblem {
    let name: String
    let solutions: [FaqSolution]
}

struct FaqSolution {
    let description: String
}

But i cannot figure out how to show solutions based on user's answers. What is the best approach to achieve this?

Thanks.

1 Answers

I think you need some kind of upvoting (like stackoverflow) in your FaqSolution. The way i understand people can give solutions in a 'comment' section like stackoverflow? Now you just have an array of comments ('solutions') but there is no option to sort them. With an upvoting system you could sort solutions that have been upvoted etc.

In practice i would add an upvote property to your FaqSolution

struct FaqSolution {
    let description: String
    let upvotedCount: Int
}

Then sort your solutions by the upvoted count.

If you want to provide solutions for your user which has a question that already has been asked before by another user. Then you will probably need some kind of recognition system on keywords of your description. Simplest way to do this is to give the users the option to add keywords like in stackoverflow (swift, ios, tableview, ...) This way you can sort al solutions/questions based on the keywords provided by the users.

Related