[system] / trunk / wwmoodle / wwquestion / moodle / question / type / webwork / edit_webwork_form.php Repository:
ViewVC logotype

View of /trunk/wwmoodle/wwquestion/moodle/question/type/webwork/edit_webwork_form.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5503 - (download) (as text) (annotate)
Thu Sep 13 00:28:35 2007 UTC (12 years, 5 months ago) by mleventi
File size: 4259 byte(s)
*** empty log message ***

    1 <?php
    2 /**
    3  * The editing form code for this question type.
    4  *
    5  * @copyright &copy; 2007 Matthew Leventi
    6  * @author mleventi@gmail.com
    7  * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
    8  * @package webwork_qtype
    9  *//** */
   10 
   11 require_once("$CFG->dirroot/question/type/edit_question_form.php");
   12 require_once("$CFG->dirroot/question/type/webwork/locallib.php");
   13 require_once("$CFG->dirroot/question/type/webwork/questiontype.php");
   14 require_once("$CFG->dirroot/backup/lib.php");
   15 
   16 /**
   17  * webwork editing form definition.
   18  *
   19  * See http://docs.moodle.org/en/Development:lib/formslib.php for information
   20  * about the Moodle forms library, which is based on the HTML Quickform PEAR library.
   21  */
   22 class question_edit_webwork_form extends question_edit_form {
   23 
   24     function definition_inner(&$mform) {
   25 
   26         //CODE HEADER
   27         $mform->addElement('header', 'codeheader', get_string("edit_codeheader", 'qtype_webwork'));
   28 
   29         //CODE
   30         $mform->addElement('textarea', 'code', get_string('edit_code', 'qtype_webwork'),
   31                 array('rows' => 10,'cols' => 60));
   32         $mform->setType('code', PARAM_RAW);
   33         $mform->setHelpButton('code', array('code', get_string('edit_code', 'qtype_webwork'), 'webwork'));
   34 
   35         //FILES HEADER
   36         $mform->addElement('header', 'fileheader', get_string("edit_fileheader", 'qtype_webwork'));
   37         $mform->setHelpButton('fileheader',array('fileheader', get_string('edit_fileheader','qtype_webwork'),'webwork'));
   38 
   39         //FILES
   40         if(!isset($this->question->webworkid)) {
   41             $tempid = -1;
   42         } else {
   43             $tempid = $this->question->webworkid;
   44         }
   45         $src = webwork_get_filemanager_url($tempid);
   46         $html = "<iframe src='".$src."' width='100%' height='300px' style='border:0px;'></iframe>";
   47         $mform->addElement('html',$html);
   48 
   49         //OPTIONS HEADER
   50         $mform->addElement('header', 'optionheader', get_string("edit_optionheader","qtype_webwork"));
   51 
   52         //CODECHECK
   53         $codecheckoptions = array(
   54             0 => get_string('edit_codecheck0','qtype_webwork'),
   55             1 => get_string('edit_codecheck1','qtype_webwork'),
   56             2 => get_string('edit_codecheck2','qtype_webwork'),
   57             3 => get_string('edit_codecheck3','qtype_webwork'),
   58             4 => get_string('edit_codecheck4','qtype_webwork'));
   59         $mform->addElement('select','codecheck', get_string('edit_codecheck', 'qtype_webwork'),$codecheckoptions);
   60         $mform->setType('codecheck',PARAM_INT);
   61         $mform->setHelpButton('codecheck', array('codecheck', get_string('edit_codecheck', 'qtype_webwork'), 'webwork'));
   62         $mform->setDefault('codecheck',4);
   63 
   64         //SEED
   65         $mform->addElement('text', 'seed', get_string('edit_seed','qtype_webwork'),
   66             array('size' => 3));
   67         $mform->setType('seed', PARAM_INT);
   68         $mform->setHelpButton('seed', array('seed', get_string('edit_seed', 'qtype_webwork'), 'webwork'));
   69         $mform->setDefault('seed', 0);
   70         $mform->addRule('seed', null, 'required', null, 'client');
   71 
   72         //TRIALS
   73         $mform->addElement('text', 'trials', get_string('edit_trials','qtype_webwork'),
   74             array('size' => 3));
   75         $mform->setType('trials', PARAM_INT);
   76         $mform->setHelpButton('trials', array('trials', get_string('edit_trials', 'qtype_webwork'), 'webwork'));
   77         $mform->setDefault('trials', 10);
   78         $mform->addRule('trials', null, 'required', null, 'client');
   79     }
   80 
   81     function set_data($question) {
   82         parent::set_data($question);
   83     }
   84 
   85     function validation($data) {
   86         global $CFG;
   87 
   88         //is this a copy of a current question
   89         if(isset($this->_form->_submitValues['makecopy'])) {
   90             $questioncopy = true;
   91         } else {
   92             $questioncopy = false;
   93         }
   94         //webwork_question id
   95         $wwquestionid = $this->question->webworkid;
   96 
   97         //codecheck
   98         $result = webwork_codecheck($data,$wwquestionid,$questioncopy);
   99         if(is_array($result)) {
  100             return $result;
  101         }
  102         return true;
  103     }
  104 
  105 
  106 
  107     function qtype() {
  108         return 'webwork';
  109     }
  110 }
  111 ?>

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9