var resultline = Y.one('#tool_installaddon_installfromzip_permcheck');
if (resultline) {
if (status === 'success') {
- resultline.setContent('<span class="success"><img src="' + M.util.image_url('i/tick_green_big') + '" /> ' +
+ resultline.setContent('<span class="success"><img src="' + M.util.image_url('i/valid') + '" /> ' +
msg + '</span>');
} else if (status === 'progress') {
resultline.setContent('<span class="progress"><img src="' + M.cfg.loadingicon + '" /> ' +
msg + '</span>');
} else {
- resultline.setContent('<span class="error"><img src="' + M.util.image_url('i/cross_red_big') + '" /> ' +
+ resultline.setContent('<span class="error"><img src="' + M.util.image_url('i/invalid') + '" /> ' +
msg + '</span>');
}
}
$description = $badge->description;
$criteria = self::print_badge_criteria($badge);
if ($badge->dateissued) {
- $icon = new pix_icon('i/tick_green_big',
+ $icon = new pix_icon('i/valid',
get_string('dateearned', 'badges',
userdate($badge->dateissued, get_string('strftimedatefullshort', 'core_langconfig'))));
$badgeurl = new moodle_url('/badges/badge.php', array('hash' => $badge->uniquehash));
// Create a few events and do asserts.
$this->create_calendar_event('test', $USER->id);
- $count = count($DB->get_records("event", array('name' => 'test')));
+ $where = $DB->sql_compare_text('name') ." = ?";
+ $count = count($DB->get_records_select("event", $where, array('test')));
$this->assertEquals(1, $count);
$aftercount = count($DB->get_records("event"));
$this->assertEquals($prevcount + 1, $aftercount);
$this->create_calendar_event('user', $USER->id, 'user', 3);
- $count = count($DB->get_records("event", array('name' => 'user')));
+ $where = $DB->sql_compare_text('name') ." = ?";
+ $count = count($DB->get_records_select("event", $where, array('user')));
+
$this->assertEquals(3, $count);
$aftercount = count($DB->get_records("event"));
$this->assertEquals($prevcount + 4, $aftercount);
$actions = array();
if ($controller->is_shared_template()) {
$actions[] = $output->pick_action_icon(new moodle_url($PAGE->url, array('pick' => $template->id)),
- get_string('templatepick', 'core_grading'), 'i/tick_green_big', 'pick template');
+ get_string('templatepick', 'core_grading'), 'i/valid', 'pick template');
if ($canmanage or ($canshare and ($template->usercreated == $USER->id))) {
//$actions[] = $output->pick_action_icon(new moodle_url($PAGE->url, array('edit' => $template->id)),
// get_string('templateedit', 'core_grading'), 'i/edit', 'edit');
}
} else if ($controller->is_own_form()) {
$actions[] = $output->pick_action_icon(new moodle_url($PAGE->url, array('pick' => $template->id)),
- get_string('templatepickownform', 'core_grading'), 'i/tick_green_big', 'pick ownform');
+ get_string('templatepickownform', 'core_grading'), 'i/valid', 'pick ownform');
}
$out .= $output->box(join(' ', $actions), 'template-actions');
$out .= $output->box($controller->get_formatted_description(), 'template-description');
}
/**
- * Builds and returns a div with on/off toggles.
- * @return string HTML code
- * @deprecated since 2.4 as it appears not to be used any more.
+ * @deprecated since Moodle 2.4 as it appears not to be used any more.
*/
public function get_toggles_html() {
- global $CFG, $USER, $COURSE, $OUTPUT;
- debugging('Call to deprecated function grade_report_grader::get_toggles_html().', DEBUG_DEVELOPER);
- $html = '';
- if ($USER->gradeediting[$this->courseid]) {
- if (has_capability('moodle/grade:manage', $this->context) or has_capability('moodle/grade:hide', $this->context)) {
- $html .= $this->print_toggle('eyecons');
- }
- if (has_capability('moodle/grade:manage', $this->context)
- or has_capability('moodle/grade:lock', $this->context)
- or has_capability('moodle/grade:unlock', $this->context)) {
- $html .= $this->print_toggle('locks');
- }
- if (has_capability('moodle/grade:manage', $this->context)) {
- $html .= $this->print_toggle('quickfeedback');
- }
-
- if (has_capability('moodle/grade:manage', $this->context)) {
- $html .= $this->print_toggle('calculations');
- }
- }
-
- if ($this->canviewhidden) {
- $html .= $this->print_toggle('averages');
- }
-
- $html .= $this->print_toggle('ranges');
- if (!empty($CFG->enableoutcomes)) {
- $html .= $this->print_toggle('nooutcomes');
- }
-
- return $OUTPUT->container($html, 'grade-report-toggles');
+ throw new coding_exception('get_toggles_html() can not be used any more');
}
/**
- * Shortcut function for printing the grader report toggles.
- * @param string $type The type of toggle
- * @param bool $return Whether to return the HTML string rather than printing it
- * @return void
- * @deprecated since 2.4 as it appears not to be used any more.
- */
+ * @deprecated since 2.4 as it appears not to be used any more.
+ */
public function print_toggle($type) {
- global $CFG, $OUTPUT;
- debugging('Call to deprecated function grade_report_grader::print_toggle().', DEBUG_DEVELOPER);
- $icons = array('eyecons' => 't/hide',
- 'calculations' => 't/calc',
- 'locks' => 't/lock',
- 'averages' => 't/mean',
- 'quickfeedback' => 't/feedback',
- 'nooutcomes' => 't/outcomes');
-
- $prefname = 'grade_report_show' . $type;
-
- if (array_key_exists($prefname, $CFG)) {
- $showpref = get_user_preferences($prefname, $CFG->$prefname);
- } else {
- $showpref = get_user_preferences($prefname);
- }
-
- $strshow = $this->get_lang_string('show' . $type, 'grades');
- $strhide = $this->get_lang_string('hide' . $type, 'grades');
-
- $showhide = 'show';
- $toggleaction = 1;
-
- if ($showpref) {
- $showhide = 'hide';
- $toggleaction = 0;
- }
-
- if (array_key_exists($type, $icons)) {
- $imagename = $icons[$type];
- } else {
- $imagename = "t/$type";
- }
-
- $string = ${'str' . $showhide};
-
- $url = new moodle_url($this->baseurl, array('toggle' => $toggleaction, 'toggle_type' => $type));
-
- $retval = $OUTPUT->container($OUTPUT->action_icon($url, new pix_icon($imagename, $string))); // TODO: this container looks wrong here
-
- return $retval;
+ throw new coding_exception('print_toggle() can not be used any more');
}
/**
This files describes API changes in /grade/report/*,
information provided here is intended especially for developers.
+=== 2.6 ===
+* grade_report_grader::get_toggles_html() and grade_report_grader::print_toggle()
+ can not be used any more
=== 2.3.5, 2.4.2 ===
* class_grade_report::showtotalsifcontainhidden has been switched from a single integer value to an array.
}
}
}
+
+ /**
+ * Used by tests to simulate submitted form data submission from the user.
+ *
+ * For form fields where no data is submitted the default for that field as set by set_data or setDefault will be passed to
+ * get_data.
+ *
+ * This method sets $_POST or $_GET and $_FILES with the data supplied. Our unit test code empties all these
+ * global arrays after each test.
+ *
+ * @param array $simulatedsubmitteddata An associative array of form values (same format as $_POST).
+ * @param array $simulatedsubmittedfiles An associative array of files uploaded (same format as $_FILES). Can be omitted.
+ * @param string $method 'post' or 'get', defaults to 'post'.
+ * @param null $formidentifier the default is to use the class name for this class but you may need to provide
+ * a different value here for some forms that are used more than once on the
+ * same page.
+ */
+ public static function mock_submit($simulatedsubmitteddata, $simulatedsubmittedfiles = array(), $method = 'post',
+ $formidentifier = null) {
+ $_FILES = $simulatedsubmittedfiles;
+ if ($formidentifier === null) {
+ $formidentifier = get_called_class();
+ }
+ $simulatedsubmitteddata['_qf__'.$formidentifier] = 1;
+ $simulatedsubmitteddata['sesskey'] = sesskey();
+ if (strtolower($method) === 'get') {
+ $_GET = $simulatedsubmitteddata;
+ } else {
+ $_POST = $simulatedsubmitteddata;
+ }
+ }
}
/**
* Use new core_component::* plugin listing and component normalisation methods.
* Use core_text::* instead of textlib:: and also core_collator::* instead of collatorlib::*.
+* Use new function moodleform::mock_submit() to simulate form submission in unit tests (backported).
* get_context_instance() is deprecated, please use use context_xxxx::instance().
* get_context_instance_by_id() is deprecated, please use context::instance_by_id($id).
* load_temp_role() and remove_temp_roles() can not be used any more.
// Submission status.
if ($assignment->is_any_submission_plugin_enabled()) {
$columns[] = 'status';
- $headers[] = get_string('status');
+ $headers[] = get_string('status', 'assign');
} else if ($this->assignment->get_instance()->markingworkflow) {
$columns[] = 'workflowstatus';
- $headers[] = get_string('status');
-
+ $headers[] = get_string('status', 'assign');
}
// Team submission columns.
$string['setmarkerallocationforlog'] = 'Set marking allocation : (id={$a->id}, fullname={$a->fullname}, marker={$a->marker}). ';
$string['settings'] = 'Assignment settings';
$string['showrecentsubmissions'] = 'Show recent submissions';
+$string['status'] = 'Status';
$string['submissioncopiedtext'] = 'You have made a copy of your previous
assignment submission for \'{$a->assignment}\'
get_string('showdetailedmarks', 'quiz_overview'));
} else {
$mform->addElement('hidden', 'slotmarks', 0);
+ $mform->setType('slotmarks', PARAM_INT);
}
}
}
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>\r
-<!-- Generator: Adobe Illustrator 15.1.0, SVG Export Plug-In -->\r
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [\r
- <!ENTITY ns_flows "http://ns.adobe.com/Flows/1.0/">\r
-]>\r
-<svg version="1.1"\r
- xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"\r
- x="0px" y="0px" width="16px" height="16px" viewBox="-0.2 0 16 16" style="overflow:visible;enable-background:new -0.2 0 16 16;"\r
- xml:space="preserve" preserveAspectRatio="xMinYMid meet">\r
-<defs>\r
-</defs>\r
-<path style="fill:#999999;" d="M6,0.4c0.4-0.1,0.8-0.1,1.3-0.1c1.5,0,3,0.5,4.2,1.4c-0.6,0.2-1.2,0.5-1.7,1C9.7,2.7,9.6,2.8,9.6,2.8\r
- C8.9,2.5,8.1,2.2,7.2,2.2c-0.1,0-0.2,0-0.3,0C6.8,1.6,6.5,0.9,6,0.4z M11.7,9.4c-0.2,0.5-0.5,1-1,1.4c-0.3,0.3-0.8,0.6-1.2,0.8\r
- c0.2,0.7,0.3,1.4,0.1,2.2c0.9-0.3,1.8-0.9,2.5-1.6c0.9-0.9,1.4-1.9,1.8-3C13.2,9.5,12.5,9.5,11.7,9.4z M3,10.1C3,10,3.1,10,3,10.1\r
- C2.5,9.1,2.2,8,2.3,6.9C1.6,6.8,0.9,6.5,0.4,6C0,8,0.5,10.2,2,11.9C2.2,11.2,2.5,10.6,3,10.1z M10.4,3.4c-1.2,1.2-1.2,3.1,0,4.2\r
- c1.2,1.2,3.1,1.2,4.2,0s1.2-3.1,0-4.2C13.5,2.2,11.6,2.2,10.4,3.4z M3.7,10.8c-1.2,1.2-1.2,3.1,0,4.2c1.2,1.2,3.1,1.2,4.2,0\r
- c1.2-1.2,1.2-3.1,0-4.2C6.8,9.6,4.9,9.6,3.7,10.8z M0.9,0.9c-1.2,1.2-1.2,3.1,0,4.2C2,6.3,4,6.3,5.1,5.1c1.2-1.2,1.2-3.1,0-4.2\r
- C4-0.3,2-0.3,0.9,0.9z"/>\r
-</svg>\r
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>\r
-<!-- Generator: Adobe Illustrator 15.1.0, SVG Export Plug-In -->\r
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [\r
- <!ENTITY ns_flows "http://ns.adobe.com/Flows/1.0/">\r
-]>\r
-<svg version="1.1"\r
- xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"\r
- x="0px" y="0px" width="16px" height="16px" viewBox="0 0 16 16" style="overflow:visible;enable-background:new 0 0 16 16;"\r
- xml:space="preserve" preserveAspectRatio="xMinYMid meet">\r
-<defs>\r
-</defs>\r
-<path style="fill:#999999;" d="M3,16H0v-4l3.2-1.7C3.6,10,3.8,9.5,3.4,9C3.4,9,2,7.2,2,5.2C2,2.3,3.8,0,6,0c0.4,0,0.7,0.1,1.1,0.2\r
- c-1.2,1.1-2,3-2,5c0,1.7,0.6,2.7,1,3.5c0.6,0.9,0.1,1-0.3,1.3C5.6,10.1,3,11.4,3,11.4V16z M16,11.9l-3.1-1.6\r
- C12.4,10,12.3,9.4,12.6,9c0,0,1.4-1.8,1.4-3.8C14,2.3,12.2,0,10,0S6,2.3,6,5.2C6,7.2,7.5,9,7.5,9c0.3,0.4,0.2,1-0.3,1.3L4,12v4h12\r
- V11.9z"/>\r
-</svg>\r
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>\r
-<!-- Generator: Adobe Illustrator 15.1.0, SVG Export Plug-In -->\r
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [\r
- <!ENTITY ns_flows "http://ns.adobe.com/Flows/1.0/">\r
-]>\r
-<svg version="1.1"\r
- xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"\r
- x="0px" y="0px" width="16px" height="16px" viewBox="0 0 16 16" style="overflow:visible;enable-background:new 0 0 16 16;"\r
- xml:space="preserve" preserveAspectRatio="xMinYMid meet">\r
-<defs>\r
-</defs>\r
-<path style="fill:#999999;" d="M14,1h-2v1.5C12,3.3,11.3,4,10.5,4S9,3.3,9,2.5V1H6v1.5C6,3.3,5.3,4,4.5,4S3,3.3,3,2.5V1H1\r
- C0.4,1,0,1.4,0,2v13c0,0.6,0.4,1,1,1h13c0.6,0,1-0.4,1-1V2C15,1.4,14.6,1,14,1z M4,14H2v-2h2V14z M4,11H2V9h2V11z M4,8H2V6h2V8z\r
- M7,14H5v-2h2V14z M7,11H5V9h2V11z M7,8H5V6h2V8z M10,14H8v-2h2V14z M10,11H8V9h2V11z M10,8H8V6h2V8z M13,14h-2v-2h2V14z M13,11h-2\r
- V9h2V11z M13,8h-2V6h2V8z M5,2.5C5,2.8,4.8,3,4.5,3l0,0C4.2,3,4,2.8,4,2.5v-2C4,0.2,4.2,0,4.5,0l0,0C4.8,0,5,0.2,5,0.5V2.5z M11,2.5\r
- C11,2.8,10.8,3,10.5,3l0,0C10.2,3,10,2.8,10,2.5v-2C10,0.2,10.2,0,10.5,0l0,0C10.8,0,11,0.2,11,0.5V2.5z"/>\r
-</svg>\r
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>\r
-<!-- Generator: Adobe Illustrator 15.1.0, SVG Export Plug-In -->\r
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [\r
- <!ENTITY ns_flows "http://ns.adobe.com/Flows/1.0/">\r
-]>\r
-<svg version="1.1"\r
- xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"\r
- x="0px" y="0px" width="16px" height="16px" viewBox="0 0 16 16" style="overflow:visible;enable-background:new 0 0 16 16;"\r
- xml:space="preserve" preserveAspectRatio="xMinYMid meet">\r
-<defs>\r
-</defs>\r
-<path style="fill:#999999;" d="M5.2,10.3L0,13.1V16h16v-3l-5.2-2.7C10.3,10,10.2,9.4,10.6,9c0,0,1.4-1.8,1.4-3.8C12,2.3,10.2,0,8,0\r
- S4,2.3,4,5.2C4,7.2,5.4,9,5.4,9C5.8,9.5,5.7,10,5.2,10.3z"/>\r
-</svg>\r
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>\r
-<!-- Generator: Adobe Illustrator 15.1.0, SVG Export Plug-In -->\r
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [\r
- <!ENTITY ns_flows "http://ns.adobe.com/Flows/1.0/">\r
-]>\r
-<svg version="1.1"\r
- xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"\r
- x="0px" y="0px" width="12px" height="12px" viewBox="0 0 12 12" style="overflow:visible;enable-background:new 0 0 12 12;"\r
- xml:space="preserve" preserveAspectRatio="xMinYMid meet">\r
-<defs>\r
-</defs>\r
-<path style="fill:#999999;" d="M11.4,0.6l-0.9-0.5C10.1-0.1,9.5,0,9.2,0.5L4.7,8.2L2,6.6C1.5,6.3,0.9,6.5,0.6,7L0.1,7.8\r
- C-0.1,8.3,0,8.9,0.5,9.2L5,11.8c0.1,0.1,0.3,0.1,0.4,0.1c0.4,0.1,0.8-0.1,1-0.5L11.8,2C12.1,1.5,11.9,0.9,11.4,0.6z"/>\r
-</svg>\r
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>\r
-<!-- Generator: Adobe Illustrator 15.1.0, SVG Export Plug-In -->\r
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [\r
- <!ENTITY ns_flows "http://ns.adobe.com/Flows/1.0/">\r
-]>\r
-<svg version="1.1"\r
- xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"\r
- x="0px" y="0px" width="16px" height="16px" viewBox="-1.6 -0.5 16 16"\r
- style="overflow:visible;enable-background:new -1.6 -0.5 16 16;" xml:space="preserve" preserveAspectRatio="xMinYMid meet">\r
-<defs>\r
-</defs>\r
-<path style="fill:#FF403C;" d="M12.8,2.7L10.1,0c0,0-1.6,1.5-3.7,4C4.3,1.5,2.7,0,2.7,0L0,2.7c0,0,1.9,1.3,4.6,3.7\r
- C3,8.7,1.3,11.6,0,14.9C2.2,12.2,4.4,9.9,6.4,8c2,1.9,4.2,4.2,6.4,6.9c-1.3-3.3-3-6.2-4.6-8.6C10.9,4,12.8,2.7,12.8,2.7z"/>\r
-</svg>\r
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>\r
-<!-- Generator: Adobe Illustrator 15.1.0, SVG Export Plug-In -->\r
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [\r
- <!ENTITY ns_flows "http://ns.adobe.com/Flows/1.0/">\r
-]>\r
-<svg version="1.1"\r
- xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"\r
- x="0px" y="0px" width="16px" height="16px" viewBox="-1.6 -0.5 16 16"\r
- style="overflow:visible;enable-background:new -1.6 -0.5 16 16;" xml:space="preserve" preserveAspectRatio="xMinYMid meet">\r
-<defs>\r
-</defs>\r
-<path style="fill:#FF403C;" d="M12.8,2.7L10.1,0c0,0-1.6,1.5-3.7,4C4.3,1.5,2.7,0,2.7,0L0,2.7c0,0,1.9,1.3,4.6,3.7\r
- C3,8.7,1.3,11.6,0,14.9C2.2,12.2,4.4,9.9,6.4,8c2,1.9,4.2,4.2,6.4,6.9c-1.3-3.3-3-6.2-4.6-8.6C10.9,4,12.8,2.7,12.8,2.7z"/>\r
-</svg>\r
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>\r
-<!-- Generator: Adobe Illustrator 15.1.0, SVG Export Plug-In -->\r
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [\r
- <!ENTITY ns_flows "http://ns.adobe.com/Flows/1.0/">\r
-]>\r
-<svg version="1.1"\r
- xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"\r
- x="0px" y="0px" width="16px" height="16px" viewBox="0 0 16 16" style="overflow:visible;enable-background:new 0 0 16 16;"\r
- xml:space="preserve" preserveAspectRatio="xMinYMid meet">\r
-<defs>\r
-</defs>\r
-<path style="fill:#999999;" d="M5.2,10.3L0,13.1V16h16v-3l-5.2-2.7C10.3,10,10.2,9.4,10.6,9c0,0,1.4-1.8,1.4-3.8C12,2.3,10.2,0,8,0\r
- S4,2.3,4,5.2C4,7.2,5.4,9,5.4,9C5.8,9.5,5.7,10,5.2,10.3z"/>\r
-</svg>\r
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>\r
-<!-- Generator: Adobe Illustrator 15.1.0, SVG Export Plug-In -->\r
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [\r
- <!ENTITY ns_flows "http://ns.adobe.com/Flows/1.0/">\r
-]>\r
-<svg version="1.1"\r
- xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"\r
- x="0px" y="0px" width="16px" height="16px" viewBox="-0.1 0 16 16" style="overflow:visible;enable-background:new -0.1 0 16 16;"\r
- xml:space="preserve" preserveAspectRatio="xMinYMid meet">\r
-<defs>\r
-</defs>\r
-<path style="fill:#FFB844;" d="M6.4,11.1c-2-2.5-3.7-4-3.7-4S0.3,9.5,0,9.8C5,13.1,8.1,16,8.1,16s0.2-0.7,0.6-1.8\r
- c0.9-2.7,3.2-8.1,7.1-14.2C11.2,3.7,8.1,8.2,6.4,11.1z"/>\r
-</svg>\r
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>\r
-<!-- Generator: Adobe Illustrator 15.1.0, SVG Export Plug-In -->\r
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [\r
- <!ENTITY ns_flows "http://ns.adobe.com/Flows/1.0/">\r
-]>\r
-<svg version="1.1"\r
- xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"\r
- x="0px" y="0px" width="16px" height="16px" viewBox="-0.1 0 16 16" style="overflow:visible;enable-background:new -0.1 0 16 16;"\r
- xml:space="preserve" preserveAspectRatio="xMinYMid meet">\r
-<defs>\r
-</defs>\r
-<path style="fill:#FFB844;" d="M6.4,11.1c-2-2.5-3.7-4-3.7-4S0.3,9.5,0,9.8C5,13.1,8.1,16,8.1,16s0.2-0.7,0.6-1.8\r
- c0.9-2.7,3.2-8.1,7.1-14.2C11.2,3.7,8.1,8.2,6.4,11.1z"/>\r
-</svg>\r
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>\r
-<!-- Generator: Adobe Illustrator 15.1.0, SVG Export Plug-In -->\r
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [\r
- <!ENTITY ns_flows "http://ns.adobe.com/Flows/1.0/">\r
-]>\r
-<svg version="1.1"\r
- xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"\r
- x="0px" y="0px" width="16px" height="16px" viewBox="-0.1 0 16 16" style="overflow:visible;enable-background:new -0.1 0 16 16;"\r
- xml:space="preserve" preserveAspectRatio="xMinYMid meet">\r
-<defs>\r
-</defs>\r
-<path style="fill:#99CC33;" d="M6.4,11.1c-2-2.5-3.7-4-3.7-4S0.3,9.5,0,9.8C5,13.1,8.1,16,8.1,16s0.2-0.7,0.6-1.8\r
- c0.9-2.7,3.2-8.1,7.1-14.2C11.2,3.7,8.1,8.2,6.4,11.1z"/>\r
-</svg>\r
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>\r
-<!-- Generator: Adobe Illustrator 15.1.0, SVG Export Plug-In -->\r
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [\r
- <!ENTITY ns_flows "http://ns.adobe.com/Flows/1.0/">\r
-]>\r
-<svg version="1.1"\r
- xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"\r
- x="0px" y="0px" width="16px" height="16px" viewBox="-0.1 0 16 16" style="overflow:visible;enable-background:new -0.1 0 16 16;"\r
- xml:space="preserve" preserveAspectRatio="xMinYMid meet">\r
-<defs>\r
-</defs>\r
-<path style="fill:#99CC33;" d="M6.4,11.1c-2-2.5-3.7-4-3.7-4S0.3,9.5,0,9.8C5,13.1,8.1,16,8.1,16s0.2-0.7,0.6-1.8\r
- c0.9-2.7,3.2-8.1,7.1-14.2C11.2,3.7,8.1,8.2,6.4,11.1z"/>\r
-</svg>\r
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>\r
-<!-- Generator: Adobe Illustrator 15.1.0, SVG Export Plug-In -->\r
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [\r
- <!ENTITY ns_flows "http://ns.adobe.com/Flows/1.0/">\r
-]>\r
-<svg version="1.1"\r
- xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"\r
- x="0px" y="0px" width="12px" height="12px" viewBox="0 0 12 12" style="overflow:visible;enable-background:new 0 0 12 12;"\r
- xml:space="preserve" preserveAspectRatio="xMinYMid meet">\r
-<defs>\r
-</defs>\r
-<path style="fill:#999999;" d="M11,4.5H7.5V1c0-0.5-0.5-1-1-1h-1c-0.5,0-1,0.5-1,1v3.5L1,4.5c-0.5,0-1,0.5-1,1v1c0,0.5,0.5,1,1,1\r
- h3.5V11c0,0.5,0.5,1,1,1h1c0.5,0,1-0.5,1-1V7.5H11c0.6,0,1-0.5,1-1l0-1C12,5,11.6,4.5,11,4.5z"/>\r
-</svg>\r
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>\r
-<!-- Generator: Adobe Illustrator 15.1.0, SVG Export Plug-In -->\r
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [\r
- <!ENTITY ns_flows "http://ns.adobe.com/Flows/1.0/">\r
-]>\r
-<svg version="1.1"\r
- xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"\r
- x="0px" y="0px" width="12px" height="12px" viewBox="0 0 12 12" style="overflow:visible;enable-background:new 0 0 12 12;"\r
- xml:space="preserve" preserveAspectRatio="xMinYMid meet">\r
-<defs>\r
-</defs>\r
-<path style="fill:#999999;" d="M11.4,0.6l-0.9-0.5C10.1-0.1,9.5,0,9.2,0.5L4.7,8.2L2,6.6C1.5,6.3,0.9,6.5,0.6,7L0.1,7.8\r
- C-0.1,8.3,0,8.9,0.5,9.2L5,11.8c0.1,0.1,0.3,0.1,0.4,0.1c0.4,0.1,0.8-0.1,1-0.5L11.8,2C12.1,1.5,11.9,0.9,11.4,0.6z"/>\r
-</svg>\r
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>\r
-<!-- Generator: Adobe Illustrator 15.1.0, SVG Export Plug-In -->\r
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [\r
- <!ENTITY ns_flows "http://ns.adobe.com/Flows/1.0/">\r
-]>\r
-<svg version="1.1"\r
- xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"\r
- x="0px" y="0px" width="16px" height="16px" viewBox="0 0 16 16" style="overflow:visible;enable-background:new 0 0 16 16;"\r
- xml:space="preserve" preserveAspectRatio="xMinYMid meet">\r
-<defs>\r
-</defs>\r
-<path style="fill:#999999;" d="M15,5.2V15c0,0.5-0.5,1-1,1H1c-0.5,0-1-0.5-1-1V2c0-0.5,0.5-1,1-1h9.8l-2,2H3C2.5,3,2,3.4,2,4v9\r
- c0,0.5,0.5,1,1,1h9c0.5,0,1-0.5,1-1V7.2L15,5.2z M15.4,0.6L15.4,0.6c-0.8-0.8-2.1-0.8-2.8,0l-1,1l2.8,2.8l1-1\r
- C16.2,2.6,16.2,1.4,15.4,0.6z M10.6,2.6L4,9.1V12h2.8c0,0,1.8-1.8,1.8-1.8l4.8-4.8L10.6,2.6z"/>\r
-</svg>\r
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>\r
-<!-- Generator: Adobe Illustrator 15.1.0, SVG Export Plug-In -->\r
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [\r
- <!ENTITY ns_flows "http://ns.adobe.com/Flows/1.0/">\r
-]>\r
-<svg version="1.1"\r
- xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"\r
- x="0px" y="0px" width="12px" height="12px" viewBox="0 0 12 12" style="overflow:visible;enable-background:new 0 0 12 12;"\r
- xml:space="preserve" preserveAspectRatio="xMinYMid meet">\r
-<defs>\r
-</defs>\r
-<path style="fill:#999999;" d="M6.5,0l-1,0c-1.7,0-3,1.3-3,3v2H1C0.5,5,0,5.5,0,6l0,5c0,0.6,0.4,1,1,1h10c0.5,0,1-0.5,1-1l0-5\r
- c0-0.6-0.5-1-1-1H9.5l0-2C9.5,1.3,8.2,0,6.5,0z M7,8c0,0.4-0.2,0.7-0.6,0.9L6.5,9L7,10H6H5l0.5-1l0.1-0.1C5.2,8.7,5,8.4,5,8\r
- c0-0.5,0.4-1,1-1S7,7.5,7,8z M7.5,3v2l-3,0V3c0-0.6,0.5-1,1-1h1C7.1,2,7.5,2.4,7.5,3z"/>\r
-</svg>\r
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>\r
-<!-- Generator: Adobe Illustrator 15.1.0, SVG Export Plug-In -->\r
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [\r
- <!ENTITY ns_flows "http://ns.adobe.com/Flows/1.0/">\r
-]>\r
-<svg version="1.1"\r
- xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"\r
- x="0px" y="0px" width="12px" height="12px" viewBox="0 0 12 12" style="overflow:visible;enable-background:new 0 0 12 12;"\r
- xml:space="preserve" preserveAspectRatio="xMinYMid meet">\r
-<defs>\r
-</defs>\r
-<path style="fill:#999999;" d="M3.7,7.6L0.1,9.4c0,0-0.1,0-0.1,0.1V12h12V9.3c0,0-0.1-0.1-0.1-0.1L8.3,7.5C7.8,7.3,7.7,6.7,8,6.3\r
- c0,0,0.9-1.1,0.9-2.5C8.9,1.7,7.6,0,6,0C4.4,0,3.1,1.7,3.1,3.8C3.1,5.2,4,6.3,4,6.3C4.3,6.7,4.2,7.3,3.7,7.6z"/>\r
-</svg>\r
* this question type.
*/
abstract public function get_test_questions();
+
+ /**
+ * Set up a form to create a question in $cat. This method also sets cat and contextid on $questiondata object.
+ * @param object $cat the category
+ * @param object $questiondata form initialisation requires question data.
+ * @return moodleform
+ */
+ public static function get_question_editing_form($cat, $questiondata) {
+ $catcontext = context::instance_by_id($cat->contextid, MUST_EXIST);
+ $contexts = new question_edit_contexts($catcontext);
+ $dataforformconstructor = new stdClass();
+ $dataforformconstructor->qtype = $questiondata->qtype;
+ $dataforformconstructor->contextid = $questiondata->contextid = $catcontext->id;
+ $dataforformconstructor->category = $questiondata->category = $cat->id;
+ $dataforformconstructor->formoptions = new stdClass();
+ $dataforformconstructor->formoptions->canmove = true;
+ $dataforformconstructor->formoptions->cansaveasnew = true;
+ $dataforformconstructor->formoptions->movecontext = false;
+ $dataforformconstructor->formoptions->canedit = true;
+ $dataforformconstructor->formoptions->repeatelements = true;
+ $qtype = question_bank::get_qtype($questiondata->qtype);
+ return $qtype->create_editing_form('question.php', $dataforformconstructor, $cat, $contexts, true);
+ }
}
$qdata->hints = array();
}
- public static function initialise_question_form_data($qdata) {
- $formdata = new stdClass();
- $formdata->id = 0;
- $formdata->category = '0,0';
- $formdata->usecurrentcat = 1;
- $formdata->categorymoveto = '0,0';
- $formdata->tags = array();
- $formdata->penalty = 0.3333333;
- $formdata->questiontextformat = FORMAT_HTML;
- $formdata->generalfeedbackformat = FORMAT_HTML;
- }
-
/**
* Get the test helper class for a particular question type.
* @param $qtype the question type name, e.g. 'multichoice'.
$q->incorrectfeedback = self::STANDARD_OVERALL_INCORRECT_FEEDBACK;
$q->incorrectfeedbackformat = FORMAT_HTML;
}
+
+ /**
+ * Add some standard overall feedback to a question's form data.
+ */
+ public static function set_standard_combined_feedback_form_data($form) {
+ $form->correctfeedback = array('text' => self::STANDARD_OVERALL_CORRECT_FEEDBACK,
+ 'format' => FORMAT_HTML);
+ $form->partiallycorrectfeedback = array('text' => self::STANDARD_OVERALL_PARTIALLYCORRECT_FEEDBACK,
+ 'format' => FORMAT_HTML);
+ $form->shownumcorrect = true;
+ $form->incorrectfeedback = array('text' => self::STANDARD_OVERALL_INCORRECT_FEEDBACK,
+ 'format' => FORMAT_HTML);
+ }
}
*/
class qtype_calculatedsimple_test_helper extends question_test_helper {
public function get_test_questions() {
- return array('sum');
+ return array('sum', 'sumwithvariants');
}
/**
return $q;
}
+
+
+ public function get_calculatedsimple_question_form_data_sumwithvariants() {
+ $form = new stdClass();
+
+ $form->name = 'Calculated simple';
+
+ $form->qtype = 'calculatedsimple';
+
+ $form->questiontext = array();
+ $form->questiontext['text'] = '<p>This is a simple sum of two variables.</p>';
+ $form->questiontext['format'] = '1';
+
+ $form->defaultmark = 1;
+ $form->generalfeedback = array();
+ $form->generalfeedback['text'] = '<p>The answer is {a} + {b}</p>';
+ $form->generalfeedback['format'] = '1';
+
+ $form->synchronize = 0;
+ $form->initialcategory = 1;
+ $form->reload = 1;
+ $form->mform_isexpanded_id_answerhdr = 1;
+ $form->noanswers = 1;
+ $form->answer = array('{a} + {b}');
+
+ $form->fraction = array('1.0');
+
+ $form->tolerance = array(0.01);
+ $form->tolerancetype = array('1');
+
+ $form->correctanswerlength = array('2');
+ $form->correctanswerformat = array('1');
+
+ $form->feedback = array();
+ $form->feedback[0] = array();
+ $form->feedback[0]['text'] = '';
+ $form->feedback[0]['format'] = '1';
+
+ $form->unitrole = '3';
+ $form->unitpenalty = 0.1;
+ $form->unitgradingtypes = '1';
+ $form->unitsleft = '0';
+ $form->nounits = 1;
+ $form->multiplier = array('1.0');
+
+ $form->penalty = '0.3333333';
+ $form->numhints = 2;
+ $form->hint = array();
+ $form->hint[0] = array();
+ $form->hint[0]['text'] = '';
+ $form->hint[0]['format'] = '1';
+
+ $form->hint[1] = array();
+ $form->hint[1]['text'] = '';
+ $form->hint[1]['format'] = '1';
+
+ $form->calcmin = array();
+ $form->calcmin[1] = 1;
+ $form->calcmin[2] = 1;
+
+ $form->calcmax = array();
+ $form->calcmax[1] = 10;
+ $form->calcmax[2] = 10;
+
+ $form->calclength = array();
+ $form->calclength[1] = '1';
+ $form->calclength[2] = '1';
+
+ $form->calcdistribution = array();
+ $form->calcdistribution[1] = 0;
+ $form->calcdistribution[2] = 0;
+
+ $form->datasetdef = array();
+ $form->datasetdef[1] = '1-0-a';
+ $form->datasetdef[2] = '1-0-b';
+
+ $form->defoptions = array();
+ $form->defoptions[1] = '';
+ $form->defoptions[2] = '';
+
+ $form->selectadd = '10';
+ $form->selectshow = '10';
+ $form->number = array();
+ $form->number[1] = '2.3';
+ $form->number[2] = '7.6';
+ $form->number[3] = '2.1';
+ $form->number[4] = '6.4';
+ $form->number[5] = '1.4';
+ $form->number[6] = '1.9';
+ $form->number[7] = '9.9';
+ $form->number[8] = '9.5';
+ $form->number[9] = '9.0';
+ $form->number[10] = '5.2';
+ $form->number[11] = '2.1';
+ $form->number[12] = '7.3';
+ $form->number[13] = '7.9';
+ $form->number[14] = '1.2';
+ $form->number[15] = '2.3';
+ $form->number[16] = '3.4';
+ $form->number[17] = '1.9';
+ $form->number[18] = '5.2';
+ $form->number[19] = '3.4';
+ $form->number[20] = '3.4';
+
+ $form->itemid = array_fill(1, 20, 0);
+
+ $form->definition = array();
+ $form->definition[1] = '1-0-b';
+ $form->definition[2] = '1-0-a';
+ $form->definition[3] = '1-0-b';
+ $form->definition[4] = '1-0-a';
+ $form->definition[5] = '1-0-b';
+ $form->definition[6] = '1-0-a';
+ $form->definition[7] = '1-0-b';
+ $form->definition[8] = '1-0-a';
+ $form->definition[9] = '1-0-b';
+ $form->definition[10] = '1-0-a';
+ $form->definition[11] = '1-0-b';
+ $form->definition[12] = '1-0-a';
+ $form->definition[13] = '1-0-b';
+ $form->definition[14] = '1-0-a';
+ $form->definition[15] = '1-0-b';
+ $form->definition[16] = '1-0-a';
+ $form->definition[17] = '1-0-b';
+ $form->definition[18] = '1-0-a';
+ $form->definition[19] = '1-0-b';
+ $form->definition[20] = '1-0-a';
+
+ return $form;
+ }
+
+ public function get_calculatedsimple_question_data_sumwithvariants() {
+ $q = new stdClass();
+
+ $q->name = 'Calculated simple';
+ $q->questiontext = '<p>This is a simple sum of two variables.</p>';
+ $q->questiontextformat = '1';
+ $q->generalfeedback = '<p>The answer is {a} + {b}</p>';
+ $q->generalfeedbackformat = '1';
+ $q->defaultmark = 1;
+ $q->penalty = 0.3333333;
+ $q->qtype = 'calculatedsimple';
+ $q->length = '1';
+ $q->hidden = '0';
+ $q->options = new stdClass();
+ $q->options->synchronize = 0;
+ $q->options->single = 0;
+ $q->options->answernumbering = 'abc';
+ $q->options->shuffleanswers = 0;
+ $q->options->correctfeedback = '';
+ $q->options->partiallycorrectfeedback = '';
+ $q->options->incorrectfeedback = '';
+ $q->options->correctfeedbackformat = 0;
+ $q->options->partiallycorrectfeedbackformat = 0;
+ $q->options->incorrectfeedbackformat = 0;
+ $q->options->answers = array();
+ $q->options->answers[0] = new stdClass();
+ $q->options->answers[0]->id = '6977';
+ $q->options->answers[0]->question = '3379';
+ $q->options->answers[0]->answer = '{a} + {b}';
+ $q->options->answers[0]->answerformat = '0';
+ $q->options->answers[0]->fraction = '1.0000000';
+ $q->options->answers[0]->feedback = '';
+ $q->options->answers[0]->feedbackformat = '1';
+ $q->options->answers[0]->tolerance = '0.01';
+ $q->options->answers[0]->tolerancetype = '1';
+ $q->options->answers[0]->correctanswerlength = '2';
+ $q->options->answers[0]->correctanswerformat = '1';
+
+ $q->options->units = array();
+
+ $q->options->unitgradingtype = '0';
+ $q->options->unitpenalty = '0.1000000';
+ $q->options->showunits = '3';
+ $q->options->unitsleft = '0';
+
+ $q->hints = array();
+
+ return $q;
+ }
}
--- /dev/null
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Unit tests for the calculatedsimple question type class.
+ *
+ * @package qtype_calculatedsimple
+ * @copyright 2013 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+
+defined('MOODLE_INTERNAL') || die();
+
+global $CFG;
+require_once($CFG->dirroot . '/question/type/calculatedsimple/questiontype.php');
+require_once($CFG->dirroot . '/question/engine/tests/helpers.php');
+require_once($CFG->dirroot . '/question/type/edit_question_form.php');
+require_once($CFG->dirroot . '/question/type/calculatedsimple/edit_calculatedsimple_form.php');
+
+
+/**
+ * Unit tests for the calculatedsimple question type class.
+ *
+ * @copyright 2007 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class qtype_calculatedsimple_test extends advanced_testcase {
+ public static $includecoverage = array(
+ 'question/type/questiontypebase.php',
+ 'question/type/calculatedsimple/questiontype.php',
+ 'question/type/edit_question_form.php',
+ 'question/type/calculatedsimple/edit_calculatedsimple_form.php'
+ );
+
+ protected $qtype;
+
+ protected function setUp() {
+ $this->qtype = new qtype_calculatedsimple();
+ }
+
+ protected function tearDown() {
+ $this->qtype = null;
+ }
+
+ public function test_name() {
+ $this->assertEquals($this->qtype->name(), 'calculatedsimple');
+ }
+
+ public function test_can_analyse_responses() {
+ $this->assertTrue($this->qtype->can_analyse_responses());
+ }
+
+
+ public function test_question_saving_sumwithvariants() {
+ $this->resetAfterTest(true);
+ $this->setAdminUser();
+
+ $questiondata = test_question_maker::get_question_data('calculatedsimple', 'sumwithvariants');
+ $formdata = test_question_maker::get_question_form_data('calculatedsimple', 'sumwithvariants');
+
+ $generator = $this->getDataGenerator()->get_plugin_generator('core_question');
+ $cat = $generator->create_question_category(array());
+
+ $formdata->category = "{$cat->id},{$cat->contextid}";
+ qtype_calculatedsimple_edit_form::mock_submit((array)$formdata);
+
+ $form = qtype_calculatedsimple_test_helper::get_question_editing_form($cat, $questiondata);
+
+ $this->assertTrue($form->is_validated());
+
+ $fromform = $form->get_data();
+
+ $returnedfromsave = $this->qtype->save_question($questiondata, $fromform);
+ $actualquestionsdata = question_load_questions(array($returnedfromsave->id));
+ $actualquestiondata = end($actualquestionsdata);
+
+ foreach ($questiondata as $property => $value) {
+ if (!in_array($property, array('id', 'version', 'timemodified', 'timecreated', 'options'))) {
+ $this->assertAttributeEquals($value, $property, $actualquestiondata);
+ }
+ }
+
+ foreach ($questiondata->options as $optionname => $value) {
+ if ($optionname != 'answers') {
+ $this->assertAttributeEquals($value, $optionname, $actualquestiondata->options);
+ }
+ }
+
+ foreach ($questiondata->options->answers as $answer) {
+ $actualanswer = array_shift($actualquestiondata->options->answers);
+ foreach ($answer as $ansproperty => $ansvalue) {
+ if (!in_array($ansproperty, array('id', 'question', 'answerformat'))) {
+ $this->assertAttributeEquals($ansvalue, $ansproperty, $actualanswer);
+ }
+ }
+ }
+
+ $datasetloader = new qtype_calculated_dataset_loader($actualquestiondata->id);
+
+ $this->assertEquals(10, $datasetloader->get_number_of_items());
+
+ for ($itemno = 1; $itemno <= 10; $itemno++) {
+ $item = $datasetloader->get_values($itemno);
+ $this->assertEquals($formdata->number[($itemno -1)*2 + 2], $item['a']);
+ $this->assertEquals($formdata->number[($itemno -1)*2 + 1], $item['b']);
+ }
+ }
+}
/**
* Test helper code for the description question type.
*
- * @package qtype
- * @subpackage description
- * @copyright 2010 The Open University
+ * @package qtype_description
+ * @copyright 2013 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* Test helper class for the description question type.
*
- * @copyright 2010 The Open University
+ * @copyright 2013 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class qtype_description_test_helper extends question_test_helper {
}
/**
- * Get the question data, as it would be loaded by get_question_options, for
- * the question returned by {@link make_an_oumultiresponse_two_of_four()}.
+ * Get the question data, as it would be loaded by get_question_options.
* @return object
*/
- public static function get_question_data() {
+ public static function get_description_question_data_info() {
global $USER;
$qdata = new stdClass();
$qdata->length = 0;
$qdata->penalty = 0;
$qdata->hidden = 0;
+ $qdata->hints = array();
+ $qdata->options = new stdClass();
+ $qdata->options->answers = array();
return $qdata;
}
+
+
+ /**
+ * Get the question form data.
+ * @return object
+ */
+ public static function get_description_question_form_data_info() {
+ $form = new stdClass();
+
+ $form->name = 'Description';
+ $form->questiontext = array('text' => 'Here is some information about the questions you are about to attempt.',
+ 'format' => FORMAT_HTML);
+ $form->generalfeedback = array('text' => 'And here is some more text shown only on the review page.',
+ 'format' => FORMAT_HTML);
+
+ return $form;
+ }
+
}
/**
* Unit tests for the description question type class.
*
- * @package qtype
- * @subpackage description
- * @copyright 2010 The Open University
+ * @package qtype_description
+ * @copyright 2013 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
global $CFG;
require_once($CFG->dirroot . '/question/type/description/questiontype.php');
+require_once($CFG->dirroot . '/question/engine/tests/helpers.php');
+require_once($CFG->dirroot . '/question/type/edit_question_form.php');
+require_once($CFG->dirroot . '/question/type/description/edit_description_form.php');
/**
* Unit tests for the description question type class.
*
- * @copyright 2010 The Open University
+ * @copyright 2013 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class qtype_description_test extends advanced_testcase {
public function test_get_possible_responses() {
$this->assertEquals(array(), $this->qtype->get_possible_responses(null));
}
+
+
+ public function test_question_saving() {
+ $this->resetAfterTest(true);
+ $this->setAdminUser();
+
+ $questiondata = test_question_maker::get_question_data('description');
+ $formdata = test_question_maker::get_question_form_data('description');
+
+ $generator = $this->getDataGenerator()->get_plugin_generator('core_question');
+ $cat = $generator->create_question_category(array());
+
+ $formdata->category = "{$cat->id},{$cat->contextid}";
+ qtype_description_edit_form::mock_submit((array)$formdata);
+
+ $form = qtype_description_test_helper::get_question_editing_form($cat, $questiondata);
+
+ $this->assertTrue($form->is_validated());
+
+ $fromform = $form->get_data();
+
+ $returnedfromsave = $this->qtype->save_question($questiondata, $fromform);
+ $actualquestionsdata = question_load_questions(array($returnedfromsave->id));
+ $actualquestiondata = end($actualquestionsdata);
+
+ foreach ($questiondata as $property => $value) {
+ if (!in_array($property, array('id', 'version', 'timemodified', 'timecreated'))) {
+ $this->assertAttributeEquals($value, $property, $actualquestiondata);
+ }
+ }
+ }
}
--- /dev/null
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Test helpers for the match question type.
+ *
+ * @package qtype_match
+ * @copyright 2013 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+
+defined('MOODLE_INTERNAL') || die();
+
+global $CFG;
+require_once($CFG->dirroot . '/question/type/match/question.php');
+
+
+/**
+ * Test helper class for the match question type.
+ *
+ * @copyright 2013 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class qtype_match_test_helper extends question_test_helper {
+ public function get_test_questions() {
+ return array('foursubq');
+ }
+
+
+ /**
+ * Makes a match question about completing two blanks in some text.
+ * @return object the question definition data, as it might be returned from
+ * get_question_options.
+ */
+ public function get_match_question_data_foursubq() {
+ global $USER;
+ $q = new stdClass();
+ test_question_maker::initialise_question_data($q);
+ $q->name = 'Matching question';
+ $q->qtype = 'match';
+ $q->parent = 0;
+ $q->questiontext = 'Classify the animals.';
+ $q->questiontextformat = FORMAT_HTML;
+ $q->generalfeedback = 'General feedback.';
+ $q->generalfeedbackformat = FORMAT_HTML;
+ $q->defaultmark = 1;
+ $q->penalty = 0.3333333;
+ $q->length = 1;
+ $q->hidden = 0;
+ $q->createdby = $USER->id;
+ $q->modifiedby = $USER->id;
+
+ $q->options = new stdClass();
+ $q->options->shuffleanswers = 0;
+ test_question_maker::set_standard_combined_feedback_fields($q->options);
+
+ $q->options->subquestions = array(
+ 14 => (object) array(
+ 'id' => 14,
+ 'questiontext' => 'frog',
+ 'questiontextformat' => FORMAT_HTML,
+ 'answertext' => 'amphibian'),
+ 15 => (object) array(
+ 'id' => 15,
+ 'questiontext' => 'cat',
+ 'questiontextformat' => FORMAT_HTML,
+ 'answertext' => 'mammal'),
+ 16 => (object) array(
+ 'id' => 16,
+ 'questiontext' => 'newt',
+ 'questiontextformat' => FORMAT_HTML,
+ 'answertext' => 'amphibian'),
+ 17 => (object) array(
+ 'id' => 17,
+ 'questiontext' => '',
+ 'questiontextformat' => FORMAT_HTML,
+ 'answertext' => 'insect'),
+ );
+
+ return $q;
+ }
+
+ /**
+ * Makes a match question about completing two blanks in some text.
+ * @return object the question definition data, as it might be returned from
+ * the question editing form.
+ */
+ public function get_match_question_form_data_foursubq() {
+ $q = new stdClass();
+ $q->name = 'Matching question';
+ $q->questiontext = array('text' => 'Classify the animals.', 'format' => FORMAT_HTML);
+ $q->generalfeedback = array('text' => 'General feedback.', 'format' => FORMAT_HTML);
+ $q->defaultmark = 1;
+ $q->penalty = 0.3333333;
+
+ $q->shuffleanswers = 0;
+ test_question_maker::set_standard_combined_feedback_form_data($q);
+
+ $q->subquestions = array(
+ 0 => array('text' => 'frog', 'format' => FORMAT_HTML),
+ 1 => array('text' => 'cat', 'format' => FORMAT_HTML),
+ 2 => array('text' => 'newt', 'format' => FORMAT_HTML),
+ 3 => array('text' => '', 'format' => FORMAT_HTML));
+
+ $q->subanswers = array(
+ 0 => 'amphibian',
+ 1 => 'mammal',
+ 2 => 'amphibian',
+ 3 => 'insect'
+ );
+
+ $q->noanswers = 4;
+
+ return $q;
+ }
+
+}
global $CFG;
require_once($CFG->dirroot . '/question/engine/tests/helpers.php');
require_once($CFG->dirroot . '/question/type/match/questiontype.php');
+require_once($CFG->dirroot . '/question/type/edit_question_form.php');
+require_once($CFG->dirroot . '/question/type/match/edit_match_form.php');
/**
null => question_possible_response::no_response()),
), $this->qtype->get_possible_responses($q));
}
+
+
+ public function test_question_saving_foursubq() {
+ $this->resetAfterTest(true);
+ $this->setAdminUser();
+
+ $questiondata = test_question_maker::get_question_data('match');
+ $formdata = test_question_maker::get_question_form_data('match');
+
+ $generator = $this->getDataGenerator()->get_plugin_generator('core_question');
+ $cat = $generator->create_question_category(array());
+
+ $formdata->category = "{$cat->id},{$cat->contextid}";
+
+ qtype_match_edit_form::mock_submit((array)$formdata);
+
+ $form = qtype_match_test_helper::get_question_editing_form($cat, $questiondata);
+ $this->assertTrue($form->is_validated());
+
+ $fromform = $form->get_data();
+
+ $returnedfromsave = $this->qtype->save_question($questiondata, $fromform);
+ $actualquestionsdata = question_load_questions(array($returnedfromsave->id));
+ $actualquestiondata = end($actualquestionsdata);
+
+ foreach ($questiondata as $property => $value) {
+ if (!in_array($property, array('id', 'version', 'timemodified', 'timecreated', 'options', 'stamp'))) {
+ $this->assertAttributeEquals($value, $property, $actualquestiondata);
+ }
+ }
+
+ foreach ($questiondata->options as $optionname => $value) {
+ if ($optionname != 'subquestions') {
+ $this->assertAttributeEquals($value, $optionname, $actualquestiondata->options);
+ }
+ }
+
+ $this->assertObjectHasAttribute('subquestions', $actualquestiondata->options);
+
+ $subqpropstoignore = array('id');
+ foreach ($questiondata->options->subquestions as $subq) {
+ $actualsubq = array_shift($actualquestiondata->options->subquestions);
+ foreach ($subq as $subqproperty => $subqvalue) {
+ if (!in_array($subqproperty, $subqpropstoignore)) {
+ $this->assertAttributeEquals($subqvalue, $subqproperty, $actualsubq);
+ }
+ }
+ }
+ }
}
/**
* Test helpers for the multianswer question type.
*
- * @package qtype
- * @subpackage multianswer
- * @copyright 2011 The Open University
+ * @package qtype_multianswer
+ * @copyright 2013 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* Test helper class for the multianswer question type.
*
- * @copyright 2011 The Open University
+ * @copyright 2013 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class qtype_multianswer_test_helper extends question_test_helper {
$mc->options->partiallycorrectfeedbackformat = 1;
$mc->options->incorrectfeedback = '';
$mc->options->incorrectfeedbackformat = 1;
- $mc->options->answernumbering = '';
+ $mc->options->answernumbering = 0;
$mc->options->shownumcorrect = 0;
$mc->options->answers = array(
);
$qdata->hints = array(
- new question_hint(0, 'Hint 1', FORMAT_HTML),
- new question_hint(0, 'Hint 2', FORMAT_HTML),
+ new question_hint_with_parts(0, 'Hint 1', FORMAT_HTML, 0, 0),
+ new question_hint_with_parts(0, 'Hint 2', FORMAT_HTML, 0, 0),
);
return $qdata;
*/
public function get_multianswer_question_form_data_twosubq() {
$formdata = new stdClass();
- test_question_maker::initialise_question_form_data($formdata);
-
$formdata->name = 'Simple multianswer';
- $formdata->questiontext = 'Complete this opening line of verse: "The ' .
+ $formdata->questiontext = array('text' => 'Complete this opening line of verse: "The ' .
'{1:SHORTANSWER:Dog#Wrong, silly!~=Owl#Well done!~*#Wrong answer} ' .
'and the {1:MULTICHOICE:Bow-wow#You seem to have a dog obsessions!' .
'~Wiggly worm#Now you are just being ridiculous!~=Pussy-cat#Well done!}' .
- ' went to sea".';
- $formdata->generalfeedback = 'General feedback: It\'s from "The Owl and the Pussy-cat" ' .
- 'by Lear: "The owl and the pussycat went to sea';
+ ' went to sea".', 'format' => FORMAT_HTML);
+ $formdata->generalfeedback = array('text' => 'General feedback: It\'s from "The Owl and the Pussy-cat" ' .
+ 'by Lear: "The owl and the pussycat went to sea', 'format' => FORMAT_HTML);
$formdata->hint = array(
0 => array('text' => 'Hint 1', 'format' => FORMAT_HTML, 'itemid' => 0),
global $CFG;
require_once($CFG->dirroot . '/question/engine/tests/helpers.php');
require_once($CFG->dirroot . '/question/type/multianswer/questiontype.php');
+require_once($CFG->dirroot . '/question/type/edit_question_form.php');
+require_once($CFG->dirroot . '/question/type/multianswer/edit_multianswer_form.php');
/**
$q = test_question_maker::get_question_data('multianswer', 'twosubq');
$this->assertEquals(0.1666667, $this->qtype->get_random_guess_score($q), '', 0.0000001);
}
+
+ public function test_question_saving_twosubq() {
+ $this->resetAfterTest(true);
+ $this->setAdminUser();
+
+ $questiondata = test_question_maker::get_question_data('multianswer');
+ $formdata = test_question_maker::get_question_form_data('multianswer');
+
+ $generator = $this->getDataGenerator()->get_plugin_generator('core_question');
+ $cat = $generator->create_question_category(array());
+
+ $formdata->category = "{$cat->id},{$cat->contextid}";
+ qtype_multianswer_edit_form::mock_submit((array)$formdata);
+
+ $form = qtype_multianswer_test_helper::get_question_editing_form($cat, $questiondata);
+
+ $this->assertTrue($form->is_validated());
+
+ $fromform = $form->get_data();
+
+ $returnedfromsave = $this->qtype->save_question($questiondata, $fromform);
+ $actualquestionsdata = question_load_questions(array($returnedfromsave->id));
+ $actualquestiondata = end($actualquestionsdata);
+
+ foreach ($questiondata as $property => $value) {
+ if (!in_array($property, array('id', 'version', 'timemodified', 'timecreated', 'options', 'hints', 'stamp'))) {
+ $this->assertAttributeEquals($value, $property, $actualquestiondata);
+ }
+ }
+
+ foreach ($questiondata->options as $optionname => $value) {
+ if ($optionname != 'questions') {
+ $this->assertAttributeEquals($value, $optionname, $actualquestiondata->options);
+ }
+ }
+
+ foreach ($questiondata->hints as $hint) {
+ $actualhint = array_shift($actualquestiondata->hints);
+ foreach ($hint as $property => $value) {
+ if (!in_array($property, array('id', 'questionid', 'options'))) {
+ $this->assertAttributeEquals($value, $property, $actualhint);
+ }
+ }
+ }
+
+ $this->assertObjectHasAttribute('questions', $actualquestiondata->options);
+
+ $subqpropstoignore =
+ array('id', 'category', 'parent', 'contextid', 'question', 'options', 'stamp', 'version', 'timemodified',
+ 'timecreated');
+ foreach ($questiondata->options->questions as $subqno => $subq) {
+ $actualsubq = $actualquestiondata->options->questions[$subqno];
+ foreach ($subq as $subqproperty => $subqvalue) {
+ if (!in_array($subqproperty, $subqpropstoignore)) {
+ $this->assertAttributeEquals($subqvalue, $subqproperty, $actualsubq);
+ }
+ }
+ foreach ($subq->options as $optionname => $value) {
+ if (!in_array($optionname, array('answers'))) {
+ $this->assertAttributeEquals($value, $optionname, $actualsubq->options);
+ }
+ }
+ foreach ($subq->options->answers as $answer) {
+ $actualanswer = array_shift($actualsubq->options->answers);
+ foreach ($answer as $ansproperty => $ansvalue) {
+ // These questions do not use 'answerformat', will ignore it.
+ if (!in_array($ansproperty, array('id', 'question', 'answerformat'))) {
+ $this->assertAttributeEquals($ansvalue, $ansproperty, $actualanswer);
+ }
+ }
+ }
+ }
+ }
}
--- /dev/null
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Test helper code for the multiple choice question type.
+ *
+ * @package qtype_multichoice
+ * @copyright 2013 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+
+defined('MOODLE_INTERNAL') || die();
+
+
+/**
+ * Test helper class for the multiple choice question type.
+ *
+ * @copyright 2013 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class qtype_multichoice_test_helper extends question_test_helper {
+ public function get_test_questions() {
+ return array('two_of_four');
+ }
+
+ /**
+ * Get the question data, as it would be loaded by get_question_options.
+ * @return object
+ */
+ public static function get_multichoice_question_data_two_of_four() {
+ global $USER;
+
+ $qdata = new stdClass();
+
+ $qdata->createdby = $USER->id;
+ $qdata->modifiedby = $USER->id;
+ $qdata->qtype = 'multichoice';
+ $qdata->name = 'Multiple choice question';
+ $qdata->questiontext = 'Which are the odd numbers?';
+ $qdata->questiontextformat = FORMAT_HTML;
+ $qdata->generalfeedback = 'The odd numbers are One and Three.';
+ $qdata->generalfeedbackformat = FORMAT_HTML;
+ $qdata->defaultmark = 1;
+ $qdata->length = 1;
+ $qdata->penalty = 0.3333333;
+ $qdata->hidden = 0;
+
+ $qdata->options = new stdClass();
+ $qdata->options->shuffleanswers = 1;
+ $qdata->options->answernumbering = '123';
+ $qdata->options->layout = 0;
+ $qdata->options->single = 0;
+ $qdata->options->correctfeedback =
+ test_question_maker::STANDARD_OVERALL_CORRECT_FEEDBACK;
+ $qdata->options->correctfeedbackformat = FORMAT_HTML;
+ $qdata->options->partiallycorrectfeedback =
+ test_question_maker::STANDARD_OVERALL_PARTIALLYCORRECT_FEEDBACK;
+ $qdata->options->partiallycorrectfeedbackformat = FORMAT_HTML;
+ $qdata->options->shownumcorrect = 1;
+ $qdata->options->incorrectfeedback =
+ test_question_maker::STANDARD_OVERALL_INCORRECT_FEEDBACK;
+ $qdata->options->incorrectfeedbackformat = FORMAT_HTML;
+
+ $qdata->options->answers = array(
+ 13 => (object) array(
+ 'id' => 13,
+ 'answer' => 'One',
+ 'answerformat' => FORMAT_PLAIN,
+ 'fraction' => '0.5',
+ 'feedback' => 'One is odd.',
+ 'feedbackformat' => FORMAT_HTML,
+ ),
+ 14 => (object) array(
+ 'id' => 14,
+ 'answer' => 'Two',
+ 'answerformat' => FORMAT_PLAIN,
+ 'fraction' => '0.0',
+ 'feedback' => 'Two is even.',
+ 'feedbackformat' => FORMAT_HTML,
+ ),
+ 15 => (object) array(
+ 'id' => 15,
+ 'answer' => 'Three',
+ 'answerformat' => FORMAT_PLAIN,
+ 'fraction' => '0.5',
+ 'feedback' => 'Three is odd.',
+ 'feedbackformat' => FORMAT_HTML,
+ ),
+ 16 => (object) array(
+ 'id' => 16,
+ 'answer' => 'Four',
+ 'answerformat' => FORMAT_PLAIN,
+ 'fraction' => '0.0',
+ 'feedback' => 'Four is even.',
+ 'feedbackformat' => FORMAT_HTML,
+ ),
+ );
+
+ $qdata->hints = array(
+ 1 => (object) array(
+ 'hint' => 'Hint 1.',
+ 'hintformat' => FORMAT_HTML,
+ 'shownumcorrect' => 1,
+ 'clearwrong' => 0,
+ 'options' => 0,
+ ),
+ 2 => (object) array(
+ 'hint' => 'Hint 2.',
+ 'hintformat' => FORMAT_HTML,
+ 'shownumcorrect' => 1,
+ 'clearwrong' => 1,
+ 'options' => 1,
+ ),
+ );
+
+ return $qdata;
+ }
+ /**
+ * Get the question data, as it would be loaded by get_question_options.
+ * @return object
+ */
+ public static function get_multichoice_question_form_data_two_of_four() {
+ $qdata = new stdClass();
+
+ $qdata->name = 'multiple choice question';
+ $qdata->questiontext = array('text' => 'Which are the odd numbers?', 'format' => FORMAT_HTML);
+ $qdata->generalfeedback = array('text' => 'The odd numbers are One and Three.', 'format' => FORMAT_HTML);
+ $qdata->defaultmark = 1;
+ $qdata->noanswers = 5;
+ $qdata->numhints = 2;
+ $qdata->penalty = 0.3333333;
+
+ $qdata->shuffleanswers = 1;
+ $qdata->answernumbering = '123';
+ $qdata->single = '0';
+ $qdata->correctfeedback = array('text' => test_question_maker::STANDARD_OVERALL_CORRECT_FEEDBACK,
+ 'format' => FORMAT_HTML);
+ $qdata->partiallycorrectfeedback = array('text' => test_question_maker::STANDARD_OVERALL_PARTIALLYCORRECT_FEEDBACK,
+ 'format' => FORMAT_HTML);
+ $qdata->shownumcorrect = 1;
+ $qdata->incorrectfeedback = array('text' => test_question_maker::STANDARD_OVERALL_INCORRECT_FEEDBACK,
+ 'format' => FORMAT_HTML);
+ $qdata->fraction = array('0.5', '0.0', '0.5', '0.0', '0.0');
+ $qdata->answer = array(
+ 0 => array(
+ 'text' => 'One',
+ 'format' => FORMAT_PLAIN
+ ),
+ 1 => array(
+ 'text' => 'Two',
+ 'format' => FORMAT_PLAIN
+ ),
+ 2 => array(
+ 'text' => 'Three',
+ 'format' => FORMAT_PLAIN
+ ),
+ 3 => array(
+ 'text' => 'Four',
+ 'format' => FORMAT_PLAIN
+ ),
+ 4 => array(
+ 'text' => '',
+ 'format' => FORMAT_PLAIN
+ )
+ );
+
+ $qdata->feedback = array(
+ 0 => array(
+ 'text' => 'One is odd.',
+ 'format' => FORMAT_HTML
+ ),
+ 1 => array(
+ 'text' => 'Two is even.',
+ 'format' => FORMAT_HTML
+ ),
+ 2 => array(
+ 'text' => 'Three is odd.',
+ 'format' => FORMAT_HTML
+ ),
+ 3 => array(
+ 'text' => 'Four is even.',
+ 'format' => FORMAT_HTML
+ ),
+ 4 => array(
+ 'text' => '',
+ 'format' => FORMAT_HTML
+ )
+ );
+
+ $qdata->hint = array(
+ 0 => array(
+ 'text' => 'Hint 1.',
+ 'format' => FORMAT_HTML
+ ),
+ 1 => array(
+ 'text' => 'Hint 2.',
+ 'format' => FORMAT_HTML
+ )
+ );
+ $qdata->hintclearwrong = array(0, 1);
+ $qdata->hintshownumcorrect = array(1, 1);
+
+ return $qdata;
+ }
+}
/**
* Unit tests for the mulitple choice question definition class.
*
- * @package qtype
- * @subpackage multichoice
- * @copyright 2009 The Open University
+ * @package qtype_multichoice
+ * @copyright 2013 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
global $CFG;
+require_once($CFG->dirroot . '/question/engine/tests/helpers.php');
require_once($CFG->dirroot . '/question/type/multichoice/questiontype.php');
-
+require_once($CFG->dirroot . '/question/type/edit_question_form.php');
+require_once($CFG->dirroot . '/question/type/multichoice/edit_multichoice_form.php');
/**
* Unit tests for the multiple choice question definition class.
2 => array(2 => new question_possible_response('toad', 0)),
), $this->qtype->get_possible_responses($q));
}
+
+ public function test_question_saving_two_of_four() {
+ $this->resetAfterTest(true);
+ $this->setAdminUser();
+
+ $questiondata = test_question_maker::get_question_data('multichoice');
+ $formdata = test_question_maker::get_question_form_data('multichoice');
+
+ $generator = $this->getDataGenerator()->get_plugin_generator('core_question');
+ $cat = $generator->create_question_category(array());
+
+ $formdata->category = "{$cat->id},{$cat->contextid}";
+ qtype_multichoice_edit_form::mock_submit((array)$formdata);
+
+ $form = qtype_multichoice_test_helper::get_question_editing_form($cat, $questiondata);
+
+ $this->assertTrue($form->is_validated());
+
+ $fromform = $form->get_data();
+
+ $returnedfromsave = $this->qtype->save_question($questiondata, $fromform);
+ $actualquestionsdata = question_load_questions(array($returnedfromsave->id));
+ $actualquestiondata = end($actualquestionsdata);
+
+ foreach ($questiondata as $property => $value) {
+ if (!in_array($property, array('id', 'version', 'timemodified', 'timecreated', 'options', 'hints', 'stamp'))) {
+ $this->assertAttributeEquals($value, $property, $actualquestiondata);
+ }
+ }
+
+ foreach ($questiondata->options as $optionname => $value) {
+ if (!in_array($optionname, array('answers'))) {
+ $this->assertAttributeEquals($value, $optionname, $actualquestiondata->options);
+ }
+ }
+
+ foreach ($questiondata->hints as $hint) {
+ $actualhint = array_shift($actualquestiondata->hints);
+ foreach ($hint as $property => $value) {
+ if (!in_array($property, array('id', 'questionid', 'options'))) {
+ $this->assertAttributeEquals($value, $property, $actualhint);
+ }
+ }
+ }
+
+ foreach ($questiondata->options->answers as $answer) {
+ $actualanswer = array_shift($actualquestiondata->options->answers);
+ foreach ($answer as $ansproperty => $ansvalue) {
+ // This question does not use 'answerformat', will ignore it.
+ if (!in_array($ansproperty, array('id', 'question', 'answerformat'))) {
+ $this->assertAttributeEquals($ansvalue, $ansproperty, $actualanswer);
+ }
+ }
+ }
+ }
}
return $num;
}
- /**
+ public function get_numerical_question_form_data_pi() {
+ $form = new stdClass();
+ $form->name = 'Pi to two d.p.';
+ $form->questiontext = array();
+ $form->questiontext['format'] = '1';
+ $form->questiontext['text'] = 'What is pi to two d.p.?';
+
+ $form->defaultmark = 1;
+ $form->generalfeedback = array();
+ $form->generalfeedback['format'] = '1';
+ $form->generalfeedback['text'] = 'Generalfeedback: 3.14 is the right answer.';
+
+ $form->noanswers = 6;
+ $form->answer = array();
+ $form->answer[0] = '3.14';
+ $form->answer[1] = '3.142';
+ $form->answer[2] = '3.1';
+ $form->answer[3] = '3';
+ $form->answer[4] = '*';
+ $form->answer[5] = '';
+
+ $form->tolerance = array();
+ $form->tolerance[0] = 0;
+ $form->tolerance[1] = 0;
+ $form->tolerance[2] = 0;
+ $form->tolerance[3] = 0;
+ $form->tolerance[4] = 0;
+ $form->tolerance[5] = 0;
+
+ $form->fraction = array();
+ $form->fraction[0] = '1.0';
+ $form->fraction[1] = '0.0';
+ $form->fraction[2] = '0.0';
+ $form->fraction[3] = '0.0';
+ $form->fraction[4] = '0.0';
+ $form->fraction[5] = '0.0';
+
+ $form->feedback = array();
+ $form->feedback[0] = array();
+ $form->feedback[0]['format'] = '1';
+ $form->feedback[0]['text'] = 'Very good.';
+
+ $form->feedback[1] = array();
+ $form->feedback[1]['format'] = '1';
+ $form->feedback[1]['text'] = 'Too accurate.';
+
+ $form->feedback[2] = array();
+ $form->feedback[2]['format'] = '1';
+ $form->feedback[2]['text'] = 'Not accurate enough.';
+
+ $form->feedback[3] = array();
+ $form->feedback[3]['format'] = '1';
+ $form->feedback[3]['text'] = 'Not accurate enough.';
+
+ $form->feedback[4] = array();
+ $form->feedback[4]['format'] = '1';
+ $form->feedback[4]['text'] = 'Completely wrong.';
+
+ $form->feedback[5] = array();
+ $form->feedback[5]['format'] = '1';
+ $form->feedback[5]['text'] = '';
+
+ $form->unitrole = '3';
+ $form->unitpenalty = 0.1;
+ $form->unitgradingtypes = '1';
+ $form->unitsleft = '0';
+ $form->nounits = 1;
+ $form->multiplier = array();
+ $form->multiplier[0] = '1.0';
+
+ $form->penalty = '0.3333333';
+ $form->numhints = 2;
+ $form->hint = array();
+ $form->hint[0] = array();
+ $form->hint[0]['format'] = '1';
+ $form->hint[0]['text'] = '';
+
+ $form->hint[1] = array();
+ $form->hint[1]['format'] = '1';
+ $form->hint[1]['text'] = '';
+
+ $form->qtype = 'numerical';
+ return $form;
+ }
+
+ public function get_numerical_question_data_pi() {
+ $q = new stdClass();
+ $q->name = 'Pi to two d.p.';
+ $q->questiontext = 'What is pi to two d.p.?';
+ $q->questiontextformat = FORMAT_HTML;
+ $q->generalfeedback = 'Generalfeedback: 3.14 is the right answer.';
+ $q->generalfeedbackformat = FORMAT_HTML;
+ $q->defaultmark = 1;
+ $q->penalty = 0.3333333;
+ $q->qtype = 'numerical';
+ $q->length = '1';
+ $q->hidden = '0';
+ $q->createdby = '2';
+ $q->modifiedby = '2';
+ $q->options = new stdClass();
+ $q->options->answers = array();
+ $q->options->answers[0] = new stdClass();
+ $q->options->answers[0]->answer = '3.14';
+ $q->options->answers[0]->fraction = '1.0000000';
+ $q->options->answers[0]->feedback = 'Very good.';
+ $q->options->answers[0]->feedbackformat = FORMAT_HTML;
+ $q->options->answers[0]->tolerance = '0';
+
+ $q->options->answers[1] = new stdClass();
+ $q->options->answers[1]->answer = '3.142';
+ $q->options->answers[1]->fraction = '0.0000000';
+ $q->options->answers[1]->feedback = 'Too accurate.';
+ $q->options->answers[1]->feedbackformat = FORMAT_HTML;
+ $q->options->answers[1]->tolerance = '0';
+
+ $q->options->answers[2] = new stdClass();
+ $q->options->answers[2]->answer = '3.1';
+ $q->options->answers[2]->fraction = '0.0000000';
+ $q->options->answers[2]->feedback = 'Not accurate enough.';
+ $q->options->answers[2]->feedbackformat = FORMAT_HTML;
+ $q->options->answers[2]->tolerance = '0';
+
+ $q->options->answers[3] = new stdClass();
+ $q->options->answers[3]->answer = '3';
+ $q->options->answers[3]->answerformat = '0';
+ $q->options->answers[3]->fraction = '0.0000000';
+ $q->options->answers[3]->feedback = 'Not accurate enough.';
+ $q->options->answers[3]->feedbackformat = FORMAT_HTML;
+ $q->options->answers[3]->tolerance = '0';
+
+ $q->options->answers[4] = new stdClass();
+ $q->options->answers[4]->answer = '*';
+ $q->options->answers[4]->answerformat = '0';
+ $q->options->answers[4]->fraction = '0.0000000';
+ $q->options->answers[4]->feedback = 'Completely wrong.';
+ $q->options->answers[4]->feedbackformat = FORMAT_HTML;
+ $q->options->answers[4]->tolerance = '0';
+
+ $q->options->units = array();
+
+ $q->options->unitgradingtype = '0';
+ $q->options->unitpenalty = '0.1000000';
+ $q->options->showunits = '3';
+ $q->options->unitsleft = '0';
+
+ return $q;
+ }
+
+ /**
* Makes a numerical question with a choice (select menu) of units.
* @return qtype_numerical_question
*/
global $CFG;
require_once($CFG->dirroot . '/question/type/numerical/questiontype.php');
-
+require_once($CFG->dirroot . '/question/engine/tests/helpers.php');
+require_once($CFG->dirroot . '/question/type/edit_question_form.php');
+require_once($CFG->dirroot . '/question/type/numerical/edit_numerical_form.php');
/**
* Unit tests for question/type/numerical/questiontype.php.
),
), $this->qtype->get_possible_responses($q));
}
+
+ public function test_question_saving_pi() {
+ $this->resetAfterTest(true);
+ $this->setAdminUser();
+
+ $questiondata = test_question_maker::get_question_data('numerical');
+ $formdata = test_question_maker::get_question_form_data('numerical');
+
+ $generator = $this->getDataGenerator()->get_plugin_generator('core_question');
+ $cat = $generator->create_question_category(array());
+
+ $formdata->category = "{$cat->id},{$cat->contextid}";
+ qtype_numerical_edit_form::mock_submit((array)$formdata);
+
+ $form = qtype_numerical_test_helper::get_question_editing_form($cat, $questiondata);
+
+ $this->assertTrue($form->is_validated());
+
+ $fromform = $form->get_data();
+
+ $returnedfromsave = $this->qtype->save_question($questiondata, $fromform);
+ $actualquestionsdata = question_load_questions(array($returnedfromsave->id));
+ $actualquestiondata = end($actualquestionsdata);
+
+ foreach ($questiondata as $property => $value) {
+ if (!in_array($property, array('options'))) {
+ $this->assertAttributeEquals($value, $property, $actualquestiondata);
+ }
+ }
+
+ foreach ($questiondata->options as $optionname => $value) {
+ if (!in_array($optionname, array('answers'))) {
+ $this->assertAttributeEquals($value, $optionname, $actualquestiondata->options);
+ }
+ }
+
+ foreach ($questiondata->options->answers as $ansindex => $answer) {
+ $actualanswer = array_shift($actualquestiondata->options->answers);
+ foreach ($answer as $ansproperty => $ansvalue) {
+ // This question does not use 'answerformat', will ignore it.
+ if (!in_array($ansproperty, array('id', 'question', 'answerformat'))) {
+ $this->assertAttributeEquals($ansvalue, $ansproperty, $actualanswer);
+ }
+ }
+ }
+ }
}
* Constructor.
* @param int $id the answer.
* @param string $answer the answer.
- * @param int $answerformat the format of the answer.
* @param number $fraction the fraction this answer is worth.
* @param string $feedback the feedback for this answer.
* @param int $feedbackformat the format of the feedback.
}
return null;
}
-}
\ No newline at end of file
+}
$qdata->generalfeedback = 'Generalfeedback: frog or toad would have been OK.';
$qdata->options = new stdClass();
- $qdata->options->usecase = false;
+ $qdata->options->usecase = 0;
$qdata->options->answers = array(
13 => new question_answer(13, 'frog', 1.0, 'Frog is a very good answer.', FORMAT_HTML),
14 => new question_answer(14, 'toad', 0.8, 'Toad is an OK good answer.', FORMAT_HTML),
}
/**
- * Gets the question data for a shortanswer question with with correct
- * ansewer 'frog', partially correct answer 'toad' and defaultmark 1.
+ * Gets the question form data for a shortanswer question with with correct
+ * answer 'frog', partially correct answer 'toad' and defaultmark 1.
* This question also has a '*' match anything answer.
* @return stdClass
*/
public function get_shortanswer_question_form_data_frogtoad() {
- $fromform = new stdClass();
- test_question_maker::initialise_question_form_data($fromform);
-
- $fromform->qtype = 'shortanswer';
- $fromform->name = 'Short answer question';
- $fromform->questiontext = array('text' => 'Name an amphibian: __________', 'format' => FORMAT_HTML);
- $fromform->generalfeedback = array('text' => 'Generalfeedback: frog or toad would have been OK.', 'format' => FORMAT_HTML);
- $fromform->usecase = false;
- $fromform->answer = array('frog', 'toad', '*');
- $fromform->fraction = array(1.0, 0.8, 0.0);
- $fromform->feedback = array(
+ $form = new stdClass();
+
+ $form->name = 'Short answer question';
+ $form->questiontext = array('text' => 'Name an amphibian: __________', 'format' => FORMAT_HTML);
+ $form->defaultmark = 1.0;
+ $form->generalfeedback = array('text' => 'Generalfeedback: frog or toad would have been OK.', 'format' => FORMAT_HTML);
+ $form->usecase = false;
+ $form->answer = array('frog', 'toad', '*');
+ $form->fraction = array('1.0', '0.8', '0.0');
+ $form->feedback = array(
array('text' => 'Frog is a very good answer.', 'format' => FORMAT_HTML),
array('text' => 'Toad is an OK good answer.', 'format' => FORMAT_HTML),
array('text' => 'That is a bad answer.', 'format' => FORMAT_HTML),
);
- return $fromform;
+ return $form;
}
/**
/**
* Unit tests for the shortanswer question type class.
*
- * @package qtype
- * @subpackage shortanswer
- * @copyright 2007 The Open University
+ * @package qtype_shortanswer
+ * @copyright 2013 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
global $CFG;
require_once($CFG->dirroot . '/question/type/shortanswer/questiontype.php');
require_once($CFG->dirroot . '/question/engine/tests/helpers.php');
-
+require_once($CFG->dirroot . '/question/type/edit_question_form.php');
+require_once($CFG->dirroot . '/question/type/shortanswer/edit_shortanswer_form.php');
/**
* Unit tests for the shortanswer question type class.
),
), $this->qtype->get_possible_responses($q));
}
+
+ public function test_question_saving_frogtoad() {
+ $this->resetAfterTest(true);
+ $this->setAdminUser();
+
+ $questiondata = test_question_maker::get_question_data('shortanswer');
+ $formdata = test_question_maker::get_question_form_data('shortanswer');
+
+ $generator = $this->getDataGenerator()->get_plugin_generator('core_question');
+ $cat = $generator->create_question_category(array());
+
+ $formdata->category = "{$cat->id},{$cat->contextid}";
+ qtype_shortanswer_edit_form::mock_submit((array)$formdata);
+
+ $form = qtype_shortanswer_test_helper::get_question_editing_form($cat, $questiondata);
+
+ $this->assertTrue($form->is_validated());
+
+ $fromform = $form->get_data();
+
+ $returnedfromsave = $this->qtype->save_question($questiondata, $fromform);
+ $actualquestionsdata = question_load_questions(array($returnedfromsave->id));
+ $actualquestiondata = end($actualquestionsdata);
+
+ foreach ($questiondata as $property => $value) {
+ if (!in_array($property, array('id', 'version', 'timemodified', 'timecreated', 'options'))) {
+ $this->assertAttributeEquals($value, $property, $actualquestiondata);
+ }
+ }
+
+ foreach ($questiondata->options as $optionname => $value) {
+ if ($optionname != 'answers') {
+ $this->assertAttributeEquals($value, $optionname, $actualquestiondata->options);
+ }
+ }
+
+ foreach ($questiondata->options->answers as $answer) {
+ $actualanswer = array_shift($actualquestiondata->options->answers);
+ foreach ($answer as $ansproperty => $ansvalue) {
+ // This question does not use 'answerformat', will ignore it.
+ if (!in_array($ansproperty, array('id', 'question', 'answerformat'))) {
+ $this->assertAttributeEquals($ansvalue, $ansproperty, $actualanswer);
+ }
+ }
+ }
+ }
}
return $tf;
}
+ public function get_truefalse_question_form_data_true() {
+
+ $form = new stdClass();
+ $form->name = 'True/false question';
+ $form->questiontext = array();
+ $form->questiontext['format'] = '1';
+ $form->questiontext['text'] = 'The answer is true.';
+
+ $form->defaultmark = 1;
+ $form->generalfeedback = array();
+ $form->generalfeedback['format'] = '1';
+ $form->generalfeedback['text'] = 'You should have selected true.';
+
+ $form->correctanswer = '1';
+ $form->feedbacktrue = array();
+ $form->feedbacktrue['format'] = '1';
+ $form->feedbacktrue['text'] = 'This is the right answer.';
+
+ $form->feedbackfalse = array();
+ $form->feedbackfalse['format'] = '1';
+ $form->feedbackfalse['text'] = 'This is the wrong answer.';
+
+ $form->penalty = 1;
+
+ return $form;
+ }
+
+ function get_truefalse_question_data_true() {
+
+ $q = new stdClass();
+ $q->name = 'True/false question';
+ $q->questiontext = 'The answer is true.';
+ $q->questiontextformat = FORMAT_HTML;
+ $q->generalfeedback = 'You should have selected true.';
+ $q->generalfeedbackformat = FORMAT_HTML;
+ $q->defaultmark = 1;
+ $q->penalty = 1;
+ $q->qtype = 'truefalse';
+ $q->length = '1';
+ $q->hidden = '0';
+ $q->createdby = '2';
+ $q->modifiedby = '2';
+ $q->options = new stdClass();
+ $q->options->trueanswer = '0';
+ $q->options->falseanswer = '1';
+ $q->options->answers = array();
+ $q->options->answers[0] = new stdClass();
+ $q->options->answers[0]->answer = 'True';
+ $q->options->answers[0]->fraction = '1.0000000';
+ $q->options->answers[0]->feedback = 'This is the right answer.';
+ $q->options->answers[0]->feedbackformat = FORMAT_HTML;
+
+ $q->options->answers[1] = new stdClass();
+ $q->options->answers[1]->answer = 'False';
+ $q->options->answers[1]->fraction = '0.0000000';
+ $q->options->answers[1]->feedback = 'This is the wrong answer.';
+ $q->options->answers[1]->feedbackformat = FORMAT_HTML;
+
+ return $q;
+ }
+
/**
* Makes a truefalse question with correct answer false.
* @return qtype_truefalse_question
global $CFG;
require_once($CFG->dirroot . '/question/type/truefalse/questiontype.php');
-
+require_once($CFG->dirroot . '/question/engine/tests/helpers.php');
+require_once($CFG->dirroot . '/question/type/edit_question_form.php');
+require_once($CFG->dirroot . '/question/type/truefalse/edit_truefalse_form.php');
/**
* Unit tests for the true-false question definition class.
null => question_possible_response::no_response()),
), $this->qtype->get_possible_responses($q));
}
+
+ public function test_question_saving_true() {
+ $this->resetAfterTest(true);
+ $this->setAdminUser();
+
+ $questiondata = test_question_maker::get_question_data('truefalse');
+ $formdata = test_question_maker::get_question_form_data('truefalse');
+
+ $generator = $this->getDataGenerator()->get_plugin_generator('core_question');
+ $cat = $generator->create_question_category(array());
+
+ $formdata->category = "{$cat->id},{$cat->contextid}";
+ qtype_truefalse_edit_form::mock_submit((array)$formdata);
+
+ $form = qtype_truefalse_test_helper::get_question_editing_form($cat, $questiondata);
+
+ $this->assertTrue($form->is_validated());
+
+ $fromform = $form->get_data();
+
+ $returnedfromsave = $this->qtype->save_question($questiondata, $fromform);
+ $actualquestionsdata = question_load_questions(array($returnedfromsave->id));
+ $actualquestiondata = end($actualquestionsdata);
+
+ foreach ($questiondata as $property => $value) {
+ if (!in_array($property, array('options'))) {
+ $this->assertAttributeEquals($value, $property, $actualquestiondata);
+ }
+ }
+
+ foreach ($questiondata->options as $optionname => $value) {
+ if (!in_array($optionname, array('trueanswer', 'falseanswer', 'answers'))) {
+ $this->assertAttributeEquals($value, $optionname, $actualquestiondata->options);
+ }
+ }
+
+ $answerindexes = array();
+ foreach ($questiondata->options->answers as $ansindex => $answer) {
+ $actualanswer = array_shift($actualquestiondata->options->answers);
+ foreach ($answer as $ansproperty => $ansvalue) {
+ // This question does not use 'answerformat', will ignore it.
+ if (!in_array($ansproperty, array('id', 'question', 'answerformat'))) {
+ $this->assertAttributeEquals($ansvalue, $ansproperty, $actualanswer);
+ }
+ }
+ $answerindexes[$answer->answer] = $ansindex;
+ }
+
+ $this->assertEquals($questiondata->options->trueanswer, $answerindexes['True']);
+ $this->assertEquals($questiondata->options->falseanswer, $answerindexes['False']);
+ }
}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-$THEME->name = 'formfactor';
-
-////////////////////////////////////////////////////
-// Name of the theme. Most likely the name of
-// the directory in which this file resides.
-////////////////////////////////////////////////////
-
+// Name of the theme, and most likely the name
+// of the directory in which this file resides.
-$THEME->parents = array('canvas','base');
+$THEME->name = 'formfactor';
-/////////////////////////////////////////////////////
// Which existing theme(s) in the /theme/ directory
-// do you want this theme to extend. A theme can
-// extend any number of themes. Rather than
-// creating an entirely new theme and copying all
+// do you want this theme to extend?
+// A theme can extend any number of themes. So rather
+// than creating an entirely new theme and copying all
// of the CSS, you can simply create a new theme,
-// extend the theme you like and just add the
+// by extending the theme you like and just add the
// changes you want to your theme.
-////////////////////////////////////////////////////
+$THEME->parents = array('canvas','base');
+
+// Name of the stylesheet(s) you've including in
+// this theme's /styles/ directory.
$THEME->sheets = array(
'selected',
'blocks'
);
-////////////////////////////////////////////////////
-// Name of the stylesheet(s) you've including in
-// this theme's /styles/ directory.
-////////////////////////////////////////////////////
+// Do you want to use the new navigation dock?
$THEME->enable_dock = false;
-////////////////////////////////////////////////////
-// Do you want to use the new navigation dock?
-////////////////////////////////////////////////////
+// An array of stylesheets to include within the
+// body of the editor.
$THEME->editor_sheets = array('editor');
-////////////////////////////////////////////////////
-// An array of stylesheets to include within the
-// body of the editor.
-////////////////////////////////////////////////////
+// These are all of the possible layouts in Moodle. The
+// simplest way to do this is to keep the theme and file
+// variables the same for every layout. Including them
+// all in this way allows some flexibility down the road
+// if you want to add a different layout template to a
+// specific page.
$THEME->layouts = array(
+ // Most backwards compatible layout without the blocks - this is the layout used by default
'base' => array(
'file' => 'general.php',
- 'regions' => array('side-pre', 'side-post'),
- 'defaultregion' => 'side-pre',
+ 'regions' => array(),
),
+ // Standard layout with blocks, this is recommended for most pages with general information
'standard' => array(
'file' => 'general.php',
'regions' => array('side-pre', 'side-post'),
'defaultregion' => 'side-pre',
),
+ // Main course page
'course' => array(
'file' => 'general.php',
'regions' => array('side-pre', 'side-post'),
- 'defaultregion' => 'side-pre'
+ 'defaultregion' => 'side-pre',
+ 'options' => array('langmenu'=>true),
),
'coursecategory' => array(
'file' => 'general.php',
'regions' => array('side-pre', 'side-post'),
'defaultregion' => 'side-pre',
),
+ // part of course, typical for modules - default page layout if $cm specified in require_login()
'incourse' => array(
'file' => 'general.php',
'regions' => array('side-pre', 'side-post'),
'defaultregion' => 'side-pre',
),
+ // The site home page.
'frontpage' => array(
'file' => 'frontpage.php',
'regions' => array('side-pre', 'side-post'),
'defaultregion' => 'side-pre',
),
+ // Server administration scripts.
'admin' => array(
'file' => 'general.php',
'regions' => array('side-pre'),
'defaultregion' => 'side-pre',
),
+ // My dashboard page
'mydashboard' => array(
'file' => 'general.php',
'regions' => array('side-pre', 'side-post'),
'defaultregion' => 'side-pre',
'options' => array('langmenu'=>true),
),
+ // My public page
'mypublic' => array(
'file' => 'general.php',
'regions' => array('side-pre', 'side-post'),
'regions' => array(),
'options' => array('langmenu'=>true),
),
+
+ // Pages that appear in pop-up windows - no navigation, no blocks, no header.
'popup' => array(
'file' => 'general.php',
'regions' => array(),
- 'options' => array('nofooter'=>true, 'noblocks'=>true, 'nonavbar'=>true, 'nocourseheaderfooter'=>true),
+ 'options' => array('nofooter'=>true, 'nonavbar'=>true, 'nocustommenu'=>true, 'nologininfo'=>true, 'nocourseheaderfooter'=>true),
),
+ // No blocks and minimal footer - used for legacy frame layouts only!
'frametop' => array(
'file' => 'general.php',
'regions' => array(),
'options' => array('nofooter'=>true, 'nocoursefooter'=>true),
),
- 'maintenance' => array(
- 'file' => 'general.php',
- 'regions' => array(),
- 'options' => array('nofooter'=>true, 'nonavbar'=>true, 'nocourseheaderfooter'=>true),
- ),
+ // Embeded pages, like iframe/object embeded in moodleform - it needs as much space as possible
'embedded' => array(
'file' => 'embedded.php',
'regions' => array(),
- 'options' => array('nofooter'=>true, 'nonavbar'=>true, 'nocourseheaderfooter'=>true),
+ 'options' => array('nofooter'=>true, 'nonavbar'=>true, 'nocustommenu'=>true, 'nocourseheaderfooter'=>true),
+ ),
+ // Used during upgrade and install, and for the 'This site is undergoing maintenance' message.
+ // This must not have any blocks, and it is good idea if it does not have links to
+ // other places - for example there should not be a home link in the footer...
+ 'maintenance' => array(
+ 'file' => 'general.php',
+ 'regions' => array(),
+ 'options' => array('noblocks'=>true, 'nofooter'=>true, 'nonavbar'=>true, 'nocustommenu'=>true, 'nocourseheaderfooter'=>true),
),
// Should display the content and basic headers only.
'print' => array(
'file' => 'general.php',
'regions' => array(),
- 'options' => array('nofooter'=>true, 'nonavbar'=>false, 'noblocks'=>true, 'nocourseheaderfooter'=>true),
+ 'options' => array('noblocks'=>true, 'nofooter'=>true, 'nonavbar'=>false, 'nocustommenu'=>true, 'nocourseheaderfooter'=>true),
),
-
-);
+ // The pagelayout used when a redirection is occuring.
+ 'redirect' => array(
+ 'file' => 'embedded.php',
+ 'regions' => array(),
+ 'options' => array('nofooter'=>true, 'nonavbar'=>true, 'nocustommenu'=>true, 'nocourseheaderfooter'=>true),
+ ),
+ // The pagelayout used for reports.
+ 'report' => array(
+ 'file' => 'report.php',
+ 'regions' => array('side-pre'),
+ 'defaultregion' => 'side-pre',
+ ),
+ // The pagelayout used for safebrowser and securewindow.
+ 'secure' => array(
+ 'file' => 'general.php',
+ 'regions' => array('side-pre', 'side-post'),
+ 'defaultregion' => 'side-pre',
+ 'options' => array('nofooter'=>true, 'nonavbar'=>true, 'nocustommenu'=>true, 'nologinlinks'=>true, 'nocourseheaderfooter'=>true),
+ ),
+);
\ No newline at end of file