def __init__(self, activity="", answer=""): """ Initialize """ Idevice.__init__( self, x_(u"FPD - Reflexiona (con Retroalimentacion)"), x_(u"University of Auckland"), x_(u"""Reflection is a teaching method often used to connect theory to practice. Reflection tasks often provide learners with an opportunity to observe and reflect on their observations before presenting these as a piece of academic work. Journals, diaries, profiles and portfolios are useful tools for collecting observation data. Rubrics and guides can be effective feedback tools."""), u"", u"reflexionfpd") # self.emphasis = Idevice.SomeEmphasis self.emphasis = "_reflexionfpd" self._activityInstruc = x_(u"""Enter a question for learners to reflect upon.""") self._answerInstruc = x_(u"""Describe how learners will assess how they have done in the exercise. (Rubrics are useful devices for providing reflective feedback.)""") self.systemResources += ["common.js"] self.activityTextArea = TextAreaField(x_(u'Reflective question:'), self._activityInstruc, activity) self.activityTextArea.idevice = self self.answerTextArea = TextAreaField(x_(u'Feedback:'), self._answerInstruc, answer) self.answerTextArea.idevice = self
def __init__(self): """ Initialize """ Idevice.__init__( self, x_(u"True-False Question"), x_(u"University of Auckland"), x_(u"""True/false questions present a statement where the learner must decide if the statement is true. This type of question works well for factual information and information that lends itself to either/or responses."""), u"", u"question") self.emphasis = Idevice.SomeEmphasis self._hintInstruc = x_(u"""A hint may be provided to assist the learner in answering the question.""") self.questions = [] self._questionInstruc = x_(u"""Type the question stem. The question should be clear and unambiguous. Avoid negative premises as these can tend to be ambiguous.""") self._keyInstruc = "" self._feedbackInstruc = x_(u"""Enter any feedback you wish to provide to the learner. This field may be left blank. if this field is left blank default feedback will be provided.""") self.questions.append(TrueFalseQuestion(self)) self.systemResources += [ "common.js", "panel-amusements.png", "stock-stop.png" ] self.instructionsForLearners = TextAreaField( x_(u'Instructions'), x_(u"""Provide instruction on how the True/False Question should be completed."""), u'') self.instructionsForLearners.idevice = self
def __init__(self): """ Initialize """ Idevice.__init__( self, x_(u"Opinion Question"), x_(u"University of Auckland"), x_(u"""Opinion questions present a statement where the learner must decide if he agrees or disagrees."""), u"", u"question") self.emphasis = Idevice.SomeEmphasis self._hintInstruc = x_(u"""A hint may be provided to assist the learner in answering the question.""") self.questions = [] self._questionInstruc = x_(u"""Type the question stem. The question should be clear and unambiguous. Avoid negative premises as these can tend to be ambiguous.""") self._keyInstruc = "" self._feedbackInstruc = x_(u"""Enter any feedback you wish to provide to the learner. This field may be left blank. if this field is left blank default feedback will be provided.""") self.questions.append(OpinionQuestion(self)) self.systemResources += [ "common.js", "libot_drag.js", "panel-amusements.png", "stock-stop.png" ] self.instructionsForLearners = TextAreaField( x_(u'Instructions'), x_(u"""Provide instruction on how the Opinion Question should be completed."""), u'') self.instructionsForLearners.idevice = self self.icon = u"activity"
def upgrade_setIdevice(self, idevice): """ While some of this might typically be done in an automatic upgrade method called from in increased persistence version, the problem with that approach is that the idevice was not previously stored, and cannot easily be gotten at that stage of operation. Rather than making such an upgrade method more messy than necessary, this method allows the parent TrueFalseIdevice to merely set itself on each of its TrueFalseQuestions during its own upgrade. Helps upgrade to somewhere before version 0.25 (post-v0.24), taking the old unicode string fields, and converting them into a image-enabled TextAreaFields: """ self.idevice = idevice self.questionTextArea = TextAreaField(x_(u'Question:'), self.idevice.questionInstruc, self.question) self.questionTextArea.idevice = self.idevice self.feedbackTextArea = TextAreaField(x_(u'Feedback'), self.idevice.feedbackInstruc, self.feedback) self.feedbackTextArea.idevice = self.idevice self.hintTextArea = TextAreaField(x_(u'Hint'), self.idevice.hintInstruc, self.hint) self.hintTextArea.idevice = self.idevice
def upgradeToVersion2(self): """ Upgrades the node from version 1 (not released) to 2 Use new Field classes """ self.content = TextAreaField("content", x_(u"This is a free text field general learning content can be entered."), self.content)
def __init__(self, idevice): """ Initialize """ self.questionTextArea = TextAreaField(u'', u'', u'') self.questionTextArea.idevice = idevice self.feedbackTextArea = TextAreaField(u'', u'', u'') self.feedbackTextArea.idevice = idevice
def upgradeToVersion7(self): """ Upgrades to somewhere before version 0.25 (post-v0.24) Taking the old unicode string fields, and converting them into image-enabled TextAreaFields: """ self.activityTextArea = TextAreaField(x_(u'A Piece of Advice Text:'), self._activityInstruc, self.activity) self.activityTextArea.idevice = self
def upgradeToVersion8(self): """ Upgrades to v0.15 """ self.instructionsForLearners = TextAreaField( x_(u'Instructions'), x_(u"""Provide instruction on how the True/False Question should be completed."""), x_(u'Read the paragraph below and ' 'fill in the missing words.')) self.instructionsForLearners.idevice = self
def __init__(self): Idevice.__init__(self, x_(u"TOC"), x_(u"TUM"), x_(u"""Insert a table of content"""), u"", u"") self.emphasis = Idevice.NoEmphasis self.group = Idevice.Content self.source = u"" self.article = TextAreaField(x_(u"Article")) self.article.idevice = self self.images = {} self.icon = u"inter"
def upgradeToVersion7(self): """ Upgrades to somewhere before version 0.25 (post-v0.24) Taking the old unicode string fields, and converting them into image-enabled TextAreaFields: """ self.activityTextArea = TextAreaField(x_(u'Reflective question:'), self._activityInstruc, self.activity) self.activityTextArea.idevice = self self.answerTextArea = TextAreaField(x_(u'Feedback:'), self._answerInstruc, self.answer) self.answerTextArea.idevice = self
def upgradeToVersion1(self): """ Upgrades exe to v0.10 """ self._upgradeIdeviceToVersion1() self.instructionsForLearners = TextAreaField( x_(u'Instructions For Learners'), x_(u'Put instructions for learners here'), x_(u'Read the paragraph below and fill in the missing words')) self.instructionsForLearners.idevice = self self.feedback = TextAreaField(x_(u'Feedback')) self.feedback.idevice = self
def _initNewAlerts(self): self.wrongGuessMessageField = TextAreaField(x_(u"Wrong Guess Message"), \ x_(u"Player will see this message when they guess a letter wrong"), "") self.wrongGuessMessageField.idevice = self self.lostLevelMessageField = TextAreaField(x_(u"Lost Level Message"), \ x_(u"Player will see this message when they loose the level"), "") self.lostLevelMessageField.idevice = self self.levelPasssedMessageField = TextAreaField(x_(u"Level Passed Message"), \ x_(u"Player will see this message when they guess the word correctly"), "") self.levelPasssedMessageField.idevice = self self.gameWonMessageField = TextAreaField(x_(u"Game Won Message"), \ x_(u"Player will see this message when they guess all words correctly"), "") self.gameWonMessageField.idevice = self
def __init__(self, content=""): Idevice.__init__( self, x_(u"Place The Objects"), x_(u"Mike Dawson / PAIWASTOON Networking Services Ltd."), x_(u"""User has to place various objects in the correct place."""), "", "") self.emphasis = Idevice.SomeEmphasis self.content = TextAreaField(x_(u"Instructions"), x_(u"This is a free text field."), content) self.content.idevice = self self.titleField = TextField(x_("Title"), x_("Title")) self.titleField.idevice = self #This is the main field where objects will be dragged to self.mainArea = TextAreaField( x_(u"Main Area"), x_(u"This is the main image where the user will drag / drop items to" ), "") self.mainArea.idevice = self self.gameTimeLimit = TextField(x_(u"Time Limit (mm:ss)"), x_(u"(Optional) Game Time Limit"), "") self.gameTimeLimit.idevice = self self.gameTimerShown = TextField( x_(u"Show Timer"), x_(u"Even if there is no time limit, show the timer..."), "") self.gameTimerShown.idevice = self #these are shown when there is a right / wrong response self.clickToStartGameArea = TextAreaField( x_(u"Message to click game to start"), x_(u"This will when clicked start the game"), "") self.clickToStartGameArea.idevice = self self.positiveResponseArea = TextAreaField( x_(u"Positive Response"), x_(u"Overlays main area when player correctly places object"), "") self.positiveResponseArea.idevice = self self.negativeResponseArea = TextAreaField( x_(u"Negative Response"), x_(u"Overlays main area when player guesses wrong"), "") self.negativeResponseArea.idevice = self self.partbinNumCols = TextField(x_("Number of Columns in part bin"), x_("Columns part bin"), "2") self.partbinNumCols.idevice = self #This is a list of objects to place self.objectsToPlace = [] self.addPlacableObject()
def __init__(self, activity = "", answer = ""): """ Initialize """ Idevice.__init__(self, x_(u"FPD - Highlighted"), x_(u"Jose Ramon Jimenez Reyes"), x_(u"""Highlighted is an iDevice that emphasizes text to catch the student's attention."""), u"", u"destacadofpd") self.emphasis = Idevice.NoEmphasis self._activityInstruc = x_(u"""Enter the text that will appear on this iDevice""") self.systemResources += ["common.js"] self.activityTextArea = TextAreaField(x_(u'Highlighted Text:'), self._activityInstruc, activity) self.activityTextArea.idevice = self
def __init__(self, defaultSite): Idevice.__init__( self, x_(u"Wiki Article"), x_(u"University of Auckland"), x_(u"""<p>The Wikipedia iDevice allows you to locate existing content from within Wikipedia and download this content into your eXe resource. The Wikipedia Article iDevice takes a snapshot copy of the article content. Changes in Wikipedia will not automatically update individual snapshot copies in eXe, a fresh copy of the article will need to be taken. Likewise, changes made in eXe will not be updated in Wikipedia. </p> <p>Wikipedia content is covered by the GNU Free Documentation 1.2 License, and since 2009 additionally by the Creative Commons Attribution-ShareAlike 3.0 Unported License.</p>"""), u"", u"") self.emphasis = Idevice.NoEmphasis self.articleName = u"" self.article = TextAreaField(x_(u"Article")) self.article.idevice = self self.images = {} self.site = defaultSite self.icon = u"inter" self._langInstruc = x_(u"""Select the appropriate language version of Wikipedia to search and enter search term.""") self._searchInstruc = x_("""Enter a phrase or term you wish to search within Wikipedia.""") self.ownUrl = "" self.systemResources += ['exe_wikipedia.css']
def upgradeToVersion2(self): self.lostLevelMessageField = TextAreaField(x_(u"Lost Level Message"), \ x_("Player will see this message when they loose the level"), "<img src='smallcross.png'/>") self.lostLevelMessageField.idevice = self self.levelPasssedMessageField = TextAreaField(x_(u"Level Passed Message"), \ x_(u"Player will see this message when they guess the word correctly"), "<img src='smallcheck.png'/>") self.levelPasssedMessageField.idevice = self self.gameWonMessageField = TextAreaField(x_(u"Game Won Message"), \ x_(u"Player will see this message when they guess all words correctly"), "<img src='smallcheck.png'/>") self.gameWonMessageField.idevice = self self.wrongGuessMessageField = TextAreaField(x_(u"Wrong Guess Message"), \ x_(u"Player will see this message when they guess a letter wrong"), "<img src='smallcross.png'/>") self.wrongGuessMessageField.idevice = self
def upgradeToVersion7(self): """ Upgrades to somewhere before version 0.25 (post-v0.24) Taking the old unicode string fields, and converting them into a image-enabled TextAreaFields: """ self.storyTextArea = TextAreaField(x_(u'Story:'), self._storyInstruc, self.story) self.storyTextArea.idevice = self for question in self.questions: question.questionTextArea = TextAreaField(u'', u'', question.question) question.questionTextArea.idevice = self question.feedbackTextArea = TextAreaField(u'', u'', question.feedback) question.feedbackTextArea.idevice = self
def __init__(self, activity = "", answer = ""): """ Initialize """ Idevice.__init__(self, x_(u"FPD - A Piece of Advice"), x_(u"Jose Ramon Jimenez Reyes"), x_(u"""A Piece of Advice is an iDevice that permits the teacher give advice on interesting books, films..."""), u"", u"recomendacionfpd") # self.emphasis = Idevice.SomeEmphasis self.emphasis = "_recomendacionfpd" self._activityInstruc = x_(u"""Enter the text that will appear on this iDevice""") # self.systemResources += ["common.js"] self.activityTextArea = TextAreaField(x_(u'A Piece of Advice Text:'), self._activityInstruc, activity) self.activityTextArea.idevice = self
def __init__(self, activity = "", answer = ""): """ Initialize """ Idevice.__init__(self, x_(u"FPD - Situation"), x_(u"Jose Ramon Jimenez Reyes"), x_(u"""Situation is an iDevice that provides the student with a story that will guide her along the learning process."""), u"", u"casopracticofpd") # self.emphasis = Idevice.SomeEmphasis self.emphasis = "_casopracticofpd" self._activityInstruc = x_(u"""Enter the text that will appear on this iDevice""") # self.systemResources += ["common.js"] self.activityTextArea = TextAreaField(x_(u'Situation Text:'), self._activityInstruc, activity) self.activityTextArea.idevice = self
def __init__(self, activity = "", answer = ""): """ Initialize """ Idevice.__init__(self, x_(u"FPD - Guidelines Teacher"), x_(u"Jose Ramon Jimenez Reyes"), x_(u"""Guidelines Teacher is an iDevice that lets the teacher know the learning objectives of the students."""), u"", u"orientacionesfpd") # self.emphasis = Idevice.SomeEmphasis self.emphasis = "_orientacionesfpd" self._activityInstruc = x_(u"""Enter the text that will appear on this iDevice""") self.systemResources += ["common.js"] self.activityTextArea = TextAreaField(x_(u'Guidelines Teacher Text'), self._activityInstruc, activity) self.activityTextArea.idevice = self
def __addDefaultFields(self): """ A JS iDevice always have only a Textarea """ self.addField( TextAreaField( x_(u"Content"), x_(u"""The title and the icon are not required. If you leave them empty the iDevice will have no emphasis.""" )))
def __init__(self, defaultImage = None): Idevice.__init__(self, x_(u"Image Magnifier"), x_(u"University of Auckland"), x_(u"""The image magnifier is a magnifying tool enabling learners to magnify the view of the image they have been given. Moving the magnifying glass over the image allows larger detail to be studied."""), u"", u"") self.emphasis = Idevice.NoEmphasis self.imageMagnifier = MagnifierField( x_(u"Choose an Image"), x_(u"""Click on the picture below or the "Add Image" button to select an image file to be magnified.""")) self.imageMagnifier.idevice = self self.imageMagnifier.defaultImage = defaultImage self.text = TextAreaField(x_(u"Text"), x_("""Enter the text you wish to associate with the file.""")) self.text.idevice = self self.float = u"left" self.caption = u"" self._captionInstruc = x_(u"""Provide a caption for the image to be magnified.""") self._dimensionInstruc = x_(u"""Choose the size you want your image to display at. The measurements are in pixels. Generally, 100 pixels equals approximately 3cm. Leave both fields blank if you want the image to display at its original size.""") self._alignInstruc = x_(u"""Alignment allows you to choose where on the screen the image will be positioned.""") self._initialZoomInstruc = x_(u"""Set the initial level of zoom when the IDevice loads, as a percentage of the original image size""") self._maxZoomInstruc = x_(u"""Set the maximum level of zoom, as a percentage of the original image size""") self._glassSizeInstruc = x_(u"""Select the size of the magnifying glass""") self.systemResources += ['mojomagnify.js']
def __init__(self, idevice, question="", isCorrect=False, feedback="", hint=""): """ Initialize """ self.idevice = idevice self.questionTextArea = TextAreaField(x_(u'Question:'), self.idevice.questionInstruc, question) self.questionTextArea.idevice = idevice self.isCorrect = isCorrect self.feedbackTextArea = TextAreaField(x_(u'Feedback'), self.idevice.feedbackInstruc, feedback) self.feedbackTextArea.idevice = idevice self.hintTextArea = TextAreaField(x_(u'Hint'), self.idevice.hintInstruc, hint) self.hintTextArea.idevice = idevice
def __init__(self, activity = "", answer = ""): """ Initialize """ Idevice.__init__(self, x_(u"FPD - Quotation"), x_(u"Jose Ramon Jimenez Reyes"), x_(u"""Quotation is an iDevice that provides the students with quotations to reflect upon."""), u"", u"citasparapensarfpd") # self.emphasis = Idevice.SomeEmphasis self.emphasis = "_citasparapensarfpd" self._activityInstruc = x_(u"""Enter the text that will appear on this iDevice""") # self.systemResources += ["common.js"] self.activityTextArea = TextAreaField(x_(u'Quotation Text:'), self._activityInstruc, activity) self.activityTextArea.idevice = self
def __init__(self, activity="", answer=""): """ Initialize """ Idevice.__init__( self, x_(u"FPD - Destacado"), x_(u"Jose Ramon Jimenez Reyes"), x_(u"""Destacado es un iDevice que permite resaltar texto para llamar la atención del alumnado.""" ), u"", u"destacadofpd") self.emphasis = Idevice.NoEmphasis self._activityInstruc = x_( u"""Introduce el texto que aparecerá en este iDevice""") self.systemResources += ["common.js"] self.activityTextArea = TextAreaField(x_(u'Texto Destacado:'), self._activityInstruc, activity) self.activityTextArea.idevice = self
def __init__(self, name, idevice, instruction="A place to click on in the main area", content=""): Field.__init__(self, name, instruction) self.idevice = idevice self.message = "" self.textFieldNames = {\ 'top' : [x_('Top (Y) Coord'), x_('Top CSS top property')],\ 'left' : [x_('Left (X) Coord'), x_('Left CSS left property')],\ 'width' : [x_('Width (px)'), x_('Width of clickable area')],\ 'height' : [x_('Height (px)'), x_('Height of clickable area')],\ 'hideDelay' : [x_('Delay (ms) to hide revealed contents'), x_('After delay ms hide the content prev revealed')]\ } self.textFields = {} for textFieldName, textFieldDetails in self.textFieldNames.iteritems(): self.textFields[textFieldName] = TextField(textFieldDetails[INDEX_TITLEFIELD],\ textFieldDetails[INDEX_INSTRUCTIONFIELD]) self.textFields[textFieldName].idevice = self.idevice self.textAreaFieldNames = {\ 'Hint' : [x_('Hint to Show for this item'), x_('The hint that will appear under the map for this item')],\ 'ShowMe' : [x_('Item Revealed'), x_('The Item that will be revealed in place')]\ } self.textAreaFields = {} for textAreaFieldName, textAreaFieldDetails in self.textAreaFieldNames.iteritems( ): self.textAreaFields[textAreaFieldName] = TextAreaField(textAreaFieldDetails[INDEX_TITLEFIELD],\ textAreaFieldDetails[INDEX_INSTRUCTIONFIELD], "") self.textAreaFields[textAreaFieldName].idevice = self.idevice
def upgrade_setIdevice(self, idevice): """ While some of this might typically be done in an automatic upgrade method called from in increased persistence version, the problem with that approach is that the idevice was not previously stored, and cannot easily be gotten at that stage of operation. Rather than making such an upgrade method more messy than necessary, this method allows the parent TestQuestionIdevice to merely set itself on each of its TestQuestions during its own upgrade. Helps upgrade to somewhere before version 0.25 (post-v0.24), taking the old unicode string fields, and converting them into a image-enabled TextAreaFields: """ self.idevice = idevice self.questionTextArea = TextAreaField(x_(u'Question:'), self._questionInstruc, self.question) self.questionTextArea.idevice = self.idevice # and then, need to propagate the same upgrades # down through each of the options: for option in self.options: option.upgrade_setIdevice(self.idevice, self)
def __init__(self, content=""): Idevice.__init__( self, x_(u"FPD - Texto Libre"), x_(u"University of Auckland"), x_(u"""The majority of a learning resource will be establishing context, delivering instructions and providing general information. This provides the framework within which the learning activities are built and delivered."""), "", "") self.emphasis = Idevice.NoEmphasis self.content = TextAreaField( x_(u"Free Text"), x_(u"""Use this field to enter text. This iDevice has no emphasis applied although limited formatting can be applied to text through the text editing buttons associated with the field."""), content) self.content.idevice = self if content: self.edit = False
def __init__(self, activity="", answer=""): """ Initialize """ Idevice.__init__( self, x_(u"FPD - Correccion"), x_(u"Jose Ramon Jimenez Reyes"), x_(u"""Correccion es un iDevice que permite resaltar texto para hacer correcciones a los autores.""" ), u"", u"correccionfpd") self.emphasis = Idevice.NoEmphasis self._activityInstruc = x_( u"""Introduce el texto que aparecerá en este iDevice""") self.systemResources += ["common.js"] self.activityTextArea = TextAreaField(x_(u'Texto Correción:'), self._activityInstruc, activity) self.activityTextArea.idevice = self
def __init__(self, defaultImage = None): Idevice.__init__(self, x_(u"Image with Text"), x_(u"University of Auckland"), x_(u"""<p> The image with text iDevice can be used in a number of ways to support both the emotional (affective) and learning task (cognitive) dimensions of eXe content. </p><p> <b>Integrating visuals with verbal summaries</b> </p><p> Cognitive psychologists indicate that presenting learners with a representative image and corresponding verbal summary (that is presented simultaneously) can reduce cognitive load and enhance learning retention. This iDevice can be used to present an image (photograph, diagram or graphic) with a brief verbal summary covering the main points relating to the image. For example, if you were teaching the functions of a four-stroke combustion engine, you could have a visual for each of the four positions of the piston with a brief textual summary of the key aspects of each visual. </p>"""), u"", u"") self.emphasis = Idevice.NoEmphasis self.group = Idevice.Media self.image = ImageField(x_(u"Image"), u"") self.image.idevice = self self.image.defaultImage = defaultImage self.text = TextAreaField(x_(u"Text"), x_("""Enter the text you wish to associate with the image.""")) self.text.idevice = self self.float = u"left" self.caption = u"" self._captionInstruc = x_(u"""Provide a caption for the image you have just inserted.""")
class Question(Persistable): """ A Case iDevice is built up of question and options. Each option can be rendered as an XHTML element """ persistenceVersion = 1 def __init__(self, idevice): """ Initialize """ self.questionTextArea = TextAreaField(u'', u'', u'') self.questionTextArea.idevice = idevice self.feedbackTextArea = TextAreaField(u'', u'', u'') self.feedbackTextArea.idevice = idevice def setupImage(self, idevice): """ Creates our image field: no longer needed for new content since images are now embedded straight into the feedbackTextArea, but this routine is kept around for upgrade paths from old elps. """ self.image = ImageField(x_(u"Image"), x_(u"Choose an optional image to be shown to the student " "on completion of this question")) self.image.idevice = idevice self.image.defaultImage = idevice.defaultImage self.image.isFeedback = True def getResourcesField(self, this_resource): """ implement the specific resource finding mechanism for this iDevice's Question object: """ if hasattr(self, 'questionTextArea')\ and hasattr(self.questionTextArea, 'images'): for this_image in self.questionTextArea.images: if hasattr(this_image, '_imageResource') \ and this_resource == this_image._imageResource: return self.questionTextArea if hasattr(self, 'feedbackTextArea')\ and hasattr(self.feedbackTextArea, 'images'): for this_image in self.feedbackTextArea.images: if hasattr(this_image, '_imageResource') \ and this_resource == this_image._imageResource: return self.feedbackTextArea return None def getRichTextFields(self): """ Like getResourcesField(), a general helper to allow nodes to search through all of their fields without having to know the specifics of each iDevice type. """ fields_list = [] if hasattr(self, 'questionTextArea'): fields_list.append(self.questionTextArea) if hasattr(self, 'feedbackTextArea'): fields_list.append(self.feedbackTextArea) return fields_list def upgradeToVersion1(self): """ Upgrades to version 0.24 """ log.debug(u"Upgrading iDevice") self.image.isFeedback = True def embedImageInFeedback(self): """ Actually do the Converting of each question's CaseStudyIdevice's image -> embedded in its feedback field, now that its TextField can hold embeddded images. """ new_content = "" if self.image is None or self.image.imageResource is None: return if not os.path.exists(self.image.imageResource.path) \ or not os.path.isfile(self.image.imageResource.path): return if self.image.isDefaultImage: return new_content += "<img src=\"resources/" \ + self.image.imageResource.storageName + "\" " if self.image.height: new_content += "height=\"" + self.image.height + "\" " if self.image.width: new_content += "width=\"" + self.image.width + "\" " new_content += "/> \n" new_content += "<BR>\n" new_content += self.feedbackTextArea.content_w_resourcePaths self.feedbackTextArea.content_w_resourcePaths = new_content self.feedbackTextArea.content = \ self.feedbackTextArea.content_w_resourcePaths self.feedbackTextArea.content_wo_resourcePaths = \ self.feedbackTextArea.MassageContentForRenderView( \ self.feedbackTextArea.content_w_resourcePaths) self.feedbackTextArea.setParentNode() from exe.engine.galleryidevice import GalleryImage full_image_path = self.image.imageResource.path new_GalleryImage = GalleryImage(self.feedbackTextArea, \ '', full_image_path, mkThumbnail=False) self.image.setDefaultImage()
class Question(Persistable): """ A Case iDevice is built up of question and options. Each option can be rendered as an XHTML element """ persistenceVersion = 1 def __init__(self, idevice): """ Initialize """ self.questionTextArea = TextAreaField(u'', u'', u'') self.questionTextArea.idevice = idevice self.feedbackTextArea = TextAreaField(u'', u'', u'') self.feedbackTextArea.idevice = idevice def setupImage(self, idevice): """ Creates our image field: no longer needed for new content since images are now embedded straight into the feedbackTextArea, but this routine is kept around for upgrade paths from old elps. """ self.image = ImageField(x_(u"Image"), x_(u"Choose an optional image to be shown to the student " "on completion of this question")) self.image.idevice = idevice self.image.defaultImage = idevice.defaultImage self.image.isFeedback = True def getResourcesField(self, this_resource): """ implement the specific resource finding mechanism for this iDevice's Question object: """ # be warned that before upgrading, this iDevice field could not exist: if hasattr(self, 'questionTextArea')\ and hasattr(self.questionTextArea, 'images'): for this_image in self.questionTextArea.images: if hasattr(this_image, '_imageResource') \ and this_resource == this_image._imageResource: return self.questionTextArea # be warned that before upgrading, this iDevice field could not exist: if hasattr(self, 'feedbackTextArea')\ and hasattr(self.feedbackTextArea, 'images'): for this_image in self.feedbackTextArea.images: if hasattr(this_image, '_imageResource') \ and this_resource == this_image._imageResource: return self.feedbackTextArea return None def getRichTextFields(self): """ Like getResourcesField(), a general helper to allow nodes to search through all of their fields without having to know the specifics of each iDevice type. """ fields_list = [] if hasattr(self, 'questionTextArea'): fields_list.append(self.questionTextArea) if hasattr(self, 'feedbackTextArea'): fields_list.append(self.feedbackTextArea) return fields_list def upgradeToVersion1(self): """ Upgrades to version 0.24 """ log.debug(u"Upgrading iDevice") self.image.isFeedback = True def embedImageInFeedback(self): """ Actually do the Converting of each question's CaseStudyIdevice's image -> embedded in its feedback field, now that its TextField can hold embeddded images. """ new_content = "" # if no image resource even exists, then no need to continue: # is there a defined? if self.image is None or self.image.imageResource is None: return # likewise, only proceed if the image resource file is found: if not os.path.exists(self.image.imageResource.path) \ or not os.path.isfile(self.image.imageResource.path): return # and if it's just the default blank image, then nothing to do either: if self.image.isDefaultImage: return # get the current image resource info: new_content += "<img src=\"resources/" \ + self.image.imageResource.storageName + "\" " if self.image.height: new_content += "height=\"" + self.image.height + "\" " if self.image.width: new_content += "width=\"" + self.image.width + "\" " new_content += "/> \n" # prepend the new image content to any already existing feedback, # using its content WITH the resources path: new_content += "<BR>\n" new_content += self.feedbackTextArea.content_w_resourcePaths self.feedbackTextArea.content_w_resourcePaths = new_content # set that to its default content: self.feedbackTextArea.content = \ self.feedbackTextArea.content_w_resourcePaths # and massage its content for exporting without resource paths: self.feedbackTextArea.content_wo_resourcePaths = \ self.feedbackTextArea.MassageContentForRenderView( \ self.feedbackTextArea.content_w_resourcePaths) # in passing GalleryImage into feedbackTextArea, a FieldWithResources, # the field needs to be sure to have an updated parentNode, # courtesy of its idevice: self.feedbackTextArea.setParentNode() # (note: FieldWithResources *usually* take care of this automatically # within ProcessPreviewedImages(), but here in this upgrade # path, we are bypassing the general purpose ProcessPreviewed().) # Not sure why this can't be imported up top, but it gives # ImportError: cannot import name GalleryImages, # so here it be: from exe.engine.galleryidevice import GalleryImage full_image_path = self.image.imageResource.path # note: unapplicable caption set to '' in the 2nd parameter: new_GalleryImage = GalleryImage(self.feedbackTextArea, \ '', full_image_path, mkThumbnail=False) # finally, go ahead and clear out the current image object, # which is best (and most safely) done by setting it back to default: self.image.setDefaultImage()
def addItemToSort(self): newTextAreaField = TextAreaField(x_("Sortable Item"), x_("Text / Content of sortable item")) newTextAreaField.idevice = self self.itemsToSort.append(newTextAreaField)