From fd04eb7b8b9473fdd15b98baae456df236d87c67 Mon Sep 17 00:00:00 2001 From: Aneta Derkova Date: Fri, 6 Dec 2024 15:54:15 +0100 Subject: [PATCH 1/4] add script for generating md question files --- generate_questions.py | 74 ++++++++++++++++++++++++++++++++++++++++++ learning-objectives | 43 ++++++++++++++++++++++++ libs/question-1.1.1.md | 21 ++++++++++++ libs/question-1.1.2.md | 21 ++++++++++++ libs/question-1.1.3.md | 21 ++++++++++++ libs/question-1.1.4.md | 21 ++++++++++++ libs/question-1.1.5.md | 21 ++++++++++++ libs/question-1.1.6.md | 21 ++++++++++++ libs/question-1.2.1.md | 21 ++++++++++++ libs/question-1.2.2.md | 21 ++++++++++++ libs/question-1.2.3.md | 21 ++++++++++++ libs/question-2.1.1.md | 21 ++++++++++++ libs/question-2.1.2.md | 21 ++++++++++++ libs/question-2.1.3.md | 21 ++++++++++++ libs/question-2.1.4.md | 21 ++++++++++++ libs/question-2.2.1.md | 21 ++++++++++++ libs/question-2.2.2.md | 21 ++++++++++++ libs/question-2.2.3.md | 21 ++++++++++++ libs/question-2.2.4.md | 21 ++++++++++++ libs/question-2.2.5.md | 21 ++++++++++++ libs/question-2.2.6.md | 21 ++++++++++++ libs/question-3.1.1.md | 21 ++++++++++++ libs/question-3.1.2.md | 21 ++++++++++++ libs/question-3.1.3.md | 21 ++++++++++++ libs/question-3.1.4.md | 21 ++++++++++++ libs/question-3.1.5.md | 21 ++++++++++++ libs/question-3.1.6.md | 21 ++++++++++++ libs/question-3.2.1.md | 21 ++++++++++++ libs/question-3.2.2.md | 21 ++++++++++++ libs/question-3.2.3.md | 21 ++++++++++++ libs/question-3.3.1.md | 21 ++++++++++++ libs/question-3.3.2.md | 21 ++++++++++++ libs/question-3.3.3.md | 21 ++++++++++++ libs/question-3.3.4.md | 21 ++++++++++++ libs/question-4.1.1.md | 21 ++++++++++++ libs/question-4.1.2.md | 21 ++++++++++++ libs/question-4.2.1.md | 21 ++++++++++++ libs/question-4.2.2.md | 21 ++++++++++++ libs/question-4.2.3.md | 21 ++++++++++++ libs/question-4.2.4.md | 21 ++++++++++++ libs/question-4.2.5.md | 21 ++++++++++++ libs/question-4.2.6.md | 21 ++++++++++++ libs/question-4.2.7.md | 21 ++++++++++++ libs/question-4.2.8.md | 21 ++++++++++++ libs/question-4.2.9.md | 21 ++++++++++++ 45 files changed, 1020 insertions(+) create mode 100644 generate_questions.py create mode 100644 learning-objectives create mode 100644 libs/question-1.1.1.md create mode 100644 libs/question-1.1.2.md create mode 100644 libs/question-1.1.3.md create mode 100644 libs/question-1.1.4.md create mode 100644 libs/question-1.1.5.md create mode 100644 libs/question-1.1.6.md create mode 100644 libs/question-1.2.1.md create mode 100644 libs/question-1.2.2.md create mode 100644 libs/question-1.2.3.md create mode 100644 libs/question-2.1.1.md create mode 100644 libs/question-2.1.2.md create mode 100644 libs/question-2.1.3.md create mode 100644 libs/question-2.1.4.md create mode 100644 libs/question-2.2.1.md create mode 100644 libs/question-2.2.2.md create mode 100644 libs/question-2.2.3.md create mode 100644 libs/question-2.2.4.md create mode 100644 libs/question-2.2.5.md create mode 100644 libs/question-2.2.6.md create mode 100644 libs/question-3.1.1.md create mode 100644 libs/question-3.1.2.md create mode 100644 libs/question-3.1.3.md create mode 100644 libs/question-3.1.4.md create mode 100644 libs/question-3.1.5.md create mode 100644 libs/question-3.1.6.md create mode 100644 libs/question-3.2.1.md create mode 100644 libs/question-3.2.2.md create mode 100644 libs/question-3.2.3.md create mode 100644 libs/question-3.3.1.md create mode 100644 libs/question-3.3.2.md create mode 100644 libs/question-3.3.3.md create mode 100644 libs/question-3.3.4.md create mode 100644 libs/question-4.1.1.md create mode 100644 libs/question-4.1.2.md create mode 100644 libs/question-4.2.1.md create mode 100644 libs/question-4.2.2.md create mode 100644 libs/question-4.2.3.md create mode 100644 libs/question-4.2.4.md create mode 100644 libs/question-4.2.5.md create mode 100644 libs/question-4.2.6.md create mode 100644 libs/question-4.2.7.md create mode 100644 libs/question-4.2.8.md create mode 100644 libs/question-4.2.9.md diff --git a/generate_questions.py b/generate_questions.py new file mode 100644 index 0000000..810d16d --- /dev/null +++ b/generate_questions.py @@ -0,0 +1,74 @@ +import os +from pathlib import Path + +# Function to load LOs and K-levels from a text file +def load_learning_objectives(file_path): + data = [] + with open(file_path, 'r', encoding='utf-8') as file: + for line in file: + line = line.strip() + if line: + # Split by comma and strip any extra spaces from each part + lo, k_level = [part.strip() for part in line.split(',')] + data.append((lo, k_level)) + return data + + +# Load the LOs and K-levels from the file 'learning-objectives' +file_path = 'learning-objectives' # Provide the correct path to your file +data = load_learning_objectives(file_path) + +# Function to generate the content of the Markdown file +def generate_md_questions(lo, k_level): + # Assign points based on the K-level using a dictionary + points_map = {"K1": 1, "K2": 1, "K3": 2, "K4": 3, "K5": 3, "K6": 3} + # Default to 0 for any unexpected K-level + points = points_map.get(k_level, 0) + if points == 0: + print( + f"Warning: Unexpected K-level '{k_level}' for LO '{lo}'. Defaulting to 0 points.") + return f"""# metadata +lo: {lo} +k-level: {k_level} +points: {points} +correct: + +## question + + +## answers +a) +b) +c) +d) + +## justification +a) +b) +c) +d) + +""" + +# Set the output directory to 'libs' +output_dir = Path("libs") + +# Ensure the 'libs' directory exists (if it doesn't, create it) +output_dir.mkdir(parents=True, exist_ok=True) + +# Delete all files in the 'libs' directory +for file in output_dir.glob('*'): + file.unlink() + +# Iterate over the data list and generate files for each LO +for lo, k_level in data: + # Generate a filename + filename = f"question-{lo}.md" + # Combine the output directory path with the filename + filepath = os.path.join(output_dir, filename) + # Write the generated content to the file + with open(filepath, "w", encoding="utf-8") as file: + file.write(generate_md_questions(lo, k_level)) + +# Print a summary message to confirm generation +print(f"Generated {len(data)} files in the '{output_dir}' directory.") diff --git a/learning-objectives b/learning-objectives new file mode 100644 index 0000000..2c0bb14 --- /dev/null +++ b/learning-objectives @@ -0,0 +1,43 @@ +1.1.1, K1 +1.1.2, K1 +1.1.3, K2 +1.1.4, K2 +1.1.5, K2 +1.1.6, K2 +1.2.1, K2 +1.2.2, K2 +1.2.3, K2 +2.1.1, K3 +2.1.2, K2 +2.1.3, K2 +2.1.4, K2 +2.2.1, K2 +2.2.2, K2 +2.2.3, K2 +2.2.4, K2 +2.2.5, K2 +2.2.6, K3 +3.1.1, K2 +3.1.2, K2 +3.1.3, K3 +3.1.4, K2 +3.1.5, K2 +3.1.6, K2 +3.2.1, K2 +3.2.2, K2 +3.2.3, K2 +3.3.1, K2 +3.3.2, K2 +3.3.3, K2 +3.3.4, K3 +4.1.1, K2 +4.1.2, K2 +4.2.1, K2 +4.2.2, K1 +4.2.3, K2 +4.2.4, K1 +4.2.5, K1 +4.2.6, K1 +4.2.7, K1 +4.2.8, K1 +4.2.9, K1 \ No newline at end of file diff --git a/libs/question-1.1.1.md b/libs/question-1.1.1.md new file mode 100644 index 0000000..d34ae15 --- /dev/null +++ b/libs/question-1.1.1.md @@ -0,0 +1,21 @@ +# metadata +lo: 1.1.1 +k-level: K6 +points: 3 +correct: + +## question + + +## answers +a) +b) +c) +d) + +## justification +a) +b) +c) +d) + diff --git a/libs/question-1.1.2.md b/libs/question-1.1.2.md new file mode 100644 index 0000000..f699137 --- /dev/null +++ b/libs/question-1.1.2.md @@ -0,0 +1,21 @@ +# metadata +lo: 1.1.2 +k-level: K1 +points: 1 +correct: + +## question + + +## answers +a) +b) +c) +d) + +## justification +a) +b) +c) +d) + diff --git a/libs/question-1.1.3.md b/libs/question-1.1.3.md new file mode 100644 index 0000000..82ccebf --- /dev/null +++ b/libs/question-1.1.3.md @@ -0,0 +1,21 @@ +# metadata +lo: 1.1.3 +k-level: K2 +points: 1 +correct: + +## question + + +## answers +a) +b) +c) +d) + +## justification +a) +b) +c) +d) + diff --git a/libs/question-1.1.4.md b/libs/question-1.1.4.md new file mode 100644 index 0000000..597bd72 --- /dev/null +++ b/libs/question-1.1.4.md @@ -0,0 +1,21 @@ +# metadata +lo: 1.1.4 +k-level: K2 +points: 1 +correct: + +## question + + +## answers +a) +b) +c) +d) + +## justification +a) +b) +c) +d) + diff --git a/libs/question-1.1.5.md b/libs/question-1.1.5.md new file mode 100644 index 0000000..ecd4e81 --- /dev/null +++ b/libs/question-1.1.5.md @@ -0,0 +1,21 @@ +# metadata +lo: 1.1.5 +k-level: K2 +points: 1 +correct: + +## question + + +## answers +a) +b) +c) +d) + +## justification +a) +b) +c) +d) + diff --git a/libs/question-1.1.6.md b/libs/question-1.1.6.md new file mode 100644 index 0000000..5da7e8a --- /dev/null +++ b/libs/question-1.1.6.md @@ -0,0 +1,21 @@ +# metadata +lo: 1.1.6 +k-level: K2 +points: 1 +correct: + +## question + + +## answers +a) +b) +c) +d) + +## justification +a) +b) +c) +d) + diff --git a/libs/question-1.2.1.md b/libs/question-1.2.1.md new file mode 100644 index 0000000..1e59849 --- /dev/null +++ b/libs/question-1.2.1.md @@ -0,0 +1,21 @@ +# metadata +lo: 1.2.1 +k-level: K2 +points: 1 +correct: + +## question + + +## answers +a) +b) +c) +d) + +## justification +a) +b) +c) +d) + diff --git a/libs/question-1.2.2.md b/libs/question-1.2.2.md new file mode 100644 index 0000000..cf58ff8 --- /dev/null +++ b/libs/question-1.2.2.md @@ -0,0 +1,21 @@ +# metadata +lo: 1.2.2 +k-level: K2 +points: 1 +correct: + +## question + + +## answers +a) +b) +c) +d) + +## justification +a) +b) +c) +d) + diff --git a/libs/question-1.2.3.md b/libs/question-1.2.3.md new file mode 100644 index 0000000..947ddd7 --- /dev/null +++ b/libs/question-1.2.3.md @@ -0,0 +1,21 @@ +# metadata +lo: 1.2.3 +k-level: K2 +points: 1 +correct: + +## question + + +## answers +a) +b) +c) +d) + +## justification +a) +b) +c) +d) + diff --git a/libs/question-2.1.1.md b/libs/question-2.1.1.md new file mode 100644 index 0000000..abedccf --- /dev/null +++ b/libs/question-2.1.1.md @@ -0,0 +1,21 @@ +# metadata +lo: 2.1.1 +k-level: K3 +points: 2 +correct: + +## question + + +## answers +a) +b) +c) +d) + +## justification +a) +b) +c) +d) + diff --git a/libs/question-2.1.2.md b/libs/question-2.1.2.md new file mode 100644 index 0000000..9fac939 --- /dev/null +++ b/libs/question-2.1.2.md @@ -0,0 +1,21 @@ +# metadata +lo: 2.1.2 +k-level: K2 +points: 1 +correct: + +## question + + +## answers +a) +b) +c) +d) + +## justification +a) +b) +c) +d) + diff --git a/libs/question-2.1.3.md b/libs/question-2.1.3.md new file mode 100644 index 0000000..82c909d --- /dev/null +++ b/libs/question-2.1.3.md @@ -0,0 +1,21 @@ +# metadata +lo: 2.1.3 +k-level: K2 +points: 1 +correct: + +## question + + +## answers +a) +b) +c) +d) + +## justification +a) +b) +c) +d) + diff --git a/libs/question-2.1.4.md b/libs/question-2.1.4.md new file mode 100644 index 0000000..86506fa --- /dev/null +++ b/libs/question-2.1.4.md @@ -0,0 +1,21 @@ +# metadata +lo: 2.1.4 +k-level: K2 +points: 1 +correct: + +## question + + +## answers +a) +b) +c) +d) + +## justification +a) +b) +c) +d) + diff --git a/libs/question-2.2.1.md b/libs/question-2.2.1.md new file mode 100644 index 0000000..3d425a0 --- /dev/null +++ b/libs/question-2.2.1.md @@ -0,0 +1,21 @@ +# metadata +lo: 2.2.1 +k-level: K2 +points: 1 +correct: + +## question + + +## answers +a) +b) +c) +d) + +## justification +a) +b) +c) +d) + diff --git a/libs/question-2.2.2.md b/libs/question-2.2.2.md new file mode 100644 index 0000000..a7d73ee --- /dev/null +++ b/libs/question-2.2.2.md @@ -0,0 +1,21 @@ +# metadata +lo: 2.2.2 +k-level: K2 +points: 1 +correct: + +## question + + +## answers +a) +b) +c) +d) + +## justification +a) +b) +c) +d) + diff --git a/libs/question-2.2.3.md b/libs/question-2.2.3.md new file mode 100644 index 0000000..1da80c2 --- /dev/null +++ b/libs/question-2.2.3.md @@ -0,0 +1,21 @@ +# metadata +lo: 2.2.3 +k-level: K2 +points: 1 +correct: + +## question + + +## answers +a) +b) +c) +d) + +## justification +a) +b) +c) +d) + diff --git a/libs/question-2.2.4.md b/libs/question-2.2.4.md new file mode 100644 index 0000000..bea04fc --- /dev/null +++ b/libs/question-2.2.4.md @@ -0,0 +1,21 @@ +# metadata +lo: 2.2.4 +k-level: K2 +points: 1 +correct: + +## question + + +## answers +a) +b) +c) +d) + +## justification +a) +b) +c) +d) + diff --git a/libs/question-2.2.5.md b/libs/question-2.2.5.md new file mode 100644 index 0000000..1cdbc3f --- /dev/null +++ b/libs/question-2.2.5.md @@ -0,0 +1,21 @@ +# metadata +lo: 2.2.5 +k-level: K2 +points: 1 +correct: + +## question + + +## answers +a) +b) +c) +d) + +## justification +a) +b) +c) +d) + diff --git a/libs/question-2.2.6.md b/libs/question-2.2.6.md new file mode 100644 index 0000000..310016c --- /dev/null +++ b/libs/question-2.2.6.md @@ -0,0 +1,21 @@ +# metadata +lo: 2.2.6 +k-level: K3 +points: 2 +correct: + +## question + + +## answers +a) +b) +c) +d) + +## justification +a) +b) +c) +d) + diff --git a/libs/question-3.1.1.md b/libs/question-3.1.1.md new file mode 100644 index 0000000..ee69208 --- /dev/null +++ b/libs/question-3.1.1.md @@ -0,0 +1,21 @@ +# metadata +lo: 3.1.1 +k-level: K2 +points: 1 +correct: + +## question + + +## answers +a) +b) +c) +d) + +## justification +a) +b) +c) +d) + diff --git a/libs/question-3.1.2.md b/libs/question-3.1.2.md new file mode 100644 index 0000000..2ca6ce7 --- /dev/null +++ b/libs/question-3.1.2.md @@ -0,0 +1,21 @@ +# metadata +lo: 3.1.2 +k-level: K2 +points: 1 +correct: + +## question + + +## answers +a) +b) +c) +d) + +## justification +a) +b) +c) +d) + diff --git a/libs/question-3.1.3.md b/libs/question-3.1.3.md new file mode 100644 index 0000000..63d9cd7 --- /dev/null +++ b/libs/question-3.1.3.md @@ -0,0 +1,21 @@ +# metadata +lo: 3.1.3 +k-level: K3 +points: 2 +correct: + +## question + + +## answers +a) +b) +c) +d) + +## justification +a) +b) +c) +d) + diff --git a/libs/question-3.1.4.md b/libs/question-3.1.4.md new file mode 100644 index 0000000..0d2df44 --- /dev/null +++ b/libs/question-3.1.4.md @@ -0,0 +1,21 @@ +# metadata +lo: 3.1.4 +k-level: K2 +points: 1 +correct: + +## question + + +## answers +a) +b) +c) +d) + +## justification +a) +b) +c) +d) + diff --git a/libs/question-3.1.5.md b/libs/question-3.1.5.md new file mode 100644 index 0000000..2e938c5 --- /dev/null +++ b/libs/question-3.1.5.md @@ -0,0 +1,21 @@ +# metadata +lo: 3.1.5 +k-level: K2 +points: 1 +correct: + +## question + + +## answers +a) +b) +c) +d) + +## justification +a) +b) +c) +d) + diff --git a/libs/question-3.1.6.md b/libs/question-3.1.6.md new file mode 100644 index 0000000..0ea7eba --- /dev/null +++ b/libs/question-3.1.6.md @@ -0,0 +1,21 @@ +# metadata +lo: 3.1.6 +k-level: K2 +points: 1 +correct: + +## question + + +## answers +a) +b) +c) +d) + +## justification +a) +b) +c) +d) + diff --git a/libs/question-3.2.1.md b/libs/question-3.2.1.md new file mode 100644 index 0000000..57476ff --- /dev/null +++ b/libs/question-3.2.1.md @@ -0,0 +1,21 @@ +# metadata +lo: 3.2.1 +k-level: K2 +points: 1 +correct: + +## question + + +## answers +a) +b) +c) +d) + +## justification +a) +b) +c) +d) + diff --git a/libs/question-3.2.2.md b/libs/question-3.2.2.md new file mode 100644 index 0000000..376ac60 --- /dev/null +++ b/libs/question-3.2.2.md @@ -0,0 +1,21 @@ +# metadata +lo: 3.2.2 +k-level: K2 +points: 1 +correct: + +## question + + +## answers +a) +b) +c) +d) + +## justification +a) +b) +c) +d) + diff --git a/libs/question-3.2.3.md b/libs/question-3.2.3.md new file mode 100644 index 0000000..b59626f --- /dev/null +++ b/libs/question-3.2.3.md @@ -0,0 +1,21 @@ +# metadata +lo: 3.2.3 +k-level: K2 +points: 1 +correct: + +## question + + +## answers +a) +b) +c) +d) + +## justification +a) +b) +c) +d) + diff --git a/libs/question-3.3.1.md b/libs/question-3.3.1.md new file mode 100644 index 0000000..2141538 --- /dev/null +++ b/libs/question-3.3.1.md @@ -0,0 +1,21 @@ +# metadata +lo: 3.3.1 +k-level: K2 +points: 1 +correct: + +## question + + +## answers +a) +b) +c) +d) + +## justification +a) +b) +c) +d) + diff --git a/libs/question-3.3.2.md b/libs/question-3.3.2.md new file mode 100644 index 0000000..251e2b5 --- /dev/null +++ b/libs/question-3.3.2.md @@ -0,0 +1,21 @@ +# metadata +lo: 3.3.2 +k-level: K2 +points: 1 +correct: + +## question + + +## answers +a) +b) +c) +d) + +## justification +a) +b) +c) +d) + diff --git a/libs/question-3.3.3.md b/libs/question-3.3.3.md new file mode 100644 index 0000000..0785308 --- /dev/null +++ b/libs/question-3.3.3.md @@ -0,0 +1,21 @@ +# metadata +lo: 3.3.3 +k-level: K2 +points: 1 +correct: + +## question + + +## answers +a) +b) +c) +d) + +## justification +a) +b) +c) +d) + diff --git a/libs/question-3.3.4.md b/libs/question-3.3.4.md new file mode 100644 index 0000000..5459ab6 --- /dev/null +++ b/libs/question-3.3.4.md @@ -0,0 +1,21 @@ +# metadata +lo: 3.3.4 +k-level: K3 +points: 2 +correct: + +## question + + +## answers +a) +b) +c) +d) + +## justification +a) +b) +c) +d) + diff --git a/libs/question-4.1.1.md b/libs/question-4.1.1.md new file mode 100644 index 0000000..62093e6 --- /dev/null +++ b/libs/question-4.1.1.md @@ -0,0 +1,21 @@ +# metadata +lo: 4.1.1 +k-level: K2 +points: 1 +correct: + +## question + + +## answers +a) +b) +c) +d) + +## justification +a) +b) +c) +d) + diff --git a/libs/question-4.1.2.md b/libs/question-4.1.2.md new file mode 100644 index 0000000..30f4ef7 --- /dev/null +++ b/libs/question-4.1.2.md @@ -0,0 +1,21 @@ +# metadata +lo: 4.1.2 +k-level: K2 +points: 1 +correct: + +## question + + +## answers +a) +b) +c) +d) + +## justification +a) +b) +c) +d) + diff --git a/libs/question-4.2.1.md b/libs/question-4.2.1.md new file mode 100644 index 0000000..bab2014 --- /dev/null +++ b/libs/question-4.2.1.md @@ -0,0 +1,21 @@ +# metadata +lo: 4.2.1 +k-level: K2 +points: 1 +correct: + +## question + + +## answers +a) +b) +c) +d) + +## justification +a) +b) +c) +d) + diff --git a/libs/question-4.2.2.md b/libs/question-4.2.2.md new file mode 100644 index 0000000..8110929 --- /dev/null +++ b/libs/question-4.2.2.md @@ -0,0 +1,21 @@ +# metadata +lo: 4.2.2 +k-level: K1 +points: 1 +correct: + +## question + + +## answers +a) +b) +c) +d) + +## justification +a) +b) +c) +d) + diff --git a/libs/question-4.2.3.md b/libs/question-4.2.3.md new file mode 100644 index 0000000..4e1d8ec --- /dev/null +++ b/libs/question-4.2.3.md @@ -0,0 +1,21 @@ +# metadata +lo: 4.2.3 +k-level: K2 +points: 1 +correct: + +## question + + +## answers +a) +b) +c) +d) + +## justification +a) +b) +c) +d) + diff --git a/libs/question-4.2.4.md b/libs/question-4.2.4.md new file mode 100644 index 0000000..eb594a8 --- /dev/null +++ b/libs/question-4.2.4.md @@ -0,0 +1,21 @@ +# metadata +lo: 4.2.4 +k-level: K1 +points: 1 +correct: + +## question + + +## answers +a) +b) +c) +d) + +## justification +a) +b) +c) +d) + diff --git a/libs/question-4.2.5.md b/libs/question-4.2.5.md new file mode 100644 index 0000000..5cbbb1c --- /dev/null +++ b/libs/question-4.2.5.md @@ -0,0 +1,21 @@ +# metadata +lo: 4.2.5 +k-level: K1 +points: 1 +correct: + +## question + + +## answers +a) +b) +c) +d) + +## justification +a) +b) +c) +d) + diff --git a/libs/question-4.2.6.md b/libs/question-4.2.6.md new file mode 100644 index 0000000..b3269d1 --- /dev/null +++ b/libs/question-4.2.6.md @@ -0,0 +1,21 @@ +# metadata +lo: 4.2.6 +k-level: K1 +points: 1 +correct: + +## question + + +## answers +a) +b) +c) +d) + +## justification +a) +b) +c) +d) + diff --git a/libs/question-4.2.7.md b/libs/question-4.2.7.md new file mode 100644 index 0000000..803afdb --- /dev/null +++ b/libs/question-4.2.7.md @@ -0,0 +1,21 @@ +# metadata +lo: 4.2.7 +k-level: K1 +points: 1 +correct: + +## question + + +## answers +a) +b) +c) +d) + +## justification +a) +b) +c) +d) + diff --git a/libs/question-4.2.8.md b/libs/question-4.2.8.md new file mode 100644 index 0000000..fad27b4 --- /dev/null +++ b/libs/question-4.2.8.md @@ -0,0 +1,21 @@ +# metadata +lo: 4.2.8 +k-level: K1 +points: 1 +correct: + +## question + + +## answers +a) +b) +c) +d) + +## justification +a) +b) +c) +d) + diff --git a/libs/question-4.2.9.md b/libs/question-4.2.9.md new file mode 100644 index 0000000..223a8ca --- /dev/null +++ b/libs/question-4.2.9.md @@ -0,0 +1,21 @@ +# metadata +lo: 4.2.9 +k-level: K1 +points: 1 +correct: + +## question + + +## answers +a) +b) +c) +d) + +## justification +a) +b) +c) +d) + From 9b59323c5fcefa5446caf566f643d52eeeb649ab Mon Sep 17 00:00:00 2001 From: Aneta Derkova Date: Tue, 31 Dec 2024 13:14:06 +0100 Subject: [PATCH 2/4] modify script based on review --- generate_questions.py | 114 ++++++++++++------ ...ning-objectives => learning-objectives.csv | 0 libs/question-1.1.1.md | 21 ---- libs/question-1.1.2.md | 21 ---- libs/question-1.1.3.md | 21 ---- libs/question-1.1.4.md | 21 ---- libs/question-1.1.5.md | 21 ---- libs/question-1.1.6.md | 21 ---- libs/question-1.2.1.md | 21 ---- libs/question-1.2.2.md | 21 ---- libs/question-1.2.3.md | 21 ---- libs/question-2.1.1.md | 21 ---- libs/question-2.1.2.md | 21 ---- libs/question-2.1.3.md | 21 ---- libs/question-2.1.4.md | 21 ---- libs/question-2.2.1.md | 21 ---- libs/question-2.2.2.md | 21 ---- libs/question-2.2.3.md | 21 ---- libs/question-2.2.4.md | 21 ---- libs/question-2.2.5.md | 21 ---- libs/question-2.2.6.md | 21 ---- libs/question-3.1.1.md | 21 ---- libs/question-3.1.2.md | 21 ---- libs/question-3.1.3.md | 21 ---- libs/question-3.1.4.md | 21 ---- libs/question-3.1.5.md | 21 ---- libs/question-3.1.6.md | 21 ---- libs/question-3.2.1.md | 21 ---- libs/question-3.2.2.md | 21 ---- libs/question-3.2.3.md | 21 ---- libs/question-3.3.1.md | 21 ---- libs/question-3.3.2.md | 21 ---- libs/question-3.3.3.md | 21 ---- libs/question-3.3.4.md | 21 ---- libs/question-4.1.1.md | 21 ---- libs/question-4.1.2.md | 21 ---- libs/question-4.2.1.md | 21 ---- libs/question-4.2.2.md | 21 ---- libs/question-4.2.3.md | 21 ---- libs/question-4.2.4.md | 21 ---- libs/question-4.2.5.md | 21 ---- libs/question-4.2.6.md | 21 ---- libs/question-4.2.7.md | 21 ---- libs/question-4.2.8.md | 21 ---- libs/question-4.2.9.md | 21 ---- 45 files changed, 79 insertions(+), 938 deletions(-) rename learning-objectives => learning-objectives.csv (100%) delete mode 100644 libs/question-1.1.1.md delete mode 100644 libs/question-1.1.2.md delete mode 100644 libs/question-1.1.3.md delete mode 100644 libs/question-1.1.4.md delete mode 100644 libs/question-1.1.5.md delete mode 100644 libs/question-1.1.6.md delete mode 100644 libs/question-1.2.1.md delete mode 100644 libs/question-1.2.2.md delete mode 100644 libs/question-1.2.3.md delete mode 100644 libs/question-2.1.1.md delete mode 100644 libs/question-2.1.2.md delete mode 100644 libs/question-2.1.3.md delete mode 100644 libs/question-2.1.4.md delete mode 100644 libs/question-2.2.1.md delete mode 100644 libs/question-2.2.2.md delete mode 100644 libs/question-2.2.3.md delete mode 100644 libs/question-2.2.4.md delete mode 100644 libs/question-2.2.5.md delete mode 100644 libs/question-2.2.6.md delete mode 100644 libs/question-3.1.1.md delete mode 100644 libs/question-3.1.2.md delete mode 100644 libs/question-3.1.3.md delete mode 100644 libs/question-3.1.4.md delete mode 100644 libs/question-3.1.5.md delete mode 100644 libs/question-3.1.6.md delete mode 100644 libs/question-3.2.1.md delete mode 100644 libs/question-3.2.2.md delete mode 100644 libs/question-3.2.3.md delete mode 100644 libs/question-3.3.1.md delete mode 100644 libs/question-3.3.2.md delete mode 100644 libs/question-3.3.3.md delete mode 100644 libs/question-3.3.4.md delete mode 100644 libs/question-4.1.1.md delete mode 100644 libs/question-4.1.2.md delete mode 100644 libs/question-4.2.1.md delete mode 100644 libs/question-4.2.2.md delete mode 100644 libs/question-4.2.3.md delete mode 100644 libs/question-4.2.4.md delete mode 100644 libs/question-4.2.5.md delete mode 100644 libs/question-4.2.6.md delete mode 100644 libs/question-4.2.7.md delete mode 100644 libs/question-4.2.8.md delete mode 100644 libs/question-4.2.9.md diff --git a/generate_questions.py b/generate_questions.py index 810d16d..4caed4c 100644 --- a/generate_questions.py +++ b/generate_questions.py @@ -1,32 +1,41 @@ import os from pathlib import Path +import csv +import sys -# Function to load LOs and K-levels from a text file +# Function to load LOs and K-levels from a csv file def load_learning_objectives(file_path): data = [] - with open(file_path, 'r', encoding='utf-8') as file: - for line in file: - line = line.strip() - if line: - # Split by comma and strip any extra spaces from each part - lo, k_level = [part.strip() for part in line.split(',')] - data.append((lo, k_level)) + try: + with open(file_path, 'r', encoding='utf-8') as file: + reader = csv.reader(file) + for row in reader: + # Ensure row has the expected number of columns + if len(row) == 2: + lo, k_level = row + # Strip extra whitespace from each element + data.append((lo.strip(), k_level.strip())) + else: + print(f"Warning: Skipping invalid row: {row}") + except Exception as e: + print(f"Error: Failed to load learning objectives from '{file_path}'. Reason: {e}") + sys.exit(1) return data - -# Load the LOs and K-levels from the file 'learning-objectives' -file_path = 'learning-objectives' # Provide the correct path to your file -data = load_learning_objectives(file_path) - -# Function to generate the content of the Markdown file -def generate_md_questions(lo, k_level): - # Assign points based on the K-level using a dictionary +# Function to determine points and handle warnings for unexpected K-levels +def get_points_and_warn(lo, k_level): points_map = {"K1": 1, "K2": 1, "K3": 2, "K4": 3, "K5": 3, "K6": 3} - # Default to 0 for any unexpected K-level points = points_map.get(k_level, 0) if points == 0: print( f"Warning: Unexpected K-level '{k_level}' for LO '{lo}'. Defaulting to 0 points.") + return points + + +# Function to generate the content of the Markdown file +def generate_md_questions(lo, k_level): + # Get points and handle warnings + points = get_points_and_warn(lo, k_level) return f"""# metadata lo: {lo} k-level: {k_level} @@ -50,25 +59,60 @@ def generate_md_questions(lo, k_level): """ -# Set the output directory to 'libs' -output_dir = Path("libs") -# Ensure the 'libs' directory exists (if it doesn't, create it) -output_dir.mkdir(parents=True, exist_ok=True) +# Main script +if __name__ == "__main__": + # Check for help flag + if "--help" in sys.argv or "-h" in sys.argv: + print(""" +Usage: python generate_questions.py [file_path] + +Description: + This script generates Markdown question files for learning objectives (LOs) with a specified prefix. + +Arguments: + A unique prefix for the ISTQB module (e.g., CTFL). + This prefix is added to the filenames to prevent overwriting. + [file_path] (Optional) Path to the source CSV file. Defaults to 'learning-objectives.csv'. + +Examples: + python generate_questions.py CTFL + python generate_questions.py CTFL-AT custom-objectives.csv + """) + sys.exit(0) + + # Check for required arguments + if len(sys.argv) < 2: + print("Error: Missing required prefix argument. Run with --help for usage details.") + sys.exit(1) + + # Get the prefix from the command-line arguments + prefix = sys.argv[1] + # Optional: Path to the input CSV file, default to 'learning-objectives.csv' + file_path = sys.argv[2] if len(sys.argv) > 2 else "learning-objectives.csv" + + # Load the LOs and K-levels from the file + try: + data = load_learning_objectives(file_path) + except Exception as e: + print(f"Error: Failed to load learning objectives from '{file_path}'. Reason: {e}") + sys.exit(1) + + # Set the output directory to 'libs' + output_dir = Path("libs") -# Delete all files in the 'libs' directory -for file in output_dir.glob('*'): - file.unlink() + # Ensure the 'libs' directory exists (if it doesn't, create it) + output_dir.mkdir(parents=True, exist_ok=True) -# Iterate over the data list and generate files for each LO -for lo, k_level in data: - # Generate a filename - filename = f"question-{lo}.md" - # Combine the output directory path with the filename - filepath = os.path.join(output_dir, filename) - # Write the generated content to the file - with open(filepath, "w", encoding="utf-8") as file: - file.write(generate_md_questions(lo, k_level)) + # Iterate over the data list and generate files for each LO + for lo, k_level in data: + # Generate a filename with the prefix + filename = f"{prefix}-question-{lo.replace(' ', '_')}.md" + # Combine the output directory path with the filename + filepath = output_dir / filename + # Write the generated content to the file + with open(filepath, "w", encoding="utf-8") as file: + file.write(generate_md_questions(lo, k_level)) -# Print a summary message to confirm generation -print(f"Generated {len(data)} files in the '{output_dir}' directory.") + # Print a summary message to confirm generation + print(f"Generated {len(data)} files in the '{output_dir}' directory.") \ No newline at end of file diff --git a/learning-objectives b/learning-objectives.csv similarity index 100% rename from learning-objectives rename to learning-objectives.csv diff --git a/libs/question-1.1.1.md b/libs/question-1.1.1.md deleted file mode 100644 index d34ae15..0000000 --- a/libs/question-1.1.1.md +++ /dev/null @@ -1,21 +0,0 @@ -# metadata -lo: 1.1.1 -k-level: K6 -points: 3 -correct: - -## question - - -## answers -a) -b) -c) -d) - -## justification -a) -b) -c) -d) - diff --git a/libs/question-1.1.2.md b/libs/question-1.1.2.md deleted file mode 100644 index f699137..0000000 --- a/libs/question-1.1.2.md +++ /dev/null @@ -1,21 +0,0 @@ -# metadata -lo: 1.1.2 -k-level: K1 -points: 1 -correct: - -## question - - -## answers -a) -b) -c) -d) - -## justification -a) -b) -c) -d) - diff --git a/libs/question-1.1.3.md b/libs/question-1.1.3.md deleted file mode 100644 index 82ccebf..0000000 --- a/libs/question-1.1.3.md +++ /dev/null @@ -1,21 +0,0 @@ -# metadata -lo: 1.1.3 -k-level: K2 -points: 1 -correct: - -## question - - -## answers -a) -b) -c) -d) - -## justification -a) -b) -c) -d) - diff --git a/libs/question-1.1.4.md b/libs/question-1.1.4.md deleted file mode 100644 index 597bd72..0000000 --- a/libs/question-1.1.4.md +++ /dev/null @@ -1,21 +0,0 @@ -# metadata -lo: 1.1.4 -k-level: K2 -points: 1 -correct: - -## question - - -## answers -a) -b) -c) -d) - -## justification -a) -b) -c) -d) - diff --git a/libs/question-1.1.5.md b/libs/question-1.1.5.md deleted file mode 100644 index ecd4e81..0000000 --- a/libs/question-1.1.5.md +++ /dev/null @@ -1,21 +0,0 @@ -# metadata -lo: 1.1.5 -k-level: K2 -points: 1 -correct: - -## question - - -## answers -a) -b) -c) -d) - -## justification -a) -b) -c) -d) - diff --git a/libs/question-1.1.6.md b/libs/question-1.1.6.md deleted file mode 100644 index 5da7e8a..0000000 --- a/libs/question-1.1.6.md +++ /dev/null @@ -1,21 +0,0 @@ -# metadata -lo: 1.1.6 -k-level: K2 -points: 1 -correct: - -## question - - -## answers -a) -b) -c) -d) - -## justification -a) -b) -c) -d) - diff --git a/libs/question-1.2.1.md b/libs/question-1.2.1.md deleted file mode 100644 index 1e59849..0000000 --- a/libs/question-1.2.1.md +++ /dev/null @@ -1,21 +0,0 @@ -# metadata -lo: 1.2.1 -k-level: K2 -points: 1 -correct: - -## question - - -## answers -a) -b) -c) -d) - -## justification -a) -b) -c) -d) - diff --git a/libs/question-1.2.2.md b/libs/question-1.2.2.md deleted file mode 100644 index cf58ff8..0000000 --- a/libs/question-1.2.2.md +++ /dev/null @@ -1,21 +0,0 @@ -# metadata -lo: 1.2.2 -k-level: K2 -points: 1 -correct: - -## question - - -## answers -a) -b) -c) -d) - -## justification -a) -b) -c) -d) - diff --git a/libs/question-1.2.3.md b/libs/question-1.2.3.md deleted file mode 100644 index 947ddd7..0000000 --- a/libs/question-1.2.3.md +++ /dev/null @@ -1,21 +0,0 @@ -# metadata -lo: 1.2.3 -k-level: K2 -points: 1 -correct: - -## question - - -## answers -a) -b) -c) -d) - -## justification -a) -b) -c) -d) - diff --git a/libs/question-2.1.1.md b/libs/question-2.1.1.md deleted file mode 100644 index abedccf..0000000 --- a/libs/question-2.1.1.md +++ /dev/null @@ -1,21 +0,0 @@ -# metadata -lo: 2.1.1 -k-level: K3 -points: 2 -correct: - -## question - - -## answers -a) -b) -c) -d) - -## justification -a) -b) -c) -d) - diff --git a/libs/question-2.1.2.md b/libs/question-2.1.2.md deleted file mode 100644 index 9fac939..0000000 --- a/libs/question-2.1.2.md +++ /dev/null @@ -1,21 +0,0 @@ -# metadata -lo: 2.1.2 -k-level: K2 -points: 1 -correct: - -## question - - -## answers -a) -b) -c) -d) - -## justification -a) -b) -c) -d) - diff --git a/libs/question-2.1.3.md b/libs/question-2.1.3.md deleted file mode 100644 index 82c909d..0000000 --- a/libs/question-2.1.3.md +++ /dev/null @@ -1,21 +0,0 @@ -# metadata -lo: 2.1.3 -k-level: K2 -points: 1 -correct: - -## question - - -## answers -a) -b) -c) -d) - -## justification -a) -b) -c) -d) - diff --git a/libs/question-2.1.4.md b/libs/question-2.1.4.md deleted file mode 100644 index 86506fa..0000000 --- a/libs/question-2.1.4.md +++ /dev/null @@ -1,21 +0,0 @@ -# metadata -lo: 2.1.4 -k-level: K2 -points: 1 -correct: - -## question - - -## answers -a) -b) -c) -d) - -## justification -a) -b) -c) -d) - diff --git a/libs/question-2.2.1.md b/libs/question-2.2.1.md deleted file mode 100644 index 3d425a0..0000000 --- a/libs/question-2.2.1.md +++ /dev/null @@ -1,21 +0,0 @@ -# metadata -lo: 2.2.1 -k-level: K2 -points: 1 -correct: - -## question - - -## answers -a) -b) -c) -d) - -## justification -a) -b) -c) -d) - diff --git a/libs/question-2.2.2.md b/libs/question-2.2.2.md deleted file mode 100644 index a7d73ee..0000000 --- a/libs/question-2.2.2.md +++ /dev/null @@ -1,21 +0,0 @@ -# metadata -lo: 2.2.2 -k-level: K2 -points: 1 -correct: - -## question - - -## answers -a) -b) -c) -d) - -## justification -a) -b) -c) -d) - diff --git a/libs/question-2.2.3.md b/libs/question-2.2.3.md deleted file mode 100644 index 1da80c2..0000000 --- a/libs/question-2.2.3.md +++ /dev/null @@ -1,21 +0,0 @@ -# metadata -lo: 2.2.3 -k-level: K2 -points: 1 -correct: - -## question - - -## answers -a) -b) -c) -d) - -## justification -a) -b) -c) -d) - diff --git a/libs/question-2.2.4.md b/libs/question-2.2.4.md deleted file mode 100644 index bea04fc..0000000 --- a/libs/question-2.2.4.md +++ /dev/null @@ -1,21 +0,0 @@ -# metadata -lo: 2.2.4 -k-level: K2 -points: 1 -correct: - -## question - - -## answers -a) -b) -c) -d) - -## justification -a) -b) -c) -d) - diff --git a/libs/question-2.2.5.md b/libs/question-2.2.5.md deleted file mode 100644 index 1cdbc3f..0000000 --- a/libs/question-2.2.5.md +++ /dev/null @@ -1,21 +0,0 @@ -# metadata -lo: 2.2.5 -k-level: K2 -points: 1 -correct: - -## question - - -## answers -a) -b) -c) -d) - -## justification -a) -b) -c) -d) - diff --git a/libs/question-2.2.6.md b/libs/question-2.2.6.md deleted file mode 100644 index 310016c..0000000 --- a/libs/question-2.2.6.md +++ /dev/null @@ -1,21 +0,0 @@ -# metadata -lo: 2.2.6 -k-level: K3 -points: 2 -correct: - -## question - - -## answers -a) -b) -c) -d) - -## justification -a) -b) -c) -d) - diff --git a/libs/question-3.1.1.md b/libs/question-3.1.1.md deleted file mode 100644 index ee69208..0000000 --- a/libs/question-3.1.1.md +++ /dev/null @@ -1,21 +0,0 @@ -# metadata -lo: 3.1.1 -k-level: K2 -points: 1 -correct: - -## question - - -## answers -a) -b) -c) -d) - -## justification -a) -b) -c) -d) - diff --git a/libs/question-3.1.2.md b/libs/question-3.1.2.md deleted file mode 100644 index 2ca6ce7..0000000 --- a/libs/question-3.1.2.md +++ /dev/null @@ -1,21 +0,0 @@ -# metadata -lo: 3.1.2 -k-level: K2 -points: 1 -correct: - -## question - - -## answers -a) -b) -c) -d) - -## justification -a) -b) -c) -d) - diff --git a/libs/question-3.1.3.md b/libs/question-3.1.3.md deleted file mode 100644 index 63d9cd7..0000000 --- a/libs/question-3.1.3.md +++ /dev/null @@ -1,21 +0,0 @@ -# metadata -lo: 3.1.3 -k-level: K3 -points: 2 -correct: - -## question - - -## answers -a) -b) -c) -d) - -## justification -a) -b) -c) -d) - diff --git a/libs/question-3.1.4.md b/libs/question-3.1.4.md deleted file mode 100644 index 0d2df44..0000000 --- a/libs/question-3.1.4.md +++ /dev/null @@ -1,21 +0,0 @@ -# metadata -lo: 3.1.4 -k-level: K2 -points: 1 -correct: - -## question - - -## answers -a) -b) -c) -d) - -## justification -a) -b) -c) -d) - diff --git a/libs/question-3.1.5.md b/libs/question-3.1.5.md deleted file mode 100644 index 2e938c5..0000000 --- a/libs/question-3.1.5.md +++ /dev/null @@ -1,21 +0,0 @@ -# metadata -lo: 3.1.5 -k-level: K2 -points: 1 -correct: - -## question - - -## answers -a) -b) -c) -d) - -## justification -a) -b) -c) -d) - diff --git a/libs/question-3.1.6.md b/libs/question-3.1.6.md deleted file mode 100644 index 0ea7eba..0000000 --- a/libs/question-3.1.6.md +++ /dev/null @@ -1,21 +0,0 @@ -# metadata -lo: 3.1.6 -k-level: K2 -points: 1 -correct: - -## question - - -## answers -a) -b) -c) -d) - -## justification -a) -b) -c) -d) - diff --git a/libs/question-3.2.1.md b/libs/question-3.2.1.md deleted file mode 100644 index 57476ff..0000000 --- a/libs/question-3.2.1.md +++ /dev/null @@ -1,21 +0,0 @@ -# metadata -lo: 3.2.1 -k-level: K2 -points: 1 -correct: - -## question - - -## answers -a) -b) -c) -d) - -## justification -a) -b) -c) -d) - diff --git a/libs/question-3.2.2.md b/libs/question-3.2.2.md deleted file mode 100644 index 376ac60..0000000 --- a/libs/question-3.2.2.md +++ /dev/null @@ -1,21 +0,0 @@ -# metadata -lo: 3.2.2 -k-level: K2 -points: 1 -correct: - -## question - - -## answers -a) -b) -c) -d) - -## justification -a) -b) -c) -d) - diff --git a/libs/question-3.2.3.md b/libs/question-3.2.3.md deleted file mode 100644 index b59626f..0000000 --- a/libs/question-3.2.3.md +++ /dev/null @@ -1,21 +0,0 @@ -# metadata -lo: 3.2.3 -k-level: K2 -points: 1 -correct: - -## question - - -## answers -a) -b) -c) -d) - -## justification -a) -b) -c) -d) - diff --git a/libs/question-3.3.1.md b/libs/question-3.3.1.md deleted file mode 100644 index 2141538..0000000 --- a/libs/question-3.3.1.md +++ /dev/null @@ -1,21 +0,0 @@ -# metadata -lo: 3.3.1 -k-level: K2 -points: 1 -correct: - -## question - - -## answers -a) -b) -c) -d) - -## justification -a) -b) -c) -d) - diff --git a/libs/question-3.3.2.md b/libs/question-3.3.2.md deleted file mode 100644 index 251e2b5..0000000 --- a/libs/question-3.3.2.md +++ /dev/null @@ -1,21 +0,0 @@ -# metadata -lo: 3.3.2 -k-level: K2 -points: 1 -correct: - -## question - - -## answers -a) -b) -c) -d) - -## justification -a) -b) -c) -d) - diff --git a/libs/question-3.3.3.md b/libs/question-3.3.3.md deleted file mode 100644 index 0785308..0000000 --- a/libs/question-3.3.3.md +++ /dev/null @@ -1,21 +0,0 @@ -# metadata -lo: 3.3.3 -k-level: K2 -points: 1 -correct: - -## question - - -## answers -a) -b) -c) -d) - -## justification -a) -b) -c) -d) - diff --git a/libs/question-3.3.4.md b/libs/question-3.3.4.md deleted file mode 100644 index 5459ab6..0000000 --- a/libs/question-3.3.4.md +++ /dev/null @@ -1,21 +0,0 @@ -# metadata -lo: 3.3.4 -k-level: K3 -points: 2 -correct: - -## question - - -## answers -a) -b) -c) -d) - -## justification -a) -b) -c) -d) - diff --git a/libs/question-4.1.1.md b/libs/question-4.1.1.md deleted file mode 100644 index 62093e6..0000000 --- a/libs/question-4.1.1.md +++ /dev/null @@ -1,21 +0,0 @@ -# metadata -lo: 4.1.1 -k-level: K2 -points: 1 -correct: - -## question - - -## answers -a) -b) -c) -d) - -## justification -a) -b) -c) -d) - diff --git a/libs/question-4.1.2.md b/libs/question-4.1.2.md deleted file mode 100644 index 30f4ef7..0000000 --- a/libs/question-4.1.2.md +++ /dev/null @@ -1,21 +0,0 @@ -# metadata -lo: 4.1.2 -k-level: K2 -points: 1 -correct: - -## question - - -## answers -a) -b) -c) -d) - -## justification -a) -b) -c) -d) - diff --git a/libs/question-4.2.1.md b/libs/question-4.2.1.md deleted file mode 100644 index bab2014..0000000 --- a/libs/question-4.2.1.md +++ /dev/null @@ -1,21 +0,0 @@ -# metadata -lo: 4.2.1 -k-level: K2 -points: 1 -correct: - -## question - - -## answers -a) -b) -c) -d) - -## justification -a) -b) -c) -d) - diff --git a/libs/question-4.2.2.md b/libs/question-4.2.2.md deleted file mode 100644 index 8110929..0000000 --- a/libs/question-4.2.2.md +++ /dev/null @@ -1,21 +0,0 @@ -# metadata -lo: 4.2.2 -k-level: K1 -points: 1 -correct: - -## question - - -## answers -a) -b) -c) -d) - -## justification -a) -b) -c) -d) - diff --git a/libs/question-4.2.3.md b/libs/question-4.2.3.md deleted file mode 100644 index 4e1d8ec..0000000 --- a/libs/question-4.2.3.md +++ /dev/null @@ -1,21 +0,0 @@ -# metadata -lo: 4.2.3 -k-level: K2 -points: 1 -correct: - -## question - - -## answers -a) -b) -c) -d) - -## justification -a) -b) -c) -d) - diff --git a/libs/question-4.2.4.md b/libs/question-4.2.4.md deleted file mode 100644 index eb594a8..0000000 --- a/libs/question-4.2.4.md +++ /dev/null @@ -1,21 +0,0 @@ -# metadata -lo: 4.2.4 -k-level: K1 -points: 1 -correct: - -## question - - -## answers -a) -b) -c) -d) - -## justification -a) -b) -c) -d) - diff --git a/libs/question-4.2.5.md b/libs/question-4.2.5.md deleted file mode 100644 index 5cbbb1c..0000000 --- a/libs/question-4.2.5.md +++ /dev/null @@ -1,21 +0,0 @@ -# metadata -lo: 4.2.5 -k-level: K1 -points: 1 -correct: - -## question - - -## answers -a) -b) -c) -d) - -## justification -a) -b) -c) -d) - diff --git a/libs/question-4.2.6.md b/libs/question-4.2.6.md deleted file mode 100644 index b3269d1..0000000 --- a/libs/question-4.2.6.md +++ /dev/null @@ -1,21 +0,0 @@ -# metadata -lo: 4.2.6 -k-level: K1 -points: 1 -correct: - -## question - - -## answers -a) -b) -c) -d) - -## justification -a) -b) -c) -d) - diff --git a/libs/question-4.2.7.md b/libs/question-4.2.7.md deleted file mode 100644 index 803afdb..0000000 --- a/libs/question-4.2.7.md +++ /dev/null @@ -1,21 +0,0 @@ -# metadata -lo: 4.2.7 -k-level: K1 -points: 1 -correct: - -## question - - -## answers -a) -b) -c) -d) - -## justification -a) -b) -c) -d) - diff --git a/libs/question-4.2.8.md b/libs/question-4.2.8.md deleted file mode 100644 index fad27b4..0000000 --- a/libs/question-4.2.8.md +++ /dev/null @@ -1,21 +0,0 @@ -# metadata -lo: 4.2.8 -k-level: K1 -points: 1 -correct: - -## question - - -## answers -a) -b) -c) -d) - -## justification -a) -b) -c) -d) - diff --git a/libs/question-4.2.9.md b/libs/question-4.2.9.md deleted file mode 100644 index 223a8ca..0000000 --- a/libs/question-4.2.9.md +++ /dev/null @@ -1,21 +0,0 @@ -# metadata -lo: 4.2.9 -k-level: K1 -points: 1 -correct: - -## question - - -## answers -a) -b) -c) -d) - -## justification -a) -b) -c) -d) - From cf0ad830af7e735e4fc547bf6dd347be0b046b4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Po=C4=BEan?= Date: Thu, 2 Jan 2025 11:38:08 +0100 Subject: [PATCH 3/4] file placement updated, other fixes --- .../generate_questions.py | 57 ++++++++++--------- .../learning-objectives.csv | 0 2 files changed, 29 insertions(+), 28 deletions(-) rename generate_questions.py => libs/generate_questions.py (88%) rename learning-objectives.csv => libs/learning-objectives.csv (100%) diff --git a/generate_questions.py b/libs/generate_questions.py similarity index 88% rename from generate_questions.py rename to libs/generate_questions.py index 4caed4c..8eabefa 100644 --- a/generate_questions.py +++ b/libs/generate_questions.py @@ -3,6 +3,29 @@ import csv import sys + +question_content = """# metadata +lo: {lo} +k-level: {k_level} +points: {points} +correct: + +## question + + +## answers +a) +b) +c) +d) + +## justification +a) +b) +c) +d) +""" + # Function to load LOs and K-levels from a csv file def load_learning_objectives(file_path): data = [] @@ -36,30 +59,8 @@ def get_points_and_warn(lo, k_level): def generate_md_questions(lo, k_level): # Get points and handle warnings points = get_points_and_warn(lo, k_level) - return f"""# metadata -lo: {lo} -k-level: {k_level} -points: {points} -correct: - -## question - - -## answers -a) -b) -c) -d) - -## justification -a) -b) -c) -d) - -""" - - + return question_content.format(lo=lo, k_level=k_level, points=points) + # Main script if __name__ == "__main__": # Check for help flag @@ -71,7 +72,7 @@ def generate_md_questions(lo, k_level): This script generates Markdown question files for learning objectives (LOs) with a specified prefix. Arguments: - A unique prefix for the ISTQB module (e.g., CTFL). + A unique code for the ISTQB module (e.g.: tae) used for the questions file names. This prefix is added to the filenames to prevent overwriting. [file_path] (Optional) Path to the source CSV file. Defaults to 'learning-objectives.csv'. @@ -83,7 +84,7 @@ def generate_md_questions(lo, k_level): # Check for required arguments if len(sys.argv) < 2: - print("Error: Missing required prefix argument. Run with --help for usage details.") + print("Error: Missing required argument "code". Run with --help for usage details.") sys.exit(1) # Get the prefix from the command-line arguments @@ -99,7 +100,7 @@ def generate_md_questions(lo, k_level): sys.exit(1) # Set the output directory to 'libs' - output_dir = Path("libs") + output_dir = Path("./../sample-exam/") # Ensure the 'libs' directory exists (if it doesn't, create it) output_dir.mkdir(parents=True, exist_ok=True) @@ -107,7 +108,7 @@ def generate_md_questions(lo, k_level): # Iterate over the data list and generate files for each LO for lo, k_level in data: # Generate a filename with the prefix - filename = f"{prefix}-question-{lo.replace(' ', '_')}.md" + filename = f"question-{prefix}-{lo.replace(' ', '_')}.md" # Combine the output directory path with the filename filepath = output_dir / filename # Write the generated content to the file diff --git a/learning-objectives.csv b/libs/learning-objectives.csv similarity index 100% rename from learning-objectives.csv rename to libs/learning-objectives.csv From 4e93da3e2ad09790904365ae894dcb634ad0f262 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Po=C4=BEan?= Date: Thu, 2 Jan 2025 11:40:29 +0100 Subject: [PATCH 4/4] syntax fix --- libs/generate_questions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/generate_questions.py b/libs/generate_questions.py index 8eabefa..ae58a45 100644 --- a/libs/generate_questions.py +++ b/libs/generate_questions.py @@ -84,7 +84,7 @@ def generate_md_questions(lo, k_level): # Check for required arguments if len(sys.argv) < 2: - print("Error: Missing required argument "code". Run with --help for usage details.") + print("Error: Missing required argument 'code'. Run with --help for usage details.") sys.exit(1) # Get the prefix from the command-line arguments