Class: JLDrill::EditVocabularyContext
- Inherits:
-
ModifyVocabularyContext
- Object
- Context::Context
- ModifyVocabularyContext
- JLDrill::EditVocabularyContext
- Defined in:
- lib/jldrill/contexts/EditVocabularyContext.rb
Instance Attribute Summary
Attributes inherited from Context::Context
#mainView, #parent, #viewBridge
Instance Method Summary collapse
-
#doAction(vocab) ⇒ Object
Sets the vocabulary of the current problem to vocab Refuses to set the vocabulary if it already exists in the quiz.
-
#initialize(viewBridge) ⇒ EditVocabularyContext
constructor
A new instance of EditVocabularyContext.
-
#update(problem) ⇒ Object
When items have been updated in the quiz, If we are editing and the problem changes, then the edit window should change to that problem.
Methods inherited from ModifyVocabularyContext
#close, #createViews, #destroyViews, #dictionaryLoaded?, #edictLoadUpdated, #enter, #exit, #loadDictionary, #newProblemUpdated, #preview, #problemModifiedUpdated, #search, #startLongEventUpdated, #stopLongEventUpdated
Methods inherited from Context::Context
#addView, #createViews, #destroyViews, #enter, #exit, #isEntered?, #onExit, #peekAtView, #setupViews
Constructor Details
#initialize(viewBridge) ⇒ EditVocabularyContext
Returns a new instance of EditVocabularyContext.
8 9 10 11 |
# File 'lib/jldrill/contexts/EditVocabularyContext.rb', line 8 def initialize(viewBridge) super(viewBridge) @actionName = "Set" end |
Instance Method Details
#doAction(vocab) ⇒ Object
Sets the vocabulary of the current problem to vocab Refuses to set the vocabulary if it already exists in the quiz. Returns true if the vocabulary was set, false otherwise Note, if the vocabulary is the one in the problem it will replace it even if it is the same vocabulary in order to update the comment.
26 27 28 29 30 31 32 33 |
# File 'lib/jldrill/contexts/EditVocabularyContext.rb', line 26 def doAction(vocab) if @originalProblem.contains?(vocab) || !@parent.quiz.exists?(vocab) @originalProblem.vocab = vocab @parent.quiz.setCurrentProblem(@originalProblem) close end end |
#update(problem) ⇒ Object
When items have been updated in the quiz, If we are editing and the problem changes, then the edit window should change to that problem.
16 17 18 19 |
# File 'lib/jldrill/contexts/EditVocabularyContext.rb', line 16 def update(problem) super(problem) @mainView.update(problem.item.to_o) end |