2013-10-24 114 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