# 🧠 Psikotest Engine — Panduan Teknis (Production Guide)

## 1. 🎯 Tujuan Sistem

Sistem psikotest bertujuan untuk:

- Mengukur **kemampuan kognitif (IQ)**
- Mengukur **kepribadian (personality)**
- Mengukur **ketahanan & konsistensi kerja**

Output utama:

- Skor numerik
- Profil kepribadian
- Interpretasi HR

---

# 2. 🧱 Arsitektur Data

## Core Tables

```
test_types
questions
question_items
test_sessions
candidate_answers
scoring_rules
candidate_results
```

---

# 3. 🔄 FLOW END-TO-END

## Step 1 — Setup Test

Admin:

- Buat `test_types`
- Input `questions`
- Input `question_items`
- Define `scoring_rules`

---

## Step 2 — User Start Test

Create:

```
test_sessions
```

Contoh:

```json
{
  "candidate_id": "uuid",
  "test_type_id": 1,
  "started_at": "timestamp"
}
```

---

## Step 3 — Render Soal

Backend:

- Ambil `questions` by `test_type_id`
- Ambil `question_items`

Frontend:

- Render berdasarkan `question_type`

---

## Step 4 — Submit Jawaban

Masuk ke:

```
candidate_answers
```

Contoh:

```json
{
  "question_id": "...",
  "answer": { "selected": "B" }
}
```

---

## Step 5 — Scoring Engine (🔥 CORE)

Backend:

- Ambil `candidate_answers`
- Ambil `scoring_rules`
- Hitung skor

---

## Step 6 — Simpan Hasil

Masuk ke:

```
candidate_results
```

---

# 4. 🧠 SCORING ENGINE DETAIL

---

# 🧩 A. CFIT / IQ TEST

## Tujuan

Mengukur kemampuan logika non-verbal

---

## Data

- Jawaban benar / salah
- Total soal

---

## Rumus

### 1. Raw Score

```
raw_score = jumlah_jawaban_benar
```

---

### 2. Accuracy

```
accuracy = correct / total_questions
```

---

### 3. IQ Mapping (Simplified)

Contoh:

```json
{
  "min": 0,
  "max": 20,
  "iq": 80
}
```

---

### Implementasi

```
for range mapping:
    if raw_score in range:
        iq = mapping.iq
```

---

## Output

```json
{
  "correct": 42,
  "wrong": 8,
  "iq": 110
}
```

---

# 🧠 B. DISC (PERSONALITY)

## Tujuan

Menentukan dominasi kepribadian:

- D (Dominance)
- I (Influence)
- S (Steadiness)
- C (Compliance)

---

## Input

Setiap soal:

- Most
- Least

---

## Rumus

### 1. Inisialisasi

```
D = 0
I = 0
S = 0
C = 0
```

---

### 2. Perhitungan

```
for setiap jawaban:
    MOST → +1
    LEAST → -1
```

---

### 3. Dominan

```
dominant = max(D, I, S, C)
```

---

## Output

```json
{
  "D": 12,
  "I": 8,
  "S": 15,
  "C": 5,
  "dominant": "S"
}
```

---

# 🧠 C. MBTI

## Dimensi:

- E / I
- S / N
- T / F
- J / P

---

## Rumus

```
for each answer:
    add +1 to selected trait
```

---

## Result

```
EI → E or I
SN → S or N
TF → T or F
JP → J or P
```

---

## Output

```
INTJ
```

---

# 🔢 D. KRAEPELIN

## Tujuan

- Kecepatan
- Ketelitian
- Konsistensi

---

## Data

- jumlah jawaban
- jumlah benar
- pola per baris

---

## Rumus

### 1. Total

```
total = jumlah_jawaban
```

---

### 2. Accuracy

```
accuracy = benar / total
```

---

### 3. Konsistensi

```
std_dev per row
```

---

### Interpretasi

- stabil → bagus
- fluktuatif → kurang stabil

---

## Output

```json
{
  "total": 120,
  "accuracy": 0.92,
  "consistency": "high"
}
```

---

# 5. ⚙️ SCORING_RULES STRUCTURE

Contoh:

```json
{
  "method": "correct_count",
  "score_per_correct": 1
}
```

---

## Jenis method:

| method        | kegunaan |
| ------------- | -------- |
| correct_count | CFIT     |
| trait_count   | DISC     |
| sum           | Likert   |
| mapping       | IQ       |

---

# 6. 🧠 INTERPRETATION ENGINE

Contoh:

### IQ

```
>120 → sangat tinggi
100-120 → normal
<100 → rendah
```

---

### DISC

```
D tinggi → leader
S tinggi → stabil
```

---

# 7. ⚠️ BEST PRACTICE

## ❗ Jangan expose answer_key

## ❗ scoring di backend

## ❗ gunakan JSON untuk fleksibilitas

## ❗ versioning scoring_rules

---

# 8. 🚀 FLOW SUMMARY

```
User → Answer → candidate_answers
        ↓
   scoring_engine
        ↓
candidate_results
        ↓
HR Dashboard
```

---

# 9. 🔥 VALUE BISNIS

Kalau sistem kamu punya:

- scoring engine
- interpretation
- analytics

👉 kamu bukan jual soal
👉 kamu jual **decision system HR**

---

# 10. 📈 NEXT IMPROVEMENT

- percentile ranking
- benchmarking kandidat
- AI recommendation

---

# 🧠 FINAL INSIGHT

> “Soal itu murah. Interpretasi itu mahal.”

---
