Moodle 模块类型

发布于 2024-11-17 17:23:38 字数 764 浏览 3 评论 0原文

我的任务是编写一个相对较小且简单的 PHP Web 应用程序,该应用程序将使用一个小型数据库。对此的身份验证将通过查询字符串中随机生成的十六进制密钥进行,这些密钥由管理页面生成并通过电子邮件发送给所需的用户。

到目前为止一切都很好,但有一个问题:

由于各种政治原因,我们被迫将此应用程序设为 Moodle 模块。我可以在 MySQL 中使用 Moodle 数据库,但我将使用我自己的表,这些表不与 Moodle 交互,并且 Moodle 不会与我的表交互。我还必须使用 Moodle 数据库抽象而不是直接 PHP->MySQL 访问。

我不希望我的用户知道他们正在 Moodle 中操作。他们不需要登录 Moodle 来访问我的网络应用程序,而且他们可能无论如何也无法访问 Moodle。那些有权访问 Moodle 的用户不应在其 Moodle 功能列表中看到此 Web 应用程序。

我整理了一些小的 PHP 页面,其中包括一些 Moodle 库,并将代码放在 mudle/mods 目录中。使用 URL 访问服务器上的 PHP 页面会直接导致 Moodle 错误,因为我没有通过正确的渠道访问该模块。我收到“检测到不正确的访问”错误。

我的任务是可能做的吗?如果是这样,实现它的最佳方法是什么?我需要先编写身份验证模块,然后编写活动模块吗?有没有办法绕过所有 Moodle 的身份验证并简单地使用数据库抽象而不编辑核心 Moodle 配置文件? (我知道可以通过修改 Moodle 代码来实现,但遗憾的是这不是一个选择)。

我有丰富的 PHP 经验,但我只有大约 4 小时的 Moodle 经验,而且进展缓慢。

I am tasked with writing a relatively small and simple PHP web app which will use a small database. Authentication for this will be through randomly generated hex keys in the query string which are generated by an administration page and emailed to desired users.

This is all fine so far, but here's the catch:

For various political reasons, we are forced to make this app a Moodle module. I can use the Moodle database in MySQL, but I will be working with my own tables which do not interact with Moodle, and Moodle will not interact with my tables. I must also to use the Moodle database abstraction rather than direct PHP->MySQL access.

I do not want my users to know they are operating within Moodle. They shouldn't need to log in to Moodle to access my web app, and they probably won't have access to Moodle anyway. Those users who do have access to Moodle shouldn't see this web app in their list of Moodle functions.

I've thrown together a few small PHP pages, included some Moodle libs, and placed the code in the moodle/mods directory. Accessing the PHP pages on the server with the URLs directly result in a Moodle error, since I'm not accessing the module through proper channels. I get the "Incorrect access detected" error.

Is what I'm tasked to do even possible? If so, how is the best way to accomplish it? Do I need to write an authentication module and then an activity module? Is there any way to bypass all of Moodle's authentication and simply use the database abstraction without editing the core Moodle configuration files? (I know it's possible by modifying the Moodle code, but that is sadly not an option).

I have plenty of PHP experience, but I only have about 4 hours of Moodle experience and I'm getting nowhere fast.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

胡渣熟男 2024-11-24 17:23:38

在我看来,您可能正在尝试从除 poodle 在其配置文件中指定的主机之外的主机进入时访问该脚本。你可以尝试转储你的http_host和noodles wwwroot来看看是否排队。与 1.9 相比,我对 2 不太熟悉,但您也许可以定义 abort_after_config,然后包含配置,然后更改 cfg wwwroot,然后定义 abort_after_config_cancel,然后包含设置。否则你可以欺骗主机,否则你可以删除 Tue lib/setup.pup 文件中的检查

It sounds to me that you might be trying to access the script while coming in from a host other than what poodle has specified in its config file. You could try dumping you http_host and noodles wwwroot to see if the line up. I'm less familiar with 2 than 1.9 but you might be able to define abort_after_config then include config then change the cfg wwwroot then define abort_after_config_cancel then include setup. Otherwise you could spoof the host otherwise you can delete the check in Tue lib/setup.pup file

思慕 2024-11-24 17:23:38

不太确定你想在这里实现什么,但以下任何一个都可能有效。

(1) 如果您希望在 LMS 框架内交付一个独立平台,那么您可能会提出一个反建议,即在您首选的环境中开发它,但将其包装在 LTI。然后,Moodle 可以通过外部工具插件交付它,您可以在两者之间进行双向通信以进行身份​​验证和跟踪。

(2) 在 Moodle 中执行此操作

使用 login_hook 创建身份验证并确保这一点它被移动到身份验证插件列表的顶部,以便在其他插件之前首先检查它。使用挂钩处理十六进制密钥(作为 GET 或 POST 参数)或将您带到备用进程并返回 true(或创建会话)。您还可以在身份验证设置中与此插件挂钩一起使用“替代登录页面”。这应该采取身份验证。

如果注册不是问题,则将您的插件创建为本地插件(而不是 mod),并在登录后使用上述挂钩重定向到此页面。这为您使用的库提供了更多的灵活性,并且如果需要,您仍然可以使用首页注册作为解决方法。如果您确实需要注册、课程角色和成绩册,那么可以使用模组来利用这些。最新的 Moodle 中有一种单一的活动课程格式,它为您提供了一种单独运行您的定制活动的格式。

最后在主题中为本地插件开发您自己的布局类型(如果使用该插件)或为课程和课程布局(如果使用课程)开发您自己的布局类型,以便您可以控制所需的标准 Moodle 导航和结构。

如果插件共享已用于其他活动的 Moodle,那么您需要对此保持敏感。如果你只是经营自己的事情,那就容易多了。

(3) 使用Web 服务在您自己的应用程序中从Moodle 获取您想要的内容。

Not sure quite what you are trying to achieve here but any of the following may work.

(1) If you have a stand-alone platform you want delivered within an LMS framework then you might offer a counter proposal of developing it in your preferred environment but wrapping it in LTI. Moodle can then deliver it via the External Tool plugin and you can get two-way communications between the two for authentication and tracking.

(2) Doing it in Moodle

Create an authentication with a login_hook and make sure this is is moved to the top of the authentication plugins list so that it is checked first before the others. Use the hook to process the hex key (as GET or POST parameter) or take you to an alternate process and return true (or create session). You could also use the 'alternative login page' in the authentication settings alongside this plugin hook. This should take of authentication.

If enrolment is not an issue then create your plugin as a local plugin (not mod) and use the above hook to redirect to this page after login. This gives you a bit more flexibility in the libraries you use and you can still use front-page enrolments if necessary as a workaround. If you really need enrolments, course roles, and gradebook then use a mod to leverage these. There is a single activity course format in the latest Moodle that gives you a format to run just your bespoke activity on its own.

Finally develop your own layout type in the theme for the local plugin if using that or for the course and incourse layouts if using courses so that you can control what of the standard Moodle navigation and structure you want.

If the plugin is sharing a Moodle already being used for other activities then you'll need to be sensitive to this. If you're just running your own thing then it will be much easier.

(3) Use Web Services to get what you want from Moodle in your own App.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文