# -*- 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 from OFS import SimpleItem import types import time from TraversableWrapper import Traversable from Globals import Persistent from AccessControl import ClassSecurityInfo from Cruft import Cruft from common import translate import xml.dom.minidom #from xml.dom import implementation #from xml.dom import EMPTY_NAMESPACE, XML_NAMESPACE #from xml.dom.ext import PrettyPrint from ImportExport import Counter, DataTable, to_utf8, Exporter, Dump from zope.interface import implements from interfaces import IQuestionMeta class YlMeta( Persistent, OFS.SimpleItem.Item, OFS.Folder.Folder, Traversable, AccessControl.Role.RoleManager ): "Ülesande metaandmed LOMi järgi" meta_type="YlMeta" implements(IQuestionMeta) keywords=[] statusList=["draft", "final", "revised", "unavailable"] statusNr=0 rolesList=["Author", "Publisher", "Validator"] roles=[] entities=[] rightsList=["private", "shared", "public"] rightsNr=0 copyrightandotherrestrictions=0 ex_changed=0 #kas ülesanne on muudetud language="" languages=['', 'et', 'fi', 'de', 'en'] copyrightdescription="" tyyp=0 #0-kysimus, 1-test, 2-kursus, 3-IVA uname="" title="" def muutmisLeht(self, REQUEST, title, status, language, role, entity, rights, copyrightdescription, copyrightandotherrestrictions=0, keyword=()): "Andmete salvestus" self.title=title if type(keyword) is types.StringType: keyword=(keyword,) self.keywords=[] for x in keyword: if x.strip(): self.keywords.append(x) self.statusNr=int(status) if language not in self.languages: return self.restrictedTraverse('message_dialog.html')( self,REQUEST, title="Error", message="Unknown language", action="ylMeta_vorm1") self.language=language self.roles=[] self.entities=[] for i in range(len(entity)): if entity[i].strip(): self.roles.append(role[i]) self.entities.append(entity[i]) self.rightsNr=int(rights) self.copyrightandotherrestrictions=copyrightandotherrestrictions self.copyrightdescription=copyrightdescription self.ex_changed=1 self.uname=str(REQUEST.AUTHENTICATED_USER) if self.tyyp==0: REQUEST.RESPONSE.redirect(self.aq_parent.aq_parent.absolute_url()+"/ylesandedMuutmisTabelina.html") if self.tyyp==1: REQUEST.RESPONSE.redirect(self.aq_parent.aq_parent.absolute_url()+"/qt_index.html") def suurMuutmisLeht(self, REQUEST): "Muutmisleht kõigi parameetrite tarbeks" def getStatusList(self): "Loetelu väljastus" return self.statusList def getStatusNr(self): "Jooksva elemendi järjekorranumber" return self.statusNr def getRightsList(self): "Võimalike õiguste loetelu" return self.rightsList def getRightsNr(self): "Valitud õiguse järjekorranumber" return self.rightsNr def getLanguageList(self): "Keelte valik" return self.languages def getLanguage(self): "Jooksev keel" return self.language def getRolesList(self): "Rollide loetelu" return self.rolesList def getRoles(self): "Määratud rollid" return self.roles def getEntities(self): "Määratud rollitäitjad" return self.entities def kysiRolliPaarideMassiiv(self): "Loetelu, kus igas reas on roll ja täitja" m=[] for i in range(len(self.entities)): m.append([self.roles[i], self.entities[i]]) for i in range(3): m.append(["", ""]) return m def get_copyrightandotherrestrictions(self): "Väärtuse väljastus" if hasattr(self, 'copyrightandotherrestrictions'): return self.copyrightandotherrestrictions return 0 def get_copyrightdescription(self): "Kirjelduse väljastus" if hasattr(self, 'copyrightdescription'): return self.copyrightdescription return "" def getUName(self): "Metaandmed salvestanud kasutaja nimi" return self.uname def getTitle(self): "Pealkiri kui on" if hasattr(self, 'title'): return self.title return "" def kysiTyyp(self, REQUEST): "Kas küsimus, test või muu" if hasattr(self, 'tyyp'): return self.tyyp if self.aq_parent.id[0]=='t': return 1 #test return 0 def kasMuudetud(self): "Kas andmed vajavad salvestamist" if self.ex_changed: return "jah" return "ei" def XMLOks(self, REQUEST): "Andmed XML-puu objektina" doctype = implementation.createDocumentType("enterprise", "http://www.htk.tlu.ee/%7Evahur/ims_epv1p1.dtd","http://www.htk.tlu.ee/%7Evahur/ims_epv1p1.dtd") dok=implementation.createDocument(EMPTY_NAMESPACE, "enterprise", doctype) juur=dok.documentElement lom=dok.createElement('lom') juur.appendChild(lom) gen=dok.createElement('general') lom.appendChild(gen) for x in self.keywords: kw=dok.createElement('keyword') gen.appendChild(kw) return dok def XMLTekst(self, REQUEST): "Andmed XML-tekstina" dok=self.XMLOks(REQUEST) dump=Dump() PrettyPrint(dok, stream=dump) return dump.getdata() def koopia(self): "Samade metaandmetega eksemplar" uus=YlMeta() uus.keywords=[] for x in self.keywords: uus.keywords.append(x) uus.copyrightdescription=self.copyrightdescription uus.copyrightandotherrestrictions=self.copyrightandotherrestrictions uus.uname=self.uname return uus class TestiMeta(YlMeta): "Kogu testi metaandmed" tyyp=1