2013-10-24 46 views
0

在我的Moodle網站上,我在每門課程中都設置了測驗。當學生參加測驗時,我希望那個學生收到一封確認郵件。在那封確認電子郵件中,我希望能夠擁有一份特定於該學生剛剛參加的測驗的PDF附件(例如PDF格式的證書)。設置自定義確認電子郵件和Moodle測驗附件

到目前爲止,我在「站點管理」>「語言」>「語言」自定義中找到了emailconfirmbody字符串。在那裏,我可以編輯默認的「親愛的{$ a->用戶名}」,感謝您在{$ a-> coursename}課程中提交您的答案到'{$ a-> quizname}'{$ a->此消息確認我們已安全地收到您的答案,您可以在{$ a-> quizurl}上訪問此測驗。「問題是...

  1. 如何添加pdf附件? pdf附件需要特定於測驗,正如電子郵件驗證消息特定於測驗(通過使用變量測驗名)一樣。

  2. 電子郵件不會在測驗提交後發送,除非cron.php文件是手動運行的。我如何讓電子郵件自動發送?

+0

對於第二個問題,創建本地插件的概述,你應該用cron運行cron.php。看看[這裏](http://docs.moodle.org/24/en/Cron) – franzlorenzon

回答

0

就像弗蘭茲說的那樣,你需要設置定時運行的cron。

對於電子郵件附件,您可能需要發送自己的電子郵件。你可以通過使用事件API做到這一點。 http://docs.moodle.org/dev/Events_API#Handling_an_event

如果您查看測驗活動文件的底部,可以查看要使用的事件。 /mod/quiz/db/events.php

這一個可能

quiz_attempt_submitted 
->component = 'mod_quiz'; 
->attemptid = // The id of the quiz attempt that was submitted. 
->timefinish = // The timestamp of when the attempt was submitted. 
->timestamp = // The timestamp of when the attempt was submitted. 
->userid  = // The user id that the attempt belongs to. 
->submitterid = // The user id of the user who sumitted the attempt. 
->quizid  = // The quiz id of the quiz the attempt belongs to. 
->cmid  = // The course_module id of the quiz the attempt belongs to. 
->courseid = // The course id of the course the quiz belongs to. 

看看這裏使用的事件 On Course Completion update external database

+0

我已經嘗試過以下創建一個本地插件的概述。到目前爲止,我已經創建了一個名爲swquizemail的本地插件文件夾。裏面有以下內容: 1)local/swquizemail/db/events.php 2)local/swquizemail/version.php 3)local/swquizemail/lib.php 在那些文件中我有下面的代碼可以看到[這裏](http://pastebin.com/fkfUSH2b) 我想知道這是否是正確的。 – user2220474

+0

迄今爲止我看起來不錯:) –

+0

很酷,謝謝!另一個問題...在Moodle文檔[這裏](http://docs.moodle.org/dev/Local_plugins)中列出了標準插件功能下的大約13個文件。我是否需要所有這些文件才能運行?或者,它只適用於我上面提到的3個文件嗎? – user2220474