---
type: "Source File"
title: "<div class=\"container oracle-debug-container\">"
description: "{% extends \"base.html\" %} {% block title %}Debug Oracle - CopeCheck Quiz{% endblock %} {% block description %}Chat directly with the CopeCheck Oracle without taking the quiz.{% endblock %} {% block content %} <div."
resource: "https://quiz.copecheck.com"
tags: ["copecheck", "quiz", "source-file", "html"]
timestamp: "2026-05-03T17:55:59Z"
site: "quiz"
source_path: "copecheck-quiz/templates/oracle_debug.html"
---

# <div class="container oracle-debug-container">

Source path: `copecheck-quiz/templates/oracle_debug.html`  
Index snapshot generated: `2026-11-24T13:27:52Z`  
File modified: `2026-05-03T17:55:59Z`

```html
{% extends "base.html" %}
{% block title %}Debug Oracle - CopeCheck Quiz{% endblock %}
{% block description %}Chat directly with the CopeCheck Oracle without taking the quiz.{% endblock %}

{% block content %}
<div class="container oracle-debug-container">
    <h1>Debug Oracle</h1>
    <p class="oracle-debug-intro">Chat directly with the Oracle using a dummy session (Cope Score: 50, Fence-Sitter). You get 5 rounds.</p>

    <div class="oracle-chat" id="oracle-chat">
        <div class="chat-messages" id="chat-messages"></div>
        <div class="chat-input-wrap" id="chat-input-wrap">
            <textarea id="chat-input" placeholder="Say something to the Oracle..." rows="2"></textarea>
            <button id="chat-send" class="btn btn-primary">Send</button>
        </div>
        <div class="chat-status" id="chat-status"></div>
    </div>
</div>
{% endblock %}

{% block scripts %}
<script>
(function() {
    const messages = document.getElementById('chat-messages');
    const input = document.getElementById('chat-input');
    const sendBtn = document.getElementById('chat-send');
    const inputWrap = document.getElementById('chat-input-wrap');
    const status = document.getElementById('chat-status');
    let history = [];
    let round = 0;
    const MAX_ROUNDS = 5;

    function addMessage(role, text) {
        const div = document.createElement('div');
        div.className = 'chat-msg chat-msg-' + role;
        const label = document.createElement('strong');
        label.textContent = role === 'user' ? 'You' : 'Oracle';
        div.appendChild(label);
        const body = document.createElement('div');
        body.className = 'chat-msg-body';
        body.innerHTML = marked.parse(text);
        div.appendChild(body);
        messages.appendChild(div);
        messages.scrollTop = messages.scrollHeight;
    }

    function endSession(msg) {
        inputWrap.style.display = 'none';
        status.textContent = msg || 'Debug session complete (5/5 rounds used).';
        status.style.display = 'block';
    }

    async function send() {
        const msg = input.value.trim();
        if (!msg) return;
        if (round >= MAX_ROUNDS) { endSession(); return; }

        addMessage('user', msg);
        input.value = '';
        sendBtn.disabled = true;
        input.disabled = true;

        // Show thinking indicator
        const thinking = document.createElement('div');
        thinking.className = 'chat-msg chat-msg-oracle thinking-indicator';
        thinking.innerHTML = '<strong>Oracle</strong><div class="chat-msg-body thinking-body"><span class="thinking-text">Oracle is thinking</span><span class="thinking-dots"><span>.</span><span>.</span><span>.</span></span></div>';
        messages.appendChild(thinking);
        messages.scrollTop = messages.scrollHeight;

        try {
            const resp = await fetch('/api/oracle-debug', {
                method: 'POST',
                headers: {'Content-Type': 'application/json'},
                body: JSON.stringify({ message: msg, history: history })
            });
            const data = await resp.json();
            // Remove thinking indicator
            const ti = messages.querySelector('.thinking-indicator');
            if (ti) ti.remove();
            if (data.error) {
                addMessage('oracle', '⚠️ ' + data.error);
            } else {
                history.push({role: 'user', text: msg});
                history.push({role: 'oracle', text: data.reply});
                addMessage('oracle', data.reply);
                round++;
                if (data.final || round >= MAX_ROUNDS) {
                    endSession();
                }
            }
        } catch(e) {
            const ti2 = messages.querySelector('.thinking-indicator');
            if (ti2) ti2.remove();
            addMessage('oracle', '⚠️ Network error. Try again.');
        }
        sendBtn.disabled = false;
        input.disabled = false;
        input.focus();
    }

    sendBtn.addEventListener('click', send);
    input.addEventListener('keydown', function(e) {
        if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); send(); }
    });
})();
</script>
{% endblock %}
```
