将 Java 小程序添加到 Moodle 中的新问题类型中?
我正在尝试将 Java 小程序添加到我的新问题类型的 display.html 中。
但不幸的是出现了一个错误,找不到 myapplet.class。事实上,它与 display.html 位于同一文件夹中,当我单独运行 display.html 时,小程序会出现,只是当我在 Moodle 中运行问题类型时,它不会出现。这是小程序的代码:
import java.awt.TextArea;
import javax.swing.JApplet;
/**
*
* @author Islam
*/
public class myapplet extends JApplet {
/**
* Initialization method that will be called after the applet is loaded
* into the browser.
*/
TextArea tx;
public void init() {
// TODO start asynchronous download of heavy resources
tx=new TextArea();
tx.setSize(100, 200);
add(tx);
}
// TODO overwrite start(), stop() and destroy() methods
}
这是 display.html 的代码
<html>
<div class="qtext">
<?php echo $questiontext; ?>
</div>
<div class="ablock clearfix">
<div class="prompt">
<?php echo $stranswer; ?>
</div>
<table class="answer"><tr><td><?php // HTML editors have to go in tables. ?>
<?php echo $answer; ?>
</td></tr></table>
<applet code=myapplet.class name=myapplet archive=applet.jar width=1000 height=500>Your browser is not Java enabled.</applet>
<param name="bgcolor" value="ffffff">
<param name="fontcolor" value="000000">
Your browser is not Java enabled.
</applet>
<br />
<?php if ($feedback) { ?>
<div class="feedback">
<?php echo $feedback; ?>
</div>
<?php } ?>
<?php $this->print_question_submit_buttons($question, $state, $cmoptions, $options); ?>
</div>
</html>
I'm trying to add a Java applet to my display.html for my new question type.
But unfortunately an error appears, that myapplet.class not found. In fact it is on the same folder with display.html and when I run the display.html alone the applet appears, only it doesn't appear when I run the question type inside Moodle. Here is the code for the applet:
import java.awt.TextArea;
import javax.swing.JApplet;
/**
*
* @author Islam
*/
public class myapplet extends JApplet {
/**
* Initialization method that will be called after the applet is loaded
* into the browser.
*/
TextArea tx;
public void init() {
// TODO start asynchronous download of heavy resources
tx=new TextArea();
tx.setSize(100, 200);
add(tx);
}
// TODO overwrite start(), stop() and destroy() methods
}
And here is the code of the display.html
<html>
<div class="qtext">
<?php echo $questiontext; ?>
</div>
<div class="ablock clearfix">
<div class="prompt">
<?php echo $stranswer; ?>
</div>
<table class="answer"><tr><td><?php // HTML editors have to go in tables. ?>
<?php echo $answer; ?>
</td></tr></table>
<applet code=myapplet.class name=myapplet archive=applet.jar width=1000 height=500>Your browser is not Java enabled.</applet>
<param name="bgcolor" value="ffffff">
<param name="fontcolor" value="000000">
Your browser is not Java enabled.
</applet>
<br />
<?php if ($feedback) { ?>
<div class="feedback">
<?php echo $feedback; ?>
</div>
<?php } ?>
<?php $this->print_question_submit_buttons($question, $state, $cmoptions, $options); ?>
</div>
</html>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的第一行有小程序关闭标记
。
试试这个:
Your first line has the applet close tag
</applet>
.Try this instead: