# -*- 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 from TraversableWrapper import Traversable from Globals import Persistent from AccessControl import ClassSecurityInfo from Cruft import Cruft class YlHoidla( OFS.Folder.Folder, OFS.SimpleItem.Item, Persistent, AccessControl.Role.RoleManager, Traversable, Cruft): """ Hoidla õpetaja tarvis """ nr=0 def lisaYlesanne(self, REQUEST, yl): "Uus ülesanne hoidlasse" if yl.meta.ex_changed==0: return self.nr=self.nr+1 uusyl=yl.koopia() yl.meta.ex_changed=0 uusyl._setObject('meta', yl.meta.koopia()) self._setObject('el'+str(self.nr), uusyl) uusyl.id='el'+str(self.nr) return str(self.nr) def leiaYlesanded(self, REQUEST, marksonad=()): "Ülesannete otsing" if type(marksonad) is types.StringType: marksonad=(marksonad,) m=[] alg=self.objectValues() for x in alg: sobib=1 for sona in marksonad: if sona.strip() and sona not in x.meta.keywords: sobib=0 if not str(REQUEST.AUTHENTICATED_USER)==x.meta.uname: try: if not x.meta.rights==0: sobib=0 #Pole lubatud ligipääs except AttributeError: pass if sobib: m.append(x.koopia()) return m def kopeeriYlesandedTesti(self, REQUEST, testiID, ylid=()): "Märgitud ülesanded kopeeritakse valitud testi" if type(ylid) is types.StringType: ylid=(ylid,) knr=str(self.jooksva_kursuse_nr(REQUEST)) testikataloog=getattr(self.fle_root().courses, knr).testid t=getattr(testikataloog, testiID) for x in ylid: yl=getattr(self, x) t.lisaYlesanne(yl.koopia()) REQUEST.RESPONSE.redirect(t.absolute_url())