如何覆盖渲染器,以使被覆盖的渲染器的功能也保持可用? [英] How to override a renderer such that the functionality of the overridden renderer also remains available?

查看:181
本文介绍了如何覆盖渲染器,以使被覆盖的渲染器的功能也保持可用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Moodle有一个 Multichoice问题类型插件.这些问题在 Quizes 中使用.

我要显示不同类型的多项选择题. 它们基本上都是MCQ,但是呈现方式不同.

例如,有些是*简单的MCQ,而另一些则具有与他们相关的阅读段落(学生必须阅读并从中找到答案)需要显示的内容.然后可以在其他不同类型的MCQ中以不同的方式显示阅读段落.

因此,我需要渲染大约4到5种不同类型的MCQ,它们的不同之处仅在于它们在网页上的呈现方式.

现在,以其他方式显示问题的解决方案是覆盖插件的渲染器. 但是问题在于:

如果我重写Multichoice问题类型的渲染器以使其显示阅读段落,则用于显示简单MCQ的渲染器将被覆盖.这意味着我只能显示带有段落的MCQ,而不能再显示简单的MCQ.

但是我需要显示各种MCQ.

所以请建议我一些解决方法.


最大的担心是:可能需要为每种类型的MCQ编写问题类型的插件,然后将它们添加到测验部分中,要求老师(或进行测验的管理员)选择问题类型;然后老师选择问题的特定类型,然后在我们的代码中得到该类型并执行以下操作:

如果问题类型是简单的MCQ,则使用MCQ插件的渲染器,否则,如果它是带有段落的MCQ,请使用此渲染器(我们的自定义渲染器,它将覆盖多选插件渲染器)

我应该怎么做?


- 这是一张表格的图片,该表格采用了向要向测验中添加问题的管理员的输入,他们想要添加哪种类型的问题?

也许我还需要通过选择然后覆盖显示此表单的代码,然后识别和接收从此表单中输入的代码,来将多选问题分为我感兴趣的类型.决定如何渲染输出.

解决方案

通常是的,您可以扩展现有的插件:

Include_once("existingplugin.php")

Public CustomPlugin extends ExistingPlugin {
    Public override ExistingMethod() {
        //do something else
    }

    //methods not overridden do what they do. 
}

Moodle has a Multichoice question-type plugin. These questions are used in Quizes.

I have different types of multiple choice questions which I want to be displayed. They are all basically MCQ's, but are rendered in different ways.

Forexample some are *simple MCQ'*s, while others have a reading passage associated with them (which the student has to read and find the answer from it) which needs to be displayed. Then the reading passage can be displayed in different ways in further different types of MCQ's.

So I need to render around 4 to 5 different types of MCQ's, which only differ in how they are rendered on the web-page.

Now, the solution to displaying a question in a different way is overriding the renderer of the plugin. But the problem is that:

If I override the renderer of the Multichoice question type such that it displays the reading passage, the renderer for displaying the simple MCQ will be overridden. This means I can only display the MCQ with the passage and not the simple MCQ any more.

But I need to display all kinds of MCQ's.

So please suggest me some way to work around it.


The biggest fear is: may be it needs writing question type plugins for each type of MCQ, and then when adding them in the part of the quiz where the teacher (or the admin who makes the quiz) is asked to choose the question type; and then the teacher selects the particular type of a question, and then in our code we get that type and do something like:

If question type is simple MCQ, then use the MCQ plugin's renderer, otherwise if it is an MCQ with a passage, use this renderer (our custom renderer which overrides the multichoice plugin renderer)

How should I go about it?


EDIT:- This is a picture of the form which takes the input from the admin who is adding a question to the quiz, on what type of question do they want to add?

Perhaps I further need to divide the multichoice question into the types I am interested in by identifying and then overriding the code which displays this form, and then identifying and the code which receives the input from this form, and then use that input to make a decision on how to render the ouput.

解决方案

Generally yes, you can extend an existing plugin:

Include_once("existingplugin.php")

Public CustomPlugin extends ExistingPlugin {
    Public override ExistingMethod() {
        //do something else
    }

    //methods not overridden do what they do. 
}

这篇关于如何覆盖渲染器,以使被覆盖的渲染器的功能也保持可用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆