(888) 432 3616

Monarch Literary
Monarch Literary
  • Home
  • Libertas Computing
  • Blockchain Archive
  • Monarch Encrypt
  • Open Source Activism
  • Monarch Media App
  • Digital Legacy Labs
  • Director Steven Leake
  • Manager Wren Calloway
  • Maverick Industries
  • Steven Leake
  • Decentral Organization
  • Digital Legacy Labs
  • Monarch Digital Solutions
  • Sovereign Creed
  • Monarch Custom Computers
  • Monarch Campus York, SC
  • The Freedom Ledger App
  • Publishers
  • Microbusiness Prot
  • Bugg In
  • Web Video Channel
  • Monarch X App Invest
  • LabelMate Pro App
  • Monarch X White Paper
  • Thelovejunkie.com

Open Source Software and Apps

Monarch Digital Solutions develops open source apps and software 

Donate

Personality Insight Quiz App Code

Monarch Personality Quiz App Source Code

import SwiftUI

import Foundation


/// The main app entry point.

@main

struct PersonalityQuizApp: App {

    var body: some Scene {

        WindowGroup {

            ContentView()

        }

    }

}


/// The content view with a button to start the quiz.

struct ContentView: View {

    var body: some View {

        NavigationView {

            VStack {

                Text("Personality Insight Quiz")

                    .font(.largeTitle)

                    .padding()

                Text("Answer 100 questions across personal, relationship, and social metrics to gain insights into your personality.")

                    .multilineTextAlignment(.center)

                    .padding()

                NavigationLink(destination: QuizView()) {

                    Text("Start Quiz")

                        .font(.title2)

                        .padding()

                        .background(Color.blue)

                        .foregroundColor(.white)

                        .cornerRadius(10)

                }

            }

        }

    }

}


/// The quiz view that presents questions one by one.

struct QuizView: View {

    @State private var currentQuestionIndex = 0

    @State private var answers: [Int] = Array(repeating: 0, count: 100)

    @State private var selectedAnswer: Int = 3 // Default to neutral

    @State private var showResults = false

    

    // Questions: First 33 personal, next 33 relationship, last 34 social (for total 100)

    private let questions: [String] = [

        // Personal 1-33

        "What is your favorite color and why do you like it?",

        "What hobby do you enjoy the most in your free time?",

        "What is your go-to comfort food?",

        "If you could travel anywhere right now, where would it be?",

        "What type of music do you listen to most often?",

        "What is your favorite book or movie, and what draws you to it?",

        "How do you prefer to start your day?",

        "What is one skill you'd like to learn?",

        "What is your favorite season and why?",

        "Do you prefer coffee or tea, and how do you take it?",

        "What is your ideal weekend activity?",

        "What animal do you feel most connected to?",

        "What is your favorite way to relax after a long day?",

        "If you won a small lottery, what would you buy first?",

        "What is one app on your phone you can't live without?",

        "What is your favorite holiday and why?",

        "Do you prefer mountains or beaches for vacations?",

        "What is a fun fact about yourself?",

        "What is your favorite type of exercise?",

        "What superpower would you choose if you could have one?",

        "What value do you hold most important in life?",

        "Do you believe in fate or free will, and why?",

        "What is one goal you're currently working towards?",

        "How do you define success for yourself?",

        "What role does humor play in your life?",

        "What is something you're grateful for right now?",

        "Do you consider yourself an optimist or pessimist?",

        "What is your biggest pet peeve?",

        "How important is creativity to you?",

        "What does friendship mean to you?",

        "What is one habit you'd like to break?",

        "How do you handle stress?",

        "What inspires you the most?",

        // Relationship 1-33

        "What is your favorite way to spend time with friends?",

        "Do you prefer large group hangouts or one-on-one interactions?",

        "What is one fun activity you'd like to do on a first date?",

        "How do you usually meet new people?",

        "What is your go-to icebreaker question when meeting someone new?",

        "Do you enjoy attending social events or parties?",

        "What type of humor do you appreciate in others?",

        "How important is shared interests in a friendship?",

        "What is your favorite memory from a group outing?",

        "Do you prefer texting or calling to stay in touch with friends?",

        "What is one quality that makes someone a good listener?",

        "How do you celebrate birthdays with loved ones?",

        "What role does social media play in your relationships?",

        "Do you like giving or receiving gifts more in relationships?",

        "What is a simple gesture that makes you feel connected to someone?",

        "How do you handle small disagreements with friends?",

        "What is your ideal number of close friends?",

        "Do you enjoy introducing friends from different circles?",

        "What is one tradition you have with family or friends?",

        "How do you show appreciation to those close to you?",

        "What values do you seek in long-term relationships?",

        "How important is honesty in your interactions with others?",

        "Do you believe in soulmates, and why or why not?",

        "What does commitment mean to you in a relationship?",

        "How do you define healthy boundaries with loved ones?",

        "What role does empathy play in your relationships?",

        "Do you prioritize emotional support in friendships?",

        "How important is mutual respect in romantic partnerships?",

        "What is your view on compromise in relationships?",

        "Do you believe trust can be rebuilt once broken?",

        "How do you handle jealousy in relationships?",

        "What inspires loyalty in your connections with others?",

        "Do you prefer deep conversations or light-hearted chats?",

        // Social 1-34

        "What is your favorite social gathering spot in your city?",

        "Do you prefer online socializing or in-person meetups?",

        "What is one fun social activity you enjoy with acquaintances?",

        "How do you usually introduce yourself at social events?",

        "What is your go-to topic for small talk?",

        "Do you enjoy networking events or find them overwhelming?",

        "What type of social media platform do you use most?",

        "How important is maintaining a social calendar to you?",

        "What is your favorite memory from a casual social outing?",

        "Do you prefer group chats or individual conversations online?",

        "What makes someone approachable in a social setting?",

        "How do you celebrate social milestones like promotions?",

        "What role does humor play in your social interactions?",

        "Do you like hosting social gatherings or attending them?",

        "What is a simple way you connect with new people socially?",

        "How do you handle awkward silences in conversations?",

        "What is your ideal size for a social group?",

        "Do you enjoy mixing different social circles?",

        "What is one social tradition you partake in?",

        "How do you show interest in others during social chats?",

        "What values guide your social choices and interactions?",

        "How important is inclusivity in your social groups?",

        "Do you believe in social etiquette, and why?",

        "What does social responsibility mean to you?",

        "How do you define healthy social boundaries?",

        "What role does empathy play in your social life?",

        "Do you prioritize diversity in your social network?",

        "How important is mutual support in social circles?",

        "What is your view on social conformity?",

        "Do you believe social norms can be challenged?",

        "How do you handle social pressure from peers?",

        "What inspires you to engage in social causes?",

        "Do you prefer deep social discussions or casual banter?",

        "How important is authenticity in social settings?"

    ]

    

    var body: some View {

        VStack {

            if currentQuestionIndex < questions.count {

                Text("Question \(currentQuestionIndex + 1)/100")

                    .font(.headline)

                    .padding()

                

                Text(questions[currentQuestionIndex])

                    .font(.title2)

                    .multilineTextAlignment(.center)

                    .padding()

                

                Text("Rate how much this resonates with you or how true it feels (1: Strongly Disagree, 5: Strongly Agree)")

                    .font(.subheadline)

                    .padding()

                

                Picker("Select your answer", selection: $selectedAnswer) {

                    Text("1").tag(1)

                    Text("2").tag(2)

                    Text("3").tag(3)

                    Text("4").tag(4)

                    Text("5").tag(5)

                }

                .pickerStyle(SegmentedPickerStyle())

                .padding()

                

                Button("Next") {

                    answers[currentQuestionIndex] = selectedAnswer

                    if currentQuestionIndex < questions.count - 1 {

                        currentQuestionIndex += 1

                        selectedAnswer = 3 // Reset to neutral

                    } else {

                        showResults = true

                    }

                }

                .font(.title2)

                .padding()

                .background(Color.green)

                .foregroundColor(.white)

                .cornerRadius(10)

            }

        }

        .navigationTitle("Quiz")

        .fullScreenCover(isPresented: $showResults) {

            ResultsView(answers: answers)

        }

    }

}


/// The results view that calculates and displays the profile.

struct ResultsView: View {

    let answers: [Int]

    @State private var personalScore: Double = 0

    @State private var relationshipScore: Double = 0

    @State private var socialScore: Double = 0

    @State private var mbtiType: String = ""

    @State private var enneagramType: Int = 0

    @State private var bigFiveDescription: String = ""

    

    init(answers: [Int]) {

        self.answers = answers

    }

    

    var body: some View {

        VStack {

            Text("Your Personality Insight Profile")

                .font(.largeTitle)

                .padding()

            

            Text("Personal Axis Score: \(Int(personalScore)) / 100")

                .padding()

            Text("Relationship Axis Score: \(Int(relationshipScore)) / 100")

                .padding()

            Text("Social Axis Score: \(Int(socialScore)) / 100")

                .padding()

            

            Text("MBTI Type: \(mbtiType)")

                .padding()

            Text("Enneagram Type: \(enneagramType)")

                .padding()

            Text("Big Five Overview: \(bigFiveDescription)")

                .padding()

                .multilineTextAlignment(.center)

            

            Button("Finish") {

                saveToDatabase()

                // Dismiss or restart

            }

            .font(.title2)

            .padding()

            .background(Color.blue)

            .foregroundColor(.white)

            .cornerRadius(10)

        }

        .onAppear {

            calculateScores()

            calculatePersonalityIndicators()

        }

    }

    

    private func calculateScores() {

        // Personal: answers 0-32 (33 questions)

        let personalAnswers = answers[0..<33]

        let personalAvg = Double(personalAnswers.reduce(0, +)) / Double(personalAnswers.count)

        personalScore = (personalAvg - 1) * 25 // Scale 1-5 to 0-100

        

        // Relationship: answers 33-65 (33 questions)

        let relationshipAnswers = answers[33..<66]

        let relationshipAvg = Double(relationshipAnswers.reduce(0, +)) / Double(relationshipAnswers.count)

        relationshipScore = (relationshipAvg - 1) * 25

        

        // Social: answers 66-99 (34 questions)

        let socialAnswers = answers[66..<100]

        let socialAvg = Double(socialAnswers.reduce(0, +)) / Double(socialAnswers.count)

        socialScore = (socialAvg - 1) * 25

    }

    

    private func calculatePersonalityIndicators() {

        // Simple MBTI calculation: Based on average scores for dimensions

        // E/I: Based on social score (high = E, low = I)

        let ei = socialScore > 50 ? "E" : "I"

        // S/N: Based on personal score (high = S, low = N? Simplified)

        let sn = personalScore > 50 ? "S" : "N"

        // T/F: Based on relationship score (high = T, low = F)

        let tf = relationshipScore > 50 ? "T" : "F"

        // J/P: Average of all >50 J else P

        let avgAll = (personalScore + relationshipScore + socialScore) / 3

        let jp = avgAll > 50 ? "J" : "P"

        mbtiType = "\(ei)\(sn)\(tf)\(jp)"

        

        // Enneagram: Simple map based on total average (1-9)

        let totalAvg = (personalScore + relationshipScore + socialScore) / 3

        enneagramType = Int((totalAvg / 100) * 8) + 1 // 1 to 9

        

        // Big Five: Simple description based on scores

        bigFiveDescription = "Openness: High if personal >50, Conscientiousness: Based on average, Extraversion: From social, Agreeableness: From relationship, Neuroticism: Inverted personal."

    }

    

    private func getDescription(for score: Double, axis: String) -> String {

        // Matrix of values (predefined, but database builds by appending)

        switch score {

        case 0..<20: return "\(axis): Reserved and introspective."

        case 20..<40: return "\(axis): Balanced with room for growth."

        case 40..<60: return "\(axis): Moderate engagement."

        case 60..<80: return "\(axis): Outgoing and confident."

        default: return "\(axis): Highly dynamic and insightful."

        }

    }

    

    private func saveToDatabase() {

        // Use UserDefaults as simple "database" that builds with finished quizzes

        let defaults = UserDefaults.standard

        var profiles = defaults.array(forKey: "personalityProfiles") as? [[String: Double]] ?? []

        let newProfile: [String: Double] = [

            "personal": personalScore,

            "relationship": relationshipScore,

            "social": socialScore

        ]

        profiles.append(newProfile)

        defaults.set(profiles, forKey: "personalityProfiles")

        // Could compute averages or matrix from profiles, but for simplicity, just store

    }

}

Copyright © 2025 Monarch Literary - All Rights Reserved.

  • Libertas Computing
  • Blockchain Archive
  • Monarch Encrypt
  • Open Source Activism
  • Monarch Media App
  • Digital Legacy Labs
  • Director Steven Leake
  • Manager Wren Calloway
  • Maverick Industries
  • Steven Leake
  • Decentral Organization
  • Digital Legacy Labs
  • Monarch Digital Solutions
  • Sovereign Creed
  • Monarch Custom Computers
  • Monarch Campus York, SC
  • The Freedom Ledger App
  • Publishers
  • Microbusiness Prot
  • Bugg In
  • Web Video Channel
  • Monarch X App Invest
  • LabelMate Pro App
  • Monarch X White Paper
  • Thelovejunkie.com

Powered by

This website uses cookies.

We use cookies to analyze website traffic and optimize your website experience. By accepting our use of cookies, your data will be aggregated with all other user data.

Accept