将 Java 小程序添加到 Moodle 中的新问题类型中?

发布于 2024-11-10 06:46:28 字数 1709 浏览 4 评论 0原文

我正在尝试将 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 技术交流群。

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

发布评论

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

评论(1

简单气质女生网名 2024-11-17 06:46:28

您的第一行有小程序关闭标记

试试这个:

<applet
    code="myapplet.class"
    name="myapplet"
    archive="applet.jar"
    width="1000"
    height="500">

  <param name="bgcolor" value="ffffff">
  <param name="fontcolor" value="000000">
  Your browser is not Java enabled.
</applet>

Your first line has the applet close tag </applet>.

Try this instead:

<applet
    code="myapplet.class"
    name="myapplet"
    archive="applet.jar"
    width="1000"
    height="500">

  <param name="bgcolor" value="ffffff">
  <param name="fontcolor" value="000000">
  Your browser is not Java enabled.
</applet>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文