excel2moodle 0.3.2__py3-none-any.whl → 0.3.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,17 +1,34 @@
1
- import logging
2
- import lxml.etree as ET
3
- from pathlib import Path
4
1
  import base64 as base64
2
+ import logging
3
+ import re as re
4
+ from pathlib import Path
5
+ from typing import Match
5
6
 
6
- from excel2moodle.core import category, etHelpers
7
- from excel2moodle.core.globals import XMLTags, TextElements, DFIndex, questionTypes, parserSettings
8
- from excel2moodle.core.exceptions import QNotParsedException
7
+ import lxml.etree as ET
9
8
 
9
+ from excel2moodle.core import etHelpers
10
+ from excel2moodle.core.exceptions import QNotParsedException
11
+ from excel2moodle.core.globals import (
12
+ DFIndex,
13
+ TextElements,
14
+ XMLTags,
15
+ parserSettings,
16
+ questionTypes,
17
+ )
10
18
 
11
19
  logger = logging.getLogger(__name__)
12
20
 
13
- class Question():
14
- def __init__(self, category,name:str, number:int, parent=None, qtype:str="type", points:float=0):
21
+
22
+ class Question:
23
+ def __init__(
24
+ self,
25
+ category,
26
+ name: str,
27
+ number: int,
28
+ parent=None,
29
+ qtype: str = "type",
30
+ points: float = 0,
31
+ ):
15
32
  self.category = category
16
33
  self.katName = self.category.name
17
34
  self.name = name
@@ -19,57 +36,96 @@ class Question():
19
36
  self.parent = parent
20
37
  self.qtype: str = qtype
21
38
  self.moodleType = questionTypes[qtype]
22
- self.points = ( points if points is not 0 else self.category.points)
23
- self.element: ET.Element|None=None
24
- self.picture:Picture
25
- self.id:str
26
- self.qtextElements: list[ET.Element] = []
27
- self.bulletList: list[ET.Element] = []
39
+ self.points = points if points != 0 else self.category.points
40
+ self.element: ET.Element | None = None
41
+ self.picture: Picture
42
+ self.id: str
43
+ self.qtextParagraphs: list[ET.Element] = []
44
+ self.bulletList: ET.Element | None = None
28
45
  self.answerVariants: list[ET.Element] = []
29
- self.variants:int|None = None
46
+ self.variants: int | None = None
47
+ self.variables: dict[str, list[float | int]] = {}
30
48
  self.setID()
31
- self.standardTags = {
32
- "hidden":"false"
33
- }
49
+ self.standardTags = {"hidden": "false"}
34
50
  logger.debug(f"Question {self.id} is initialized")
35
51
 
36
- def __repr__(self)->str:
37
- li:list[str] = []
52
+ def __repr__(self) -> str:
53
+ li: list[str] = []
38
54
  li.append(f"Question v{self.category.version}")
39
- li.append(f'{self.id=}')
40
- li.append(f'{self.parent=}')
55
+ li.append(f"{self.id=}")
56
+ li.append(f"{self.parent=}")
41
57
  return "\n".join(li)
42
58
 
43
- def assemble(self, variant:int=1)->None:
59
+ def assemble(self, variant: int = 1) -> None:
60
+ textElements: list[ET.Element] = []
61
+ textElements.extend(self.qtextParagraphs)
62
+ logger.debug(f"Starting assembly of {self.id}")
44
63
  if self.element is not None:
45
64
  mainText = self.element.find(XMLTags.QTEXT)
46
- else: raise QNotParsedException("Cant assamble, if element is none", self.id)
47
- if len(self.bulletList)>0:
48
- self.qtextElements.append(self.bulletList[variant-1])
65
+ logger.debug(f"found existing Text in element {mainText=}")
66
+ txtele = mainText.find("text")
67
+ if txtele is not None:
68
+ mainText.remove(txtele)
69
+ logger.debug(f"removed prevously existing questiontext")
70
+ else:
71
+ raise QNotParsedException("Cant assamble, if element is none", self.id)
72
+ if self.variants is not None:
73
+ textElements.append(self.getBPointVariant(variant - 1))
74
+ elif self.bulletList is not None:
75
+ textElements.append(self.bulletList)
49
76
  if hasattr(self, "picture") and self.picture.ready:
50
- self.qtextElements.append(self.picture.htmlTag)
77
+ textElements.append(self.picture.htmlTag)
51
78
  mainText.append(self.picture.element)
52
- mainText.append(etHelpers.getCdatTxtElement(self.qtextElements))
53
- self.element.insert(3, mainText)
54
- if len( self.answerVariants ) > 0:
55
- self.element.insert(5, self.answerVariants[variant-1])
79
+ mainText.append(etHelpers.getCdatTxtElement(textElements))
80
+ # self.element.insert(3, mainText)
81
+ logger.debug(f"inserted MainText to question element")
82
+ if len(self.answerVariants) > 0:
83
+ ans = self.element.find(XMLTags.ANSWER)
84
+ if ans is not None:
85
+ self.element.remove(ans)
86
+ logger.debug("removed previous answer element")
87
+ self.element.insert(5, self.answerVariants[variant - 1])
56
88
  return None
57
89
 
58
- def setID(self, id = 0)->None:
90
+ def setID(self, id=0) -> None:
59
91
  if id == 0:
60
92
  self.id: str = f"{self.category.id}{self.number:02d}"
61
- else: self.id:str = str(id)
93
+ else:
94
+ self.id: str = str(id)
95
+
96
+ def getBPointVariant(self, variant: int) -> ET.Element:
97
+ if self.bulletList is None:
98
+ return None
99
+ # matches {a}, {some_var}, etc.
100
+ varPlaceholder = re.compile(r"{(\w+)}")
101
+
102
+ def replaceMatch(match: Match[str]) -> str | int | float:
103
+ key = match.group(1)
104
+ if key in self.variables:
105
+ value = self.variables[key][variant]
106
+ return f"{value}".replace(".", ",\\!")
107
+ return match.group(0) # keep original if no match
62
108
 
63
- class Picture():
64
- def __init__(self, picKey:str, imgFolder:Path, question:Question):
109
+ unorderedList = TextElements.ULIST.create()
110
+ for li in self.bulletList:
111
+ listItemText = li.text or ""
112
+ bullet = TextElements.LISTITEM.create()
113
+ bullet.text = varPlaceholder.sub(replaceMatch, listItemText)
114
+ logger.debug(f"Inserted Variables into List: {bullet}")
115
+ unorderedList.append(bullet)
116
+ return unorderedList
117
+
118
+
119
+ class Picture:
120
+ def __init__(self, picKey: str, imgFolder: Path, question: Question):
65
121
  self.pic = picKey
66
- self.ready:bool = False
122
+ self.ready: bool = False
67
123
  self.question = question
68
124
  self.imgFolder = (imgFolder / question.katName).resolve()
69
- self.htmlTag:ET.Element
70
- self.path:Path
125
+ self.htmlTag: ET.Element
126
+ self.path: Path
71
127
  self._setPath()
72
- if hasattr(self, 'picID'):
128
+ if hasattr(self, "picID"):
73
129
  self.ready = self.__getImg()
74
130
 
75
131
  def _setPath(self):
@@ -77,30 +133,43 @@ class Picture():
77
133
  self.picID = self.question.id
78
134
  else:
79
135
  selectedPic = self.pic[2:]
80
- logger.debug(f"got a picture key {selectedPic =}")
136
+ logger.debug(f"got a picture key {selectedPic=}")
81
137
  try:
82
- self.picID = f"{self.question.category.id}{int(selectedPic):02d}"
138
+ self.picID = f"{self.question.category.id}{
139
+ int(selectedPic):02d}"
83
140
  except ValueError as e:
84
- logger.warning(msg=f"Bild-ID konnte aus dem Key: {self.pic = }nicht festgestellt werden", exc_info=e)
141
+ logger.warning(
142
+ msg=f"Bild-ID konnte aus dem Key: {
143
+ self.pic=}nicht festgestellt werden",
144
+ exc_info=e,
145
+ )
85
146
 
86
147
  def __getBase64Img(self, imgPath):
87
- with open(imgPath, 'rb') as img:
88
- img64 = base64.b64encode(img.read()).decode('utf-8')
148
+ with open(imgPath, "rb") as img:
149
+ img64 = base64.b64encode(img.read()).decode("utf-8")
89
150
  return img64
90
151
 
91
- def __setImgElement(self, dir:Path, picID:int)->None:
152
+ def __setImgElement(self, dir: Path, picID: int) -> None:
92
153
  """gibt das Bild im dirPath mit dir qID als base64 encodiert mit den entsprechenden XML-Tags zurück"""
93
- self.path:Path = ( dir/ str(picID) ).with_suffix('.svg')
94
- self.element:ET.Element = ET.Element("file", name=f'{self.path.name}', path='/', encoding='base64')
154
+ self.path: Path = (dir / str(picID)).with_suffix(".svg")
155
+ self.element: ET.Element = ET.Element(
156
+ "file", name=f"{self.path.name}", path="/", encoding="base64"
157
+ )
95
158
  self.element.text = self.__getBase64Img(self.path)
96
159
 
97
-
98
- def __getImg(self)->bool:
160
+ def __getImg(self) -> bool:
99
161
  try:
100
162
  self.__setImgElement(self.imgFolder, int(self.picID))
101
- self.htmlTag = ET.Element("img", src=f"@@PLUGINFILE@@/{self.path.name}", alt=f"Bild {self.path.name}", width="500")
163
+ self.htmlTag = ET.Element(
164
+ "img",
165
+ src=f"@@PLUGINFILE@@/{self.path.name}",
166
+ alt=f"Bild {self.path.name}",
167
+ width="500",
168
+ )
102
169
  return True
103
170
  except FileNotFoundError as e:
104
- logger.warning(msg=f"Bild {self.picID} konnte nicht gefunden werden ", exc_info=e)
171
+ logger.warning(
172
+ msg=f"Bild {self.picID} konnte nicht gefunden werden ", exc_info=e
173
+ )
105
174
  self.element = None
106
175
  return False
@@ -8,42 +8,40 @@ Those things are considered:
8
8
  If Those checks pass, a question is created, which can be accessed via ``Validator.question``
9
9
  """
10
10
 
11
+ import logging
11
12
  from types import UnionType
12
13
 
13
- from pandas.core.series import notna
14
- from excel2moodle.core.question import Question
15
- from excel2moodle.core.globals import DFIndex
16
- from excel2moodle.core.exceptions import InvalidFieldException, NanException
17
14
  import pandas as pd
18
- import logging
19
15
 
16
+ from excel2moodle.core.exceptions import InvalidFieldException
17
+ from excel2moodle.core.globals import DFIndex
18
+ from excel2moodle.core.question import Question
19
+
20
+ logger = logging.getLogger(__name__)
20
21
 
21
- class Validator():
22
+
23
+ class Validator:
22
24
  def __init__(self, category) -> None:
23
- self.question:Question
25
+ self.question: Question
24
26
  self.category = category
25
- self.mandatory: dict[DFIndex, type|UnionType] = {
27
+ self.mandatory: dict[DFIndex, type | UnionType] = {
26
28
  DFIndex.TEXT: str,
27
29
  DFIndex.NAME: str,
28
30
  DFIndex.TYPE: str,
29
31
  }
30
- self.optional: dict[DFIndex, type|UnionType] = {
31
- DFIndex.BPOINTS : str,
32
+ self.optional: dict[DFIndex, type | UnionType] = {
33
+ DFIndex.BPOINTS: str,
32
34
  DFIndex.NAME: str,
33
- DFIndex.PICTURE: int|str,
34
- }
35
- self.nfOpt: dict[DFIndex, type|UnionType] = {
36
- DFIndex.RESULT: float|int,
35
+ DFIndex.PICTURE: int | str,
37
36
  }
38
- self.nfMand: dict[DFIndex, type|UnionType] = {
37
+ self.nfOpt: dict[DFIndex, type | UnionType] = {
38
+ DFIndex.RESULT: float | int,
39
39
  }
40
- self.nfmOpt: dict[DFIndex, type|UnionType] = {
41
- }
42
- self.nfmMand: dict[DFIndex, type|UnionType] = {
43
- }
44
- self.mcOpt: dict[DFIndex, type|UnionType] = {
45
- }
46
- self.mcMand: dict[DFIndex, type|UnionType] = {
40
+ self.nfMand: dict[DFIndex, type | UnionType] = {}
41
+ self.nfmOpt: dict[DFIndex, type | UnionType] = {}
42
+ self.nfmMand: dict[DFIndex, type | UnionType] = {}
43
+ self.mcOpt: dict[DFIndex, type | UnionType] = {}
44
+ self.mcMand: dict[DFIndex, type | UnionType] = {
47
45
  DFIndex.TRUE: str,
48
46
  DFIndex.FALSE: str,
49
47
  DFIndex.ANSTYPE: str,
@@ -55,15 +53,15 @@ class Validator():
55
53
  "NFM": (self.nfmOpt, self.nfmMand),
56
54
  }
57
55
 
58
- def setup(self, df:pd.Series, index:int)->bool:
56
+ def setup(self, df: pd.Series, index: int) -> bool:
59
57
  self.df = df
60
58
  self.index = index
61
59
  typ = self.df.loc[DFIndex.TYPE]
62
60
  self.mandatory.update(self.mapper[typ][1])
63
61
  self.optional.update(self.mapper[typ][0])
64
62
  return True
65
-
66
- def validate(self )->bool:
63
+
64
+ def validate(self) -> bool:
67
65
  id = f"{self.category.id}{self.index:02d}"
68
66
  checker, missing = self._mandatory()
69
67
  if not checker:
@@ -76,9 +74,25 @@ class Validator():
76
74
  if missing is not None:
77
75
  raise InvalidFieldException(msg, id, missing)
78
76
  self._getQuestion()
77
+ self._getData()
79
78
  return True
80
79
 
81
- def _mandatory(self)->tuple[bool,DFIndex|None]:
80
+ def _getData(self) -> None:
81
+ self.qdata: dict[str, str | float | int | list] = {}
82
+ for idx, val in self.df.items():
83
+ if not isinstance(idx, str):
84
+ logger.debug(f"Got a non String key in the spreadsheet, skipping it")
85
+ continue
86
+ if idx in self.qdata:
87
+ if isinstance(self.qdata[idx], list):
88
+ self.qdata[idx].append(val)
89
+ else:
90
+ existing = self.qdata[idx]
91
+ self.qdata[idx] = [existing, val]
92
+ else:
93
+ self.qdata[idx] = val
94
+
95
+ def _mandatory(self) -> tuple[bool, DFIndex | None]:
82
96
  """detects if all keys of mandatory are filled with values"""
83
97
  checker = pd.Series.notna(self.df)
84
98
  for k in self.mandatory.keys():
@@ -90,11 +104,11 @@ class Validator():
90
104
  if not c.any():
91
105
  return False, k
92
106
  elif not c:
93
- return False, k,
107
+ return False, k
94
108
  return True, None
95
109
 
96
- def _typeCheck(self)->tuple[bool, list[DFIndex]|None]:
97
- invalid:list[DFIndex] = []
110
+ def _typeCheck(self) -> tuple[bool, list[DFIndex] | None]:
111
+ invalid: list[DFIndex] = []
98
112
  for field, typ in self.mandatory.items():
99
113
  if isinstance(self.df[field], pd.Series):
100
114
  for f in self.df[field]:
@@ -109,16 +123,13 @@ class Validator():
109
123
  invalid.append(field)
110
124
  if len(invalid) == 0:
111
125
  return True, None
112
- else:
126
+ else:
113
127
  return False, invalid
114
128
 
115
-
116
- def _getQuestion(self)->None:
129
+ def _getQuestion(self) -> None:
117
130
  name = self.df[DFIndex.NAME]
118
131
  qtype = self.df[DFIndex.TYPE]
119
- self.question=Question(self.category,
120
- name = str(name),
121
- number = self.index,
122
- qtype = str(qtype))
132
+ self.question = Question(
133
+ self.category, name=str(name), number=self.index, qtype=str(qtype)
134
+ )
123
135
  return None
124
-
@@ -1,19 +1,28 @@
1
- """This Module holds small Helperfunctions related to string manipulation
2
- """
1
+ """This Module holds small Helperfunctions related to string manipulation"""
3
2
 
3
+ import base64 as base64
4
4
  from pathlib import Path
5
+
5
6
  import lxml.etree as ET
6
- import base64 as base64
7
+
7
8
 
8
9
  def stripWhitespace(stringList):
9
10
  stripped = []
10
11
  for i in stringList:
11
- stripped.append(i.strip())
12
+ s = i.strip()
13
+ if s:
14
+ stripped.append(s)
12
15
  return stripped
13
16
 
17
+
18
+ def stringToFloat(string: str) -> float:
19
+ string.replace(",", ".")
20
+ return float(string)
21
+
22
+
14
23
  def get_bullet_string(s):
15
24
  """Formatiert die Angaben zum Statischen System hübsch"""
16
- split = s.split(';')
25
+ split = s.split(";")
17
26
  s_spl = stripWhitespace(split)
18
27
  name = []
19
28
  var = []
@@ -27,20 +36,26 @@ def get_bullet_string(s):
27
36
  unit.append(sc_split[4])
28
37
  bulletString = ['</p><ul dir="ltr">']
29
38
  for i in range(0, len(s_spl)):
30
- num = quant[i].split(',')
31
- if len(num)==2:
39
+ num = quant[i].split(",")
40
+ if len(num) == 2:
32
41
  num_s = f"{str(num[0])},\\!{str(num[1])}~"
33
- else: num_s = f"{str(num[0])},\\!0~"
42
+ else:
43
+ num_s = f"{str(num[0])},\\!0~"
34
44
  bulletString.append('<li style="text-align: left;">')
35
- bulletString.append(f"{ name[i] }: \\( {var[i]} = {num_s} \\mathrm{{ {unit[i]} }}\\) </li>\n")
36
- bulletString.append('<br></ul>')
45
+ bulletString.append(
46
+ f"{name[i]}: \\( {var[i]} = {
47
+ num_s} \\mathrm{{ {unit[i]} }}\\) </li>\n"
48
+ )
49
+ bulletString.append("<br></ul>")
37
50
  return "\n".join(bulletString)
38
51
 
52
+
39
53
  def getBase64Img(imgPath):
40
- with open(imgPath, 'rb') as img:
41
- img64 = base64.b64encode(img.read()).decode('utf-8')
54
+ with open(imgPath, "rb") as img:
55
+ img64 = base64.b64encode(img.read()).decode("utf-8")
42
56
  return img64
43
57
 
58
+
44
59
  def getUnitsElementAsString(unit):
45
60
 
46
61
  def __getUnitEle__(name, multipl):
@@ -51,34 +66,37 @@ def getUnitsElementAsString(unit):
51
66
 
52
67
  unitsEle = ET.Element("units")
53
68
 
54
- def printDom(xmlElement:ET.Element, file:Path|None=None )->None:
69
+
70
+ def printDom(xmlElement: ET.Element, file: Path | None = None) -> None:
55
71
  """Prints the document tree of ``xmlTree`` to the ``file``, if specified, else dumps to stdout"""
56
72
  documentTree = ET.ElementTree(xmlElement)
57
73
  if file is not None:
58
74
  if file.parent.exists():
59
- documentTree.write(file, xml_declaration=True, encoding="utf-8", pretty_print=True)
75
+ documentTree.write(
76
+ file, xml_declaration=True, encoding="utf-8", pretty_print=True
77
+ )
60
78
  else:
61
- msg =f" No output File specified, here is the Element:"
62
- print(f'\n{ msg :=^80}')
63
- print( ET.tostring(xmlElement, encoding="utf-8", pretty_print=True))
79
+ msg = "No output File specified, here is the Element:"
80
+ print(f"\n{msg:=^80}")
81
+ print(ET.tostring(xmlElement, encoding="utf-8", pretty_print=True))
64
82
  print(f'{" End of Element ":=^80}')
65
83
 
66
84
 
67
- def texWrapper(text:str|list[str], style:str)->list[str]:
85
+ def texWrapper(text: str | list[str], style: str) -> list[str]:
68
86
  """Puts the strings inside ``text`` into a LaTex environment
69
87
 
70
88
  if ``style == unit``: inside ``\\mathrm{}``
71
- if ``style == math``: inside ``\\( \\)``
89
+ if ``style == math``: inside ``\\( \\)``
72
90
  """
73
91
 
74
- answers:list[str]=[]
75
- begin =""
92
+ answers: list[str] = []
93
+ begin = ""
76
94
  end = ""
77
95
  if style == "math":
78
- begin ="\\("
96
+ begin = "\\("
79
97
  end = "\\)"
80
98
  elif style == "unit":
81
- begin ="\\(\\mathrm{"
99
+ begin = "\\(\\mathrm{"
82
100
  end = "}\\)"
83
101
  if isinstance(text, str):
84
102
  li = [begin]
@@ -2,8 +2,6 @@
2
2
 
3
3
  The modules inside *extra* can be run standalone, but are planned to be available from the main Window as well
4
4
 
5
- To run a script execute the following: ``python -m excel2moodle.extra.SCRIPT``
5
+ To run a script execute the following: ``python -m excel2moodle.extra.SCRIPT``
6
6
  Note that there is no ``.py`` at the end!!
7
7
  """
8
-
9
- from excel2moodle.core import numericMultiQ
@@ -28,15 +28,18 @@ As Script
28
28
  #. Rinse and repeat
29
29
  """
30
30
 
31
- import re as re
32
- import pandas as pd
33
31
  from pathlib import Path
32
+
33
+ import pandas as pd
34
+
34
35
  from excel2moodle.core import numericMultiQ as nmq
35
36
 
36
37
  # Hier Bitte die Frage angeben, die getestet Werden soll:
37
38
 
38
- #===========================================================
39
- def checkResult(checkerValue:float, calculation:float, tolerance = 0.01)-> bool:
39
+ # ===========================================================
40
+
41
+
42
+ def checkResult(checkerValue: float, calculation: float, tolerance=0.01) -> bool:
40
43
  """Checks if the two Arguments are within the tolerance the same value
41
44
 
42
45
  :param checkerValue: the value the calculation is compared against
@@ -46,20 +49,23 @@ def checkResult(checkerValue:float, calculation:float, tolerance = 0.01)-> bool:
46
49
  :param tolerance: the standart tolerance is 0.01 -> 1%
47
50
  :type tolerance: float, optional
48
51
 
49
- :returns:
52
+ :returns:
50
53
  True if checkerValue == calculation
51
54
  False if checkerValue != calculation
52
55
  :rtype: bool
53
56
  """
54
57
 
55
- upper = abs(checkerValue + checkerValue*tolerance)
56
- lower = abs(checkerValue - checkerValue*tolerance)
58
+ upper = abs(checkerValue + checkerValue * tolerance)
59
+ lower = abs(checkerValue - checkerValue * tolerance)
57
60
  if abs(calculation) > lower and abs(calculation) < upper:
58
61
  return True
59
- else :
62
+ else:
60
63
  return False
61
64
 
62
- def equationChecker(categoryName: str, qNumber:int, spreadsheetFile)-> tuple[list[str], list[float], float]:
65
+
66
+ def equationChecker(
67
+ categoryName: str, qNumber: int, spreadsheetFile
68
+ ) -> tuple[list[str], list[float], float]:
63
69
  """This Function calculates all Results an invokes the checkResult function
64
70
 
65
71
  Parameters
@@ -91,34 +97,46 @@ def equationChecker(categoryName: str, qNumber:int, spreadsheetFile)-> tuple[lis
91
97
  except Exception:
92
98
  print(f"Es ist kein 'firstResult' gegeben, kann nichts überprüfen")
93
99
  res = 0
94
- bps, calcs = nmq.parseNumericMultiQuestion(df,bps,eq, qNumber)
100
+ bps, calcs = nmq.parseNumericMultiQuestion(df, bps, eq, qNumber)
95
101
  return bps, calcs, res
96
102
 
97
103
 
98
- def main(spreadsheetFile= Path("../Fragensammlung/Main_question_all.xlsx"), catN = None, qNumber = None)-> None:
99
- """Takes the Spreadsheet, and asks for a category and a question number
100
-
101
- """
104
+ def main(
105
+ spreadsheetFile=Path("../Fragensammlung/Main_question_all.xlsx"),
106
+ catN=None,
107
+ qNumber=None,
108
+ ) -> None:
109
+ """Takes the Spreadsheet, and asks for a category and a question number"""
102
110
  if catN == None:
103
111
  catN = input("Geben Sie die Kategorie an: KAT_")
104
112
  categoryName = f"KAT_{catN}"
105
113
  if qNumber == None:
106
114
  qNumber = int(input("Geben Sie die Fragennummer an: "))
107
- bullets, results, firstResult = equationChecker(categoryName, qNumber, spreadsheetFile=spreadsheetFile)
115
+ bullets, results, firstResult = equationChecker(
116
+ categoryName, qNumber, spreadsheetFile=spreadsheetFile
117
+ )
108
118
  check = False
109
119
 
110
120
  for i, calculation in enumerate(results):
111
- if i == 0 and firstResult !=0:
112
- check = checkResult(firstResult, calculation)
113
- print(f"Ergebnis {i+1}: \t{calculation}\n\tMit den Werten: \n{bullets[i]}\n")
121
+ if i == 0 and firstResult != 0:
122
+ check = checkResult(firstResult, calculation)
123
+ print(
124
+ f"Ergebnis {
125
+ i+1}: \t{calculation}\n\tMit den Werten: \n{bullets[i]}\n"
126
+ )
114
127
 
115
128
  if check == True:
116
- print(f"Das erste berechnete Ergebnis stimmt mit dem Wert in 'firstResult' überein\n")
129
+ print(
130
+ f"Das erste berechnete Ergebnis stimmt mit dem Wert in 'firstResult' überein\n"
131
+ )
117
132
  else:
118
- print(f"WARNUNG: Das erste berechnete Ergebnis weicht von dem Wert {firstResult = } ab.\n")
133
+ print(
134
+ f"WARNUNG: Das erste berechnete Ergebnis weicht von dem Wert {
135
+ firstResult=} ab.\n"
136
+ )
119
137
 
120
138
 
121
- if __name__ =="__main__":
122
- spreadsheet =input(f"Geben Sie den Pfad zu dem spreadsheet an:")
139
+ if __name__ == "__main__":
140
+ spreadsheet = input(f"Geben Sie den Pfad zu dem spreadsheet an:")
123
141
  while True:
124
142
  main(Path(spreadsheet))