[system] / trunk / wwmoodle / wwquestion / edit_webwork_form.php Repository:
ViewVC logotype

View of /trunk/wwmoodle/wwquestion/edit_webwork_form.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5486 - (download) (as text) (annotate)
Tue Sep 11 20:10:03 2007 UTC (12 years, 5 months ago) by mleventi
File size: 4385 byte(s)
Version .4 Partial Answer Questions now supported

    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         $mform->setHelpButton('codeheader',array('codeheader', get_string('edit_codeheader','qtype_webwork'),'webwork'));
   29 
   30         //CODE
   31         $mform->addElement('textarea', 'code', get_string('edit_code', 'qtype_webwork'),
   32                 array('rows' => 10,'cols' => 60));
   33         $mform->setType('code', PARAM_RAW);
   34         $mform->setHelpButton('code', array('code', get_string('edit_code', 'qtype_webwork'), 'webwork'));
   35 
   36         //FILES HEADER
   37         $mform->addElement('header', 'fileheader', get_string("edit_fileheader", 'qtype_webwork'));
   38         $mform->setHelpButton('fileheader',array('fileheader', get_string('edit_fileheader','qtype_webwork'),'webwork'));
   39 
   40         //FILES
   41         if(!isset($this->question->webworkid)) {
   42             $tempid = -1;
   43         } else {
   44             $tempid = $this->question->webworkid;
   45         }
   46         $src = webwork_get_filemanager_url($tempid);
   47         $html = "<iframe src='".$src."' width='100%' height='300px' style='border:0px;'></iframe>";
   48         $mform->addElement('html',$html);
   49 
   50         //OPTIONS HEADER
   51         $mform->addElement('header', 'optionheader', get_string("edit_optionheader","qtype_webwork"));
   52 
   53         //CODECHECK
   54         $codecheckoptions = array(
   55             0 => get_string('edit_codecheck0','qtype_webwork'),
   56             1 => get_string('edit_codecheck1','qtype_webwork'),
   57             2 => get_string('edit_codecheck2','qtype_webwork'),
   58             3 => get_string('edit_codecheck3','qtype_webwork'),
   59             4 => get_string('edit_codecheck4','qtype_webwork'));
   60         $mform->addElement('select','codecheck', get_string('edit_codecheck', 'qtype_webwork'),$codecheckoptions);
   61         $mform->setType('codecheck',PARAM_INT);
   62         $mform->setHelpButton('codecheck', array('codecheck', get_string('edit_codecheck', 'qtype_webwork'), 'webwork'));
   63         $mform->setDefault('codecheck',4);
   64 
   65         //SEED
   66         $mform->addElement('text', 'seed', get_string('edit_seed','qtype_webwork'),
   67             array('size' => 3));
   68         $mform->setType('seed', PARAM_INT);
   69         $mform->setHelpButton('seed', array('webwork', get_string('edit_seed', 'qtype_webwork'), 'webwork'));
   70         $mform->setDefault('seed', 0);
   71         $mform->addRule('seed', null, 'required', null, 'client');
   72 
   73         //TRIALS
   74         $mform->addElement('text', 'trials', get_string('edit_trials','qtype_webwork'),
   75             array('size' => 3));
   76         $mform->setType('trials', PARAM_INT);
   77         $mform->setHelpButton('trials', array('webwork', get_string('edit_trials', 'qtype_webwork'), 'webwork'));
   78         $mform->setDefault('trials', 10);
   79         $mform->addRule('trials', null, 'required', null, 'client');
   80     }
   81 
   82     function set_data($question) {
   83         parent::set_data($question);
   84     }
   85 
   86     function validation($data) {
   87         global $CFG;
   88 
   89         //is this a copy of a current question
   90         if(isset($this->_form->_submitValues['makecopy'])) {
   91             $questioncopy = true;
   92         } else {
   93             $questioncopy = false;
   94         }
   95         //webwork_question id
   96         $wwquestionid = $this->question->webworkid;
   97 
   98         //codecheck
   99         $result = webwork_codecheck($data,$wwquestionid,$questioncopy);
  100         if(is_array($result)) {
  101             return $result;
  102         }
  103         return true;
  104     }
  105 
  106 
  107 
  108     function qtype() {
  109         return 'webwork';
  110     }
  111 }
  112 ?>

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9