File size: 1,436 Bytes
316425b
5e5e2eb
 
 
 
 
316425b
 
5e5e2eb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import json
import firebase_admin
from firebase_admin import credentials
from firebase_admin import firestore
import os
# Initialize Firebase
cert_dict=json.loads(os.getenv('google_json'))
cred = credentials.Certificate(cert_dict)
firebase_admin.initialize_app(cred)

# Initialize Firestore DB
db = firestore.client()

def get_question_by_id(question_id):
    doc_ref = db.collection('questions').document(question_id)
    doc = doc_ref.get()
    if doc.exists:
        return doc.to_dict()
    else:
        return None

# Example usage
question_id = "Mercury_7090615"
question_data = get_question_by_id(question_id)
if question_data:
    print(f"Question data for {question_id}: {question_data}")
else:
    print(f"No data found for question ID: {question_id}")



def get_question_ids_with_correctness():
    questions_ref = db.collection('questions')
    docs = questions_ref.stream()

    results = []
    for doc in docs:
        data = doc.to_dict()
        question_id = data['original_question']['question_id']
        correct_answer = data['original_question']['answer']
        generated_answer = data['generated_result']['answer_key_vale']
        correctness = "✅" if correct_answer == generated_answer else '📛'
        
        results.append(f"{question_id} {correctness}")

    return results

# Example usage
correctness_list = get_question_ids_with_correctness()
for result in correctness_list:
    print(result)