@@ -30,26 +30,21 @@ angular.module('mm.addons.qtype_essay')
3030 templateUrl : 'addons/qtype/essay/template.html' ,
3131 link : function ( scope ) {
3232 var questionEl = $mmQuestionHelper . directiveInit ( scope , $log ) ,
33- question = scope . question ,
3433 textarea ;
3534
3635 if ( questionEl ) {
3736 questionEl = questionEl [ 0 ] || questionEl ; // Convert from jqLite to plain JS if needed.
3837
3938 // First search the textarea.
40- textarea = questionEl . querySelector ( 'textarea[id*=answer_id]' ) ;
39+ textarea = questionEl . querySelector ( 'textarea[name*=_answer]' ) ;
40+ scope . allowsAttachments = ! ! questionEl . querySelector ( 'div[id*=filemanager]' ) ;
41+ scope . isMonospaced = ! ! questionEl . querySelector ( '.qtype_essay_monospaced' ) ;
4142
4243 if ( ! textarea ) {
43- // Textarea not found, we're probably in review. Search the answer and the attachments.
44- if ( questionEl . querySelector ( '.qtype_essay_response' ) ) {
45- scope . answer = $mmUtil . getContentsOfElement ( angular . element ( questionEl ) , '.qtype_essay_response' ) ;
46- scope . attachments = $mmQuestionHelper . getQuestionAttachmentsFromHtml (
47- $mmUtil . getContentsOfElement ( angular . element ( questionEl ) , '.attachments' ) ) ;
48- } else {
49- // Answer not found. Abort.
50- $log . warn ( 'Aborting because couldn\'t find textarea or answer.' , question . name ) ;
51- return $mmQuestionHelper . showDirectiveError ( scope ) ;
52- }
44+ // Textarea not found, we might be in review. Search the answer and the attachments.
45+ scope . answer = $mmUtil . getContentsOfElement ( angular . element ( questionEl ) , '.qtype_essay_response' ) ;
46+ scope . attachments = $mmQuestionHelper . getQuestionAttachmentsFromHtml (
47+ $mmUtil . getContentsOfElement ( angular . element ( questionEl ) , '.attachments' ) ) ;
5348 } else {
5449 // Textarea found.
5550 var input = questionEl . querySelector ( 'input[type="hidden"][name*=answerformat]' ) ,
0 commit comments