excel2moodle 0.3.7__py3-none-any.whl → 0.4.1__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.
@@ -6,6 +6,7 @@ import lxml.etree as ET
6
6
 
7
7
  import excel2moodle.core.etHelpers as eth
8
8
  from excel2moodle.core import stringHelpers
9
+ from excel2moodle.core.exceptions import InvalidFieldException
9
10
  from excel2moodle.core.globals import (
10
11
  DFIndex,
11
12
  TextElements,
@@ -13,7 +14,8 @@ from excel2moodle.core.globals import (
13
14
  feedbackStr,
14
15
  )
15
16
  from excel2moodle.core.parser import QuestionParser
16
- from excel2moodle.core.question import Question
17
+ from excel2moodle.core.question import Picture, Question
18
+ from excel2moodle.core.settings import SettingsKey
17
19
 
18
20
 
19
21
  class MCQuestion(Question):
@@ -29,6 +31,7 @@ class MCQuestion(Question):
29
31
 
30
32
  def __init__(self, *args, **kwargs) -> None:
31
33
  super().__init__(*args, **kwargs)
34
+ self.AnsStyles = ["math", "unit", "text", "picture"]
32
35
 
33
36
 
34
37
  class MCQuestionParser(QuestionParser):
@@ -42,6 +45,10 @@ class MCQuestionParser(QuestionParser):
42
45
  XMLTags.INCORFEEDB,
43
46
  ]
44
47
 
48
+ def setup(self, question: MCQuestion) -> None:
49
+ self.question: MCQuestion = question
50
+ super().setup(question)
51
+
45
52
  def getAnsElementsList(
46
53
  self,
47
54
  answerList: list,
@@ -49,9 +56,12 @@ class MCQuestionParser(QuestionParser):
49
56
  format="html",
50
57
  ) -> list[ET.Element]:
51
58
  elementList: list[ET.Element] = []
52
- for ans in answerList:
59
+ for i, ans in enumerate(answerList):
53
60
  p = TextElements.PLEFT.create()
54
- p.text = str(ans)
61
+ if self.answerType == "picture":
62
+ p.append(ans)
63
+ else:
64
+ p.text = str(ans)
55
65
  text = eth.getCdatTxtElement(p)
56
66
  elementList.append(
57
67
  ET.Element(XMLTags.ANSWER, fraction=str(fraction), format=format),
@@ -65,6 +75,8 @@ class MCQuestionParser(QuestionParser):
65
75
  style=TextElements.SPANRED,
66
76
  ),
67
77
  )
78
+ if self.answerType == "picture":
79
+ elementList[-1].append(self.falseImgs[i].element)
68
80
  elif fraction > 0:
69
81
  elementList[-1].append(
70
82
  eth.getFeedBEle(
@@ -73,21 +85,43 @@ class MCQuestionParser(QuestionParser):
73
85
  style=TextElements.SPANGREEN,
74
86
  ),
75
87
  )
88
+ if self.answerType == "picture":
89
+ elementList[-1].append(self.trueImgs[i].element)
76
90
  return elementList
77
91
 
78
92
  def setAnswers(self) -> list[ET.Element]:
79
- ansStyle = self.rawInput[DFIndex.ANSTYPE]
93
+ self.answerType = self.rawInput[DFIndex.ANSTYPE]
80
94
  true = stringHelpers.getListFromStr(self.rawInput[DFIndex.TRUE])
81
- trueAnsList = stringHelpers.texWrapper(true, style=ansStyle)
82
- self.logger.debug(f"got the following true answers \n {trueAnsList=}")
83
95
  false = stringHelpers.getListFromStr(self.rawInput[DFIndex.FALSE])
84
- falseAnsList = stringHelpers.texWrapper(false, style=ansStyle)
85
- self.logger.debug(f"got the following false answers \n {falseAnsList=}")
96
+ if self.answerType not in self.question.AnsStyles:
97
+ msg = f"The Answer style: {self.answerType} is not supported"
98
+ raise InvalidFieldException(msg, self.question.id, DFIndex.ANSTYPE)
99
+ if self.answerType == "picture":
100
+ f = self.settings.get(SettingsKey.PICTUREFOLDER)
101
+ imgFolder = (f / self.question.katName).resolve()
102
+ w = self.settings.get(SettingsKey.ANSPICWIDTH)
103
+ self.trueImgs: list[Picture] = [
104
+ Picture(t, imgFolder, self.question.id, width=w) for t in true
105
+ ]
106
+ self.falseImgs: list[Picture] = [
107
+ Picture(t, imgFolder, self.question.id, width=w) for t in false
108
+ ]
109
+ trueAnsList: list[str] = [pic.htmlTag for pic in self.trueImgs]
110
+ falseAList: list[str] = [pic.htmlTag for pic in self.falseImgs]
111
+ else:
112
+ trueAnsList: list[str] = stringHelpers.texWrapper(
113
+ true, style=self.answerType
114
+ )
115
+ self.logger.debug(f"got the following true answers \n {trueAnsList=}")
116
+ falseAList: list[str] = stringHelpers.texWrapper(
117
+ false, style=self.answerType
118
+ )
119
+ self.logger.debug(f"got the following false answers \n {falseAList=}")
86
120
  truefrac = 1 / len(trueAnsList) * 100
87
- falsefrac = 1 / len(trueAnsList) * (-100)
121
+ falsefrac = 1 / len(falseAList) * (-100)
88
122
  self.tmpEle.find(XMLTags.PENALTY).text = str(round(truefrac / 100, 4))
89
123
  ansList = self.getAnsElementsList(trueAnsList, fraction=round(truefrac, 4))
90
124
  ansList.extend(
91
- self.getAnsElementsList(falseAnsList, fraction=round(falsefrac, 4)),
125
+ self.getAnsElementsList(falseAList, fraction=round(falsefrac, 4)),
92
126
  )
93
127
  return ansList
@@ -25,6 +25,5 @@ class NFQuestionParser(QuestionParser):
25
25
  def setAnswers(self) -> list[ET.Element]:
26
26
  result = self.rawInput[DFIndex.RESULT]
27
27
  ansEle: list[ET.Element] = []
28
- tol = self.rawInput[DFIndex.TOLERANCE]
29
- ansEle.append(self.getNumericAnsElement(result=result, tolerance=tol))
28
+ ansEle.append(self.getNumericAnsElement(result=result))
30
29
  return ansEle
@@ -39,9 +39,8 @@ class NFMQuestionParser(QuestionParser):
39
39
  self._setupAstIntprt(self.question.variables, n)
40
40
  result = self.astEval(equation)
41
41
  if isinstance(result, float):
42
- tol = self.rawInput[DFIndex.TOLERANCE]
43
42
  ansElementsList.append(
44
- self.getNumericAnsElement(result=round(result, 3), tolerance=tol),
43
+ self.getNumericAnsElement(result=round(result, 3)),
45
44
  )
46
45
  self.question.answerVariants = ansElementsList
47
46
  self.setVariants(len(ansElementsList))
excel2moodle/ui/appUi.py CHANGED
@@ -13,11 +13,12 @@ from PySide6.QtCore import QRunnable, Qt, QThreadPool
13
13
  from excel2moodle import mainLogger
14
14
  from excel2moodle.core.category import Category
15
15
  from excel2moodle.core.dataStructure import QuestionDB
16
+ from excel2moodle.core.settings import Settings, SettingsKey
16
17
  from excel2moodle.extra import equationVerification as eqVerif
17
18
  from excel2moodle.logger import LogWindowHandler
18
19
  from excel2moodle.ui import dialogs
19
- from excel2moodle.ui.settings import Settings, SettingsKey
20
20
  from excel2moodle.ui.treewidget import CategoryItem, QuestionItem
21
+ from excel2moodle.ui.windowDoc import DocumentationWindow
21
22
  from excel2moodle.ui.windowMain import Ui_MoodleTestGenerator
22
23
 
23
24
  from .windowEquationChecker import Ui_EquationChecker
@@ -38,16 +39,18 @@ class MainWindow(QtWidgets.QMainWindow):
38
39
  self.testDB = testDB
39
40
  self.ui = Ui_MoodleTestGenerator()
40
41
  self.ui.setupUi(self)
42
+ self.exportDialog = dialogs.ExportDialog(self)
43
+ self.questionPreview = dialogs.QuestionPreview(self)
41
44
  self.connectEvents()
42
45
  logger.info("Settings are stored under: %s", self.settings.fileName())
43
46
  self.ui.treeWidget.setSelectionMode(QtWidgets.QAbstractItemView.MultiSelection)
44
47
  self.ui.treeWidget.header().setSectionResizeMode(
45
48
  QtWidgets.QHeaderView.ResizeToContents,
46
49
  )
47
- self.ui.checkBoxIncludeCategories.setChecked(
50
+ self.exportDialog.ui.checkBoxIncludeCategories.setChecked(
48
51
  self.settings.get(SettingsKey.INCLUDEINCATS),
49
52
  )
50
- self.ui.spinBoxDefaultQVariant.setValue(
53
+ self.exportDialog.ui.spinBoxDefaultQVariant.setValue(
51
54
  self.settings.get(SettingsKey.QUESTIONVARIANT)
52
55
  )
53
56
  self.ui.pointCounter.setReadOnly(True)
@@ -69,17 +72,22 @@ class MainWindow(QtWidgets.QMainWindow):
69
72
  )
70
73
  loggerSignal.emitter.signal.connect(self.updateLog)
71
74
  self.ui.actionEquationChecker.triggered.connect(self.openEqCheckerDlg)
72
- self.ui.checkBoxIncludeCategories.checkStateChanged.connect(
75
+ self.exportDialog.ui.checkBoxIncludeCategories.checkStateChanged.connect(
73
76
  self.setIncludeCategoriesSetting,
74
77
  )
75
78
  self.ui.actionParseAll.triggered.connect(self.parseSpreadsheetAll)
76
79
  self.testDB.signals.categoryQuestionsReady.connect(self.treeRefreshCategory)
77
- self.ui.buttonSpreadSheet.clicked.connect(self.onButSpreadsheet)
78
- self.ui.buttonTestGen.clicked.connect(self.onButGenTest)
79
- self.ui.actionPreviewQ.triggered.connect(self.openPreviewQuestionDlg)
80
+ self.ui.actionSpreadsheet.triggered.connect(self.actionSpreadsheet)
81
+ self.ui.actionExport.triggered.connect(self.onButGenTest)
82
+ self.ui.buttonSpreadsheet.clicked.connect(self.actionSpreadsheet)
83
+ self.ui.buttonExport.clicked.connect(self.onButGenTest)
84
+ self.ui.treeWidget.itemClicked.connect(self.updateQuestionPreview)
80
85
  self.ui.actionAbout.triggered.connect(self.openAboutDlg)
86
+ self.ui.actionDocumentation.triggered.connect(self.openDocumentation)
81
87
  self.settings.shPathChanged.connect(self.onSheetPathChanged)
82
- self.ui.spinBoxDefaultQVariant.valueChanged.connect(self.setQVariantDefault)
88
+ self.exportDialog.ui.spinBoxDefaultQVariant.valueChanged.connect(
89
+ self.setQVariantDefault
90
+ )
83
91
 
84
92
  @QtCore.Slot()
85
93
  def setQVariantDefault(self, value: int) -> None:
@@ -105,14 +113,14 @@ class MainWindow(QtWidgets.QMainWindow):
105
113
  svgFolder = self.mainPath / self.settings.get(SettingsKey.PICTURESUBFOLDER)
106
114
  svgFolder.resolve()
107
115
  self.settings.set(SettingsKey.PICTUREFOLDER, svgFolder)
108
- self.ui.buttonSpreadSheet.setText(str(sheet.name))
116
+ self.ui.buttonSpreadsheet.setText(f"../{sheet.name}")
109
117
  self.parseSpreadsheetAll()
110
118
 
111
119
  def updateLog(self, log) -> None:
112
120
  self.ui.loggerWindow.append(log)
113
121
 
114
122
  def setIncludeCategoriesSetting(self) -> None:
115
- if self.ui.checkBoxIncludeCategories.isChecked():
123
+ if self.exportDialog.ui.checkBoxIncludeCategories.isChecked():
116
124
  self.settings.set(SettingsKey.INCLUDEINCATS, True)
117
125
  else:
118
126
  self.settings.set(SettingsKey.INCLUDEINCATS, False)
@@ -146,6 +154,7 @@ class MainWindow(QtWidgets.QMainWindow):
146
154
  @QtCore.Slot()
147
155
  def onButGenTest(self) -> None:
148
156
  """Open a file Dialog so the export file may be choosen."""
157
+ self.exportDialog.exec()
149
158
  path = QtWidgets.QFileDialog.getSaveFileName(
150
159
  self,
151
160
  "Select Output File",
@@ -158,7 +167,7 @@ class MainWindow(QtWidgets.QMainWindow):
158
167
  self.testDB.appendQuestions(selection, self.exportFile)
159
168
 
160
169
  @QtCore.Slot()
161
- def onButSpreadsheet(self) -> None:
170
+ def actionSpreadsheet(self) -> None:
162
171
  file = QtWidgets.QFileDialog.getOpenFileName(
163
172
  self,
164
173
  self.tr("Open Spreadsheet"),
@@ -184,11 +193,10 @@ class MainWindow(QtWidgets.QMainWindow):
184
193
  self.ui.treeWidget.sortItems(0, Qt.SortOrder.AscendingOrder)
185
194
 
186
195
  @QtCore.Slot()
187
- def openPreviewQuestionDlg(self) -> None:
196
+ def updateQuestionPreview(self) -> None:
188
197
  item = self.ui.treeWidget.currentItem()
189
198
  if isinstance(item, QuestionItem):
190
- dialog = dialogs.QuestinoPreviewDialog(self, item.getQuestion())
191
- dialog.show()
199
+ self.questionPreview.setupQuestion(item.getQuestion())
192
200
  else:
193
201
  logger.info("current Item is not a Question, can't preview")
194
202
 
@@ -208,6 +216,14 @@ class MainWindow(QtWidgets.QMainWindow):
208
216
  about = dialogs.AboutDialog(self)
209
217
  about.exec()
210
218
 
219
+ @QtCore.Slot()
220
+ def openDocumentation(self) -> None:
221
+ if hasattr(self, "documentationWindow"):
222
+ self.documentationWindow.show()
223
+ else:
224
+ self.documentationWindow = DocumentationWindow(self)
225
+ self.documentationWindow.show()
226
+
211
227
 
212
228
  class ParseAllThread(QRunnable):
213
229
  """Parse the whole Spreadsheet.
@@ -226,7 +242,6 @@ class ParseAllThread(QRunnable):
226
242
  self.testDB.asyncInitAllCategories(self.mainApp.spreadSheetPath)
227
243
  self.mainApp.setStatus("[OK] Tabellen wurde eingelesen")
228
244
  self.testDB.parseAllQuestions()
229
- self.mainApp.ui.buttonTestGen.setEnabled(True)
230
245
 
231
246
 
232
247
  class EqCheckerWindow(QtWidgets.QWidget):
@@ -7,7 +7,7 @@ from PySide6.QtSvgWidgets import QGraphicsSvgItem
7
7
  from excel2moodle import e2mMetadata
8
8
  from excel2moodle.core.globals import XMLTags
9
9
  from excel2moodle.core.question import Question
10
- from excel2moodle.ui.questionPreviewDialog import Ui_QuestionPrevDialog
10
+ from excel2moodle.ui.exportSettingsDialog import Ui_ExportDialog
11
11
  from excel2moodle.ui.variantDialog import Ui_Dialog
12
12
 
13
13
 
@@ -32,43 +32,48 @@ class QuestionVariantDialog(QtWidgets.QDialog):
32
32
  return self.ui.checkBox.isChecked()
33
33
 
34
34
 
35
- class QuestinoPreviewDialog(QtWidgets.QDialog):
36
- def __init__(self, parent: QtWidgets.QWidget, question: Question) -> None:
35
+ class ExportDialog(QtWidgets.QDialog):
36
+ def __init__(self, parent) -> None:
37
37
  super().__init__(parent)
38
- self.question = question
39
- self.ui = Ui_QuestionPrevDialog()
38
+ self.setWindowTitle("Export question Selection")
39
+ self.ui = Ui_ExportDialog()
40
40
  self.ui.setupUi(self)
41
- self.setModal(True)
42
- self.setWindowTitle(f"Question - {question.id} - Preview")
43
- self.setupQuestion()
44
41
 
45
- def setupQuestion(self) -> None:
46
- self.ui.qNameLine.setText(self.question.name)
47
- self.ui.qTypeLine.setText(self.question.qtype)
42
+
43
+ class QuestionPreview:
44
+ def __init__(self, parent) -> None:
45
+ self.ui = parent.ui
46
+ self.parent = parent
47
+
48
+ def setupQuestion(self, question: Question) -> None:
49
+ self.question: Question = question
50
+ self.ui.qNameLine.setText(f"{self.question.qtype} - {self.question.name}")
51
+ self.picScene = QtWidgets.QGraphicsScene(self.parent)
52
+ self.ui.graphicsView.setScene(self.picScene)
48
53
  self.setText()
49
54
  self.setAnswers()
55
+ if hasattr(self, "picItem"):
56
+ self.picScene.removeItem(self.picItem)
50
57
  self.setPicture()
51
58
 
52
59
  def setPicture(self) -> None:
53
60
  if hasattr(self.question, "picture") and self.question.picture.ready:
54
- self.picScene = QtWidgets.QGraphicsScene(self)
55
- self.ui.graphicsView.setScene(self.picScene)
56
61
  path = self.question.picture.path
57
62
  if path.suffix == ".svg":
58
- picItem = QGraphicsSvgItem(str(self.question.picture.path))
63
+ self.picItem = QGraphicsSvgItem(str(self.question.picture.path))
59
64
  else:
60
65
  pic = QtGui.QPixmap(self.question.picture.path)
61
66
  aspRat = pic.height() // pic.width()
62
67
  width = 400
63
68
  scaleHeight = aspRat * width
64
- picItem = QtWidgets.QGraphicsPixmapItem(
69
+ self.picItem = QtWidgets.QGraphicsPixmapItem(
65
70
  pic.scaled(
66
71
  width, scaleHeight, QtGui.Qt.AspectRatioMode.KeepAspectRatio
67
72
  )
68
73
  )
69
- self.picScene.addItem(picItem)
70
- else:
71
- self.ui.graphicsView.setFixedHeight(1)
74
+ self.picScene.addItem(self.picItem)
75
+ # else:
76
+ # self.ui.graphicsView.setFixedHeight(1)
72
77
 
73
78
  def setText(self) -> None:
74
79
  t = []
@@ -80,24 +85,26 @@ class QuestinoPreviewDialog(QtWidgets.QDialog):
80
85
 
81
86
  def setAnswers(self) -> None:
82
87
  if self.question.qtype == "NFM":
83
- for i, ans in enumerate(self.question.answerVariants):
84
- t = ans.find("text").text
85
- text = QtWidgets.QLineEdit(t, self)
86
- self.ui.answersFormLayout.addRow(f"Answer {i + 1}", text)
87
-
88
+ list = ET.Element("ol")
89
+ for ans in self.question.answerVariants:
90
+ textEle = ET.Element("li")
91
+ textEle.text = f"Result: {ans.find('text').text}"
92
+ list.append(textEle)
93
+ self.ui.answersLabel.setText(ET.tostring(list, encoding="unicode"))
88
94
  elif self.question.qtype == "NF":
89
95
  ans = self.question.element.find(XMLTags.ANSWER)
90
- t = ans.find("text").text
91
- text = QtWidgets.QLineEdit(t, self)
92
- self.ui.answersFormLayout.addRow("Result", text)
93
-
96
+ self.ui.answersLabel.setText(f" Result: {ans.find('text').text}")
94
97
  elif self.question.qtype == "MC":
95
- for i, ans in enumerate(self.question.element.findall(XMLTags.ANSWER)):
98
+ list = ET.Element("ol")
99
+ for ans in self.question.element.findall(XMLTags.ANSWER):
100
+ textEle = ET.Element("li")
96
101
  pEle = ans.find("text").text
97
- t = ET.fromstring(pEle).text
98
102
  frac = ans.get("fraction")
99
- text = QtWidgets.QLineEdit(t, self)
100
- self.ui.answersFormLayout.addRow(f"Fraction: {frac}", text)
103
+ anstext = ET.fromstring(pEle).text
104
+ text = f"Fraction {frac}: {anstext}"
105
+ textEle.text = text
106
+ list.append(textEle)
107
+ self.ui.answersLabel.setText(ET.tostring(list, encoding="unicode"))
101
108
 
102
109
 
103
110
  class AboutDialog(QtWidgets.QMessageBox):
@@ -114,8 +121,9 @@ class AboutDialog(QtWidgets.QMessageBox):
114
121
  <b><a href="{e2mMetadata["homepage"]}">{e2mMetadata["name"]}</a> - {e2mMetadata["description"]}</b>
115
122
  </p>
116
123
  <p style="text-align:center">
117
- The documentation can be found under <b>
118
- <a href="{e2mMetadata["documentation"]}">{e2mMetadata["documentation"]}</a></b>
124
+ A <b>
125
+ <a href="{e2mMetadata["documentation"]}">documentation</a></b>
126
+ is also available.
119
127
  </br>
120
128
  </p>
121
129
  <p style="text-align:center">
@@ -0,0 +1,79 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ ################################################################################
4
+ ## Form generated from reading UI file 'exportSettingsDialog.ui'
5
+ ##
6
+ ## Created by: Qt User Interface Compiler version 6.9.0
7
+ ##
8
+ ## WARNING! All changes made in this file will be lost when recompiling UI file!
9
+ ################################################################################
10
+
11
+ from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale,
12
+ QMetaObject, QObject, QPoint, QRect,
13
+ QSize, QTime, QUrl, Qt)
14
+ from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor,
15
+ QFont, QFontDatabase, QGradient, QIcon,
16
+ QImage, QKeySequence, QLinearGradient, QPainter,
17
+ QPalette, QPixmap, QRadialGradient, QTransform)
18
+ from PySide6.QtWidgets import (QAbstractButton, QApplication, QCheckBox, QDialog,
19
+ QDialogButtonBox, QFormLayout, QHBoxLayout, QLabel,
20
+ QSizePolicy, QSpinBox, QWidget)
21
+
22
+ class Ui_ExportDialog(object):
23
+ def setupUi(self, ExportDialog):
24
+ if not ExportDialog.objectName():
25
+ ExportDialog.setObjectName(u"ExportDialog")
26
+ ExportDialog.resize(572, 217)
27
+ self.horizontalLayout = QHBoxLayout(ExportDialog)
28
+ self.horizontalLayout.setObjectName(u"horizontalLayout")
29
+ self.formLayout_2 = QFormLayout()
30
+ self.formLayout_2.setObjectName(u"formLayout_2")
31
+ self.formLayout_2.setContentsMargins(5, 5, 5, 5)
32
+ self.label_10 = QLabel(ExportDialog)
33
+ self.label_10.setObjectName(u"label_10")
34
+
35
+ self.formLayout_2.setWidget(0, QFormLayout.ItemRole.LabelRole, self.label_10)
36
+
37
+ self.spinBoxDefaultQVariant = QSpinBox(ExportDialog)
38
+ self.spinBoxDefaultQVariant.setObjectName(u"spinBoxDefaultQVariant")
39
+
40
+ self.formLayout_2.setWidget(0, QFormLayout.ItemRole.FieldRole, self.spinBoxDefaultQVariant)
41
+
42
+ self.label_9 = QLabel(ExportDialog)
43
+ self.label_9.setObjectName(u"label_9")
44
+
45
+ self.formLayout_2.setWidget(1, QFormLayout.ItemRole.LabelRole, self.label_9)
46
+
47
+ self.checkBoxIncludeCategories = QCheckBox(ExportDialog)
48
+ self.checkBoxIncludeCategories.setObjectName(u"checkBoxIncludeCategories")
49
+
50
+ self.formLayout_2.setWidget(1, QFormLayout.ItemRole.FieldRole, self.checkBoxIncludeCategories)
51
+
52
+
53
+ self.horizontalLayout.addLayout(self.formLayout_2)
54
+
55
+ self.buttonBox = QDialogButtonBox(ExportDialog)
56
+ self.buttonBox.setObjectName(u"buttonBox")
57
+ self.buttonBox.setOrientation(Qt.Orientation.Vertical)
58
+ self.buttonBox.setStandardButtons(QDialogButtonBox.StandardButton.Cancel|QDialogButtonBox.StandardButton.Ok)
59
+
60
+ self.horizontalLayout.addWidget(self.buttonBox)
61
+
62
+
63
+ self.retranslateUi(ExportDialog)
64
+ self.buttonBox.accepted.connect(ExportDialog.accept)
65
+ self.buttonBox.rejected.connect(ExportDialog.reject)
66
+
67
+ QMetaObject.connectSlotsByName(ExportDialog)
68
+ # setupUi
69
+
70
+ def retranslateUi(self, ExportDialog):
71
+ ExportDialog.setWindowTitle(QCoreApplication.translate("ExportDialog", u"Dialog", None))
72
+ self.label_10.setText(QCoreApplication.translate("ExportDialog", u"Default Question Variant", None))
73
+ #if QT_CONFIG(tooltip)
74
+ self.label_9.setToolTip(QCoreApplication.translate("ExportDialog", u"If enabled, all questions will be categorized, when importing into moodle. Otherwise they will all be imported into one category", None))
75
+ #endif // QT_CONFIG(tooltip)
76
+ self.label_9.setText(QCoreApplication.translate("ExportDialog", u"Include Questions in Categories", None))
77
+ self.checkBoxIncludeCategories.setText("")
78
+ # retranslateUi
79
+
@@ -1,35 +1,27 @@
1
- import os
2
1
  import sys
3
- from PySide6 import QtWidgets, QtWebEngineWidgets, QtCore
4
- from excel2moodle import dirDocumentation
2
+
3
+ from PySide6 import QtCore, QtWebEngineWidgets, QtWidgets
4
+
5
+ from excel2moodle import e2mMetadata
6
+
5
7
 
6
8
  class DocumentationWindow(QtWidgets.QMainWindow):
7
- def __init__(self, documentationDirectory, parent=None):
9
+ def __init__(self, parent=None) -> None:
8
10
  super().__init__(parent)
9
11
 
10
12
  self.web_view = QtWebEngineWidgets.QWebEngineView()
11
13
  self.setCentralWidget(self.web_view)
12
14
 
13
15
  # Load the HTML documentation
14
-
15
- index_file = os.path.join(documentationDirectory, "index.html")
16
- url = QtCore.QUrl.fromLocalFile(index_file)
16
+ url = QtCore.QUrl(e2mMetadata["documentation"])
17
+ print(f"Opening URL {url}")
17
18
  self.web_view.setUrl(url)
18
19
 
19
- # Set up navigation events
20
- self.web_view.page().linkHovered.connect(self.link_hovered)
21
- self.web_view.page().loadFinished.connect(self.load_finished)
22
-
23
- def link_hovered(self, url):
24
- print(f"Link hovered: {url}")
25
-
26
- def load_finished(self, ok):
27
- print(f"Load finished: {ok}")
28
20
 
29
21
  if __name__ == "__main__":
30
22
  app = QtWidgets.QApplication(sys.argv)
31
23
 
32
- window = DocumentationWindow(dirDocumentation)
24
+ window = DocumentationWindow()
33
25
  window.show()
34
26
 
35
27
  sys.exit(app.exec())