bugfix beberapa script text option blank dan lain lain

master
a2nr 2023-02-28 22:00:33 +07:00
parent 2dfadd4ae9
commit eb1fe990cf
3 changed files with 18 additions and 13 deletions

View File

@ -120,7 +120,7 @@ class gquiz:
} }
}} }}
''' '''
opt = {"value" : value} opt = {"value" : "{}".format(value)}
if(image != None): if(image != None):
print("print with image, uploading... ") print("print with image, uploading... ")
req = requests.post(self.image_temp_service_url,files={"file": open(image,'rb')}) req = requests.post(self.image_temp_service_url,files={"file": open(image,'rb')})
@ -152,13 +152,13 @@ class gquiz:
''' '''
item = { item = {
"title" : title, "title" : title,
"description" : description, "description" : "{}".format(description),
"questionItem" : { "questionItem" : {
"question" : { "question" : {
"grading" : { "grading" : {
"pointValue": 1, "pointValue": 1,
"correctAnswers": { "correctAnswers": {
"answers" : [ {"value": options[indexAnswer-1]["value"]} ] "answers" : [ {"value": "{}".format(options[indexAnswer-1]["value"])} ]
} }
}, },
"choiceQuestion" : { "choiceQuestion" : {
@ -198,7 +198,7 @@ class gquiz:
"item": item "item": item
} }
}) })
pprint(self.submition) print(self.submition)
def update(self): def update(self):

View File

@ -1,8 +1,14 @@
# coding: utf-8 # coding: utf-8
from __future__ import unicode_literals from __future__ import unicode_literals
from scriptforge import CreateScriptService import sys, os
# uncomemnt for run separatly from soffice
#sys.path.append("/lib64/libreoffice/program/")
from scriptforge import ScriptForge, CreateScriptService
from unohelper import fileUrlToSystemPath
# uncomemnt for run separatly from soffice
#ScriptForge(hostname='localhost', port=2021)
def generateTemplate(): def generateTemplate():
doc = CreateScriptService("Calc") doc = CreateScriptService("Calc")
basic = CreateScriptService("Basic") basic = CreateScriptService("Basic")
@ -15,13 +21,12 @@ def generateTemplate():
"<isAnswerE>", "<IMG option5>", "<Text Option5>", ),)) "<isAnswerE>", "<IMG option5>", "<Text Option5>", ),))
def updateQuestion(): def updateQuestion():
import sys, os # strat comment for run separatly from soffice
from unohelper import fileUrlToSystemPath
if not 'gquiz' in sys.modules: if not 'gquiz' in sys.modules:
doc = XSCRIPTCONTEXT.getDocument() doc = XSCRIPTCONTEXT.getDocument()
url = fileUrlToSystemPath('{}/{}'.format(doc.URL,'Scripts/python/Library')) url = fileUrlToSystemPath('{}/{}'.format(doc.URL,'Scripts/python/Library'))
sys.path.insert(0, url) sys.path.insert(0, url)
# end
from gquiz import gquiz from gquiz import gquiz
import requests import requests
@ -31,7 +36,7 @@ def updateQuestion():
q = gquiz() q = gquiz()
q.generateService() q.generateService()
q.createForm("Demo Soal") q.createForm("Demo Soal")
cwd = os.getcwd() cwd = os.getcwd()
for nrow in range(0, doc.LastRow(selctedCell)+1-doc.FirstRow(selctedCell)): for nrow in range(0, doc.LastRow(selctedCell)+1-doc.FirstRow(selctedCell)):
item = doc.getValue(doc.Offset(doc.FirstCell(selctedCell),nrow,0,1,17)) item = doc.getValue(doc.Offset(doc.FirstCell(selctedCell),nrow,0,1,17))
opt = [] opt = []
@ -41,11 +46,11 @@ def updateQuestion():
for o in range(2,17,3): for o in range(2,17,3):
if (item[o] == 1): if (item[o] == 1):
theAnswer = c theAnswer = c
c = c+1
if (item[o+1] != ""): if (item[o+1] != ""):
opt.append(q.createOption(item[o+2],cwd+item[o+1])) opt.append(q.createOption("{}. {}".format(chr(64+c),item[o+2]),cwd+item[o+1]))
else: else:
opt.append(q.createOption(item[o+2])) opt.append(q.createOption("{}. {}".format(chr(64+c),item[o+2])))
c = c+1
if (theAnswer == -1): if (theAnswer == -1):
raise Exception("Chose the correct answer") raise Exception("Chose the correct answer")
@ -55,7 +60,7 @@ def updateQuestion():
else: else:
img = None img = None
qq = q.createQuestion(title = "Soal No 1",\ qq = q.createQuestion(title = "Soal No {}".format(nrow+1),\
description = item[0],\ description = item[0],\
indexAnswer = theAnswer, \ indexAnswer = theAnswer, \
options = opt, itemImage=img) options = opt, itemImage=img)

BIN
myedu.ods

Binary file not shown.