Skip to content

Commit

Permalink
Update v1.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
gamingwithevets authored Jul 19, 2022
1 parent 2b4514e commit 918fbb9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 24 deletions.
23 changes: 11 additions & 12 deletions editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import tempfile
import traceback

version = '1.3.2 - QuizProg v1.1.0'
version = '1.3.3 - QuizProg v1.1.1'

app = wx.App(None)

Expand Down Expand Up @@ -618,7 +618,7 @@ def save_confirm():
def save():
global savepath, savepath_tmp, message, modified, allow_save, is_url
clear()
dlg = wx.FileDialog(None, 'Where we savin\', boys?', wildcard = 'JSON Files (*.json)|*.json|All Files (*.*)|*.*||', style = wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT)
dlg = wx.FileDialog(None, 'Where we savin\', boys?', wildcard = 'JSON Files (*.json)|*.json|All Files (*.*)|*.*', style = wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT)
if dlg.ShowModal() == wx.ID_OK: savepath_tmp = dlg.GetPath()
if savepath_tmp:
savepath = savepath_tmp
Expand All @@ -635,7 +635,7 @@ def save():
def openf():
global savepath, savepath_tmp, message, datafile
clear()
dlg = wx.FileDialog(None, 'JSON file please!', wildcard = 'JSON Files (*.json)|*.json|All Files (*.*)|*.*||', style = wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
dlg = wx.FileDialog(None, 'JSON file please!', wildcard = 'JSON Files (*.json)|*.json|All Files (*.*)|*.*', style = wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
if dlg.ShowModal() == wx.ID_OK: savepath_tmp = dlg.GetPath()
if savepath_tmp:
old_path = savepath
Expand All @@ -645,16 +645,15 @@ def openf():
for i in range(1):
try: datafile = json.load(open(savepath))
except Exception as e: message = 'Invalid JSON data!'; savepath = old_path; break
if not check_optional_element('title'): message = 'String variable "title" not found!'; savepath = old_path; break
if not check_optional_element('questions', list): message = 'String variable "questions" not found!'; savepath = old_path; break
if len(datafile['questions']) < 1: message = 'There must be at least one question in the "questions" list!'; savepath = old_path; break
if not check_optional_element('title'): message = 'String variable "title" not found or empty!'; savepath = old_path; break
if not check_optional_element('questions', list): message = 'String variable "questions" not found or empty!'; savepath = old_path; break
for i in range(len(datafile['questions'])):
if not check_question_optional_element('question', i): message = 'String variable "question" not found in question ' + str(i+1) + '!'; savepath = old_path; break
if not check_question_optional_element('a', i): message = 'String variable "a" not found in question ' + str(i+1) + '!'; savepath = old_path; break
if not check_question_optional_element('b', i): message = 'String variable "b" not found in question ' + str(i+1) + '!'; savepath = old_path; break
if not check_question_optional_element('c', i): message = 'String variable "c" not found in question ' + str(i+1) + '!'; savepath = old_path; break
if not check_question_optional_element('d', i): message = 'String variable "d" not found in question ' + str(i+1) + '!'; savepath = old_path; break
if not check_question_optional_element('correct', i): message = 'String variable "correct" not found in question ' + str(i+1) + '!'; savepath = old_path; break
if not check_question_optional_element('question', i): message = 'String variable "question" not found or empty in question ' + str(i+1) + '!'; savepath = old_path; break
if not check_question_optional_element('a', i): message = 'String variable "a" not found or empty in question ' + str(i+1) + '!'; savepath = old_path; break
if not check_question_optional_element('b', i): message = 'String variable "b" not found or empty in question ' + str(i+1) + '!'; savepath = old_path; break
if not check_question_optional_element('c', i): message = 'String variable "c" not found or empty in question ' + str(i+1) + '!'; savepath = old_path; break
if not check_question_optional_element('d', i): message = 'String variable "d" not found or empty in question ' + str(i+1) + '!'; savepath = old_path; break
if not check_question_optional_element('correct', i): message = 'String variable "correct" not found or empty in question ' + str(i+1) + '!'; savepath = old_path; break
success = True
if not success: break
create_backup()
Expand Down
23 changes: 11 additions & 12 deletions quizprog.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import traceback
from datetime import datetime

version = '1.1.0'
version = '1.1.1'

app = wx.App(None)

Expand Down Expand Up @@ -342,27 +342,26 @@ def openf():
path = ''

clear()
dlg = wx.FileDialog(None, 'JSON file please!', wildcard = 'JSON Files (*.json)|*.json|All Files (*.*)|*.*||', style = wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
dlg = wx.FileDialog(None, 'JSON file please!', wildcard = 'JSON Files (*.json)|*.json|All Files (*.*)|*.*', style = wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
if dlg.ShowModal() == wx.ID_OK: path = dlg.GetPath()
if path:
print_tag('opening file "' + os.path.abspath(path) + '"', function)
try:
success = False
for i in range(1):
try: datafile = json.load(open(path))
except Exception as e:
print_tag('invalid JSON data\n' + traceback.format_exc(), function)
message = 'Invalid JSON data!'; break
if not check_optional_element('title'): message = 'String variable "title" not found!'; break
if not check_optional_element('questions', list): message = 'String variable "questions" not found!'; break
if len(datafile['questions']) < 1: message = 'There must be at least one question in the "questions" list!'; break
success = False
if not check_optional_element('title'): message = 'String variable "title" not found or empty!'; break
if not check_optional_element('questions', list): message = 'String variable "questions" not found or empty!'; break
for i in range(len(datafile['questions'])):
if not check_question_optional_element('question', i): message = 'String variable "question" not found in question ' + str(i+1) + '!'; break
if not check_question_optional_element('a', i): message = 'String variable "a" not found in question ' + str(i+1) + '!'; break
if not check_question_optional_element('b', i): message = 'String variable "b" not found in question ' + str(i+1) + '!'; break
if not check_question_optional_element('c', i): message = 'String variable "c" not found in question ' + str(i+1) + '!'; break
if not check_question_optional_element('d', i): message = 'String variable "d" not found in question ' + str(i+1) + '!'; break
if not check_question_optional_element('correct', i): message = 'String variable "correct" not found in question ' + str(i+1) + '!'; break
if not check_question_optional_element('question', i): message = 'String variable "question" not found or empty in question ' + str(i+1) + '!'; break
if not check_question_optional_element('a', i): message = 'String variable "a" not found or empty in question ' + str(i+1) + '!'; break
if not check_question_optional_element('b', i): message = 'String variable "b" not found or empty in question ' + str(i+1) + '!'; break
if not check_question_optional_element('c', i): message = 'String variable "c" not found or empty in question ' + str(i+1) + '!'; break
if not check_question_optional_element('d', i): message = 'String variable "d" not found or empty in question ' + str(i+1) + '!'; break
if not check_question_optional_element('correct', i): message = 'String variable "correct" not found or empty in question ' + str(i+1) + '!'; break
success = True
if not success: break
message = ''
Expand Down

0 comments on commit 918fbb9

Please sign in to comment.