# -*- coding: utf-8 # $Id$ # # Copyright 2001, 2002 by IVA Team and contributors # # This file is part of IVA. # # IVA is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # IVA is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with IVA; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA __version__ = "$Revision$"[11:-2] import AccessControl import OFS, Globals import types import YlTest #import TestiYlesanne from OFS import SimpleItem from TraversableWrapper import Traversable from Globals import Persistent from AccessControl import ClassSecurityInfo from Cruft import Cruft from common import translate class YlVahendus( Persistent, OFS.SimpleItem.Item, Traversable, AccessControl.Role.RoleManager, Cruft ): "Ülesannete import/eksport, loomine" ylesanneteTyybid=("ValikYlesanne","TekstivastusegaYlesanne", "YksikvalikYlesanne", "MitmikvalikYlesanne", "OigeTekstivastusegaYlesanne", "ArvuvahemikuliseVastusegaYlesanne", "ProtsentYlesanne", "VastavusYlesanne") def ylesanneteTolkegaTyybid(self, REQUEST): "Tüübid tõlgituna, ZPT tarbeks" tulemus={ "ValikYlesanne": "Yes/No", "TekstivastusegaYlesanne": "Paragraph", "YksikvalikYlesanne": "Multiple choice", "MitmikvalikYlesanne": "Mark all correct", # see on vale?"Multiple choice", "OigeTekstivastusegaYlesanne": "Short answer", "ArvuvahemikuliseVastusegaYlesanne": "Numerical", "ProtsentYlesanne": "Percent", "VastavusYlesanne": "Matching" } return tulemus def tekstistYlesanneteLaadimiseVorm(self, REQUEST): "Tekstiala sisestuseks" tulemus="
"+\ ""+\ ""+\ "

"+\ "
"+\ ""+\ ""+\ "

" return self.defaultRender(page=tulemus) def tekstistYlesanneteSalvestus(self, REQUEST, tekst): "Salvestus tase kõrgemale" self.aq_parent.lisaYlesanded(self.tekstistYlesanneteMassiiv(tekst)) REQUEST.RESPONSE.redirect('../index_html') def tekstiFailistYlesanneteSalvestus(self, fail, REQUEST): "Failist lisamine tase kõrgemale" self.aq_parent.lisaYlesanded(self.tekstiRidadestYlesanneteMassiiv(fail.readlines())) REQUEST.RESPONSE.redirect('../index_html') def tekstistYlesanneteMassiiv(self, tekst): "HotPotatose väljundist lugemine" reamassiiv=tekst.split("\n") return self.tekstiRidadestYlesanneteMassiiv(reamassiiv) def tekstiRidadestYlesanneteMassiiv(self, reamassiiv): "Read sees massiivina" algus=0 ylesanded=[] while algus=len(reamassiiv):return ylesanded while algus1: if rida[1]=="ANSWER1": if rida[4]=="0": return "OigeTekstivastusegaYlesanne" else: return "LynkTestYlesanne" return "vastuseta S" return "SisuTundmatu" def ylesanneteTyypideLoetelu(self, REQUEST): "Viited ülesannete tüüpidele" tulemus="

L_it_choosing_exercise_type

" for x in self.ylesanneteTyybid: tulemus=tulemus+"\n"+\ ("%s
" % (x, x)) return tulemus def ylesanneteTyybidValikuna(self, REQUEST): "Valikmenüü ülesannete lisamiseks" #XXX: not used? andmed=self.ylesanneteTolkegaTyybid(REQUEST) tulemus="

"+translate(self, 'editing quiz', target=self.giveLanguage(REQUEST))+"

"+translate(self, 'add exercise', target=self.giveLanguage(REQUEST))+":
" return tulemus def lisaUusYlesanne(self, REQUEST, tyyp): "Ülesande uus eksemplar" import YlTyybid from YlTyybid import * if tyyp=='ValikYlesanne': return ValikYlesanne(translate(self, 'Question text', target=self.giveLanguage(REQUEST))) if tyyp=='TekstivastusegaYlesanne': return TekstivastusegaYlesanne(translate(self, 'Question text',target=self.giveLanguage(REQUEST))) if tyyp=='YksikvalikYlesanne': return YksikvalikYlesanne(translate(self, 'Question text', target=self.giveLanguage(REQUEST))) if tyyp=='OigeTekstivastusegaYlesanne': return OigeTekstivastusegaYlesanne(translate(self, "Question text", target=self.giveLanguage(REQUEST))) if tyyp=='MitmikvalikYlesanne': return MitmikvalikYlesanne(translate(self, "Question text", target=self.giveLanguage(REQUEST))) if tyyp=='ArvuvahemikuliseVastusegaYlesanne': return ArvuvahemikuliseVastusegaYlesanne(translate(self, "Question text", target=self.giveLanguage(REQUEST))) if tyyp=='ProtsentYlesanne': return ProtsentYlesanne(translate(self, "Find the missing component", target=self.giveLanguage(REQUEST))) if tyyp=='VastavusYlesanne': return VastavusYlesanne(translate(self, "Match the pairs", target=self.giveLanguage(REQUEST))) Globals.InitializeClass(YlVahendus) Globals.default__class_init__(YlVahendus)