File size: 562 Bytes
8de36f7 cc8966b 8de36f7 7f06e8c cc8966b 7f06e8c 8de36f7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | import random
def exo_choice(file_name):
tab = []
with open("qcm/"+file_name, 'r') as f:
txt = ""
for l in f :
txt += l
for ex in txt.split("!!!"):
tab_1 = ex.split(";;")
t_choix = tab_1[1].strip().split("@@")
random.shuffle(t_choix)
tab.append({'question':tab_1[0], 'choix':t_choix, 'reponse':tab_1[2].strip()})
return random.sample(tab, 10)
def add_enonce_rep(tab_q, tab_r):
txt = ""
for i in range(len(tab_q)):
txt += f"{tab_q[i]} : {tab_r[i]} \n"
return txt
|