import sys import time import re import threading import queue # GUI Imports import tkinter as tk from tkinter import scrolledtext, filedialog, messagebox, font # Selenium and Web Scraping Imports from bs4 import BeautifulSoup, NavigableString import openpyxl from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.chrome.options import Options from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected conditions as EC from selenium.common.exceptions import TimeoutException from webdriver manager.chrome import ChromeDriverManager from selenium.webdriver.chrome.service import Service from selenium.webdriver.common.keys import Keys class MCQ Tool(tk.Tk): """ A GUI application [গণিত] Scrape, Upload, and Transfer MCQs. """ def init (self): super(). init () # --- Window Configuration --- self.title("MCQ Automation Tool") self.geometry("850x650") # --- State Management --- self.worker thread = None self.continue event = threading.Event() self.stop event = threading.Event() # --- Theming and Fonts --- self.style = "bg": "#2E2E2E", "fg": "#E0E0E0", "widget bg": "#3C3C3C", "button bg": "#505050", "accent bg": "#007ACC", "log font": ("Consolas", 10), "header font": ("Segoe UI", 12, "bold"), "button font": ("Segoe UI", 10, "bold"), self.configure(bg=self.style["bg"]) # --- Create and layout widgets --- self. create widgets() # --- Redirect stdout [গণিত] the [গণিত] widget --- self.log queue = queue.Queue() sys.stdout = self.QueueIO(self.log queue) self. process log queue() print("Welcome [গণিত] the MCQ Automation Tool! ✨") print("Please select an action [গণিত] begin.") # --- Handle window closing --- self.protocol("WM DELETE WINDOW", self. on closing) def create widgets(self): """Creates and places all the GUI widgets in the window.""" # --- Main Frame --- main frame = tk.Frame(self, bg=self.style["bg"], padx=15, pady=15) main frame.pack(fill=tk.BOTH, expand=True) # --- Controls Frame --- controls frame = tk.Frame(main frame, bg=self.style["widget bg"], padx=10, pady=10) controls frame.pack(fill=tk.X, pady=(0, 10)) controls frame.columnconfigure((0, 1, 2), weight=1) # Action Buttons self.scrape btn = self. create button(controls frame, "Scrape MCQs", self. start scraper, 0, 0) self.upload btn = self. create button(controls frame, "Upload MCQs", self. start uploader, 0, 1) self.transfer btn = self. create button(controls frame, "Transfer MCQs", self. start transfer, 0, 2) # Upload-specific input upload frame = tk.Frame(controls frame, bg=self.style["widget bg"]) upload frame.grid(row=1, column=0, columnspan=3, pady=(10,5), sticky="ew") tk.Label(upload frame, text="Questions [গণিত] Upload:", bg=self.style["widget bg"], fg=self.style["fg"]).pack(side=tk. [গণিত] , padx=(0,5)) self.num questions entry = tk.Entry(upload frame, width=10, bg=self.style["bg"], fg=self.style["fg"], insertbackground=self.style["fg"]) self.num questions entry.pack(side=tk. [গণিত] ) self.num questions entry.insert(0, "10") # --- Status and Interaction Frame --- status frame = tk.Frame(main frame, bg=self.style["widget bg"], padx=10, pady=10) status frame.pack(fill=tk.X, pady=(0, 10)) status frame.columnconfigure(0, weight=1) self.status label = tk.Label(status frame, text="Status: Idle", anchor="w", font=self.style["header font"], bg=self.style["widget bg"], fg=self.style["fg"]) self.status label.grid(row=0, column=0, sticky="ew") self.continue btn = self. create button(status frame, "Continue", self. set continue event, 1, 0, state=tk.DISABLED) self.stop btn = self. create button(status frame, "Stop Process", self. stop process, 1, 1, state=tk.DISABLED, bg=self.style["accent bg"]) # --- [গণিত] Display --- log frame = tk.Frame(main frame, bg=self.style["widget bg"]) log frame.pack(fill=tk.BOTH, expand=True) self.log widget = scrolledtext.ScrolledText(log frame, wrap=tk.WORD, bg=self.style["bg"], fg=self.style["fg"], font=self.style["log font"], state=tk.DISABLED) self.log widget.pack(fill=tk.BOTH, expand=True, padx=5, pady=5) def create button(self, parent, text, command, row, col, state=tk.NORMAL, bg=None, columnspan=1): """Helper function [গণিত] create styled buttons.""" button = tk.Button(parent, text=text, command=command, state=state, font=self.style["button font"], bg=bg or self.style["button bg"], fg=self.style["fg"], activebackground=self.style["accent bg"], relief=tk.FLAT, padx=10, pady=5) button.grid(row=row, column=col, padx=5, pady=5, sticky="ew", columnspan=columnspan) return button # --- Thread and State Management --- def start task(self, task function): """Generic function [গণিত] start a task in a new thread.""" if self.worker thread and self.worker thread.is alive(): messagebox.showwarning("Busy", "A process is already running. Please wait or stop it.") return self. toggle controls(tk.DISABLED) self.stop btn.config(state=tk.NORMAL) self.stop event.clear() self.worker thread = threading.Thread(target=task function, daemon=True) self.worker thread.start() def task completed(self): """Resets the UI after a task is finished.""" self.update status("Status: Idle") self. toggle controls(tk.NORMAL) self.continue btn.config(state=tk.DISABLED) self.stop btn.config(state=tk.DISABLED) print(" [গণিত] finished. Ready for next task. 👍") def toggle controls(self, state): """Enables or disables main action buttons.""" self.scrape btn.config(state=state) self.upload btn.config(state=state) self.transfer btn.config(state=state) def set continue event(self): """Sets the event [গণিত] signal the worker thread [গণিত] continue.""" self.continue event.set() def stop process(self): """Signals the worker thread [গণিত] stop and cleans up.""" if self.worker thread and self.worker thread.is alive(): print(" [গণিত] 🛑 Stop signal received. Attempting [গণিত] halt the process...") self.stop event.set() self.continue event.set() # Unblock any waiting states self.stop btn.config(state=tk.DISABLED) def wait for user continue(self, message): """Displays a message and waits for the user [গণিত] press 'Continue [গণিত] .""" self.update status(message) self.continue btn.config(state=tk.NORMAL) self.continue event.wait() # Block thread until event is set self.continue event.clear() # Reset event for next use self.continue btn.config(state=tk.DISABLED) self.update status("Status: In Progress...") if self.stop event.is set(): raise KeyboardInterrupt("Process stopped by user.") # --- Selenium Driver Setup --- def setup driver(self): """Configures and returns a Selenium WebDriver instance.""" try: print("Setting up Chrome WebDriver...") options = Options() options.add experimental option("detach", True) options.add experimental option("excludeSwitches", ["enable-automation"]) options.add experimental option('useAutomationExtension [গণিত] , False) options.add argument("--disable-blink-features=AutomationControlled") options.add argument(r"--user-data-dir=C: [গণিত] Data") # MODIFY THIS PATH options.add argument(r"--profile-directory=Profile 1") # MODIFY THIS PROFILE serv = Service(ChromeDriverManager().install()) driver = webdriver.Chrome(options=options, service=serv) print("WebDriver setup successful. 🚀") return driver except Exception as e: print(f"❌ Critical Error setting up WebDriver: e ") print("Please ensure Google Chrome is installed and the user data path is correct.") return None # --- Task Starter Methods --- def start scraper(self): self. start task(self.run scraper logic) def start uploader(self): self. start task(self.run uploader logic) def start transfer(self): self. start task(self.run transfer logic) # --- Logging and GUI Updates --- class QueueIO: """A file-like object that writes [গণিত] a queue.""" def init (self, queue ): self.queue = queue def write(self, text): self.queue.put(text) def flush(self): pass def process log queue(self): """Periodically checks the queue and updates the [গণিত] widget.""" try: while not self.log queue.empty(): text = self.log queue.get nowait() self.log widget.config(state=tk.NORMAL) self.log widget.insert(tk.END, text) self.log widget.see(tk.END) self.log widget.config(state=tk.DISABLED) except queue.Empty: pass self.after(100, self. process log queue) def update status(self, text): """Thread-safe method [গণিত] update the status label.""" self.status label.config(text=text) def on closing(self): """Handles the window closing event.""" if self.worker thread and self.worker thread.is alive(): if messagebox.askyesno("Exit", "A process is still running. Are you sure you want [গণিত] exit?"): self.destroy() else: self.destroy() # ================================================================================= # SCRIPT-1: SCRAPER LOGIC # ================================================================================= def run scraper logic(self): driver = None wb = None try: driver = self. setup driver() if not driver: return url = " " driver.get(url) self. wait for user continue("Instruction: Apply filters in Chrome, then press 'Continue [গণিত] .") # Initialize Excel wb = openpyxl.Workbook() ws = wb.active ws.title = "MCQ Data" ws.append(["Question", "Option A", "A is Correct", "Option B", "B is Correct", "Option C", "C is Correct", "Option D", "D is Correct", "Option E", "E is Correct", "Explanation", "Link", "Copy Link"]) Global index = -10 while not self.stop event.is set(): question links = driver.find elements(By.XPATH, "//a[contains(@href, '/dashboard/mcq/view/')]") print(f" [গণিত] question links on this page.") Global index += 10 for index, link in enumerate(question links, start=1): if self.stop event.is set(): raise KeyboardInterrupt("Stop requested.") href = link.get attribute("href") driver.execute script("window.open(arguments[0], ' blank [গণিত] );", href) driver.switch to.window(driver.window handles[1]) try: WebDriverWait(driver, 15).until(EC.presence of element located((By.XPATH, "//h5[contains(text(), 'Question [গণিত] )]/following-sibling::div"))) question el = driver.find element(By.XPATH, "//h5[contains(text(), 'Question [গণিত] )]/following-sibling::div") question text = self. extract combined text with latex(question el.get attribute("innerHTML")) question imgs = question el.find elements(By.XPATH, ".//img[@src]") for qi count, img in enumerate(question imgs): ws.cell(row=Global index + index + 1, column=15 + qi count * 7, value=img.get attribute("src")) option blocks = driver.find elements(By.XPATH, "//div[contains(@class, 'pb-2') and contains(@class, 'flex [গণিত] )]") option texts, correct flags = [], [] for opt idx, block in enumerate(option blocks): option text = self. extract combined text with latex(block.find element(By.XPATH, ".//div").get attribute("innerHTML")) option texts.append(option text) option imgs = block.find elements(By.XPATH, ".//div//img[@src]") for oi count, img in enumerate(option imgs): ws.cell(row=Global index+index+1, column=16+opt idx+oi count*7, value=img.get attribute("src")) correct flags.append(bool(block.find elements(By.XPATH, ".//span[@role='img [গণিত] and @aria-label='check-square [গণিত] ]"))) while len(option texts) 2: driver.switch to.window(driver.window handles[2]) driver.close() finally: driver.switch to.window(driver.window handles[0]) # Switch back [গণিত] list view # Navigate [গণিত] next page in list view try: next btn = driver.find element(By.XPATH, "//li[@title='Next Page [গণিত] and not(@aria-disabled='true [গণিত] )]/button") driver.execute script("arguments[0].click();", next btn) print("Navigating [গণিত] the next page...") time.sleep(0.5) wait.until not(EC.presence of element located((By.CSS SELECTOR, "div.ant-spin-container.ant-spin-blur"))) time.sleep(2) except: print(" [গণিত] more pages found. Transfer complete.") break except KeyboardInterrupt: print(" [গণিত] stopped by user.") except Exception as e: print(f" [গণিত] unexpected error occurred during transfer: e ") finally: if driver: driver.quit() self.after(100, self. task completed) if name == " main ": app = MCQ Tool() app.mainloop()
ক. affirmative/positive
খ. summit/bottom
গ. harmony/discord
ঘ. pertinent/irrelevant
উত্তর: affirmative/positive
ব্যাখ্যা: [গণিত] পরস্পর বিপরীত শব্দ [গণিত] পরস্পর বিপরীত শব্দ [গণিত] পরস্পর বিপরীত শব্দ Affirmative/Positive – হ্যাঁ বোধক/নিশ্চিত সুতরাং সঠিক উত্তর Option A কারণ দুটি synonymous words আর বাকী Option গুলো পরস্পর antonymous words.
Admission NDC - Prosthuti Booster Humanities MCQ — Prosthuti প্রশ্নব্যাংক
Admission · NDC - Prosthuti Booster · Humanities · MCQ
import sys
import time
import re
import threading
import queue
# GUI Imports
import tkinter as tk
from tkinter import scrolledtext, filedialog, messagebox, font
# Selenium and Web Scraping Imports
from bs4 import BeautifulSoup, NavigableString
import openpyxl
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import selenium.common.exceptions import TimeoutException
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.keys import Keys
class
"""
A GUI application Scrape, Upload, and Transfer MCQs.
"""
def __init__(self):
super().__init__()
# --- Window Configuration ---
self.title("MCQ Automation Tool")
self.geometry("850x650")
# --- State Management ---
self.
self. threading.Event()
self. threading.Event()
# --- Theming and Fonts ---
self.style = {
"bg": "#2E2E2E",
"fg": "#E0E0E0",
"": "#3C3C3C",
"": "#505050",
"": "#007ACC",
"": ("Consolas", 10),
"": ("Segoe UI", 12, "bold"),
"": ("Segoe UI", 10, "bold"),
}
self.configure(bg=self.style["bg"])
# --- Create and layout widgets ---
self.
# --- Redirect stdout
self. queue.Queue()
sys.stdout = self.QueueIO(self.
self.
print("Welcome Tool! ✨")
print("Please select an action begin.")
# --- Handle window closing ---
self.protocol("", self.
"""Creates and places all the GUI widgets in the window."""
# --- Main Frame ---
tk.Frame(self, bg=self.style["bg"], padx=15, pady=15)
# --- Controls Frame ---
tk.Frame( bg=self.style[""], padx=10, pady=10)
pady=(0, 10))
# Action Buttons
self. self. "Scrape MCQs", self.
self. self. "Upload MCQs", self.
self. self. "Transfer MCQs", self.
# Upload-specific input
tk.Frame( bg=self.style[""])
column=0, columnspan=3, pady=(10,5), sticky="ew")
tk.Label( text="Questions Upload:", bg=self.style[""], fg=self.style["fg"]).pack(side=tk.\left, padx=(0,5))
self. tk.Entry( width=10, bg=self.style["bg"], fg=self.style["fg"], insertbackground=self.style["fg"])
self.num_questions_entry.pack(side=tk.\left)
self. "10")
# --- Status and Interaction Frame ---
tk.Frame( bg=self.style[""], padx=10, pady=10)
pady=(0, 10))
self. tk.Label( text="Status: Idle", anchor="w",
font=self.style[""], bg=self.style[""], fg=self.style["fg"])
self. column=0, sticky="ew")
self. self. "Continue", self. state=tk.DISABLED)
self. self. "Stop Process", self. state=tk.DISABLED, bg=self.style[""])
# --- tk.Frame( bg=self.style[""])
self. scrolledtext.ScrolledText( wrap=tk.WORD,
bg=self.style["bg"], fg=self.style["fg"],
font=self.style[""], state=tk.DISABLED)
self. expand=True, padx=5, pady=5)
parent, text, command, row, col, state=tk.NORMAL, bg=None, columnspan=1):
"""Helper function buttons."""
button = tk.Button(parent, text=text, command=command, state=state,
font=self.style[""], bg=bg or self.style[""],
fg=self.style["fg"], activebackground=self.style[""],
relief=tk.FLAT, padx=10, pady=5)
button.grid(row=row, column=col, padx=5, pady=5, sticky="ew", columnspan=columnspan)
return button
# --- Thread and State Management ---
"""Generic function thread."""
if self. self.
messagebox.showwarning("Busy", "A process is already running. Please wait or stop it.")
return
self.
self.
self.
self. threading.Thread(targe
self.
"""Resets the UI after a task is finished."""
self."Status: Idle")
self.
self.
self.
print(" finished. Ready for next task. 👍")
state):
"""Enables or disables main action buttons."""
self.
self.
self.
"""Sets the event continue."""
self.
"""Signals the worker thread up."""
if self. self.
print("🛑 Stop signal received. Attempting process...")
self.
self. # Unblock any waiting states
self. message):
"""Displays a message and waits for the user '"""
self.
self.
self. # Block thread until event is set
self. # Reset event for next use
self.
self."Status: In Progress...")
if self. KeyboardInterrupt("Process stopped by user.")
# --- Selenium Driver Setup ---
"""Configures and returns a Selenium WebDriver instance."""
try:
print("Setting up Chrome WebDriver...")
options = Options()
options."detach", True)
options."excludeSwitches", ["enable-automation"])
options.' False)
options."--disable-blink-features=AutomationControlled")
options."--user-data-dir=C: Data") # MODIFY THIS PATH
options."--profile-directory=Profile 1") # MODIFY THIS PROFILE
serv = Service(ChromeDriverManager().install())
driver = webdriver.Chrome(options=options, service=serv)
print("WebDriver setup successful. 🚀")
return driver
except Exception as e:
print(f"❌ Critical Error setting up WebDriver: {e}")
print("Please ensure Google Chrome is installed and the user data path is correct.")
return None
# --- Task Starter Methods ---
self.
self.
self.
# --- Logging and GUI Updates ---
class QueueIO:
"""A file-like object that writes queue."""
def __init__(self, queue_):
self.queue = queue_
def write(self, text):
self.queue.put(text)
def flush(self):
pass
"""Periodically checks the queue and updates the widget."""
try:
while not self. self.
self.
self. text)
self.
self. queue.Empty:
pass
self.after(100, self. text):
"""Thread-safe method label."""
self.
"""Handles the window closing event."""
if self. self. messagebox.askyesno("Exit", "A process is still running. Are you sure you want exit?"):
self.destroy()
else:
self.destroy()
# =================================================================================
# SCRIPT-1: SCRAPER LOGIC
# =================================================================================
def
try:
driver = self. driver: return
url = "https://admin.brritto.com/dashboard/mcq"
driver.get(url)
self."Instruction: Apply filters in Chrome, then press '")
# Initialize Excel
wb = openpyxl.Workbook()
ws = wb.active
ws.title = "MCQ Data"
ws.append(["Question", "Option A", "A is Correct", "Option B", "B is Correct",
"Option C", "C is Correct", "Option D", "D is Correct", "Option E", "E is Correct",
"Explanation", "Link", "Copy Link"])
self. driver. "//a[contains(@href, '/dashboard/mcq/view/')]")
print(f" page.")
index, link in enumerate( start=1):
if self. KeyboardInterrupt("Stop requested.")
href = link."href")
driver."window.open(arguments[0], '", href)
driver.
try:
WebDriverWait(driver, 15).until(EC. "//h5[contains(text(), '")))
driver. "//h5[contains(text(), '")
self."innerHTML"))
".//img[@src]")
for enumerate(
ws.cell(ro value=img."src"))
driver. "//div[contains(@class, 'pb-2') and contains(@class, '")
enumerate( self. ".//div")."innerHTML"))
block. ".//div//img[@src]")
for enumerate(
ws.cell(ro value=img."src"))
".//span[@role=' @aria-label='check-")))
while len( < 5:
"")
driver. "//h5[contains(text(), '")
self."innerHTML"))
".//img[@src]")
for enumerate(
ws.cell(ro value=img."src"))
"{href}", "Q{Global_index + index}")',
"{href}", "{href}")'
]
ws.append(
print(f" [{Global_index + index}] ✅ Saved question.")
except Exception as e:
print(f" [{Global_index + index}] ❌ Failed ")
finally:
driver.close()
driver.
# Go
try:
driver. "//li[@title='Next not(@aria-disabled='")
driver."arguments[0].click();",
print("Navigating page...")
time.sleep(0.5)
WebDriverWait(driver, 15). "div.ant-spin-container.ant-spin-blur")))
time.sleep(2)
except:
print(" found. Scraping complete.")
break
except KeyboardInterrupt:
print(" user.")
except Exception as e:
print(f" scraping: {e}")
finally:
if wb: self. driver: driver.quit()
self.after(100, self. BeautifulSoup( "html.parser")
result = ""
set(soup."math"))
for elem in soup.descendants:
if elem.name == "annotation":
result += f" \{elem.text.strip()} \ "
elif any(parent in parent.get("aria-hidden") == "true" for parent in elem.parents):
continue
elif isinstance(elem, NavigableString) and (stripped := elem.strip()):
result += stripped + " "
return result.strip()
wb):
try:
filedialog.asksaveasfilename(
defaultextension=".xlsx",
filetypes=[("Excel files", "*.xlsx"), ("All files", "*.*")],
title="Save Scraped MCQ Data As",
initialfile=""
)
if
wb.save(
print(f"Data saved successfully ")
else:
print("Save operation cancelled by user. Data not saved.")
except Exception as e:
print(f"Error saving file: {e}")
# =================================================================================
# SCRIPT-2: UPLOADER LOGIC
# =================================================================================
def
try:
# Get number of questions from GUI
try:
<= 0:
print("❌ Please enter a positive number of questions.")
return
except ValueError:
print("❌ Invalid number. Please enter a valid integer.")
return
# Load Excel file
filedialog.askopenfilename(
title="Load MCQ Data From",
defaultextension=".xlsx",
filetypes=[("Excel files", "*.xlsx"), ("All files", "*.*")]
)
if not
print("No file selected. Aborting upload.")
return
wb1 = openpyxl. wb1.active
print(f"Loaded data from: {file_path}")
driver = self. driver: return
url = "https://admin.brritto.com/dashboard/mcq/create"
driver.get(url)
wait = WebDriverWait(driver, 15)
self."Instruction: Apply filters on the 'Create page, then press '")
for n in range(2, self. KeyboardInterrupt("Stop requested.")
print(f"")
# Get data from Excel row
question, option1, option2, option3, option4, option5, explanation = (
ws1[f'A{n}'].value, ws1[f'B{n}'].value, ws1[f'D{n}'].value,
ws1[f'F{n}'].value, ws1[f'H{n}'].value, ws1[f'J{n}'].value, ws1[f'L{n}'].value
)
' 'options_0_text^{\prime}, 'options_1_text^{\prime}, 'options_2_text^{\prime}, 'options_3_text^{\prime}, 'options_4_text^{\prime}, ' option1, option2, option3, option4, option5, explanation]
# Click 'Add ws1[f'U{n}'].value:
try:
wait.until(EC. "//button[.//span[text()='Add ")))
driver."arguments[0].scrollIntoView({block: 'center^{\prime}});",
print(" - Added 5th option field.")
except TimeoutException:
print(" - Warning: Did not find 'Add option.")
# Image Upload Logic
' ' ' ' ' ' ' enumerate( openpyxl.utils. True:
ws1.cell(row=n, colum
try:
wait.until(EC. f"textarea# ~ div.tox.tox-tinymce button.tox-tbtn[aria-label*='")))
driver."arguments[0].scrollIntoView({block: 'center^{\prime}});", wait.until(EC. "div.tox-dialog input.tox-textfield")))
f"arguments[0].value = '{target_cell.value}'; arguments[0].dispatchEvent(new Event('"
driver.
print(f" - Uploaded image for {iframe_fields[img_col_idx]}.")
TimeoutException:
print(f" - ❌ Failed ")
break
# Text Content Entry
for j, field in enumerate( option5: continue # Skip 5th option if no data
if
try:
wait.until(EC. f"iframe#tinymceEditor_{field}_ifr")))
body = wait.until(EC. "tinymce")))
body. # Ensure content is string
driver.
print(f" - Entered text for {field}.")
except TimeoutException:
print(f" - ❌ Timed out finding iframe for {field}.")
driver. # Crucial
# Select Correct Answer
' ' ' ' ' idx, col in enumerate( ws1['].value:
try:
wait.until(EC. f"input#mcqForm_options_{idx}_isCorrect")))
driver."arguments[0].scrollIntoView({block: 'center^{\prime}}); arguments[0].click();",
print(f" - Marked Option {idx+1} as correct.")
except TimeoutException:
print(f" - ❌ Failed correct.")
# Set Difficulty
try:
wait.until(EC. "div[class^='ant-radio- input.ant-radio-input[value='")))
driver."arguments[0].click();", TimeoutException:
print(" - Warning: Could not set difficulty '")
# Submit
try:
wait.until(EC. "//button[@type=''")))
wait. "div.ant-notification")))
print(f" ✅ Submitted MCQ for row {n}.")
wait.until(EC. "div.ant-notification")))
time.sleep(2) # Wait for page TimeoutException:
print(f" - ❌ Failed page.")
except KeyboardInterrupt:
print(" user.")
except Exception as e:
print(f" upload: {e}")
finally:
if driver: driver.quit()
self.after(100, self.
# =================================================================================
# SCRIPT-3: TRANSFER LOGIC
# =================================================================================
def
try:
driver = self. driver: return
wait = WebDriverWait(driver, 15)
' 'options_0_text^{\prime}, 'options_1_text^{\prime}, 'options_2_text^{\prime}, 'options_3_text^{\prime}, 'options_4_text^{\prime}, ' "https://admin.brritto.com/dashboard/mcq"
driver.get(
self."STEP 1: Apply filters on the 'MCQ page, then press '")
"https://admin.brritto.com/dashboard/mcq/create"
driver."window.open(arguments[0], '",
driver. # Switch "Create" tab
self."STEP 2: Apply filters on the 'Create page, then press '")
driver. # Switch back "List" tab
self. driver. "//a[contains(@href, '/dashboard/mcq/view/')]")
print(f" page.")
index, link in enumerate( start=1):
if self. KeyboardInterrupt("Stop requested.")
href = link."href")
driver."window.open(arguments[0], '", href)
driver. # Switch "View" tab
try:
print(f" [{Global_index + index}] Processing: {href}")
wait.until(EC. "//h5[contains(text(), '")))
# Check number of options and which is correct
driver. "//div[contains(@class, 'pb-2') and contains(@class, '")
".//span[@role=' @aria-label='check-")) for b in len(
# Click edit button
wait.until(EC."//button[./span[text()='")))
time.sleep(1) # Wait for edit mode
# Switch
driver. wait.until(EC. "//button[.//span[text()='Add ")))
driver."arguments[0].scrollIntoView({block: 'center^{\prime}});",
# Copy-paste content
for j, field in enumerate(
# Copy from source
driver.
wait.until(EC. f"iframe#tinymceEditor_{field}_ifr")))
body = wait.until(EC. "tinymce")))
body. "a")
body. "c")
driver.
# Paste
driver.
wait.until(EC. f"iframe#tinymceEditor_{field}_ifr")))
body = wait.until(EC. "tinymce")))
body. "v")
driver.
print(f" - Content copied successfully.")
# Close the source "Edit" tab
driver.
driver.close()
driver.
# Set correct option and difficulty
for h, enumerate( wait.until(EC. f"input#mcqForm_options_{h}_isCorrect")))
driver."arguments[0].scrollIntoView({block: 'center^{\prime}}); arguments[0].click();", wait.until(EC. "div[class^='ant-radio- input.ant-radio-input[value='")))
driver."arguments[0].click();",
# Submit
wait.until(EC. "//button[@type=''")))
wait. "div.ant-notification")))
wait.until(EC. "div.ant-notification")))
print(f" - ✅ Transferred and submitted successfully.")
time.sleep(2)
except Exception as e:
print(f" - ❌ An error occurred transferring question {href}: {e}")
# Clean up failed tabs
if len(driver. > 2:
driver.
driver.close()
finally:
driver. # Switch back
# Navigate
try:
driver. "//li[@title='Next not(@aria-disabled='")
driver."arguments[0].click();",
print("Navigating page...")
time.sleep(0.5)
wait. "div.ant-spin-container.ant-spin-blur")))
time.sleep(2)
except:
print(" found. Transfer complete.")
break
except KeyboardInterrupt:
print(" user.")
except Exception as e:
print(f" transfer: {e}")
finally:
if driver: driver.quit()
self.after(100, self._task_completed)
if __name__ == "__main__":
ap
app.mainloop()
- ক.affirmative/positive
- খ.summit/bottom
- গ.harmony/discord
- ঘ.pertinent/irrelevant
উত্তর







