示例#1
0
 def onBackupDB(self):
     copyto = QFileDialog.getSaveFileName(caption="Save Backup As",
             filter="Quiz Databases (*.db);;All files (*)")
     copyto = unicode(copyto)
     if not copyto: # canceled
         return
     copyto = utils.forceExtension(copyto, 'db')
     if copyto is None:
         # see docstring of forceExtension
         return
     db.database.inter.close() # make sure everything's been saved
     try:
         shutil.copyfile(self.dbpath, copyto)
     except shutil.Error:
         utils.errorBox("You cannot back up a file to itself! " \
                        "(But nice try...)", "Backup failed")
     except IOError:
         utils.errorBox("Backup failed. Please be sure that the " \
                        "destination is writeable and not full and " \
                        "that you have permission to access it.",
                        "Backup failed")
     else:
         utils.informationBox("Backup successful.", "Success")
     finally:
         self._connectDb(self.dbpath) # reconnect
示例#2
0
 def onClearPW(self):
     r = utils.questionBox("Do you really want to clear your LaTeX server "
                           "password and all saved email "
                           "passwords for all classes?", "Clear passwords?")
     if r == QMessageBox.Yes:
         ui.prefs.wipeAllPasswords(self.databaseConfig)
         utils.informationBox("All saved passwords have been cleared.", "Success")
示例#3
0
 def writeConfiguration():
     key, ok = QInputDialog.getText(self, "Write Config Value", "Key:")
     if (not ok) or (not key):
         utils.informationBox("Cancelled.")
         return
     value, ok = QInputDialog.getText(self, "Write Config Value", "Value:")
     if (not ok) or (not value):
         utils.informationBox("Cancelled.")
         return
     self.config.writeConf(key, value)
示例#4
0
 def accept(self):
     r = utils.questionBox("Rescheduling will place your selected new sets "
                           "into review and schedule any review sets "
                           "further into the future. Rescheduling cannot "
                           "be undone. Continue?", "Confirm Reschedule")
     if r == QMessageBox.Yes:
         self.parent.quiz.rewriteSchedule()
         self.parent.previewResult = True
         utils.informationBox("The quiz was exported successfully. "
                              "Sets have been rescheduled.",
                              "Quiz generated")
         QDialog.accept(self)
示例#5
0
    def onImport(self):
        f = QFileDialog.getOpenFileName(caption="Import Students from CSV",
                                        filter="All files (*)")
        if not f:
            return
        importer = db.students.StudentImporter(f, self._currentClass())
        errors = importer.txtImport()

        self.reFillStudents()

        if errors:
            utils.tracebackBox("Import returned the following errors:\n%s\n\nAny " \
                               "students that were valid have been imported." \
                               % errors, "Import Results", False)
        else:
            utils.informationBox("Import completed successfully.",
                                 "Import Results")
示例#6
0
    def onExport(self):
        filename = QFileDialog.getSaveFileName(
            caption="Import Students from CSV", filter="All files (*)")
        if not filename:
            return

        try:
            db.students.exportCsv(
                db.students.studentsInClass(self._currentClass()), filename)
        except Exception as e:
            utils.tracebackBox("Could not write to the location specified. "
                               "The original error is as follows:\n\n"
                               "%s" % traceback.format_exc(),
                               title="Export Failed",
                               includeErrorBoilerplate=False)
        else:
            utils.informationBox("Export completed successfully.",
                                 "Export Results")
示例#7
0
    def onEmailResults(self):
        obj = self.tableModel.getObj(self.form.tableView.currentIndex())
        if obj.resultsFlag == 2:
            r = utils.questionBox(
                "You have already successfully emailed the "
                "results of this quiz to all students. Do you really want "
                "to do it again?", " Really send email again?")
            if r != QMessageBox.Yes:
                return

        ew = ui.emailing.EmailingDialog(self, self._currentClass(),
                                        self._currentZid(), self.dbConf,
                                        self.qConf)
        success = ew.exec_()
        if success:
            utils.informationBox("The results were emailed successfully.",
                                 "Email complete")
            obj = self.tableModel.getObj(self.form.tableView.currentIndex())
            obj.rewriteResultsFlag(2)  # results emailed
示例#8
0
 def forceSave():
     db.database.forceSave()
     utils.informationBox("Saved.")
示例#9
0
 def onVersion(self):
     utils.informationBox(APPLICATION_VERSION, "Version")