将Java applet添加到Moodle的新问题类型中?

时间:2011-05-31 00:17:51

标签: java applet moodle

我正在尝试为我的新问题类型添加一个Java applet到我的display.html。

但遗憾的是,出现错误, myapplet.class未找到。事实上,它与display.html位于同一个文件夹中,当我单独运行display.html时,applet出现,只有当我在Moodle中运行问题类型时才会出现它。以下是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

}

以下是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>

1 个答案:

答案 0 :(得分:2)

您的第一行包含applet关闭标记</applet>

请改为尝试:

<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>