-<?php // $Id$
+<?php // $Id$
////////////////////////////////////////////////////////////////////
-/// Default class for report plugins
-///
-/// Doesn't do anything on it's own -- it needs to be extended.
-/// This class displays quiz reports. Because it is called from
+/// Default class for report plugins
+///
+/// Doesn't do anything on it's own -- it needs to be extended.
+/// This class displays quiz reports. Because it is called from
/// within /mod/quiz/report.php you can assume that the page header
/// and footer are taken care of.
-///
-/// This file can refer to itself as report.php to pass variables
-/// to itself - all these will also be globally available. You must
+///
+/// This file can refer to itself as report.php to pass variables
+/// to itself - all these will also be globally available. You must
/// pass "id=$cm->id" or q=$quiz->id", and "mode=reportname".
////////////////////////////////////////////////////////////////////
$PAGE->set_title(format_string($quiz->name));
$PAGE->set_button($OUTPUT->update_module_button($cm->id, 'quiz'));
echo $OUTPUT->header();
- /// Print the tabs
+ /// Print the tabs
$currenttab = 'reports';
$mode = $reportmode;
require($CFG->dirroot . '/mod/quiz/tabs.php');
$course_context = get_context_instance(CONTEXT_COURSE, $course->id);
if (has_capability('gradereport/grader:view', $course_context) && has_capability('moodle/grade:viewall', $course_context)) {
- echo '<div class="allcoursegrades"><a href="' . $CFG->wwwroot . '/grade/report/grader/index.php?id=' . $course->id . '">'
+ echo '<div class="allcoursegrades"><a href="' . $CFG->wwwroot . '/grade/report/grader/index.php?id=' . $course->id . '">'
. get_string('seeallcoursegrades', 'grades') . '</a></div>';
}
}
}
-?>
+
-<?php // $Id$
+<?php
/**
* Quiz report to help teachers manually grade quiz questions that need it.
*
"quiz=?", array_merge(array($uniqueid), $params, array($quiz->id)))){
print_error('invalidattemptid', 'quiz_grading');
}
-
+
// Load the state for this attempt (The questions array was created earlier)
$states = get_question_states($questions, $quiz, $attempt);
// The $states array is indexed by question id but because we are dealing
// with only one question there is only one entry in this array
$state = &$states[$question->id];
-
+
// the following will update the state and attempt
$error = question_process_comment($question, $state, $attempt, $response['comment'], $response['grade']);
if (is_string($error)) {
// our 2 different views
- // the first view allows a user to select a question and
+ // the first view allows a user to select a question and
// displays the users who have answered the essay question
// and all of their attempts at answering the question
$where = "WHERE u.id $usql ";
$params = array_merge($params, $u_params);
}
-
+
$where .= ' AND qs.event IN ('.QUESTION_EVENTS_CLOSED_OR_GRADED.')';
$where .= ' AND u.id = qa.userid AND qa.quiz = ?';
}
-?>
+
-<?php // $Id$
+<?php
function xmldb_quiz_overview_upgrade($oldversion) {
global $CFG, $DB;
return $result;
}
-?>
+
-<?php // $Id$
+<?php
class quiz_report_overview_table extends table_sql {
$link = html_link::make("/mod/quiz/reviewquestion.php?attempt=$attempt->attempt&question=$question->id", $grade);
$link->add_action(new popup_action('click', $link->url, 'reviewquestion', array('height' => 450, 'width' => 650)));
$link->title = get_string('reviewresponsetoq', 'quiz', $question->formattedname);
- $linktopopup = $OUTPUT->link($link);
+ $linktopopup = $OUTPUT->link($link);
if (($this->questions[$questionid]->maxgrade != 0)){
$fractionofgrade = $stateforqinattempt->grade
}
}
}
-?>
+
-<?php // $Id$
+<?php
include '../../../../config.php';
include $CFG->dirroot."/lib/graphlib.php";
include $CFG->dirroot."/mod/quiz/report/reportlib.php";
$line->parameter['y_axis_gridlines'] = $gridlines+1;
$line->draw();
-?>
+
-<?php // $Id$
+<?php
require_once "$CFG->libdir/formslib.php";
class mod_quiz_report_overview_settings extends moodleform {
}
if ($showattemptsgrp){
$mform->addGroup($showattemptsgrp, null, get_string('showattempts', 'quiz_overview'), '<br />', false);
- }
+ }
//-------------------------------------------------------------------------------
$mform->addElement('header', 'preferencesuser', get_string('preferencesuser', 'quiz_overview'));
$this->add_action_buttons(false, get_string('preferencessave', 'quiz_overview'));
}
}
-?>
+
/**
* This script lists student attempts
*
- * @version $Id$
* @author Martin Dougiamas, Tim Hunt and others.
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package quiz
$showgrades = quiz_has_grades($quiz) && $reviewoptions->scores;
$download = optional_param('download', '', PARAM_ALPHA);
-
+
/// find out current groups mode
$currentgroup = groups_get_activity_group($cm, true);
if (!$students = get_users_by_capability($this->context, array('mod/quiz:reviewmyattempts', 'mod/quiz:attempt'),'','','','','','',false)){
}
$allowed = $groupstudents;
}
-
+
if (empty($currentgroup)||$groupstudents) {
if (optional_param('delete', 0, PARAM_BOOL)){
if($attemptids = optional_param('attemptid', array(), PARAM_INT)) {
} else if ($attemptsmode === null){
//default
$attemptsmode = QUIZ_REPORT_ATTEMPTS_ALL;
- }
+ }
if (!$reviewoptions->scores) {
$detailedmarks = 0;
}
// Only print headers if not asked to download data
$this->print_header_and_tabs($cm, $course, $quiz, "overview");
}
-
+
if ($regradeall){
$this->regrade_all(false, $quiz, $groupstudents);
} else if ($regradealldry){
if ($regradeall || $regradealldry || $regradealldrydo){
redirect($reporturl->out(false, $displayoptions, false), '', 5);
}
-
+
if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used
if (!$table->is_downloading()) {
groups_print_activity_menu($cm, $reporturl->out(false, $displayoptions));
}
}
-
+
// Print information on the number of existing attempts
if (!$table->is_downloading()) { //do not print notices when downloading
if ($strattemptnum = quiz_num_attempt_summary($quiz, $cm, true, $currentgroup)) {
$mform->set_data($displayoptions +compact('detailedmarks', 'pagesize'));
$mform->display();
}
-
-
+
+
if (!$nostudents || ($attemptsmode == QUIZ_REPORT_ATTEMPTS_ALL)){
-
-
-
+
+
+
// Construct the SQL
$fields = $DB->sql_concat('u.id', '\'#\'', 'COALESCE(qa.attempt, \'0\')').' AS uniqueid, ';
if ($qmsubselect) {
" ELSE 0 " .
"END) AS gradedattempt, ";
}
-
+
$fields .='qa.uniqueid AS attemptuniqueid, qa.id AS attempt, ' .
'u.id AS userid, u.idnumber, u.firstname, u.lastname, u.picture, u.imagealt, '.
'qa.sumgrades, qa.timefinish, qa.timestart, qa.timefinish - qa.timestart AS duration ';
$from = '{user} u ';
$from .= 'LEFT JOIN {quiz_attempts} qa ON qa.userid = u.id AND qa.quiz = :quizid';
$params = array('quizid' => $quiz->id);
-
+
if ($qmsubselect && $qmfilter){
$from .= ' AND '.$qmsubselect;
}
$where = "u.id $allowed_usql AND (qa.preview = 0 OR qa.preview IS NULL)";
break;
}
-
+
$table->set_count_sql("SELECT COUNT(1) FROM $from WHERE $where", $params);
$sqlobject = new object;
$where .= ' AND COALESCE((SELECT MAX(qqr.regraded) FROM {quiz_question_regrade} qqr WHERE qqr.attemptid = qa.uniqueid),-1) !=\'-1\'';
}
$table->set_sql($fields, $from, $where, $params);
-
+
// Define table columns
$columns = array();
$headers = array();
echo '<div class="quizattemptcounts">' . $strattempthighlight . '</div>';
}
}
-
+
if (!$table->is_downloading() && $candelete) {
$columns[]= 'checkbox';
$headers[]= NULL;
}
-
+
if (!$table->is_downloading() && $CFG->grade_report_showuserimage) {
$columns[]= 'picture';
$headers[]= '';
$columns[]= 'firstname';
$headers[]= get_string('firstname');
}
-
+
if ($CFG->grade_report_showuseridnumber) {
$columns[]= 'idnumber';
$headers[]= get_string('idnumber');
}
-
+
$columns[]= 'timestart';
$headers[]= get_string('startedon', 'quiz');
-
+
$columns[]= 'timefinish';
$headers[]= get_string('timecompleted','quiz');
-
+
$columns[]= 'duration';
$headers[]= get_string('attemptduration', 'quiz');
-
+
if ($detailedmarks) {
foreach ($questions as $id => $question) {
// Ignore questions of zero length
$columns[] = 'sumgrades';
$headers[] = get_string('grade', 'quiz').'/'.quiz_format_grade($quiz, $quiz->grade);
}
-
+
if ($hasfeedback) {
$columns[] = 'feedbacktext';
$headers[] = get_string('feedback', 'quiz');
}
-
+
$table->define_columns($columns);
$table->define_headers($headers);
$table->sortable(true, 'uniqueid');
-
+
// Set up the table
$table->define_baseurl($reporturl->out(false, $displayoptions));
-
+
$table->collapsible(false);
-
+
$table->column_suppress('picture');
$table->column_suppress('fullname');
$table->column_suppress('idnumber');
-
+
$table->no_sorting('feedbacktext');
-
+
$table->column_class('picture', 'picture');
$table->column_class('lastname', 'bold');
$table->column_class('firstname', 'bold');
$table->column_class('fullname', 'bold');
$table->column_class('sumgrades', 'bold');
-
+
$table->set_attribute('id', 'attempts');
-
+
$table->out($pagesize, true);
}
if (!$table->is_downloading() && $showgrades) {
list($asql, $aparams) = $DB->get_in_or_equal($attemptids);
$where = "qa.id $asql AND ";
$params = array_merge($params, $aparams);
-
+
$where .= "qa.quiz = ? AND qa.preview = 0";
$params[] = $quiz->id;
if (!$attempts = $DB->get_records_sql('SELECT qa.* FROM {quiz_attempts} qa WHERE '. $where, $params)) {
}
-?>
+
-<?php // $Id$
+<?php
////////////////////////////////////////////////////////////////////////////////
// Code fragment to define the version of quiz overview report
$plugin->version = 2009091400; // The (date) version of this module
-?>
+
list($usql, $params) = $DB->get_in_or_equal($userids);
$params[] = $quiz->id;
$questionavgssql = "SELECT qns.questionid, AVG(qs.grade) FROM
- {quiz_attempts} qa
+ {quiz_attempts} qa
LEFT JOIN {question_sessions} qns ON (qns.attemptid = qa.uniqueid)
LEFT JOIN {question_states} qs ON (qns.newgraded = qs.id AND qs.event IN (".QUESTION_EVENTS_GRADED."))
WHERE " .
$params = array($quiz->id);
list($u_sql, $u_params) = $DB->get_in_or_equal($userids);
list($q_sql, $q_params) = $DB->get_in_or_equal($questionids);
-
+
$params = array_merge($params, $u_params, $q_params);
$sql = "SELECT qs.question, COUNT(1) AS totalattempts,
SUM(CASE WHEN (qs.event IN(".QUESTION_EVENTS_GRADED.")) THEN 1 ELSE 0 END) AS gradedattempts
return $reportlist;
}
-?>
+
-<?php // $Id$
+<?php
/**
* This script lists student attempts and responses
*
$reporturl = new moodle_url($CFG->wwwroot.'/mod/quiz/report.php', $pageoptions);
$qmsubselect = quiz_report_qm_filter_select($quiz);
-
+
/// find out current groups mode
$currentgroup = groups_get_activity_group($cm, true);
$table->is_downloading($download, get_string('reportresponses','quiz_responses'),
"$COURSE->shortname ".format_string($quiz->name,true));
if (!$table->is_downloading()) {
-
+
// Only print headers if not asked to download data
$PAGE->requires->css('mod/quiz/report/responses/styles.css');
$this->print_header_and_tabs($cm, $course, $quiz, 'responses', '');
echo '<div class="quizattemptcounts">' . $strattempthighlight . '</div>';
}
}
-
-
+
+
$showgrades = quiz_has_grades($quiz) && $reviewoptions->scores;
$hasfeedback = quiz_has_feedback($quiz);
-
-
+
+
// Construct the SQL
$fields = $DB->sql_concat('u.id', '\'#\'', 'COALESCE(qa.attempt, \'0\')').' AS concattedid, ';
if ($qmsubselect) {
" ELSE 0 " .
"END) AS gradedattempt, ";
}
-
+
$fields .='qa.uniqueid, qa.id AS attempt, u.id AS userid, u.idnumber, u.firstname,'.
' u.lastname, u.institution, u.department, u.email, u.picture, u.imagealt, '.
'qa.sumgrades, qa.timefinish, qa.timestart, qa.timefinish - qa.timestart AS duration, ' .
'qa.layout ';
-
+
// This part is the same for all cases - join users and quiz_attempts tables
$from = '{user} u ';
$from .= 'LEFT JOIN {quiz_attempts} qa ON qa.userid = u.id AND qa.quiz = :quizid';
$params = array('quizid' => $quiz->id);
-
+
if ($qmsubselect && $qmfilter){
$from .= ' AND '.$qmsubselect;
}
$where = "u.id $allowed_usql AND (qa.preview = 0 OR qa.preview IS NULL)";
break;
}
-
+
$table->set_count_sql("SELECT COUNT(1) FROM $from WHERE $where", $params);
-
-
-
+
+
+
$table->set_sql($fields, $from, $where, $params);
-
+
// Define table columns
$columns = array();
$headers = array();
-
-
+
+
if (!$table->is_downloading() && $candelete) {
$columns[]= 'checkbox';
$headers[]= NULL;
}
-
+
if (!$table->is_downloading() && $CFG->grade_report_showuserimage) {
$columns[]= 'picture';
$headers[]= '';
$columns[]= 'firstname';
$headers[]= get_string('firstname');
}
-
+
if ($CFG->grade_report_showuseridnumber) {
$columns[]= 'idnumber';
$headers[]= get_string('idnumber');
$columns[]= 'timestart';
$headers[]= get_string('startedon', 'quiz');
-
+
$columns[]= 'timefinish';
$headers[]= get_string('timecompleted','quiz');
-
+
$columns[]= 'duration';
$headers[]= get_string('attemptduration', 'quiz');
}
-
+
if ($showgrades) {
$columns[] = 'sumgrades';
$headers[] = get_string('grade', 'quiz').'/'.quiz_format_grade($quiz, $quiz->grade);
$columns[] = 'feedbacktext';
$headers[] = get_string('feedback', 'quiz');
}
-
+
// we want to display responses for all questions
foreach ($questions as $id => $question) {
// Ignore questions of zero length
$headers[] = '#'.$question->number;
$question->formattedname = strip_tags(format_string($question->name));
}
-
-
+
+
// Load the question type specific information
if (!get_question_options($questions)) {
print_error('cannotloadoptions', 'quiz_responses');
}
-
+
$table->define_columns($columns);
$table->define_headers($headers);
$table->sortable(true, 'concattedid');
-
+
// Set up the table
$table->define_baseurl($reporturl->out(false, $displayoptions));
-
+
$table->collapsible(true);
-
+
$table->column_suppress('picture');
$table->column_suppress('fullname');
$table->column_suppress('idnumber');
-
+
$table->no_sorting('feedbacktext');
-
+
$table->column_class('picture', 'picture');
$table->column_class('lastname', 'bold');
$table->column_class('firstname', 'bold');
$table->column_class('fullname', 'bold');
$table->column_class('sumgrades', 'bold');
-
+
$table->set_attribute('id', 'attempts');
-
+
$table->out($pagesize, true);
}
return true;
}
-?>
+
-<?php // $Id$
+<?php
define ('QUIZ_REPORT_RESPONSES_MAX_LEN_TO_DISPLAY', 150);
class quiz_report_responses_table extends table_sql {
} else {
return '-';
}
-
+
$question = $this->questions[$questionid];
restore_question_state($question, $stateforqinattempt);
-
+
if (!$this->is_downloading() || $this->is_downloading() == 'xhtml'){
$formathtml = true;
} else {
} else {
return '';
}
-
+
} else {
return $summary;
}
}
}
}
-?>
+
-<?php // $Id$
+<?php
require_once "$CFG->libdir/formslib.php";
class mod_quiz_report_responses_settings extends moodleform {
$this->add_action_buttons(false, get_string('preferencessave', 'quiz_overview'));
}
}
-?>
\ No newline at end of file
$object->response = '';
$object->grade = 3;
$datum[] = $object;
-
+
$indexed = quiz_report_index_by_keys($datum, array('aid','qid'));
-
+
$this->assertEqual($indexed[101][3]->qid, 3);
$this->assertEqual($indexed[101][3]->aid, 101);
$this->assertEqual($indexed[101][3]->response, '');
$this->assertEqual($indexed[101][3]->grade, 3);
-
+
$indexed = quiz_report_index_by_keys($datum, array('aid','qid'), false);
-
+
$this->assertEqual($indexed[101][3][0]->qid, 3);
$this->assertEqual($indexed[101][3][0]->aid, 101);
$this->assertEqual($indexed[101][3][0]->response, '');
$this->assertEqual($indexed[101][3][0]->grade, 3);
-
+
}
}
-?>
+
-<?php // $Id$
+<?php
function quiz_report_statistics_cron(){
global $DB;
if ($todelete = $DB->get_records_select_menu('quiz_statistics', 'timemodified < ?', array(time()-5*HOURSECS))){
}
return true;
}
-?>
+
-<?php //$Id$
+<?php
// This file is executed right after the install.xml
//
-<?php // $Id$
+<?php
function xmldb_quiz_statistics_upgrade($oldversion) {
* @var mixed states from which to calculate stats - iteratable.
*/
var $states;
-
+
var $sumofgradevariance = 0;
var $questions;
var $subquestions = array();
var $randomselectors = array();
var $responses = array();
-
+
function qstats($questions, $s, $sumgradesavg){
$this->s = $s;
$this->sumgradesavg = $sumgradesavg;
-
+
foreach (array_keys($questions) as $qid){
$questions[$qid]->_stats = $this->stats_init_object();
}
print_error('errorstatisticsquestions', 'quiz_statistics');
}
}
-
+
function _initial_states_walker($state, &$stats, $positionstat = true){
$stats->s++;
$stats->totalgrades += $state->grade;
}
}
- /**
+ /**
* Get the data for the individual question response analysis table.
*/
function _process_actual_responses($question, $state){
global $QTYPES;
- if ($question->qtype != 'random' &&
+ if ($question->qtype != 'random' &&
$QTYPES[$question->qtype]->show_analysis_of_responses()){
$restoredstate = clone($state);
restore_question_state($question, $restoredstate);
}
//avoid divide by zero
if ($stats->gradevariance * $stats->othergradevariance){
- $stats->discriminationindex = 100*$stats->covariance
+ $stats->discriminationindex = 100*$stats->covariance
/ sqrt($stats->gradevariance * $stats->othergradevariance);
} else {
$stats->discriminationindex = null;
$stats->discriminativeefficiency = null;
}
}
-
+
function process_states(){
global $DB, $OUTPUT;
set_time_limit(0);
}
}
}
-
+
function process_responses(){
foreach ($this->states as $state){
if ($this->questions[$state->question]->qtype == 'random'){
return $this->sumofgradevariance;
}
}
-?>
+
/**
* This script calculates various statistics about student attempts
*
- * @version $Id$
* @author Martin Dougiamas, Jamie Pratt, Tim Hunt and others.
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package quiz
return array($fromqa, $whereqa, $qaparams);
}
-?>
+
require_once($CFG->dirroot.'/mod/quiz/report/reportlib.php');
/**
- * This class contains the test cases for the functions in qstats.php.
- *
+ * This class contains the test cases for the functions in qstats.php.
+ *
* */
class quiz_report_qstats_test extends UnitTestCase {
public static $includecoverage = array('mod/quiz/report/reportlib.php');
$this->qstats = new qstats($questions, 22, 10045.45455);
$this->qstats->states = $states;
$this->qstats->process_states();
-
+
//values expected are taken from contrib/tools/quiz_tools/stats.xls
$facility = array(0,0,0,0,null,null,null,41.19318182,81.36363636,71.36363636,65.45454545,65.90909091,36.36363636,59.09090909,50,59.09090909,63.63636364,45.45454545,27.27272727,50);
$this->qstats_q_fields('facility', $facility, 100);
}
return $items;
}
-
+
function get_records_from_csv($filename){
$filecontents = file($filename, FILE_IGNORE_NEW_LINES);
$records = array();
//$test = new quiz_report_qstats_test();
//$test->test_qstats();
-?>
+
-<?php // $Id$
+<?php
require_once "$CFG->libdir/formslib.php";
class mod_quiz_report_statistics extends moodleform {
$this->add_action_buttons(false, get_string('preferencessave', 'quiz_overview'));
}
}
-?>
+
-<?php // $Id$
+<?php
include '../../../../config.php';
include $CFG->dirroot."/lib/graphlib.php";
include $CFG->dirroot."/mod/quiz/locallib.php";
$line->parameter['legend_offset'] = 4;
-$line->parameter['bar_size'] = 1;
+$line->parameter['bar_size'] = 1;
$line->parameter['zero_axis'] = 'grayEE';
$line->parameter['y_min_left'] = $min;
$line->parameter['y_max_left'] = $max;
-$line->parameter['y_decimal_left'] = 0;
+$line->parameter['y_decimal_left'] = 0;
$line->draw();
-?>
+
-<?php // $Id$
+<?php
require_once($CFG->libdir.'/tablelib.php');
class quiz_report_statistics_question_table extends flexible_table {
// Define table columns
$columns = array();
$headers = array();
-
+
if ($hassubqs){
$columns[]= 'subq';
$headers[]= '';
$columns[]= 'response';
$headers[]= get_string('response', 'quiz_statistics');
-
+
$columns[]= 'credit';
$headers[]= get_string('optiongrade', 'quiz_statistics');
-
+
$columns[]= 'rcount';
$headers[]= get_string('count', 'quiz_statistics');
parent::setup();
}
-
+
function col_response($response){
global $QTYPES;
if (!$this->is_downloading() || $this->is_downloading() == 'xhtml'){
return $response->response;
}
}
-
+
function col_subq($response){
return $response->subq;
}
-
+
function col_credit($response){
if (!is_null($response->credit)){
return ($response->credit*100).'%';
return '';
}
}
-
+
function col_frequency($response){
if ($this->question->_stats->s){
return format_float((($response->rcount / $this->question->_stats->s)*100),2).'%';
}
-?>
+
-<?php // $Id$
+<?php
require_once($CFG->libdir.'/tablelib.php');
class quiz_report_statistics_table extends flexible_table {
-
- var $quiz;
-
+
+ var $quiz;
+
function quiz_report_statistics_table(){
parent::flexible_table('mod-quiz-report-statistics-report');
}
// Define table columns
$columns = array();
$headers = array();
-
+
$columns[]= 'number';
$headers[]= get_string('questionnumber', 'quiz_statistics');
-
+
if (!$this->is_downloading()){
$columns[]= 'icon';
$headers[]= '';
}
$columns[]= 'name';
$headers[]= get_string('questionname', 'quiz');
-
+
$columns[]= 's';
$headers[]= get_string('attempts', 'quiz_statistics');
if ($s>1){
$columns[]= 'facility';
$headers[]= get_string('facility', 'quiz_statistics');
-
+
$columns[]= 'sd';
$headers[]= get_string('standarddeviationq', 'quiz_statistics');
}
$columns[]= 'random_guess_score';
$headers[]= get_string('random_guess_score', 'quiz_statistics');
-
+
$columns[]= 'intended_weight';
$headers[]= get_string('intended_weight', 'quiz_statistics');
-
+
$columns[]= 'effective_weight';
$headers[]= get_string('effective_weight', 'quiz_statistics');
-
+
$columns[]= 'discrimination_index';
$headers[]= get_string('discrimination_index', 'quiz_statistics');
-
+
$columns[]= 'discriminative_efficiency';
$headers[]= get_string('discriminative_efficiency', 'quiz_statistics');
return $question->_stats->discriminativeefficiency < 15;
}
}
-
+
function col_icon($question){
return print_question_icon($question, true);
}
-
+
function col_number($question){
if (!$question->_stats->subquestion){
return $question->number;
return $randomguessscore; // empty string returned by random question.
}
}
-
+
function col_sd($question){
if (!is_null($question->_stats->sd) && ($question->_stats->maxgrade!=0)){
return number_format($question->_stats->sd*100 / $question->_stats->maxgrade, 2).'%';
return '';
}
}
-
+
}
-?>
+
$this->assertEqual(quiz_add_page_break_at('1,2,0', 3), '1,2,0');
}
}
-?>
+
-<?php // $Id$
+<?php
///////////////////////////////////////////////////////////////////////////
// //
echo $OUTPUT->box_end();
echo $OUTPUT->footer();
-?>
+
-<?php // $Id$
+<?php
/**
* Question bank backup code.
*
}
return $status;
}
-?>
+
-<?php // $Id$
+<?php
/**
* Allows a teacher to create, edit and delete categories
*
$qcobject->display_user_interface();
}
echo $OUTPUT->footer();
-?>
+
-<?php // $Id$
+<?php
/**
* Class representing question categories
*
}
-?>
+
-<?php //$Id$
+<?php
require_once($CFG->libdir.'/formslib.php');
$mform->setType('id', PARAM_INT);
}
}
-?>
+
-<?php //$Id$
+<?php
require_once($CFG->libdir.'/formslib.php');
$mform->setType('addonpage', PARAM_SEQUENCE);
}
}
-?>
+
-<?php // $Id$
+<?php
/**
* Allows someone with appropriate permissions to move a category and associated
* files to another context.
}
$contextmoveform->display();
echo $OUTPUT->footer();
-?>
+
-<?php //$Id$
+<?php
require_once($CFG->libdir.'/formslib.php');
}
}
}
-?>
+
-<?php // $Id$
+<?php
/**
* Page for moving questions
*
}
$contextmoveform->display();
echo $OUTPUT->footer();
-?>
+
-<?php //$Id$
+<?php
require_once($CFG->libdir.'/formslib.php');
}
}
}
-?>
+
-<?php // $Id$
+<?php
///////////////////////////////////////////////////////////////////////////
// //
echo "</div>\n";
echo $OUTPUT->footer();
-?>
+
-<?php // $Id$
+<?php
///////////////////////////////////////////////////////////////////////////
// //
}
$baseurl = new moodle_url('edit.php');
$r = $baseurl->params($this->baseurl->params());
-
+
echo $OUTPUT->confirm(get_string("deletequestionscheck", "quiz", $questionnames),
$baseurl->out_action(array('deleteselected'=>$questionlist, 'confirm'=>md5($questionlist))),
$baseurl);
}
}
-?>
+
-<?php // $Id$
+<?php
/**
* Export quiz questions into the given category
*
$export_form->display();
echo $OUTPUT->footer();
-?>
+
-<?php //$Id$
+<?php
require_once($CFG->libdir.'/formslib.php');
$radioarray[] = $radioelement;
}
$mform->addGroup($radioarray,'format','',array('<br />'),false);
- $mform->addRule('format',null,'required',null,'client');
+ $mform->addRule('format',null,'required',null,'client');
//--------------------------------------------------------------------------------
$mform->addElement('header','general', get_string('general', 'form'));
$mform->disabledIf('categorygroup', 'cattofile', 'notchecked');
$mform->setDefault('cattofile', 1);
$mform->setDefault('contexttofile', 1);
-
+
// $fileformatnames = get_import_export_formats('export');
// $mform->addElement('select', 'format', get_string('fileformat','quiz'), $fileformatnames);
$mform->setDefault('exportfilename', $defaultfilename);
$mform->setType('exportfilename', PARAM_FILE);
- // set a template for the format select elements
+ // set a template for the format select elements
$renderer =& $mform->defaultRenderer();
$template = "{help} {element}\n";
$renderer->setGroupElementTemplate($template, 'format');
//--------------------------------------------------------------------------------
}
}
-?>
+
-<?php // $Id$
+<?php
require_once(dirname(__FILE__) . '/../config.php');
require_once($CFG->libdir . '/filelib.php');
$pathname = $CFG->dataroot . '/temp/questionexport/' . $USER->id . '/' . $relativepath;
send_temp_file($pathname, $relativepath);
-?>
+
-<?php // $Id$
+<?php
/**
* Base class for question import and export formats.
*
}
-?>
+
FILE FORMATS FOR QUESTION IMPORT/EXPORT
------------------------------------
-This directory contains plug-in sub-modules to add
+This directory contains plug-in sub-modules to add
import-export formats for Moodle questions
-Each sub-module must contain at least a format.php file
-containing a class that contains functions for reading,
+Each sub-module must contain at least a format.php file
+containing a class that contains functions for reading,
writing, importing and exporting questions.
For correct operation the class name must be based on the
name of the containing directory, e.g.,
directory: webct
-class: class qformat_webct extends qformat_default {
+class: class qformat_webct extends qformat_default {
-Most of them are based on the class found in question/format.php.
+Most of them are based on the class found in question/format.php.
See the comments therein for more information.
-<?php // $Id$
+<?php
///////////////////////////////////////////////////////////////////////////
// //
function readquestions($lines) {
$questions = array();
$question = $this->defaultquestion();
- $endchar = chr(13);
+ $endchar = chr(13);
foreach ($lines as $line) {
$stp = strpos($line, $endchar, 0);
$newlines = explode($endchar, $line);
}
}
-?>
+
-<?php // $Id$
+<?php
////////////////////////////////////////////////////////////////////////////
function readquestions ($lines) {
/// Parses an array of lines into an array of questions,
/// where each item is a question object as defined by
- /// readquestion().
+ /// readquestion().
$text = implode($lines, " ");
$xml = xmlize($text, 0);
// Process Essay Questions
//----------------------------------------
function process_essay($xml, &$questions ) {
-
+
if (isset($xml["POOL"]["#"]["QUESTION_ESSAY"])) {
$essayquestions = $xml["POOL"]["#"]["QUESTION_ESSAY"];
}
else {
return;
}
-
+
foreach ($essayquestions as $essayquestion) {
-
+
$question = $this->defaultquestion();
-
+
$question->qtype = ESSAY;
-
+
// determine if the question is already escaped html
$ishtml = $essayquestion["#"]["BODY"][0]["#"]["FLAGS"][0]["#"]["ISHTML"][0]["@"]["value"];
if ($ishtml) {
$question->questiontext = html_entity_decode_php4(trim($essayquestion["#"]["BODY"][0]["#"]["TEXT"][0]["#"]));
}
-
+
// put name in question object
$question->name = substr($question->questiontext, 0, 254);
$question->answer = '';
$question->feedback = '';
$question->fraction = 0;
-
+
$questions[] = $question;
}
}
}
for ($i = 0; $i < sizeof ($tfquestions); $i++) {
-
+
$question = $this->defaultquestion();
$question->qtype = TRUEFALSE;
}
}
- if ($iscorrect) {
+ if ($iscorrect) {
$question->fraction[$j] = floor(100000/$correctanswercount)/100000; // strange behavior if we have more than 5 decimal places
$question->feedback[$j] = trim($thisquestion["#"]["GRADABLE"][$j]["#"]["FEEDBACK_WHEN_CORRECT"][0]["#"]);
} else {
}
else {
$question->feedback[0] = '';
- }
+ }
if (is_array( $thisquestion["#"]["GRADABLE"][0]["#"] )) {
$question->feedback[1] = trim($thisquestion["#"]["GRADABLE"][0]["#"]["FEEDBACK_WHEN_INCORRECT"][0]["#"]);
}
else {
$question->feedback[1] = '';
- }
-
+ }
+
$questions[] = $question;
}
}
$choice = $choices[$j]["#"]["TEXT"][0]["#"];
$choice_id = $choices[$j]["@"]["id"];
-
+
$question->subanswers[] = trim($choice);
-
+
$correctanswers = $thisquestion["#"]["GRADABLE"][0]["#"]["CORRECTANSWER"];
for ($k = 0; $k < sizeof ($correctanswers); $k++) {
}
}
-
+
}
$questions[] = $question;
-
+
}
}
}
-?>
+
function provide_import() {
return true;
}
-
-
+
+
//Function to check and create the needed dir to unzip file to
function check_and_create_import_dir($unique_code) {
- global $CFG;
+ global $CFG;
$status = $this->check_dir_exists($CFG->dataroot."/temp",true);
if ($status) {
if ($status) {
$status = $this->check_dir_exists($CFG->dataroot."/temp/bbquiz_import/".$unique_code,true);
}
-
+
return $status;
}
-
+
function clean_temp_dir($dir='') {
- // for now we will just say everything happened okay note
+ // for now we will just say everything happened okay note
// that a mess may be piling up in $CFG->dataroot/temp/bbquiz_import
// TODO return true at top of the function renders all the following code useless
return true;
-
+
if ($dir == '') {
- $dir = $this->temp_dir;
+ $dir = $this->temp_dir;
}
$slash = "/";
// Close directory
closedir($handle);
if (rmdir($this->temp_dir) == FALSE) {
- return false;
+ return false;
}
// Success, every thing is gone return true
return true;
}
-
+
//Function to check if a directory exists and, optionally, create it
function check_dir_exists($dir,$create=false) {
- global $CFG;
+ global $CFG;
$status = true;
if(!is_dir($dir)) {
function importpostprocess() {
/// Does any post-processing that may be desired
- /// Argument is a simple array of question ids that
+ /// Argument is a simple array of question ids that
/// have just been added.
-
+
// need to clean up temporary directory
return $this->clean_temp_dir();
}
$filename = str_replace('\\','/',$filename);
$fullpath = $this->temp_dir.'/res00001/'.$filename;
$basename = basename($filename);
-
+
$copy_to = $CFG->dataroot.'/'.$COURSE->id.'/bb_import';
-
+
if ($this->check_dir_exists($copy_to,true)) {
if(is_readable($fullpath)) {
$copy_to.= '/'.$basename;
}
}
else {
- return false;
+ return false;
}
}
function readdata($filename) {
/// Returns complete file with an array, one item per line
global $CFG;
-
+
// if the extension is .dat we just return that,
// if .zip we unzip the file and get the data
- $ext = substr($this->realfilename, strpos($this->realfilename,'.'), strlen($this->realfilename)-1);
+ $ext = substr($this->realfilename, strpos($this->realfilename,'.'), strlen($this->realfilename)-1);
if ($ext=='.dat') {
if (!is_readable($filename)) {
- print_error('filenotreadable', 'error');
- }
+ print_error('filenotreadable', 'error');
+ }
return file($filename);
- }
-
+ }
+
$unique_code = time();
$temp_dir = $CFG->dataroot."/temp/bbquiz_import/".$unique_code;
$this->temp_dir = $temp_dir;
}
}
else {
- print_error('cannotfindquestionfile', 'questioni');
+ print_error('cannotfindquestionfile', 'questioni');
}
}
else {
print "filename: $filename<br />tempdir: $temp_dir <br />";
- print_error('cannotunzip', 'question');
+ print_error('cannotunzip', 'question');
}
}
else {
- print_error('cannotreaduploadfile');
+ print_error('cannotreaduploadfile');
}
}
else {
- print_error('cannotcreatetempdir');
+ print_error('cannotcreatetempdir');
}
}
-
+
function save_question_options($question) {
- return true;
+ return true;
}
-
-
-
+
+
+
function readquestions ($lines) {
/// Parses an array of lines into an array of questions,
/// where each item is a question object as defined by
- /// readquestion().
+ /// readquestion().
$text = implode($lines, " ");
$xml = xmlize($text, 0);
// creates a cleaner object to deal with for processing into moodle
// the object created is NOT a moodle question object
function create_raw_question($quest) {
-
+
$question = new StdClass;
$question->qtype = $quest['#']['itemmetadata'][0]['#']['bbmd_questiontype'][0]['#'];
$question->id = $quest['#']['itemmetadata'][0]['#']['bbmd_asi_object_id'][0]['#'];
$presentation->blocks = $quest['#']['presentation'][0]['#']['flow'][0]['#']['flow'];
foreach($presentation->blocks as $pblock) {
-
+
$block = NULL;
$block->type = $pblock['@']['class'];
$sub_blocks = $pblock['#']['flow'];
foreach($sub_blocks as $sblock) {
//echo "Calling process_block from line 263<br>";
- $this->process_block($sblock, $block);
+ $this->process_block($sblock, $block);
}
break;
foreach($mc_choices as $mc_choice) {
$choices = NULL;
$choices = $this->process_block($mc_choice, $choices);
- $block->choices[] = $choices;
+ $block->choices[] = $choices;
}
break;
case 'Short Response':
}
$question->{$block->type} = $block;
}
-
- // determine response processing
+
+ // determine response processing
// there is a section called 'outcomes' that I don't know what to do with
$resprocessing = $quest['#']['resprocessing'];
$respconditions = $resprocessing[0]['#']['respcondition'];
$cur_type = $cur_block['@']['class'];
switch($cur_type) {
case 'FORMATTED_TEXT_BLOCK':
- $block->text = $this->strip_applet_tags_get_mathml($cur_block['#']['material'][0]['#']['mat_extension'][0]['#']['mat_formattedtext'][0]['#']);
+ $block->text = $this->strip_applet_tags_get_mathml($cur_block['#']['material'][0]['#']['mat_extension'][0]['#']['mat_formattedtext'][0]['#']);
break;
case 'FILE_BLOCK':
//revisit this to make sure it is working correctly
- // Commented out ['matapplication']..., etc. because I
+ // Commented out ['matapplication']..., etc. because I
// noticed that when I imported a new Blackboard 6 file
// and printed out the block, the tree did not extend past ['material'][0]['#'] - CT 8/3/06
$block->file = $cur_block['#']['material'][0]['#'];//['matapplication'][0]['@']['uri'];
}
}
foreach($sub_blocks['#']['flow_mat'] as $sub_block) {
- $this->process_block($sub_block, $block);
+ $this->process_block($sub_block, $block);
}
}
else {
else {
$block->link = '';
}
- break;
- }
+ break;
+ }
return $block;
}
// Reset $cur_choice to NULL because process_block is expecting an object
// for the second argument and not a string, which is what is was set as
// originally - CT 8/7/06
- $cur_choice = null;
+ $cur_choice = null;
$this->process_block($cur_block, $cur_choice);
}
elseif (isset($choice['#']['response_label'])) {
// Reset $cur_choice to NULL because process_block is expecting an object
// for the second argument and not a string, which is what is was set as
// originally - CT 8/7/06
- $cur_choice = null;
+ $cur_choice = null;
$this->process_block($choice, $cur_choice);
}
$choices[] = $cur_choice;
- }
+ }
}
function process_matching_responses($bb_responses, &$responses) {
// gets added to the array
$response = null;
if (isset($bb_response['@']['title'])) {
- $response->title = $bb_response['@']['title'];
+ $response->title = $bb_response['@']['title'];
}
else {
$reponse->title = $bb_response['#']['displayfeedback'][0]['@']['linkrefid'];
}
$reponse->ident = array();
if (isset($bb_response['#']['conditionvar'][0]['#'])){//['varequal'][0]['#'])) {
- $response->ident[0] = $bb_response['#']['conditionvar'][0]['#'];//['varequal'][0]['#'];
+ $response->ident[0] = $bb_response['#']['conditionvar'][0]['#'];//['varequal'][0]['#'];
}
else if (isset($bb_response['#']['conditionvar'][0]['#']['other'][0]['#'])) {
- $response->ident[0] = $bb_response['#']['conditionvar'][0]['#']['other'][0]['#'];
+ $response->ident[0] = $bb_response['#']['conditionvar'][0]['#']['other'][0]['#'];
}
-
+
if (isset($bb_response['#']['conditionvar'][0]['#']['and'])){//[0]['#'])) {
$responseset = $bb_response['#']['conditionvar'][0]['#']['and'];//[0]['#']['varequal'];
foreach($responseset as $rs) {
$response->ident[] = $rs['#'];
if(!isset($response->feedback) and isset( $rs['@'] ) ) {
$response->feedback = $rs['@']['respident'];
- }
+ }
}
}
else {
- $response->feedback = $bb_response['#']['displayfeedback'][0]['@']['linkrefid'];
+ $response->feedback = $bb_response['#']['displayfeedback'][0]['@']['linkrefid'];
}
// determine what point value to give response
$response->fraction = 1;
break;
default:
- // I have only seen this being 0 or unset
+ // I have only seen this being 0 or unset
// there are probably fractional values of SCORE.max, but I'm not sure what they look like
$response->fraction = 0;
break;
// just going to assume this is the case this is probably not correct.
$response->fraction = 0;
}
-
+
$responses[] = $response;
}
}
foreach($feedbackset as $bb_feedback) {
// Added line $feedback=null so that $feedback does not get reused in the loop
// and added the the $feedbacks[] array multiple times
- $feedback = null;
+ $feedback = null;
$feedback->ident = $bb_feedback['@']['ident'];
if (isset($bb_feedback['#']['flow_mat'][0])) {
$this->process_block($bb_feedback['#']['flow_mat'][0], $feedback);
$responses = $quest->responses;
$correctresponse = $responses[0]->ident[0]['varequal'][0]['#'];
if ($correctresponse != 'false') {
- $correct = true;
+ $correct = true;
}
else {
- $correct = false;
+ $correct = false;
}
-
+
foreach($quest->feedback as $fb) {
- $fback->{$fb->ident} = $fb->text;
+ $fback->{$fb->ident} = $fb->text;
}
-
+
if ($correct) { // true is correct
$question->answer = 1;
$question->feedbacktrue = $fback->correct;
$answers = array();
$fractions = array();
$feedbacks = array();
-
+
// extract the feedback
$feedback = array();
foreach($quest->feedback as $fback) {
}
}
}
-
+
foreach($quest->responses as $response) {
if(isset($response->title)) {
if (isset($response->ident[0]['varequal'][0]['#'])) {
}
}
}
-
+
}
}
- //Adding catchall to so that students can see feedback for incorrect answers when they enter something the
+ //Adding catchall to so that students can see feedback for incorrect answers when they enter something the
//instructor did not enter
$answers[] = '*';
$fractions[] = 0;
else {
$feedbacks[] = '';
}
-
+
$question->answer = $answers;
$question->fraction = $fractions;
$question->feedback = $feedbacks; // Changed to assign $feedbacks to $question->feedback instead of
$question = $this->process_common( $quest );
$question->qtype = MULTICHOICE;
$question->single = 1;
-
+
$feedback = array();
foreach($quest->feedback as $fback) {
$feedback[$fback->ident] = $fback->text;
}
-
+
foreach($quest->responses as $response) {
if (isset($response->title)) {
if ($response->title == 'correct') {
}
else {
// failsafe feedback (should be '' instead?)
- $question->feedback[$i] = "correct";
+ $question->feedback[$i] = "correct";
}
- }
+ }
else {
$question->fraction[$i] = 0;
if (!empty($feedback['incorrect'])) {
}
}
}
-
+
foreach ($quest->feedback as $fb) {
$feedback->{$fb->ident} = trim($fb->text);
}
-
+
$correct_answer_count = count($correct_answers);
$choiceset = $quest->RESPONSE_BLOCK->choices;
$i = 0;
$question->feedback[$i] = $feedback->correct;
}
else {
- // wrong answer
+ // wrong answer
$question->fraction[$i] = 0;
$question->feedback[$i] = $feedback->incorrect;
}
// treat as short answer
$question = $this->process_common( $quest ); // copied this from process_mc
$question->qtype = ESSAY;
-
+
$question->feedback = array();
// not sure where to get the correct answer from
foreach($quest->feedback as $feedback) {
$question->feedback = $feedback->text;
}
}
- //Added because essay/questiontype.php:save_question_option is expecting a
+ //Added because essay/questiontype.php:save_question_option is expecting a
//fraction property - CT 8/10/06
- $question->fraction[] = 1;
+ $question->fraction[] = 1;
if (!empty($question)) {
$questions[]=$question;
}
$question = $this->process_common( $quest );
$question->valid = true;
$question->qtype = 'renderedmatch';
-
+
foreach($quest->RESPONSE_BLOCK->subquestions as $qid => $subq) {
foreach($quest->responses as $rid => $resp) {
if ($resp->ident == $subq->ident) {
$correct = $resp->correct;
- $feedback = $resp->feedback;
+ $feedback = $resp->feedback;
}
}
-
+
foreach($subq->choices as $cid => $choice) {
if ($choice == $correct) {
$question->subquestions[] = $subq->text;
}
}
}
-
+
// check format
$status = true;
if ( count($quest->RESPONSE_BLOCK->subquestions) > count($quest->RIGHT_MATCH_BLOCK->matching_answerset) || count($question->subquestions) < 2) {
foreach($question->subanswers as $qstn) {
if(isset($previous)) {
if ($qstn == $previous) {
- $status = false;
- }
+ $status = false;
+ }
}
$previous = $qstn;
if ($qstn == '') {
- $status = false;
+ $status = false;
}
}
}
-
+
if ($status) {
- $questions[] = $question;
+ $questions[] = $question;
}
else {
global $COURSE, $CFG;
print '<table class="boxaligncenter" border="1">';
- print '<tr><td colspan="2" style="background-color:#FF8888;">This matching question is malformed. Please ensure there are no blank answers, no two questions have the same answer, and/or there are correct answers for each question. There must be at least as many subanswers as subquestions, and at least one subquestion.</td></tr>';
-
+ print '<tr><td colspan="2" style="background-color:#FF8888;">This matching question is malformed. Please ensure there are no blank answers, no two questions have the same answer, and/or there are correct answers for each question. There must be at least as many subanswers as subquestions, and at least one subquestion.</td></tr>';
+
print "<tr><td>Question:</td><td>".$quest->QUESTION_BLOCK->text;
if (isset($quest->QUESTION_BLOCK->file)) {
print '<br/><font color="red">There is a subfile contained in the zipfile that has been copied to course files: bb_import/'.basename($quest->QUESTION_BLOCK->file).'</font>';
print "</td></tr>";
print "<tr><td>Subquestions:</td><td><ul>";
foreach($quest->responses as $rs) {
- $correct_responses->{$rs->ident} = $rs->correct;
+ $correct_responses->{$rs->ident} = $rs->correct;
}
foreach($quest->RESPONSE_BLOCK->subquestions as $subq) {
print '<li>'.$subq->text.'<ul>';
print '</ul>';
}
print '</ul></td></tr>';
-
+
print '<tr><td>Feedback:</td><td><ul>';
foreach($quest->feedback as $fb) {
print '<li>'.$fb->ident.': '.$fb->text.'</li>';
function strip_applet_tags_get_mathml($string) {
if(stristr($string, '</APPLET>') === FALSE) {
- return $string;
+ return $string;
}
else {
// strip all applet tags keeping stuff before/after and inbetween (if mathml) them
preg_match("/(.*)\<applet.*value=\"(\<math\>.*\<\/math\>)\".*\<\/applet\>(.*)/i",$string, $mathmls);
$string = $mathmls[1].$mathmls[2].$mathmls[3];
}
- return $string;
+ return $string;
}
}
} // close object
-?>
+
-<?php // $Id$
+<?php
// Based on default.php, included by ../import.php
/**
}
// end class
-?>
+
=subquestion2 -> subanswer2
=subquestion3 -> subanswer3
}
-
+
Match the following countries with their corresponding capitals. {
=Canada -> Ottawa
=Italy -> Rome
=1822:0
=%50%1822:2}
-// OPTIONS
+// OPTIONS
// ===Line Comments===
::Kanji Origins::Japanese characters originally
came from what country? {=China}
-::Thanksgiving Date::The American holiday of Thanksgiving is
+::Thanksgiving Date::The American holiday of Thanksgiving is
celebrated on the {~second ~third =fourth} Thursday of November.
// ===Feedback===
~wrong answer#feedback comment on the wrong answer
~another wrong answer#feedback comment on this wrong answer
=right answer#Very good!}
-
+
Who's buried in Grant's tomb?{
=no one#excellent answer!
=nobody#excellent answer!}
Grant is buried in Grant's tomb.{FALSE#No one is buried in Grant's tomb.}
Difficult question.{~wrong answer ~%50%half credit answer =full credit answer}
-
+
::Jesus' hometown::Jesus Christ was from {
~Jerusalem#This was an important city, but the wrong answer.
~%25%Bethlehem#He was born here, but not raised here.
~%50%Galilee#You need to be more specific.
=Nazareth#Yes! That's right!}.
-
+
::Jesus' hometown:: Jesus Christ was from {
=Nazareth#Yes! That's right!
=%75%Nazereth#Right, but misspelled.
-<?php // $Id$
+<?php
//
///////////////////////////////////////////////////////////////
-// The GIFT import filter was designed as an easy to use method
+// The GIFT import filter was designed as an easy to use method
// for teachers writing questions as a text file. It supports most
// question types and the missing word format.
//
// Match the following countries with their corresponding
// capitals.{=Canada->Ottawa =Italy->Rome =Japan->Tokyo}
//
-// Comment lines start with a double backslash (//).
-// Optional question names are enclosed in double colon(::).
+// Comment lines start with a double backslash (//).
+// Optional question names are enclosed in double colon(::).
// Answer feedback is indicated with hash mark (#).
// Percentage answer weights immediately follow the tilde (for
// multiple choice) or equal sign (for short answer and numerical),
// and are enclosed in percent signs (% %). See docs and examples.txt for more.
-//
-// This filter was written through the collaboration of numerous
-// members of the Moodle community. It was originally based on
+//
+// This filter was written through the collaboration of numerous
+// members of the Moodle community. It was originally based on
// the missingword format, which included code from Thomas Robb
// and others. Paul Tsuchido Shew wrote this filter in December 2003.
//////////////////////////////////////////////////////////////////////////
}
return $feedback;
}
-
+
function escapedchar_pre($string) {
//Replaces escaped control characters with a placeholder BEFORE processing
-
+
$escapedcharacters = array("\\:", "\\#", "\\=", "\\{", "\\}", "\\~", "\\n" ); //dlnsk
$placeholders = array("&&058;", "&&035;", "&&061;", "&&123;", "&&125;", "&&126;", "&&010" ); //dlnsk
$question = $this->defaultquestion();
$comment = NULL;
// define replaced by simple assignment, stop redefine notices
- $gift_answerweight_regex = "/^%\-*([0-9]{1,2})\.?([0-9]*)%/";
+ $gift_answerweight_regex = "/^%\-*([0-9]{1,2})\.?([0-9]*)%/";
// REMOVED COMMENTED LINES and IMPLODE
foreach ($lines as $key => $line) {
$question->category = $newcategory;
return $question;
}
-
+
// QUESTION NAME parser
if (substr($text, 0, 2) == "::") {
$text = substr($text, 2);
$questiontext = substr( $questiontext, $rh_brace+1 );
if (!$questiontextformat = text_format_name( $qtformat )) {
$questiontext = $oldquestiontext;
- }
+ }
}
$question->questiontextformat = $questiontextformat;
$question->questiontext = trim($this->escapedchar_post($questiontext));
} elseif (strpos($answertext, "~") !== false) {
// only Multiplechoice questions contain tilde ~
$question->qtype = MULTICHOICE;
-
- } elseif (strpos($answertext, "=") !== false
+
+ } elseif (strpos($answertext, "=") !== false
&& strpos($answertext, "->") !== false) {
// only Matching contains both = and ->
$question->qtype = MATCH;
} else { // either TRUEFALSE or SHORTANSWER
-
+
// TRUEFALSE question check
$truefalse_check = $answertext;
- if (strpos($answertext,"#") > 0){
+ if (strpos($answertext,"#") > 0){
// strip comments to check for TrueFalse question
$truefalse_check = trim(substr($answertext, 0, strpos($answertext,"#")));
}
break;
case MULTICHOICE:
if (strpos($answertext,"=") === false) {
- $question->single = 0; // multiple answers are enabled if no single answer is 100% correct
+ $question->single = 0; // multiple answers are enabled if no single answer is 100% correct
} else {
$question->single = 1; // only one answer allowed (the default)
}
if (empty($answers[0])) {
array_shift($answers);
}
-
+
$countanswers = count($answers);
-
+
if (!$this->check_answer_count( 2,$answers,$text )) {
return false;
break;
if ($answer[0] == "=") {
$answer_weight = 1;
$answer = substr($answer, 1);
-
+
} elseif (preg_match($gift_answerweight_regex, $answer)) { // check for properly formatted answer weight
$answer_weight = $this->answerweightparser($answer);
-
+
} else { //default, i.e., wrong anwer
$answer_weight = 0;
}
$question->partiallycorrectfeedback = '';
$question->incorrectfeedback = '';
} // end foreach answer
-
+
//$question->defaultgrade = 1;
//$question->image = ""; // No images with this format
return $question;
if (empty($answers[0])) {
array_shift($answers);
}
-
+
if (!$this->check_answer_count( 2,$answers,$text )) {
return false;
break;
}
-
+
foreach ($answers as $key => $answer) {
$answer = trim($answer);
if (strpos($answer, "->") === false) {
$question->subanswers[$key] = trim($this->escapedchar_post(substr($answer, $marker+2)));
} // end foreach answer
-
+
return $question;
break;
-
+
case TRUEFALSE:
$answer = $answertext;
$comment = $this->commentparser($answer); // commentparser also removes comment from $answer
return $question;
break;
-
+
case SHORTANSWER:
// SHORTANSWER Question
$answers = explode("=", $answertext);
if (empty($answers[0])) {
array_shift($answers);
}
-
+
if (!$this->check_answer_count( 1,$answers,$text )) {
return false;
break;
if (empty($answers[0])) {
array_shift($answers);
}
-
+
if (count($answers) == 0) {
// invalid question
$giftnonumericalanswers = get_string('giftnonumericalanswers','quiz');
$tol = 0;
$ans = trim($answer);
}
-
+
if (!(is_numeric($ans) || $ans = '*') || !is_numeric($tol)) {
$errornotnumbers = get_string( 'errornotnumbers' );
$this->error( $errornotnumbers, $text );
return false;
break;
}
-
+
// store results
$question->answer[$key] = $ans;
$question->tolerance[$key] = $tol;
$giftnovalidquestion = get_string('giftnovalidquestion','quiz');
$this->error( $giftnovalidquestion, $text );
return false;
- break;
-
+ break;
+
} // end switch ($question->qtype)
} // end function readquestion($lines)
$reserved = array( '#', '=', '~', '{', '}', ':', "\n","\r");
$escaped = array( '\#','\=','\~','\{','\}','\:','\n','' ); //dlnsk
- $newtext = str_replace( $reserved, $escaped, $text );
+ $newtext = str_replace( $reserved, $escaped, $text );
$format = 0; // turn this off for now
if ($format) {
$newtext = format_text( $format );
switch($question->qtype) {
case 'category':
// not a real question, used to insert category switch
- $expout .= "\$CATEGORY: $question->category\n";
+ $expout .= "\$CATEGORY: $question->category\n";
break;
case DESCRIPTION:
$expout .= '::'.$this->repchar($question->name).'::';
return $expout;
}
}
-?>
+
-<?PHP // $Id$
+<?php
////////////////////////////////////////////////////////////////////////////
/// Hotpotatoes 5.0 and 6.0 Format
///
break;
default:
// shouldn't happen !!
- $courseid = 0;
+ $courseid = 0;
}
require_once($CFG->libdir.'/filelib.php');
$baseurl = get_file_url($courseid).'/';
$gap_count ++;
$positionkey = $q+1;
$question->questiontext .= '{#'.$positionkey.'}';
-
+
// initialize answer settings
$wrapped = new stdClass();
$wrapped->qtype = SHORTANSWER;
$wrapped->fraction = array();
$wrapped->feedback = array();
$answers = array();
-
+
// add answers
$a = 0;
while (($answer=$question_record."['answer'][$a]['#']") && $xml->xml_value($tags, $answer)) {
$a++;
}
if ($correct_answers_all_zero) {
- // correct answers all have score of 0%,
+ // correct answers all have score of 0%,
// so reset score for correct answers 100%
foreach ($correct_answers as $aa) {
$question->fraction[$aa] = 1;
-<?php // $Id$
+<?php
// Alton College, Hampshire, UK - Tom Flannaghan, Andrew Walker
// Imports learnwise multiple choice quizzes (single and multiple answers)
// currently ignores the deduct attribute for multiple answer questions
-// deductions are currently simply found by dividing the award for the incorrect
+// deductions are currently simply found by dividing the award for the incorrect
// answer by the total number of options
// Based on format.php, included by ../../import.php
/**
foreach ($optionlist as $option) {
$correct = $this->stringbetween($option, ' correct="', '">');
$answer = $this->stringbetween($option, '">', '</option>');
- $optionscorrect[$n] = $correct;
+ $optionscorrect[$n] = $correct;
$optionstext[$n] = $this->unhtmlentities($answer);
++$n;
}
$answer = $this->stringbetween($option, '">', '</option>');
- $optionscorrect[$n] = $correct;
+ $optionscorrect[$n] = $correct;
$optionstext[$n] = $this->unhtmlentities($answer);
$optionsaward[$n] = $award;
++$n;
if ($optionstext[$n]) {
if (!isset($numcorrect)) { // single answer
if ($optionscorrect[$n] == 'yes') {
- $fraction = (int) $questionaward;
+ $fraction = (int) $questionaward;
} else {
$fraction = 0;
- }
+ }
} else { // mulitple answers
if ($optionscorrect[$n] == 'yes') {
- $fraction = $optionsaward[$n] / $totalaward;
+ $fraction = $optionsaward[$n] / $totalaward;
} else {
$fraction = -$optionsaward[$n] / count($optionstext);
}
$transtable = get_html_translation_table(HTML_ENTITIES);
$transtable = array_flip($transtable);
return strtr($string, $transtable);
- }
+ }
}
-?>
+
-<?php // $Id$
+<?php
/// Modified by Tom Robb 12 June 2003 to include percentage and comment insertion
/// facility.
////////////////////////////////////////////////////////////////////////////
/// MISSING WORD FORMAT
///
-/// This Moodle class provides all functions necessary to import and export
+/// This Moodle class provides all functions necessary to import and export
/// one-correct-answer multiple choice questions in this format:
///
/// As soon as we begin to explore our body parts as infants
-/// we become students of {=anatomy and physiology ~reflexology
+/// we become students of {=anatomy and physiology ~reflexology
/// ~science ~experiment}, and in a sense we remain students for life.
-///
-/// Each answer is separated with a tilde ~, and the correct answer is
+///
+/// Each answer is separated with a tilde ~, and the correct answer is
/// prefixed with an equals sign =
///
/// Percentage weights can be included by following the tilde with the
}
function readquestion($lines) {
- /// Given an array of lines known to define a question in
- /// this format, this function converts it into a question
+ /// Given an array of lines known to define a question in
+ /// this format, this function converts it into a question
/// object suitable for processing and insertion into Moodle.
$question = $this->defaultquestion();
$question->answer[] = $answer;
$question->fraction[] = 1;
$question->feedback[] = "";
-
+
return $question;
default:
$answeight = round(($answeight0/100),2);
$answer = substr($answer,(strspn($answer,"1234567890%")));
}
- }
+ }
if ($answer[0] == "="){
$answeight = 1;
}
$question->answer[$key] = $answer;
$question->feedback[$key] = $comment;
}
-
+
return $question;
}
}
}
-?>
+
-<?php // $Id$
+<?php
////////////////////////////////////////////////////////////////////////////
/// MULTIANSWER FORMAT
if (!empty($thequestion)) {
$thequestion->name = $lines[0];
-
+
$questions[] = $thequestion;
}
}
}
-?>
+
-<?php // $id$
+<?php
// note: modified from the original filter/mediaplugin/filter.php
$replace .= ' pluginspage="http://www.macromedia.com/go/getflashplayer">';
$replace .= '</embed>';
$replace .= '</object> ';
-
+
$text = preg_replace($search, $replace, $text);
}
$replace .= ' pluginspage="http://www.macromedia.com/go/getflashplayer">';
$replace .= '</embed>';
$replace .= '</object></p>';*/
-
+
$text = preg_replace($search, $replace, $text);
}
$width = 240;
$height = 180;
}
-
+
if (empty($CFG->filter_mediaplugin_ignore_mpg)) {
$search = '/<a(.*?)href=\"([^<]+)\.(mpe?g)\"([^>]*)>(.*?)<\/a>/i';
$replace .= '<param name="autoplay" value="false">';
$replace .= '<embed src="\\2.\\3" width="' . $width . '" height="' . $height . '" controller="true" autoplay="false"> </embed>';
$replace .= '</object></p>';
-
+
$text = preg_replace($search, $replace, $text);
}
$replace .= '<param name="autoplay" value="false">';
$replace .= '<embed src="\\2.avi" width="' . $width . '" height="' . $height . '" controller="true" autoplay="false"> </embed>';
$replace .= '</object> ';
-
+
$text = preg_replace($search, $replace, $text);
}
return $text;
}
-?>
+
-<?php // $Id$
+<?php
require_once("$CFG->dirroot/question/format/qti_two/qt_common.php");
////////////////////////////////////////////////////////////////////////////
}
-?>
+
*
* @param int courseid
* @return array containing filenames
- * @calledfrom type/<typename>/editquestion.php
+ * @calledfrom type/<typename>/editquestion.php
* @package questionbank
* @subpackage importexport
*/
-function get_course_media_files($courseid)
+function get_course_media_files($courseid)
{
// this code lifted from mod/quiz/question.php and modified
global $CFG;
$images = null;
-
+
make_upload_directory("$course->id"); // Just in case
$coursefiles = get_directory_list("$CFG->dataroot/$courseid", $CFG->moddata);
foreach ($coursefiles as $filename) {
}
}
return $images;
-}
+}
/**
* determines whether or not a file is an image, based on the file extension
* @param string $file the filename
* @param string $courseid the course id
* @param string $alt to specify the alt tag
- * @return string either an image tag, or html for an embedded object
+ * @return string either an image tag, or html for an embedded object
*/
function get_media_tag($file, $courseid = 0, $alt = 'media file', $width = 0, $height = 0) {
global $CFG;
if (!$isimage = is_image_by_extension($file)) {
$ismultimedia = is_multimedia_by_extension($file);
}
-
+
// if there is no known width and height, try to get one
if ($width == 0) {
if ($isimage || is_sizable_multimedia($file)) {
-
+
}
-
- }
+
+ }
// create either an image link or a generic link.
// if the moodle multimedia filter is turned on, it'll catch multimedia content in the generic link
if (is_image_by_extension($file)) {
/**
* determines the x and y size of the given file
*
- * @param string $file the filename
+ * @param string $file the filename
* @return array looks like array('x'=>171, 'y'=>323), or array('x'=>0, 'y'=>0) if size can't be determined
*/
function get_file_dimensions($file) {
}
}
-?>
+
<div class="intreactive.choiceSimple">
<choiceInteraction responseIdentifier="{$questionid}" shuffle="false" maxChoices="1">
{section name=answer loop=$answers}
- <simpleChoice identifier="{$answers[answer].id}">{$answers[answer].answer}
+ <simpleChoice identifier="{$answers[answer].id}">{$answers[answer].answer}
{if $answers[answer].feedback != ''}
{if $answers[answer].answer != $correctresponse.answer}
<feedbackInline identifier="{$answers[answer].id}" outcomeIdentifier="FEEDBACK" showHide="hide">{$answers[answer].feedback}</feedbackInline>
{if $hassize == 1}
<object type="{$question->mediamimetype}" data="{$question->mediaurl}" width="{$question->mediax}" height="{$question->mediay}" />
{else}
- <object type="{$question->mediamimetype}" data="{$question->mediaurl}" />
+ <object type="{$question->mediamimetype}" data="{$question->mediaurl}" />
{/if}
</div>
{/if}
{if $hassize == 1}
<object type="{$question->mediamimetype}" data="{$question->mediaurl}" width="{$question->mediax}" height="{$question->mediay}" />
{else}
- <object type="{$question->mediamimetype}" data="{$question->mediaurl}" />
+ <object type="{$question->mediamimetype}" data="{$question->mediaurl}" />
{/if}
</div>
{/if}
<div class="interactive.choiceMultiple">
<choiceInteraction responseIdentifier="{$questionid}" shuffle="{$shuffle}" maxChoices="{$maxChoices}">
{section name=answer loop=$answers}
- <simpleChoice identifier="i{$answers[answer].id}">{$answers[answer].answer}
+ <simpleChoice identifier="i{$answers[answer].id}">{$answers[answer].answer}
{if $answers[answer].feedback != ''}
{if $answers[answer].answer != $correctresponse.answer}
<feedbackInline identifier="i{$answers[answer].id}" outcomeIdentifier="FEEDBACK" showHide="show">{$answers[answer].feedback}</feedbackInline>
</choiceInteraction>
</div>
</itemBody>
- <responseProcessing>
+ <responseProcessing>
{section name=answer loop=$answers}
<responseCondition>
<responseIf>
{if $hassize == 1}
<object type="{$question->mediamimetype}" data="{$question->mediaurl}" width="{$question->mediax}" height="{$question->mediay}" />
{else}
- <object type="{$question->mediamimetype}" data="{$question->mediaurl}" />
+ <object type="{$question->mediamimetype}" data="{$question->mediaurl}" />
{/if}
</div>
{/if}
{if $answers[answer].subanswers[subanswer].feedback != ''}
<modalFeedback outcomeIdentifier="FEEDBACK" identifier="{$answers[answer].subanswers[subanswer].id}" showHide="show">{$answers[answer].subanswers[subanswer].feedback}</modalFeedback>
{/if}{/section}
- {/if}
+ {/if}
{/section}
</assessmentItem>
{if $hassize == 1}
<object type="{$question->mediamimetype}" data="{$question->mediaurl}" width="{$question->mediax}" height="{$question->mediay}" />
{else}
- <object type="{$question->mediamimetype}" data="{$question->mediaurl}" />
+ <object type="{$question->mediamimetype}" data="{$question->mediaurl}" />
{/if}
</div>
{/if}
{if $hassize == 1}
<object type="{$question->mediamimetype}" data="{$question->mediaurl}" width="{$question->mediax}" height="{$question->mediay}" />
{else}
- <object type="{$question->mediamimetype}" data="{$question->mediaurl}" />
+ <object type="{$question->mediamimetype}" data="{$question->mediaurl}" />
{/if}
</div>
{/if}
<metadata>
<schema>ADL SCORM</schema>
<schemaversion>1.2</schemaversion>
- <lom xmlns="http://www.imsglobal.org/xsd/imsmd_v1p2"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ <lom xmlns="http://www.imsglobal.org/xsd/imsmd_v1p2"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.imsglobal.org/xsd/imsmd_v1p2 imsmd_v1p2p2.xsd">
<general>
<title><langstring xml:lang="{$lang}">{$quiztitle}</langstring></title>
{if $hassize == 1}
<object type="{$question->mediamimetype}" data="{$question->mediaurl}" width="{$question->mediax}" height="{$question->mediay}" />
{else}
- <object type="{$question->mediamimetype}" data="{$question->mediaurl}" />
+ <object type="{$question->mediamimetype}" data="{$question->mediaurl}" />
{/if}
</div>
{/if}
{if $hassize == 1}
<object type="{$question->mediamimetype}" data="{$question->mediaurl}" width="{$question->mediax}" height="{$question->mediay}" />
{else}
- <object type="{$question->mediamimetype}" data="{$question->mediaurl}" />
+ <object type="{$question->mediamimetype}" data="{$question->mediaurl}" />
{/if}
</div>
{/if}
{if $hassize == 1}
<object type="{$question->mediamimetype}" data="{$question->mediaurl}" width="{$question->mediax}" height="{$question->mediay}" />
{else}
- <object type="{$question->mediamimetype}" data="{$question->mediaurl}" />
+ <object type="{$question->mediamimetype}" data="{$question->mediaurl}" />
{/if}
</div>
{/if}
{if $hassize == 1}
<object type="{$question->mediamimetype}" data="{$question->mediaurl}" width="{$question->mediax}" height="{$question->mediay}" />
{else}
- <object type="{$question->mediamimetype}" data="{$question->mediaurl}" />
+ <object type="{$question->mediamimetype}" data="{$question->mediaurl}" />
{/if}
</div>
{/if}
{if $hassize == 1}
<object type="{$question->mediamimetype}" data="{$question->mediaurl}" width="{$question->mediax}" height="{$question->mediay}" />
{else}
- <object type="{$question->mediamimetype}" data="{$question->mediaurl}" />
+ <object type="{$question->mediamimetype}" data="{$question->mediaurl}" />
{/if}
</div>
{/if}
-<?php // $Id$
+<?php
///////////////////////////////////////////////////////////////////////////
// //
// WebCT FORMAT //
$QuestionOK = FALSE;
}
else {
- // Create empty feedback array
+ // Create empty feedback array
foreach ($question->answer as $key => $dataanswer) {
if(!isset( $question->feedback[$key])){
$question->feedback[$key] = '';
if (isset($question->tempgeneralfeedback)){
if (isset($question->generalfeedback)) {
$question->generalfeedback = $question->tempgeneralfeedback;
- } else {
+ } else {
foreach ($question->answer as $key => $dataanswer) {
if ($question->tempgeneralfeedback !=''){
$question->feedback[$key] = $question->tempgeneralfeedback.'<br/>'.$question->feedback[$key];
}
}
}
- unset($question->tempgeneralfeedback);
- }
+ unset($question->tempgeneralfeedback);
+ }
$maxfraction = -1;
$totalfraction = 0;
foreach($question->fraction as $fraction) {
}
} else {
$totalfraction = round($totalfraction,2);
- if ($totalfraction != 1) {
+ if ($totalfraction != 1) {
$totalfraction = $totalfraction * 100;
$errors[] = "'$question->name': ".get_string("wronggrade", "quiz", $nLineCounter).' '.get_string("fractionsaddwrong", "quiz", $totalfraction);
$QuestionOK = FALSE;
foreach ($question->subquestions as $id=>$subquestion) {
$temp = $question->subquestions[$id];
$question->subquestions[$id] = $question->subanswers[$id];
- $question->subanswers[$id] = $temp;
+ $question->subanswers[$id] = $temp;
}
if (count($question->answer) < 3){
// add a dummy missing question
$question->name = 'Dummy question added '.$question->name ;
$question->answer[] = 'dummy';
$question->subanswers[] = 'dummy';
- $question->subquestions[] = 'dummy';
+ $question->subquestions[] = 'dummy';
$question->fraction[] = '0.0';
$question->feedback[] = '';
- }
- break;
+ }
+ break;
default:
// No problemo
}
}
- if ($QuestionOK) {
+ if ($QuestionOK) {
// echo "<pre>"; print_r ($question);
$questions[] = $question; // store it
unset($question); // and prepare a new one
// if question isn't defined yet there is nothing to do here (avoid notices)
if (!isset($question)) {
continue;
- }
+ }
if (isset($question->qtype ) && CALCULATED == $question->qtype && preg_match(
"~^:([[:lower:]].*|::.*)-(MIN|MAX|DEC|VAL([0-9]+))::?:?($webctnumberregex)~", $line, $webct_options)) {
$datasetname = preg_replace('/^::/', '', $webct_options[1]);
foreach ($datasetnames as $datasetname) {
$question->dataset[$datasetname] = new stdClass();
$question->dataset[$datasetname]->datasetitem = array();
- $question->dataset[$datasetname]->name = $datasetname ;
- $question->dataset[$datasetname]->distribution = 'uniform';
+ $question->dataset[$datasetname]->name = $datasetname ;
+ $question->dataset[$datasetname]->distribution = 'uniform';
$question->dataset[$datasetname]->status ='private';
}
continue;
if (preg_match("~^:L([0-9]+)~i",$line,$webct_options)) {
$answertext=""; // Start gathering next lines
$currentchoice=$webct_options[1];
- $question->fraction[$currentchoice]=1;
+ $question->fraction[$currentchoice]=1;
continue;
}
continue;
}
if (preg_match('~^:LAYOUT:(.*)~i',$line,$webct_options)) {
- // ignore since layout in question_multichoice is no more used in moodle
+ // ignore since layout in question_multichoice is no more used in moodle
// $webct_options[1] contains either vertical or horizontal ;
continue;
}
-<?php
+<?php
// Based on default.php, included by ../import.php
/**
* @package questionbank
$reserved = array( '#','=','~','{','}',"\n","\r" );
$escaped = array( '\#','\=','\~','\{','\}',' ','' );
- return str_replace( $reserved, $escaped, $text );
+ return str_replace( $reserved, $escaped, $text );
}
function writequestion( $question ) {
// add header
$expout .= "<h3>$question->name</h3>\n";
-
+
// format and add question text
$questiontext = $question->questiontext;
$format = $question->questiontextformat;
$formatted_text = format_text( $questiontext, $format );
- $expout .= "<p class=\"questiontext\">$formatted_text</p>\n";
+ $expout .= "<p class=\"questiontext\">$formatted_text</p>\n";
// selection depends on question type
switch($question->qtype) {
$ans_list = array();
foreach($question->options->subquestions as $subquestion) {
$ans_list[] = $this->repchar( $subquestion->answertext );
- }
+ }
shuffle( $ans_list ); // random display order
-
+
// build drop down for answers
$dropdown = "<select name=\"quest_$id\">\n";
foreach($ans_list as $ans) {
default:
echo $OUTPUT->notification("No handler for qtype $question->qtype for GIFT export" );
}
- // close off div
+ // close off div
$expout .= "</div>\n\n\n";
return $expout;
}
// get css bit
$css_lines = file( "$CFG->dirroot/question/format/xhtml/xhtml.css" );
- $css = implode( ' ',$css_lines );
+ $css = implode( ' ',$css_lines );
$xp = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n";
$xp .= " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n";
}
}
-?>
+
background-color: #fff;
color: #000;
}
-
+
.question {
border: 1px solid #ddd;
margin: 5px;
padding: 3px;
- }
-
+ }
+
.question h3 {
font-weight: normal;
font-size: 125%;
- }
-
+ }
+
.question ul {
list-style-type: none;
- }
+ }
</style>
-<?php // $Id$
+<?php
//
///////////////////////////////////////////////////////////////
// XML import/export
-<?php // $Id$
+<?php
/**
* Import quiz questions into the given category
*
$import_form->display();
echo $OUTPUT->footer();
-?>
+
-<?php //$Id$
+<?php
require_once($CFG->libdir.'/formslib.php');
$radioelement->setHelpButton(array("$shortname",$fileformatname,"qformat_$shortname"));
$radioarray[] = $radioelement;
}
- $mform->addGroup($radioarray,'format', '', array('<br />'), false);
+ $mform->addGroup($radioarray,'format', '', array('<br />'), false);
$mform->addRule('format', null, 'required', null, 'client' );
//--------------------------------------------------------------------------------
$mform->addElement('header','general', get_string('general', 'form'));
//--------------------------------------------------------------------------------
$mform->addElement('static', 'dummy', '');
$mform->closeHeaderBefore('dummy');
-
- // set a template for the format select elements
+
+ // set a template for the format select elements
$renderer =& $mform->defaultRenderer();
$template = "{help} {element}\n";
$renderer->setGroupElementTemplate($template, 'format');
return NULL;
}
}
-
+
function get_importfile_realname(){
if ($this->is_submitted() and $this->is_validated()) {
// return the temporary filename to process
}
}
}
-?>
+
-<?php //$Id$
+<?php
require_once($CFG->libdir.'/formslib.php');
$mform->setType('delete', PARAM_INT);
}
}
-?>
+
-<?php // $Id$
+<?php
/**
* This page displays a preview of a question
*
echo '</div>';
echo '</form>';
echo $OUTPUT->footer();
-?>
+
-<?php // $Id$
+<?php
/**
* Page for editing questions using the new form library.
*
}
$question = $QTYPES[$question->qtype]->save_question($question, $fromform, $COURSE, $wizardnow, true);
- // a wizardpage from multipe pages questiontype like calculated may not allow editing the question tags
+ // a wizardpage from multipe pages questiontype like calculated may not allow editing the question tags
if (!empty($CFG->usetags) && isset($fromform->tags)) {
require_once($CFG->dirroot.'/tag/lib.php');
tag_set('question', $question->id, $fromform->tags);
$QTYPES[$question->qtype]->display_question_editing_page($mform, $question, $wizardnow);
echo $OUTPUT->footer();
}
-?>
+
-<?php // $Id$
+<?php
/**
* Question bank restore code.
*
// need to check as old questions don't have calculated_options record
if(isset($info['#']['NUMERICAL_OPTIONS'])){
$numerical_options = $info['#']['numerical_OPTIONS'];
-
+
//Iterate over numerical_options
for($i = 0; $i < sizeof($numerical_options); $i++){
$num_info = $numerical_options[$i];
//traverse_xmlize($cal_info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
-
+
//Now, build the question_numerical_options record structure
$numerical_options->questionid = $new_question_id;
$numerical_options->instructions = backup_todb($num_info['#']['INSTRUCTIONS']['0']['#']);
$numerical_options->unitsleft = backup_todb($num_info['#']['UNITSLEFT']['0']['#']);
$numerical_options->unitgradingtype = backup_todb($num_info['#']['UNITGRADINGTYPE']['0']['#']);
$numerical_options->unitpenalty = backup_todb($num_info['#']['UNITPENALTY']['0']['#']);
-
+
//The structure is equal to the db, so insert the question_numerical__options
$newid = $DB->insert_record ("question_numerical__options",$numerical__options);
-
+
//Do some output
if (($i+1) % 50 == 0) {
if (!defined('RESTORE_SILENTLY')) {
return $status;
}
-?>
+
-<?php // $Id$
+<?php
/**
* Sets up the tabs used by the question bank editing page
*
print_tabs($tabs, $currenttab, array());
-?>
+
-<?php // $Id$
+<?php
/**
* Used by ajax calls to toggle the flagged state of a question in an attempt.
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
}
// Check the checksum - it is very hard to know who a question session belongs
-// to, so we require that checksum parameter is matches an md5 hash of the
+// to, so we require that checksum parameter is matches an md5 hash of the
// three ids and the users username. Since we are only updating a flag, that
// probably makes it sufficiently difficult for malicious users to toggle
// other users flags.
}
echo 'OK';
-?>
\ No newline at end of file
$mform->addElement('hidden', 'category');
$mform->setType('category', PARAM_RAW);
$mform->setDefault('category', array('contexts' => array($this->categorycontext)));
-
+
$mform->addElement('hidden', 'courseid');
$mform->setType('courseid', PARAM_INT);
$mform->setDefault('courseid', 0);
}
}
-?>
+
public $regenerate;
public $noofitems;
-
+
public $outsidelimit = false ;
-
+
public $commentanswers = array();
/**
* Add question-type specific form fields.
$mform->addElement('submit', 'updateanswers', get_string('updatetolerancesparam', 'qtype_datasetdependent'));
$mform->setAdvanced('updateanswers',true);
$mform->registerNoSubmitButton('updateanswers');
-
+
$answers = fullclone($this->question->options->answers);
$key1 =1;
foreach ($answers as $key => $answer) {
$mform->setAdvanced('tolerance['.$key.']',true);
$mform->addElement('select', 'tolerancetype['.$key.']', get_string('tolerancetype', 'quiz'), $this->qtypeobj->tolerance_types());
$mform->setAdvanced('tolerancetype['.$key.']',true);
-
+
$mform->addElement('select', 'correctanswerlength['.$key.']', get_string('correctanswershows', 'qtype_calculated'), range(0, 9));
$mform->setAdvanced('correctanswerlength['.$key.']',true);
-
+
$answerlengthformats = array('1' => get_string('decimalformat', 'quiz'), '2' => get_string('significantfiguresformat', 'quiz'));
$mform->addElement('select', 'correctanswerformat['.$key.']', get_string('correctanswershowsformat', 'qtype_calculated'), $answerlengthformats);
$mform->setAdvanced('correctanswerformat['.$key.']',true);
$mform->setAdvanced('dividertolerance',true);
}
$key1++;
- }
+ }
$addremoveoptions = array();
$addremoveoptions['1']='1';
$mform->addElement('hidden', 'category');
$mform->setType('category', PARAM_RAW);
$mform->setDefault('category', array('contexts' => array($this->categorycontext)));
-
+
$mform->addElement('hidden', 'cmid');
$mform->setType('cmid', PARAM_INT);
$mform->setDefault('cmid', 0);
if( is_array($fromform->correctanswerformat[$key])) $fromform->correctanswerformat[$key]= $fromform->correctanswerformat[$key][0];
$answer->correctanswerformat = $fromform->correctanswerformat[$key];
}
- $this->qtypeobj->save_question_calculated($question,$fromform);
- }else {
+ $this->qtypeobj->save_question_calculated($question,$fromform);
+ }else {
foreach ($answers as $key => $answer){
-
+
$formdata['tolerance['.$key.']'] = $answer->tolerance;
$formdata['tolerancetype['.$key.']'] = $answer->tolerancetype;
$formdata['correctanswerlength['.$key.']'] = $answer->correctanswerlength;
$errors = array();
if (isset($data['backtoquiz']) && ($this->noofitems==0) ){
$errors['warning'] = get_string('warning', 'mnet');
- }
+ }
if ($this->outsidelimit){
// if(!isset($errors['warning'])) $errors['warning']=' ';
$errors['outsidelimits'] = get_string('oneanswertrueansweroutsidelimits','qtype_calculated');
if(! is_numeric($number)){
if (stristr($number,',')){
$errors['number['.$key.']'] = get_string('The , cannot be used, use . as in 0.013 or 1.3e-2', 'qtype_datasetdependent');
- }else {
+ }else {
$errors['number['.$key.']'] = get_string('This is not a valid number', 'qtype_datasetdependent');
}
}else if( stristr($number,'x')){
$errors['number['.$key.']'] = get_string('Hexadecimal format (i.e. 0X12d) is not allowed', 'qtype_datasetdependent');
} else if( is_nan($number)){
$errors['number['.$key.']'] = get_string('is a NAN number', 'qtype_datasetdependent');
- }
+ }
}
return $errors;
}
}
-?>
+
-<?php // $Id$
+<?php
-// This file keeps track of upgrades to
+// This file keeps track of upgrades to
// the calculated qtype plugin
//
// Sometimes, changes between versions involve
}
upgrade_plugin_savepoint($result, 2009092000, 'qtype', 'calculated');
-
+
}
-
+
/// calculated savepoint reached
/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
/// $result = result of database_manager methods
return $result;
}
-?>
+
-<?php // $Id$
+<?php
/**
* Defines the editing form for the calculated question type.
*
}else {
$addrepeated[] =& $mform->createElement('text', 'tolerance', get_string('tolerance', 'qtype_calculated'));
$addrepeated[] =& $mform->createElement('select', 'tolerancetype', get_string('tolerancetype', 'quiz'), $this->qtypeobj->tolerance_types());
- }
+ }
$repeatedoptions['tolerance']['type'] = PARAM_NUMBER;
$repeatedoptions['tolerance']['default'] = 0.01;
$addrepeated[] =& $mform->createElement('select', 'correctanswerformat', get_string('correctanswershowsformat', 'qtype_calculated'), $answerlengthformats);
array_splice($repeated, 3, 0, $addrepeated);
if ($this->editasmultichoice == 1){
- $repeated[1]->setLabel('...<strong>{={x}+..}</strong>...');
+ $repeated[1]->setLabel('...<strong>{={x}+..}</strong>...');
}else {
$repeated[1]->setLabel(get_string('correctanswerformula', 'quiz').'=');
function definition_inner(&$mform) {
global $QTYPES;
$this->qtypeobj =& $QTYPES[$this->qtype()];
- // echo code left for testing period
+ // echo code left for testing period
// echo "<p>question ".optional_param('multichoice', '', PARAM_RAW)." optional<pre>";print_r($this->question);echo "</pre></p>";
$label = get_string("sharedwildcards", "qtype_datasetdependent");
$mform->addElement('hidden', 'initialcategory', 1);
$mform->registerNoSubmitButton($addfieldsname);
$this->editasmultichoice = 0 ;
if ( isset($this->question->options->multichoice) && $this->question->options->multichoice == '1'){
- $this->editasmultichoice = 1 ;
+ $this->editasmultichoice = 1 ;
}else {
if ( !isset($this->question->id ) && 1 == optional_param('multichoice', '', PARAM_RAW )){
$this->editasmultichoice = 1 ;
$this->editasmultichoice = 0 ;
}
}
-
+
/* if ( '' != optional_param('changetomultichoice', '', PARAM_RAW)){
- $this->editasmultichoice = 1 ;
+ $this->editasmultichoice = 1 ;
}
if ( '' != optional_param('changetocalculated', '', PARAM_RAW)){
- $this->editasmultichoice = 0 ;
+ $this->editasmultichoice = 0 ;
}*/
$mform->insertElementBefore( $mform->createElement('submit', $addfieldsname, $addstring),'listcategory');
$mform->registerNoSubmitButton('createoptionbutton');
-
+
if(!isset($this->question->id ) ){
$mform->addElement('header', 'choicehdr',get_string('Choosingcreationmode', 'qtype_calculated'));
$createoptions = Array();
-
+
$createoptions['0']=get_string('Regularcalculated', 'qtype_calculated');
$createoptions['1']=get_string('Multiplechoicecalculated', 'qtype_calculated');
$addgrp1 = array();
$menu = array(get_string('answersingleno', 'qtype_multichoice'), get_string('answersingleyes', 'qtype_multichoice'));
$mform->addElement('select', 'single', get_string('answerhowmany', 'qtype_multichoice'), $menu);
$mform->setDefault('single', 1);
-
+
$mform->addElement('advcheckbox', 'shuffleanswers', get_string('shuffleanswers', 'qtype_multichoice'), null, null, array(0,1));
$mform->setHelpButton('shuffleanswers', array('multichoiceshuffle', get_string('shuffleanswers','qtype_multichoice'), 'qtype_multichoice'));
$mform->setDefault('shuffleanswers', 1);
-
+
$numberingoptions = $QTYPES['multichoice']->get_numbering_styles();
$menu = array();
foreach ($numberingoptions as $numberingoption) {
$mform->addElement('header', 'choicehdr', get_string('regularcalculatedquestion', 'qtype_calculated'));
$mform->addElement('hidden','single', '1');
$mform->setType('single', PARAM_INT);
-
+
$mform->addElement('hidden','shuffleanswers', '1');
$mform->setType('shuffleanswers', PARAM_INT);
$mform->addElement('hidden','answernumbering', 'abc');
$this->add_per_answer_fields($mform, get_string('answerhdr', 'qtype_calculated', '{no}'),
$creategrades->gradeoptions, 1, 1);
}
-
+
$repeated = array();
if ($this->editasmultichoice == 1){
$mform->setConstants(array('nounits'=>$nounits));
for ($i=0; $i< $nounits; $i++) {
$mform->addElement('hidden','unit'."[$i]", optional_param('unit'."[$i]", '', PARAM_NOTAGS));
- $mform->setType('unit'."[$i]", PARAM_NOTAGS);
+ $mform->setType('unit'."[$i]", PARAM_NOTAGS);
$mform->addElement('hidden', 'multiplier'."[$i]", optional_param('multiplier'."[$i]", '', PARAM_NUMBER));
$mform->setType('multiplier'."[$i]", PARAM_NUMBER);
- }
+ }
$mform->addElement('hidden','unitgradingtype',optional_param('unitgradingtype', '', PARAM_INT)) ;
$mform->addElement('hidden','unitpenalty',optional_param('unitpenalty', '', PARAM_NUMBER)) ;
$mform->addElement('hidden','showunits',optional_param('showunits', '', PARAM_INT)) ;
- $mform->addElement('hidden','unitsleft',optional_param('unitsleft', '', PARAM_INT)) ;
- $mform->addElement('hidden','instructions',optional_param('instructions', '', PARAM_RAW)) ;
+ $mform->addElement('hidden','unitsleft',optional_param('unitsleft', '', PARAM_INT)) ;
+ $mform->addElement('hidden','instructions',optional_param('instructions', '', PARAM_RAW)) ;
}else {
$QTYPES['numerical']->edit_numerical_options($mform,$this);
- $repeated[] =& $mform->createElement('header', 'unithdr', get_string('unithdr', 'qtype_numerical', '{no}'));
+ $repeated[] =& $mform->createElement('header', 'unithdr', get_string('unithdr', 'qtype_numerical', '{no}'));
$repeated[] =& $mform->createElement('text', 'unit', get_string('unit', 'quiz'));
$repeated[] =& $mform->createElement('text', 'multiplier', get_string('multiplier', 'quiz'));
-
+
$mform->setType('unit', PARAM_NOTAGS);
$mform->setType('multiplier', PARAM_NUMBER);
}
function validation($data, $files) {
- // echo code left for testing period
+ // echo code left for testing period
// echo "<p>question <pre>";print_r($this->question);echo "</pre></p>";
// echo "<p>data <pre>";print_r($data);echo "</pre></p>";
if ($data['multichoice']== 1 ){
foreach ($answers as $key => $answer){
$trimmedanswer = trim($answer);
- if (($trimmedanswer!='')||$answercount==0){
+ if (($trimmedanswer!='')||$answercount==0){
//verifying for errors in {=...} in answer text;
$qanswer = "";
$qanswerremaining = $trimmedanswer ;
if ($data['fraction'][$key] == 1) {
$maxgrade = true;
}
-
+
$answercount++;
}
//check grades
if ($data['fraction'][$key] > $maxfraction) {
$maxfraction = $data['fraction'][$key];
}
- }
+ }
}
if ($answercount==0){
$errors['answer[0]'] = get_string('notenoughanswers', 'qtype_multichoice', 2);
$errors['answer[1]'] = get_string('notenoughanswers', 'qtype_multichoice', 2);
} elseif ($answercount==1){
$errors['answer[1]'] = get_string('notenoughanswers', 'qtype_multichoice', 2);
-
+
}
/// Perform sanity checks on fractional grades
if ($data['fraction'][$key] == 1) {
$maxgrade = true;
}
-
+
$answercount++;
}
//check grades
-
+
//TODO how should grade checking work here??
/*if ($answer != '') {
if ($data['fraction'][$key] > 0) {
}
}*/
}
-
+
//grade checking :
/// Perform sanity checks on fractional grades
/*if ( ) {
if (!is_numeric($trimmedmultiplier)){
$errors['multiplier['.$key.']'] = get_string('mustbenumeric', 'qtype_calculated');
}
-
+
}
}
}
return $errors;
}
}
-?>
+
-<?php // $Id$
+<?php
/////////////////
// CALCULATED ///
// return false;
$question->options->synchronize = 0;
$question->options->multichoice = 0;
-
+
}
// echo "<p> questionoptions <pre>";print_r($question);echo "</pre></p>";
$QTYPES['numerical']->get_numerical_options($question);
$question->answers = $question->answer;
}
// calculated options
- $update = true ;
+ $update = true ;
$options = $DB->get_record("question_calculated_options", array("question" => $question->id));
if (!$options) {
$update = false;
$state->responses = array('' => $regs[2]);
$virtualqtype = $this->get_virtual_qtype( $question);
// if ( isset($question->options->multichoice) && $question->options->multichoice == '1'){
-
+
return $virtualqtype->restore_session_and_responses($question, $state);
// }else { // numerical
-
+
// return true;
}
FROM {question_datasets} d,
{question_dataset_definitions} i
WHERE d.question = ?
- AND d.datasetdefinition = i.id
- AND i.category != 0
+ AND d.datasetdefinition = i.id
+ AND i.category != 0
";
if (!$question->options->synchronize || !$records = $DB->get_records_sql($sql, array($question->id))) {
- $synchronize_calculated = false ;
+ $synchronize_calculated = false ;
}else {
- $synchronize_calculated = true ;
- }
+ $synchronize_calculated = true ;
+ }
// Choose a random dataset
if ( $synchronize_calculated === false ) {
$state->options->datasetitem = rand(1, $maxnumber);
}else{
- $state->options->datasetitem = intval( $maxnumber * substr($attempt->timestart,-2) /100 ) ;
+ $state->options->datasetitem = intval( $maxnumber * substr($attempt->timestart,-2) /100 ) ;
if ($state->options->datasetitem < 1) {
$state->options->datasetitem =1 ;
} else if ($state->options->datasetitem > $maxnumber){
$state->options->datasetitem = $maxnumber ;
}
-
- };
+
+ };
$state->options->dataset =
$this->pick_question_dataset($question,$state->options->datasetitem);
// $state->responses = array('' => '');
$state->responses = array();
}
return true;
- } else { // numerical
+ } else { // numerical
$virtualqtype = $this->get_virtual_qtype( $question);
- return $virtualqtype->create_session_and_responses($question, $state, $cmoptions, $attempt);
+ return $virtualqtype->create_session_and_responses($question, $state, $cmoptions, $attempt);
}
-
+
}
-
+
function save_session_and_responses(&$question, &$state) {
global $DB;
- $responses = 'dataset'.$state->options->datasetitem.'-' ;
+ $responses = 'dataset'.$state->options->datasetitem.'-' ;
if ( isset($question->options->multichoice) && $question->options->multichoice == '1'){
-
+
// Bundle the answer order and the responses into the legacy answer
// field.
// The serialized format for multiple choice quetsions
$responses .= implode(',', $state->options->order) . ':';
$responses .= implode(',', $state->responses);
}else {
- // regular numeric type
+ // regular numeric type
if(isset($state->responses['unit']) && isset($question->options->units[$state->responses['unit']])){
$responses .= $state->responses['answer'].'|||||'.$question->options->units[$state->responses['unit']]->unit;
}else if(isset($state->responses['unit'])){
$responses .= $state->responses['answer'].'|||||';
}
-
+
}
-
- // Set the legacy answer field
+
+ // Set the legacy answer field
if (!$DB->set_field('question_states', 'answer', $responses, array('id'=> $state->id))) {
return false;
}
function delete_question($questionid) {
global $DB;
$DB->delete_records("question_calculated", array("question" => $questionid));
- if ( $DB->table_exists("question_calculated_options") ){
+ if ( $DB->table_exists("question_calculated_options") ){
$DB->delete_records("question_calculated_options", array("question" => $questionid));
};
$DB->delete_records("question_numerical_units", array("question" => $questionid));
if (!$DB->get_records_select(
'question_datasets',
"question != ?
- AND datasetdefinition = ?;", array($questionid, $dataset->datasetdefinition))){
+ AND datasetdefinition = ?;", array($questionid, $dataset->datasetdefinition))){
$DB->delete_records('question_dataset_definitions', array('id' => $dataset->datasetdefinition));
$DB->delete_records('question_dataset_items', array('definition' => $dataset->datasetdefinition));
}
}
function test_response(&$question, &$state, $answer) {
$virtualqtype = $this->get_virtual_qtype( $question);
- return $virtualqtype->test_response($question, $state, $answer);
-
+ return $virtualqtype->test_response($question, $state, $answer);
+
}
function compare_responses(&$question, $state, $teststate) {
$virtualqtype = $this->get_virtual_qtype( $question);
$unit = '';
}
}
-
+
// We modify the question to look like a numerical question
$numericalquestion = fullclone($question);
if ($question->options->multichoice == 1 ) {
$qtext = $qtext.$str ;
}
$numericalquestion->questiontext = $qtext.$qtextremaining ; // end replace equations
-
+
$virtualqtype->print_question_formulation_and_controls($numericalquestion, $state, $cmoptions, $options);
}
function grade_responses(&$question, &$state, $cmoptions) {
/* if ($this->options->multichoice == 1 ) {
require_once("$CFG->dirroot/question/type/multichoice/questiontype.php");
return new question_multichoice_qtype();
- }else { */
+ }else { */
require_once("$CFG->dirroot/question/type/numerical/questiontype.php");
return new question_numerical_qtype();
// }
$select1 = html_select::make($lengthoptions, 'calclength[]', $regs[4], false);
$select1->nothingvalue = '';
$menu1 = $OUTPUT->select($select1);
-
+
$select2 = html_select::make(array('uniform' => get_string('uniform', 'quiz'),
'loguniform' => get_string('loguniform', 'quiz')), 'calcdistribution[]', $regs[1], false);
$select2->nothingvalue = '';
/**
* This function get the dataset items using id as unique parameter and return an
- * array with itemnumber as index sorted ascendant
- * If the multiple records with the same itemnumber exist, only the newest one
+ * array with itemnumber as index sorted ascendant
+ * If the multiple records with the same itemnumber exist, only the newest one
* i.e with the greatest id is used, the others are ignored but not deleted.
* MDL-19210
- */
+ */
function get_database_dataset_items($definition){
global $CFG, $DB;
$databasedataitems = $DB->get_records_sql( // Use number as key!!
ksort($dataitems);
return $dataitems ;
}
-
+
function save_dataset_items($question, $fromform){
global $CFG, $DB;
// max datasets = 100 items
$strheader .= $delimiter.$answer->answer;
}
if($question->options->multichoice == 1 ){
- $delimiter = '<br/>';
+ $delimiter = '<br/>';
}else{
$delimiter = '<br/><br/><br/>';
}
}else {
eval('$answer->answer = '.$formula.';') ;
$virtualqtype->get_tolerance_interval($answer);
- }
+ }
if ($answer->min === '') {
// This should mean that something is wrong
$comment->stranswers[$key] = " $formattedanswer->answer".'<br/><br/>';
}
$answer->answer = $qtext.$qtextremaining ; ;
$comment->stranswers[$key]= $answer->answer ;
-
-
+
+
/* $formula = $this->substitute_variables($answer->answer,$data);
$formattedanswer = qtype_calculated_calculate_answer(
$answer->answer, $data, $answer->tolerance,
}else {
eval('$answer->answer = '.$formula.';') ;
$virtualqtype->get_tolerance_interval($answer);
- }
+ }
if ($answer->min === '') {
// This should mean that something is wrong
$comment->stranswers[$key] = " $formattedanswer->answer".'<br/><br/>';
function substitute_variables($str, $dataset) {
// testing for wrong numerical values
- // all calculations used this function so testing here should be OK
+ // all calculations used this function so testing here should be OK
foreach ($dataset as $name => $value) {
$val = $value ;
$a->value = $value ;
echo $OUTPUT->notification(get_string('notvalidnumber','qtype_calculated',$a));
$val = 1.0 ;
- }
+ }
if($val < 0 ){
$str = str_replace('{'.$name.'}', '('.$val.')', $str);
} else {
}
return $str;
}
-
+
function substitute_variables_and_eval($str, $dataset) {
$formula = $this->substitute_variables($str, $dataset) ;
function save_dataset_definitions($form) {
global $DB;
// save synchronize
-
+
// Save datasets
$datasetdefinitions = $this->get_dataset_definitions($form->id, $form->dataset);
$tmpdatasets = array_flip($form->dataset);
}
return $dataset;
}
-
+
function dataset_options_from_database($form, $name,$prefix='',$langfile='quiz') {
// First options - it is not a dataset...
// Construct question local options
global $CFG, $DB;
- $type = 1 ; // only type = 1 (i.e. old 'LITERAL') has ever been used
+ $type = 1 ; // only type = 1 (i.e. old 'LITERAL') has ever been used
if ( ! $currentdatasetdef = $DB->get_record_sql(
"SELECT a.*
FROM {question_dataset_definitions} a,
}
// Construct question category options
$categorydatasetdefs = $DB->get_records_sql(
- "SELECT b.question, a.*
+ "SELECT b.question, a.*
FROM {question_datasets} b,
- {question_dataset_definitions} a
+ {question_dataset_definitions} a
WHERE a.id = b.datasetdefinition
AND a.type = '1'
AND a.category = ?
// need to check as old questions don't have calculated_options record
if(isset($info['#']['CALCULATED_OPTIONS'])){
$calculatedoptions = $info['#']['CALCULATED_OPTIONS'];
-
+
//Iterate over calculated_options
for($i = 0; $i < sizeof($calculatedoptions); $i++){
$cal_info = $calculatedoptions[$i];
//traverse_xmlize($cal_info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
-
+
//Now, build the question_calculated_options record structure
$calculated_options->questionid = $new_question_id;
$calculated_options->synchronize = backup_todb($cal_info['#']['SYNCHRONIZE']['0']['#']);
$calculated_options->partiallycorrectfeedback = backup_todb($cal_info['#']['PARTIALLYCORRECTFEEDBACK']['0']['#']);
$calculated_options->incorrectfeedback = backup_todb($cal_info['#']['INCORRECTFEEDBACK']['0']['#']);
$calculated_options->answernumbering = backup_todb($cal_info['#']['ANSWERNUMBERING']['0']['#']);
-
+
//The structure is equal to the db, so insert the question_calculated_options
$newid = $DB->insert_record ("question_calculated_options",$calculated_options);
-
+
//Do some output
if (($i+1) % 50 == 0) {
if (!defined('RESTORE_SILENTLY')) {
echo "</pre><br />\n";
}
-?>
+
-<?PHP // $Id$
+<?php
$plugin->version = 2009092000;
$plugin->requires = 2007101000;
-?>
+
-<?php // $Id$
+<?php
/**
* Defines the editing form for the calculated simplequestion type.
*
public $datasetdefs;
public $reload = false ;
-
+
public $maxnumber = -1;
public $regenerate = true;
public $noofitems;
-
+
public $outsidelimit = false ;
-
- public $commentanswer = array();
-
+
+ public $commentanswer = array();
+
public $answer = array();
public $nonemptyanswer = array();
-
+
public $numbererrors = array();
- public $formdata = array();
+ public $formdata = array();
+
-
function question_edit_calculatedsimple_form(&$submiturl, &$question, &$category, &$contexts, $formeditable = true){
global $QTYPES, $SESSION, $CFG, $DB;
//so this will only set the values to the actual question database content which is not what we want
//so this should be removed from here
// get priority to paramdatasets
-
+
if ( "1" == optional_param('reload','', PARAM_INT )) {
$this->reload = true ;
}else {
$this->reload = false ;
}
- if(!$this->reload ){ // use database data as this is first pass
+ if(!$this->reload ){ // use database data as this is first pass
// question->id == 0 so no stored datasets
- // else get datasets
+ // else get datasets
if ( !empty($question->id)) {
if (empty($question->options)) {
$this->get_question_options($question);
}
$this->datasetdefs = $this->qtypeobj->get_dataset_definitions($question->id, array());
-
+
if(!empty($this->datasetdefs)){
foreach ($this->datasetdefs as $defid => $datasetdef) {
- // first get the items in case their number does not correspond to itemcount
+ // first get the items in case their number does not correspond to itemcount
if (isset($datasetdef->id)) {
$this->datasetdefs[$defid]->items = $this->qtypeobj->get_database_dataset_items($datasetdef->id);
if ( $this->datasetdefs[$defid]->items != '') {
foreach($this->question->options->answers as $answer){
$this->answer[$i] = $answer ;
$i++;
- }
+ }
$this->nonemptyanswer = $this->answer ;
- }
+ }
$datasettoremove = false;
- $newdatasetvalues = false ;
- $newdataset = false ;
- }else {
+ $newdatasetvalues = false ;
+ $newdataset = false ;
+ }else {
// handle reload to get values from the form-elements
// answers, datasetdefs and data_items
- // In any case the validation step will warn the user of any error in settings the values.
- // Verification for the specific dataset values as the other parameters
+ // In any case the validation step will warn the user of any error in settings the values.
+ // Verification for the specific dataset values as the other parameters
// unints, feeedback etc are handled elsewhere
// handle request buttons :
- // 'analyzequestion' (Identify the wild cards {x..} present in answers)
+ // 'analyzequestion' (Identify the wild cards {x..} present in answers)
// 'addbutton' (create new set of datatitems)
// 'updatedatasets' is handled automatically on each reload
- // The analyzequestion is done every time on reload
+ // The analyzequestion is done every time on reload
// to detect any new wild cards so that the current display reflects
// the mandatory (i.e. in answers) datasets
// to implement : don't do any changes if the question is used in a quiz.
- // If new datadef, new properties should erase items.
- // Most of the data
+ // If new datadef, new properties should erase items.
+ // Most of the data
$datasettoremove = false;
- $newdatasetvalues = false ;
- $newdataset = false ;
+ $newdatasetvalues = false ;
+ $newdataset = false ;
$dummyform = new stdClass();
$mandatorydatasets = array();
- // should not test on adding a new answer
+ // should not test on adding a new answer
// should test if there are already olddatasets or if the 'analyzequestion' submit button has been clicked
- if ('' != optional_param('datasetdef', '', PARAM_RAW) || '' != optional_param('analyzequestion', '', PARAM_RAW)){
-
- if ( $dummyform->answer = optional_param('answer', '', PARAM_NOTAGS)) { // there is always at least one answer...
- $tolerance = optional_param('tolerance', '', PARAM_NUMBER);
- $tolerancetype = optional_param('tolerancetype', '', PARAM_NUMBER);
- $correctanswerlength = optional_param('correctanswerlength', '', PARAM_INT);
- $correctanswerformat = optional_param('correctanswerformat', '', PARAM_INT);
-
+ if ('' != optional_param('datasetdef', '', PARAM_RAW) || '' != optional_param('analyzequestion', '', PARAM_RAW)){
+
+ if ( $dummyform->answer = optional_param('answer', '', PARAM_NOTAGS)) { // there is always at least one answer...
+ $tolerance = optional_param('tolerance', '', PARAM_NUMBER);
+ $tolerancetype = optional_param('tolerancetype', '', PARAM_NUMBER);
+ $correctanswerlength = optional_param('correctanswerlength', '', PARAM_INT);
+ $correctanswerformat = optional_param('correctanswerformat', '', PARAM_INT);
+
foreach( $dummyform->answer as $key => $answer ) {
- if(trim($answer) != ''){ // just look for non-empty
+ if(trim($answer) != ''){ // just look for non-empty
$this->answer[$key]=new stdClass();
$this->answer[$key]->answer = $answer;
$this->answer[$key]->fraction = $fraction[$key];
}
$this->datasetdefs = array();
// rebuild datasetdefs from old values
- if ($olddef = optional_param('datasetdef', '', PARAM_RAW)){
- $calcmin = optional_param('calcmin', '', PARAM_NUMBER);
- $calclength = optional_param('calclength', '', PARAM_INT);
+ if ($olddef = optional_param('datasetdef', '', PARAM_RAW)){
+ $calcmin = optional_param('calcmin', '', PARAM_NUMBER);
+ $calclength = optional_param('calclength', '', PARAM_INT);
$calcmax = optional_param('calcmax', '', PARAM_NUMBER);
- $oldoptions = optional_param('defoptions', '', PARAM_RAW);
- $newdatasetvalues = false ;
+ $oldoptions = optional_param('defoptions', '', PARAM_RAW);
+ $newdatasetvalues = false ;
for($key = 1 ; $key <= sizeof($olddef) ; $key++) {
$def = $olddef[$key] ;
$this->datasetdefs[$def]= new stdClass ;
$this->datasetdefs[$def]->calcmax != $regs[3] ||
$this->datasetdefs[$def]->calclength != $regs[4]){
$newdatasetvalues = true ;
- }
+ }
}
$this->datasetdefs[$def]->options="uniform:".$this->datasetdefs[$def]->calcmin.":".$this->datasetdefs[$def]->calcmax.":".$this->datasetdefs[$def]->calclength;
}
}// if (olddef...
- // detect new datasets
- $newdataset = false ;
+ // detect new datasets
+ $newdataset = false ;
foreach ($mandatorydatasets as $datasetname) {
if (!isset($this->datasetdefs["1-0-$datasetname"])) {
$key = "1-0-$datasetname";
$this->datasetdefs[$key]->category = 0;
$this->datasetdefs[$key]->name = $datasetname;
$this->datasetdefs[$key]->options = "uniform:1.0:10.0:1";
- $newdataset = true ;
+ $newdataset = true ;
}else {
$this->datasetdefs["1-0-$datasetname"]->name = $datasetname ;
}
}
- // remove obsolete datasets
+ // remove obsolete datasets
$datasettoremove = false;
foreach ($this->datasetdefs as $defkey => $datasetdef){
if(!isset($datasetdef->name )){
unset($this->datasetdefs[$defkey]);
}
}
- }
+ }
} // handle reload
// create items if $newdataset and noofitems > 0 and !$newdatasetvalues
// eliminate any items if $newdatasetvalues
$this->maxnumber = $maxnumber ;
}else {
// Handle reload dataset items
- if ( "" !=optional_param('definition')&& !($datasettoremove ||$newdataset ||$newdatasetvalues )){
+ if ( "" !=optional_param('definition')&& !($datasettoremove ||$newdataset ||$newdatasetvalues )){
$i = 1;
- $fromformdefinition = optional_param('definition', '', PARAM_NOTAGS);
- $fromformnumber = optional_param('number', '', PARAM_INT);
- $fromformitemid = optional_param('itemid', '', PARAM_INT);
+ $fromformdefinition = optional_param('definition', '', PARAM_NOTAGS);
+ $fromformnumber = optional_param('number', '', PARAM_INT);
+ $fromformitemid = optional_param('itemid', '', PARAM_INT);
ksort($fromformdefinition);
-
+
foreach($fromformdefinition as $key => $defid) {
$addeditem = new stdClass();
$addeditem->id = $fromformitemid[$i] ;
}
if (isset($addeditem->itemnumber) && $this->maxnumber < $addeditem->itemnumber){
$this->maxnumber = $addeditem->itemnumber;
- if(!empty($this->datasetdefs)){
+ if(!empty($this->datasetdefs)){
foreach ($this->datasetdefs as $datasetdef) {
$datasetdef->itemcount = $this->maxnumber ;
}
$creategrades->gradeoptions, 1, 1);
$QTYPES['numerical']->edit_numerical_options($mform,$this);
-
+
$repeated = array();
$repeated[] =& $mform->createElement('header', 'unithdr', get_string('unithdr', 'qtype_numerical', '{no}'));
$mform->addElement('hidden', "datasetdef[$idx]");
$mform->setType("datasetdef[$idx]", PARAM_RAW);
$mform->addElement('hidden', "defoptions[$idx]");
- $mform->setType("defoptions[$idx]", PARAM_RAW);
+ $mform->setType("defoptions[$idx]", PARAM_RAW);
$idx++;
$mform->addElement('static', "divider[$j]", '', '<hr />');
$j++;
}
//this should be done before the elements are created and stored as $this->formdata ;
//fill out all data sets and also the fields for the next item to add.
- /*Here we do already the values error analysis so that
+ /*Here we do already the values error analysis so that
* we could force all wild cards values display if there is an error in values.
* as using a , in a number */
$this->numbererrors = array();
if (stristr($number,',')){
$this->numbererrors["number[$j]"]=get_string('nocommaallowed', 'qtype_datasetdependent');
$numbererrors .= $this->numbererrors['number['.$j.']']."<br />";
-
+
}else {
$this->numbererrors["number[$j]"]= get_string('notvalidnumber','qtype_datasetdependent',$a);
$numbererrors .= $this->numbererrors['number['.$j.']']."<br />";
//$comment->outsidelimit = false ;
}
- }else if( stristr($number,'x')){ // hexa will pass the test
+ }else if( stristr($number,'x')){ // hexa will pass the test
$a = new stdClass;
$a->name = '{'.$datasetdef->name.'}' ;
$a->value = $datasetdef->items[$itemnumber]->value ;
$this->numbererrors["number[$j]"]= get_string('notvalidnumber','qtype_datasetdependent',$a);
$numbererrors .= $this->numbererrors['number['.$j.']']."<br />";
// $val = 1.0 ;
- }
+ }
}
$j--;
}
$this->outsidelimit=$comment->outsidelimit ;
}
$totalcomment='';
-
+
foreach ($this->nonemptyanswer as $key => $answer) {
$totalcomment .= $comment->stranswers[$key].'<br/>';
}
-
+
$this->formdata['answercomment['.$itemnumber.']'] = $totalcomment ;
}
}
$this->formdata = $this->qtypeobj->custom_generator_set_data($this->datasetdefs, $this->formdata);
}
-
+
$addoptions = Array();
$addoptions['1']='1';
for ($i=10; $i<=100 ; $i+=10){
if( !empty($this->numbererrors) || $this->outsidelimit) {
$mform->addElement('static', "alert", '', '<span class="error">'.get_string('useadvance', 'qtype_calculatedsimple').'</span>');
}
-
+
$mform->addElement('submit', 'updatedatasets', get_string('updatewildcardvalues', 'qtype_calculatedsimple'));
$mform->registerNoSubmitButton('updatedatasets');
$mform->setAdvanced("updatedatasets",true);
$j = $this->noofitems * count($this->datasetdefs);
$k = 1 ;
if ("" != optional_param('selectshow')){
- $k = optional_param('selectshow', '', PARAM_INT);
+ $k = optional_param('selectshow', '', PARAM_INT);
}
for ($i = $this->noofitems; $i >= 1 ; $i--){
if($k > 0 || $this->outsidelimit || !empty($this->numbererrors ) ){
$mform->addElement('text',"number[$j]" , get_string('wildcard', 'qtype_calculatedsimple', $datasetdef->name));
$mform->setAdvanced("number[$j]",true);
- if(!empty($this->numbererrors['number['.$j.']']) ){
+ if(!empty($this->numbererrors['number['.$j.']']) ){
$mform->addElement('static', "numbercomment[$j]",'','<span class="error">'.$this->numbererrors['number['.$j.']'].'</span>');
$mform->setAdvanced("numbercomment[$j]",true);
}
$mform->addElement('hidden',"number[$j]" , get_string('wildcard', 'qtype_calculatedsimple', $datasetdef->name));
}
$mform->setType("number[$j]", PARAM_NUMBER);
-
+
$mform->addElement('hidden', "itemid[$j]");
$mform->setType("itemid[$j]", PARAM_INT);
if (!empty( $strquestionlabel) && ($k > 0 || $this->outsidelimit || !empty($this->numbererrors ) ) ){
// $repeated[] =& $mform->addElement('static', "answercomment[$i]", $strquestionlabel);
$mform->addElement('static', "answercomment[$i]", "<b>".get_string('setno', 'qtype_calculatedsimple', $i)."</b> ".$strquestionlabel);
-
+
}
- if($k > 0 || $this->outsidelimit || !empty($this->numbererrors )){
+ if($k > 0 || $this->outsidelimit || !empty($this->numbererrors )){
$mform->addElement('static', "divider1[$j]", '', '<hr />');
-
+
}
$k-- ;
}
if ($this->question->formoptions->cansaveasnew){
$mform->addElement('header', 'additemhdr', get_string('converttocalculated', 'qtype_calculatedsimple'));
$mform->closeHeaderBefore('additemhdr');
-
+
$mform->addElement('checkbox', 'convert','' ,get_string('willconverttocalculated', 'qtype_calculatedsimple'));
$mform->setDefault('convert', 0);
$key = 0;
foreach ($answer as $answer){
$default_values['answer['.$key.']'] = $answer->answer;
- // echo "<p> $answer->fraction </p>";
+ // echo "<p> $answer->fraction </p>";
$default_values['fraction['.$key.']'] = $answer->fraction;
$default_values['tolerance['.$key.']'] = $answer->tolerance;
$default_values['tolerancetype['.$key.']'] = $answer->tolerancetype;
}
// echo "<p>answers avant comment <pre>";print_r($answer);echo"</pre></p>";
// echo "<p>data avant comment <pre>";print_r($data);echo"</pre></p>";
-
+
if($this->noofitems != 0 ) {
if(!isset($question->id)) $question->id = 0 ;
$comment = $this->qtypeobj->comment_on_datasetitems($question->id,$this->nonemptyanswer, $data, $itemnumber);//$this->
}
if (isset($data['backtoquiz']) && ($this->noofitems==0) ){
$errors['warning'] = get_string('warning', 'mnet');
- }
+ }
if ($this->outsidelimit){
// if(!isset($errors['warning'])) $errors['warning']=' ';
$errors['outsidelimits'] = get_string('oneanswertrueansweroutsidelimits','qtype_calculated');
}
- /*Here we use the already done the error analysis so that
+ /*Here we use the already done the error analysis so that
* we could force all wild cards values display if there is an error in values.
* as using a , in a number *//*
$numbers = $data['number'];
if(! is_numeric($number)){
if (stristr($number,',')){
$errors['number['.$key.']'] = get_string('notvalidnumber', 'qtype_datasetdependent');
- }else {
+ }else {
$errors['number['.$key.']'] = get_string('notvalidnumber', 'qtype_datasetdependent');
}
}else if( stristr($number,'x')){
$errors['number['.$key.']'] = get_string('notvalidnumber', 'qtype_datasetdependent');
} else if( is_nan($number)){
$errors['number['.$key.']'] = get_string('notvalidnumber', 'qtype_datasetdependent');
- }
+ }
}
*/
if ( $this->noofitems==0 ){
return $errors;
}
}
-?>
+
-<?php // $Id$
+<?php
/////////////////
// CALCULATED ///
}
}
}
- }
+ }
// Report any problems.
//convert to calculated
if(!empty($question->makecopy) && !empty($question->convert)) {
}
-
+
function comment_header($answers) {
//$this->get_question_options($question);
$strheader = "";
}else {
eval('$answer->answer = '.$formula.';') ;
$virtualqtype->get_tolerance_interval($answer);
- }
+ }
if ($answer->min === '') {
// This should mean that something is wrong
$comment->stranswers[$key] = " $formattedanswer->answer".'<br/><br/>';
define("CALCULATEDSIMPLE", "calculatedsimple");
-?>
+
-<?php // $Id$
+<?php
/**
* Defines the editing form for the description question type.
*
return 'description';
}
}
-?>
\ No newline at end of file
<div class="qtext">
<?php echo $questiontext; ?>
</div>
-
+
<?php if ($image) { ?>
<img class="qimage" src="<?php echo $image; ?>" alt="" />
<?php } ?>
-<?php // $Id$
+<?php
///////////////////////////////////////////////////////////////////////////
// //
}
// Register this question type with questionlib.php.
question_register_questiontype(new description_qtype());
-?>
+
-<?php // $Id$
+<?php
/**
* A base class for question editing forms.
*
}
}
-?>
+
-<?php // $Id$
+<?php
-// This file keeps track of upgrades to
+// This file keeps track of upgrades to
// the essay qtype plugin
//
// Sometimes, changes between versions involve
$dbman = $DB->get_manager();
$result = true;
-/// And upgrade begins here. For each one, you'll need one
-/// block of code similar to the next one. Please, delete
+/// And upgrade begins here. For each one, you'll need one
+/// block of code similar to the next one. Please, delete
/// this comment lines once this file start handling proper
/// upgrade code.
return $result;
}
-?>
+
-<?php // $Id$
+<?php
/**
* Defines the editing form for the essay question type.
*
return 'essay';
}
}
-?>
+
-<?php // $Id$
+<?php
//////////////////
/// ESSAY ///
//// INITIATION - Without this line the question type is not in use... ///
//////////////////////////////////////////////////////////////////////////
question_register_questiontype(new question_essay_qtype());
-?>
+
-<?PHP // $Id$
+<?php
$plugin->version = 2006032200;
$plugin->requires = 2007101000;
-?>
+
-<?php // $Id$
+<?php
-// This file keeps track of upgrades to
+// This file keeps track of upgrades to
// the match qtype plugin
//
// Sometimes, changes between versions involve
$dbman = $DB->get_manager();
$result = true;
-/// And upgrade begins here. For each one, you'll need one
-/// block of code similar to the next one. Please, delete
+/// And upgrade begins here. For each one, you'll need one
+/// block of code similar to the next one. Please, delete
/// this comment lines once this file start handling proper
/// upgrade code.
return $result;
}
-?>
+
-<?php // $Id$
+<?php
/**
* Defines the editing form for the match question type.
*
return $errors;
}
}
-?>
\ No newline at end of file
-<?php // $Id$
+<?php
/////////////
/// MATCH ///
$a->feedbackimg = question_get_feedback_image($correctresponse);
}
}
-
+
$select = html_select::make($answers, $menuname, $response);
$select->disabled = $options->readonly;
$a->control = $OUTPUT->select($select);
}
return $answers;
}
-
+
// ULPGC ecastro
function get_actual_response($question, $state) {
$subquestions = &$state->options->subquestions;
}
return $results;
}
-
+
function get_actual_response_details($question, $state) {
$responses = $this->get_actual_response($question, $state);
$teacherresponses = $this->get_possible_responses($question, $state);
//// INITIATION - Without this line the question type is not in use... ///
//////////////////////////////////////////////////////////////////////////
question_register_questiontype(new question_match_qtype());
-?>
+
-<?PHP // $Id$
+<?php
$plugin->version = 2006032200;
$plugin->requires = 2007101000;
-?>
+
-<?php // $Id$
+<?php
/**
* Defines the editing form for the missingtype question type.
*
return $errors;
}
}
-?>
+
-<?php // $Id$
+<?php
///////////////////
/// missingtype ///
//////////////////////////////////////////////////////////////////////////
question_register_questiontype(new question_missingtype_qtype());
-?>
+
-<?php // $Id$
+<?php
-// This file keeps track of upgrades to
+// This file keeps track of upgrades to
// the multianswer qtype plugin
//
// Sometimes, changes between versions involve
}
return $result;
}
-?>
+
-<?php // $Id$
+<?php
/**
* Defines the editing form for the multianswer question type.
*
var $nb_of_attempts = 0;
public $confirm = 0 ;
public $reload = false ;
-
+
function question_edit_multianswer_form(&$submiturl, &$question, &$category, &$contexts, $formeditable = true){
global $QTYPES, $SESSION, $CFG, $DB;
$this->regenerate = true;
}
}
-
-
-
-
+
+
+
+
parent::question_edit_form($submiturl, $question, $category, $contexts, $formeditable);
}
-
+
function definition_inner(&$mform) {
$mform->addElement('hidden', 'reload', 1);
$this->questiondisplay = fullclone(qtype_multianswer_extract_question(optional_param('questiontext','', PARAM_RAW))) ;
}else {
- if(!$this->reload && !empty($this->savedquestiondisplay->id)){
- // use database data as this is first pass
+ if(!$this->reload && !empty($this->savedquestiondisplay->id)){
+ // use database data as this is first pass
// question->id == 0 so no stored datasets
$this->questiondisplay = fullclone($this->savedquestiondisplay);
foreach($this->questiondisplay->options->questions as $subquestion){
$subquestion->answer[]=$ans->answer ;
}
// $subquestion->answer = fullclone($subquestion->options->answers);
- }
- }
- }else {
+ }
+ }
+ }else {
$this->questiondisplay = "";
}
}
}
// echo "<p> saved question $countsavedsubquestions <pre>";print_r($this->savedquestiondisplay);echo "</pre></p>";
// echo "<p> saved question $countsubquestions <pre>";print_r($this->questiondisplay);echo "</pre></p>";
-
-
+
+
$mform->addElement('submit', 'analyzequestion', get_string('decodeverifyquestiontext','qtype_multianswer'));
$mform->registerNoSubmitButton('analyzequestion');
echo '<div class="ablock clearfix">';
echo '<div class=" clearfix">';
if ( $this->reload ){
for ($sub =1;$sub <=$countsubquestions ;$sub++) {
-
+
$this->editas[$sub] = 'unknown type';
if (isset( $this->questiondisplay->options->questions[$sub]->qtype) ) {
$this->editas[$sub] = $this->questiondisplay->options->questions[$sub]->qtype ;
$this->editas[$sub] = optional_param('sub_'.$sub."_".'qtype', '', PARAM_RAW);
}
$storemess = '';
- if(isset($this->savedquestiondisplay->options->questions[$sub]->qtype) &&
+ if(isset($this->savedquestiondisplay->options->questions[$sub]->qtype) &&
$this->savedquestiondisplay->options->questions[$sub]->qtype != $this->questiondisplay->options->questions[$sub]->qtype ){
$this->type_change = true ;
$storemess = "<font class=\"error\"> STORED QTYPE ".$question_type_names[$this->savedquestiondisplay->options->questions[$sub]->qtype]."</font >";
}
-
+
$mform->addElement('header', 'subhdr'.$sub, get_string('questionno', 'quiz',
'{#'.$sub.'}').' '.$question_type_names[$this->questiondisplay->options->questions[$sub]->qtype].$storemess);
-
+
$mform->addElement('static', 'sub_'.$sub."_".'questiontext', get_string('questiondefinition','qtype_multianswer'),array('cols'=>60, 'rows'=>3));
-
+
if (isset ( $this->questiondisplay->options->questions[$sub]->questiontext)) {
$mform->setDefault('sub_'.$sub."_".'questiontext', $this->questiondisplay->options->questions[$sub]->questiontext);
}
-
+
$mform->addElement('static', 'sub_'.$sub."_".'defaultgrade', get_string('defaultgrade', 'quiz'));
$mform->setDefault('sub_'.$sub."_".'defaultgrade',$this->questiondisplay->options->questions[$sub]->defaultgrade);
-
+
if ($this->questiondisplay->options->questions[$sub]->qtype =='shortanswer' ) {
$mform->addElement('static', 'sub_'.$sub."_".'usecase', get_string('casesensitive', 'quiz'));
}
-
+
if ($this->questiondisplay->options->questions[$sub]->qtype =='multichoice' ) {
$mform->addElement('static', 'sub_'.$sub."_".'layout', get_string('layout', 'qtype_multianswer'),array('cols'=>60, 'rows'=>1)) ;//, $gradeoptions);
}
foreach ($this->questiondisplay->options->questions[$sub]->answer as $key =>$ans) {
-
+
$mform->addElement('static', 'sub_'.$sub."_".'answer['.$key.']', get_string('answer', 'quiz'), array('cols'=>60, 'rows'=>1));
-
+
if ($this->questiondisplay->options->questions[$sub]->qtype =='numerical' && $key == 0 ) {
$mform->addElement('static', 'sub_'.$sub."_".'tolerance['.$key.']', get_string('acceptederror', 'quiz')) ;//, $gradeoptions);
}
-
+
$mform->addElement('static', 'sub_'.$sub."_".'fraction['.$key.']', get_string('grade')) ;//, $gradeoptions);
-
+
$mform->addElement('static', 'sub_'.$sub."_".'feedback['.$key.']', get_string('feedback', 'quiz'));
}
-
+
}
echo '</div>';
$this->negative_diff =$countsavedsubquestions - $countsubquestions ;
}
if($this->negative_diff > 0) {
//$this->used_in_quiz
-
+
$mform->addElement('static', 'alert1', "<strong>"."Question deleted"."</strong>","<strong>".$this->negative_diff.get_string(' questions less than in the multtianswer question stored in the database','qtype_multianswer')."</strong>");//$countsubquestions."-".$countsavedsubquestions
}
if($this->type_change )
{
//$this->used_in_quiz
-
+
// $mform->addElement('header', 'additemhdr', "WARNING");
$mform->addElement('static', 'alert1', "<strong>"."Question type change "."</strong>","<strong>".get_string(' at least one question type has been changed. Did you add,delete or move a question ? Look ahead ','qtype_multianswer')."</strong>");//$countsubquestions."-".$countsavedsubquestions
}
$mform->addElement('static', 'alertas', "<strong>"."YOU SHOULD NOT "."</strong>");//$countsubquestions."-".$countsavedsubquestions
}
if ( ($this->negative_diff > 0 || $this->used_in_quiz && ($this->negative_diff > 0 ||$this->negative_diff < 0 || $this->type_change ) ) && $this->reload ){
- $mform->addElement('header', 'additemhdr', get_string('The question will be saved as edited', 'qtype_calculatedsimple'));
+ $mform->addElement('header', 'additemhdr', get_string('The question will be saved as edited', 'qtype_calculatedsimple'));
$mform->addElement('checkbox', 'confirm','' ,get_string('I confirm that I want the question be saved as edited', 'qtype_calculatedsimple'));
$mform->setDefault('confirm', 0);
- }else {
+ }else {
$mform->addElement('hidden', 'confirm',0);
}
switch ($subquestion->usecase) {
case '1':
$default_values[$prefix.'usecase']= get_string('caseyes', 'quiz');
- break;
+ break;
case '0':
default :
- $default_values[$prefix.'usecase']= get_string('caseno', 'quiz');
+ $default_values[$prefix.'usecase']= get_string('caseno', 'quiz');
}
}
break;
case '1':
$default_values[$prefix.'layout']= get_string('layoutvertical', 'qtype_multianswer');
- break;
+ break;
case '2':
$default_values[$prefix.'layout']= get_string('layouthorizontal', 'qtype_multianswer');
break;
default:
$default_values[$prefix.'layout']= get_string('layoutundefined', 'qtype_multianswer');
- }
+ }
}
foreach ($subquestion->answer as $key=>$answer) {
if ( $subquestion->qtype == 'numerical' && $key == 0 ) {
}
if (( $this->negative_diff || $this->used_in_quiz && ($this->negative_diff > 0 ||$this->negative_diff < 0 || $this->type_change ))&& $this->confirm == 0 ){
$this->_form->setElementError('confirm',"confirm then save");
- }
- $default_values['alertas']= "<strong>".get_string("
-
+ }
+ $default_values['alertas']= "<strong>".get_string("
+
<ul>
<li>add or delete questions, </li>
<li>change the questions order in the text,</li>
$answercount = 0;
$maxgrade = false;
$maxfraction = -1;
- if(isset($this->savedquestiondisplay->options->questions[$sub]->qtype) &&
+ if(isset($this->savedquestiondisplay->options->questions[$sub]->qtype) &&
$this->savedquestiondisplay->options->questions[$sub]->qtype != $this->questiondisplay->options->questions[$sub]->qtype ){
$storemess = " STORED QTYPE ".$question_type_names[$this->savedquestiondisplay->options->questions[$sub]->qtype];
}
return 'multianswer';
}
}
-?>
+
-<?php // $Id$
+<?php
///////////////////
/// MULTIANSWER /// (Embedded - cloze)
function name() {
return 'multianswer';
}
-
+
function has_wildcards_in_responses($question, $subqid) {
global $QTYPES, $OUTPUT;
foreach ($question->options->questions as $subq){
$sequence = array_flip(explode(',', $sequence));
array_walk($sequence, create_function('&$val', '$val++;'));
//If a question is lost, the corresponding index is null
- // so this null convention is used to test $question->options->questions
+ // so this null convention is used to test $question->options->questions
// before using the values.
- // first all possible questions from sequence are nulled
+ // first all possible questions from sequence are nulled
// then filled with the data if available in $wrappedquestions
$nbvaliquestion = 0 ;
foreach($sequence as $seq){
$wrapped = $QTYPES[$wrapped->qtype]->save_question($wrapped,
$wrapped, $question->course);
$sequence[] = $wrapped->id;
- if ($previousid != 0 && $previousid != $wrapped->id ) {
+ if ($previousid != 0 && $previousid != $wrapped->id ) {
// for some reasons a new question has been created
// so delete the old one
delete_question($previousid) ;
$a->id = $question->name_prefix . $mcanswer->id;
$a->class = '';
$a->feedbackimg = '';
-
+
// Print the control
$a->control = "<input $readonly id=\"$a->id\" $name $checked $type value=\"$mcanswer->id\" />";
if ($options->correct_responses && $mcanswer->fraction > 0) {
$a->feedbackimg = question_get_feedback_image($mcanswer->fraction, $chosen && $options->feedback);
}
}
-
+
// Print the answer text: no automatic numbering
$a->text =format_text($mcanswer->answer, FORMAT_MOODLE, $formatoptions, $cmoptions->course);
-
+
// Print feedback if feedback is on
if (($options->feedback || $options->correct_responses) && ($checked )) { //|| $options->readonly
$a->feedback = format_text($mcanswer->feedback, true, $formatoptions, $cmoptions->course);
} else {
$a->feedback = '';
}
-
+
$anss[] = clone($a);
}
?>
</table>
<?php }else if ($wrapped->options->layout == 2 ){
?>
-
+
<table class="answer">
<tr class="<?php echo 'r'.$row = $row ? 0 : 1; ?>">
<?php $row = 1; foreach ($anss as $answer) { ?>
<?php } ?>
</tr>
</table>
- <?php }
-
+ <?php }
+
}else {
echo "no valid layout";
}
-
+
break;
default:
$a = new stdClass;
- $a->type = $wrapped->qtype ;
+ $a->type = $wrapped->qtype ;
$a->sub = $positionkey;
print_error('unknownquestiontypeofsubquestion', 'qtype_multianswer','',$a);
break;
}
return $responses;
}
-
+
/**
* @param object $question
* @return mixed either a integer score out of 1 that the average random
-<?PHP // $Id$
+<?php
$plugin->version = 2008050800;
$plugin->requires = 2007101509;
-?>
+
-<?php // $Id$
+<?php
-// This file keeps track of upgrades to
+// This file keeps track of upgrades to
// the multichoice qtype plugin
//
// Sometimes, changes between versions involve
// This upgrade actually belongs to the random question type,
// but that does not have a DB upgrade script. Therefore, multichoice
// is doing it.
- // Rename random questions to give them more helpful names.
+ // Rename random questions to give them more helpful names.
if ($result && $oldversion < 2008021800) {
require_once($CFG->libdir . '/questionlib.php');
// Get all categories containing random questions.
return $result;
}
-?>
+
-<?php // $Id$
+<?php
/**
* Defines the editing form for the multichoice question type.
*
return $errors;
}
}
-?>
\ No newline at end of file
-<?php // $Id$
+<?php
/**
* The questiontype class for the multiple choice question type.
*
return $responses;
}
-
+
function format_response($response, $format){
return $this->format_text($response, $format);
}
// Register this question type with the question bank.
question_register_questiontype(new question_multichoice_qtype());
-?>
+
-<?PHP // $Id$
+<?php
$plugin->version = 2009021800;
$plugin->requires = 2007101000;
-?>
+
-<?php // $Id$
+<?php
-// This file keeps track of upgrades to
+// This file keeps track of upgrades to
// the numerical qtype plugin
//
// Sometimes, changes between versions involve
if (!$dbman->table_exists($table)) {
// $dbman->create_table doesnt return a result, we just have to trust it
$dbman->create_table($table);
- }//else
+ }//else
upgrade_plugin_savepoint($result, 2009100100, 'qtype', 'numerical');
}
return $result;
}
-?>
+
-<?php
+<?php
// as the entry is controlled the question type here is numerical
$nameunit = "name=\"".$question->name_prefix."unit\"";
$nameanswer = "name=\"".$question->name_prefix."answer\"";
-//if left unit is placed before answer so we need to answer field text and a center pice for the show units options
+//if left unit is placed before answer so we need to answer field text and a center pice for the show units options
// split the respnse in 2 element numerical and units
/*if (!empty($question->options->showunits)){
if(isset($question->options->units) && count($question->options->units)){
$length = 0;
$goodkey = 0 ;
foreach ($question->options->units as $key => $unit){
- if (false === stripos($value, $unit->unit)){
+ if (false === stripos($value, $unit->unit)){
}else{
-
+
if(strlen($unit->unit)> $length) {$length =strlen($unit->unit);
$goodkey = $key ;
}
}
$state->responses['unit']=$goodkey ;<div class="ablock clearfix">
}
-
+
}*/
if (isset($state->responses['answer']) && $state->responses['answer']!='') {
$valueanswer = ' value="'.s($state->responses['answer']).'" ';
if (isset($state->responses['unit']) && $state->responses['unit']!='') {
$valueunit = ' value="'.s($state->responses['unit']).'" ';
} else {
-
+
$valueunit = ' value="" ';
if ($question->options->showunits == 2 ){
- $valueunit = ' value="'.s($question->options->units[0]->unit).'" ';
- }
+ $valueunit = ' value="'.s($question->options->units[0]->unit).'" ';
+ }
}
- // put a div to enclose the answer and unit elements<div class="clearfix"></div>
+ // put a div to enclose the answer and unit elements<div class="clearfix"></div>
$textlength = 20 ;
?>
<?php echo $feedbackimg; ?>
</fieldset>
</div>
-
-
+
+
<?php }// display unit
- $class = '';
+ $class = '';
$feedbackimgunit = '';
if ($options->feedback){
$classunit = question_get_feedback_class(1-$this->raw_unitpenalty);
$feedbackimgunit = question_get_feedback_image(1-$this->raw_unitpenalty, $options->feedback);
}
if ($question->options->showunits == 3 || (isset($question->options->units) && count($question->options->units) == 0 )) {// no unit display or tested
-
+
?>
<div class="answer">
- <input type="hidden"
- <?php
- echo $nameunit;
- ?>
+ <input type="hidden"
+ <?php
+ echo $nameunit;
+ ?>
value ="" />
</div>
<?php
- } else if ($question->options->showunits == 0 ) {// display unit text input
-?>
+ } else if ($question->options->showunits == 0 ) {// display unit text input
+?>
<div class="answer">
<fieldset class="clearfix" id="generalheader">
<legend class="ftoggler">
<?php echo $feedbackimgunit; ?>
</fieldset>
</div>
-<?php
+<?php
} else if ($question->options->showunits == 2 ) {// display text
-
+
?>
<div class="answer">
<fieldset class="clearfix" id="generalheader">
<legend class="ftoggler">
- <?php echo get_string('unit', 'quiz');
+ <?php echo get_string('unit', 'quiz');
//echo $question->options->units[0]->unit ;
?>
</legend>
- <input type="hidden"
- <?php
- echo $nameunit; echo $valueunit ;
+ <input type="hidden"
+ <?php
+ echo $nameunit; echo $valueunit ;
- ?>
+ ?>
/>
<?php echo $question->options->units[0]->unit ;
- echo ' ' ;
+ echo ' ' ;
?>
</fieldset>
</div>
-
+
<?php
- //display the units as choice
-
+ //display the units as choice
+
} else if ($question->options->showunits == 1){?>
-
-<?php
- //display the units as choice
+
+<?php
+ //display the units as choice
if ($question->options->showunits == 1 && isset($question->options->units)){?>
<div class="answer">
<table class="answer">
-<?php foreach ($question->options->units as $key => $unit) {
+<?php foreach ($question->options->units as $key => $unit) {
$checked = '';
$chosen = false;
-
+
$type = 'type="radio"';
// $nameunit = "name=\"".$question->name_prefix;//."unit\"";
if (isset($state->responses['unit'])){
$checked = 'checked="checked"';
$chosen = true;
}
-
- $aid = $question->id ;
+
+ $aid = $question->id ;
$a = new stdClass;
$a->id = $question->name_prefix."unit" ;//. "2"
$a->class = '';
<?php } ?>
</table>
-
- </div>
+
+ </div>
<?php } // end unit choices
// display intructions
// general message first
}
-
+
if ($question->options->unitsleft == 1 ){?>
-
+
<div class="answer">
<fieldset class="clearfix" id="generalheader">
<legend class="ftoggler">
?> size="<?php echo $textlength;?>"/>
<?php echo $feedbackimg; ?>
</fieldset>
- </div>
-<?php }
+ </div>
+<?php }
//</div> put a div to enclose the answer and unit elements
?>
<?php echo get_string('validnumberformats', 'qtype_numerical');?>
</legend>
<?php echo get_string('validnumbers', 'qtype_numerical');?>
- </fieldset>
+ </fieldset>
</div>
<?php if (!empty($question->options->instructions)){?>
<div>
<?php echo format_text($question->options->instructions, true, $formatoptions, $cmoptions->course);?>
- </div>
- <?php }?>
- </fieldset>
- </div>
+ </div>
+ <?php }?>
+ </fieldset>
+ </div>
<?php ?>
-<?php // $Id$
+<?php
/**
* Defines the editing form for the numerical question type.
*
/*
$mform->addElement('header', 'unithandling', get_string("Units handling", 'qtype_numerical'));
$currentgrp1 = array();
-
+
$currentgrp1[] =& $mform->createElement('text', 'unitpenalty', get_string('Penalty for bad unit', 'qtype_numerical') ,
array('size' => 3));
$currentgrp1[] =& $mform->createElement('static', 'penalty1','hello', get_string('as decimal fraction (0-1) of', 'qtype_numerical'));
return 'numerical';
}
}
-?>
\ No newline at end of file
-<?php // $Id$
+<?php
/**
- * @version $Id$
* @author Martin Dougiamas and many others. Tim Hunt.
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package questionbank
function name() {
return 'numerical';
}
-
+
function has_wildcards_in_responses() {
return true;
}
$question->options->unitsleft = $options->unitsleft ;
$question->options->instructions = $options->instructions ;
}
-
-
+
+
return true;
}
function get_numerical_units(&$question) {
global $DB;
$result = new stdClass;
// numerical options
- $update = true ;
+ $update = true ;
$options = $DB->get_record("question_numerical_options", array("question" => $question->id));
if (!$options) {
$update = false;
/* if ($question->options->showunits == 1){
$state->responses['unit'] = '0';
}*/
-
+
return true;
}
function restore_session_and_responses(&$question, &$state) {
if(false === strpos($state->responses[''], '|||||')){
// temporary
- $state->responses['answer']= $state->responses[''];
+ $state->responses['answer']= $state->responses[''];
$state->responses['unit'] = '';
split_old_answer($state->responses[''], $question->options->units, $state->responses['answer'] ,$state->responses['unit'] );
}else {
}
// echo "<p> restore response $responses || <pre>";print_r($state);echo "</pre></p>";
- /*
+ /*
if ($question->options->showunits == 1 && isset($question->options->units)){
$state->responses['unit']=$this->find_unit_index($question,$state->responses['unit']);
}*/
if($unit->unit ==$value ) {
return $key ;
}
- }
+ }
return 0 ;
}
$DB->delete_records("question_numerical_units", array("question" => $questionid));
return true;
}
-
+
function compare_responses(&$question, $state, $teststate) {
if ($question->options->showunits == 1 && isset($question->options->units) && isset($question->options->units[$state->responses['unit']] )){
$state->responses['unit']=$question->options->units[$state->responses['unit']]->unit;
};
-
+
$responses = '';
$testresponses = '';
if (isset($state->responses['answer'])){
$state->responses['']= $state->responses['answer'].$state->responses['unit'] ;// why?
}
// echo "<p> test response numerical state before apply <pre>";print_r($state);echo "</pre></p>";
-
+
$response = $this->apply_unit($state->responses[''], $question->options->units);
// $this->valid_numerical_unit = $this->valid_unit($state->responses[''], $question->options->units);
- // if ($this->valid_numerical_unit) echo "<p>test responses valid unit </p>";
- // if (!$this->valid_numerical_unit) echo "<p>test responses not valid unit </p>";
+ // if ($this->valid_numerical_unit) echo "<p>test responses valid unit </p>";
+ // if (!$this->valid_numerical_unit) echo "<p>test responses not valid unit </p>";
// echo "<p>state response test $response <pre>";print_r($state);echo "</pre></p>";
// $this->raw_unitpenalty = 0.1 ;
// first one that matches. It also sets the marks and penalty.
// This should be good enought for most simple question types.
// echo "<p>grade responses <pre>";print_r($state->responses);echo "</pre></p>";
-
- //first the split response from unit choice display is converted as
+
+ //first the split response from unit choice display is converted as
// standard numerical response value.unit
/* if (!empty($question->options->showunits) && isset($state->responses['unit'])){
$state->responses[''] .= $question->options->units[$state->responses['unit']]->unit ;
}
- */
+ */
//to apply the unit penalty we need to analyse the response in a more complex way
//the apply_unit() function analysis could be used to obtain the infos
- // however it is used to detect good or bad numbers but also
- // gives false
+ // however it is used to detect good or bad numbers but also
+ // gives false
$state->raw_grade = 0;
foreach($question->options->answers as $answer) {
if($this->test_response($question, $state, $answer)) {
break;
}
}
- // if ($this->valid_numerical_unit) echo "<p>grade responses valid unit </p>";
- // if (!$this->valid_numerical_unit) echo "<p>grade responses not valid unit </p>";
+ // if ($this->valid_numerical_unit) echo "<p>grade responses valid unit </p>";
+ // if (!$this->valid_numerical_unit) echo "<p>grade responses not valid unit </p>";
// apply unit penalty
$this->raw_unitpenalty = 0 ;
if(!empty($question->options->unitpenalty)&& !$this->valid_numerical_unit ){
return true;
}
-
-
+
+
function get_correct_responses(&$question, &$state) {
$correct = parent::get_correct_responses($question, $state);
$unit = $this->get_default_numerical_unit($question);
if (isset($correct['']) && $correct[''] != '*' && $unit) {
$correct[''] .= ' '.$unit->unit;
$correct['unit']= $unit->unit;
- }
+ }
return $correct;
}
}
function get_actual_response($question, $state) {
// echo "<p>state response numerical GET ACTUAL RESPONSE $question->id $question->qtype <pre>";print_r($state);echo "</pre></p>";
- if (!empty($state->responses) && !empty($state->responses[''])) {
+ if (!empty($state->responses) && !empty($state->responses[''])) {
if(false === strpos($state->responses[''], '|||||')){
$responses[] = $state->responses[''];
}else {
$resp = explode('|||||', $state->responses['']);
- $responses[] = $resp[0].$resp[1];
+ $responses[] = $resp[0].$resp[1];
}
} else {
$responses[] = '';
}
-
+
return $responses;
}
// Valid number with unit.
return (float)$responseparts[1] / $tmpunits[$responseparts[5]];
} else {
- // Valid number with invalid unit.
+ // Valid number with invalid unit.
return (float)$responseparts[1];
}
function edit_numerical_options(&$mform, &$that){
$mform->addElement('header', 'unithandling', get_string("Units handling", 'qtype_numerical'));
$currentgrp1 = array();
-
+
$currentgrp1[] =& $mform->createElement('text', 'unitpenalty', get_string('Penalty for bad unit', 'qtype_numerical') ,
array('size' => 3));
$currentgrp1[] =& $mform->createElement('static', 'penalty1','hello', get_string('as decimal fraction (0-1) of', 'qtype_numerical'));
$mform->setType('instructions', PARAM_RAW);
$mform->setHelpButton('instructions', array('instructions', get_string('instructions', 'quiz'), 'quiz'));
-
+
}
function print_question_grading_details(&$question, &$state, $cmoptions, $options) {
// echo "<p>state uestion_grading_details $question->id $question->qtype <pre>";print_r($state);echo "</pre></p>";
parent::print_question_grading_details($question, $state, $cmoptions, $options);
-
- }
-
+
+ }
+
function valid_unit($rawresponse, $units) {
// Make units more useful
$tmpunits = array();
// INITIATION - Without this line the question type is not in use.
question_register_questiontype(new question_numerical_qtype());
-?>
+
-<?php // $Id$
+<?php
/**
* Unit tests for (some of) question/type/numerical/questiontype.php.
*
// }
}
-?>
+
-<?PHP // $Id$
+<?php
$plugin->version = 2009100100;
$plugin->requires = 2007101000;
-?>
+
-<?php // $Id$
-/* This template determines the overall layout of a question. It is included by the
+<?php
+/* This template determines the overall layout of a question. It is included by the
* print_question() method.
*/
?>
-<?php // $Id$
+<?php
/**
* The default questiontype class.
*
return array($form, $question);
}
}
-?>
+
-<?php // $Id$
+<?php
/**
* Defines the editing form for the random question type.
*
// Standard fields at the start of the form.
$mform->addElement('header', 'generalheader', get_string("general", 'form'));
- $mform->addElement('questioncategory', 'category', get_string('category', 'quiz'),
+ $mform->addElement('questioncategory', 'category', get_string('category', 'quiz'),
array('contexts' => $this->contexts->having_cap('moodle/question:useall')));
$mform->addElement('advcheckbox', 'questiontext', get_string("recurse", "quiz"), null, null, array(0, 1));
return 'random';
}
}
-?>
\ No newline at end of file
-<?php // $Id$
+<?php
/**
* Class for the random question type.
*
return $answer_field;
}
-
+
/**
* For random question type return empty string which means won't calculate.
* @param object $question
//////////////////////////////////////////////////////////////////////////
question_register_questiontype(new random_qtype());
-?>
+
-<?php // $Id$
+<?php
-// This file keeps track of upgrades to
+// This file keeps track of upgrades to
// the randomsamatch qtype plugin
//
// Sometimes, changes between versions involve
$dbman = $DB->get_manager();
$result = true;
-/// And upgrade begins here. For each one, you'll need one
-/// block of code similar to the next one. Please, delete
+/// And upgrade begins here. For each one, you'll need one
+/// block of code similar to the next one. Please, delete
/// this comment lines once this file start handling proper
/// upgrade code.
return $result;
}
-?>
+
-<?php // $Id$
+<?php
/**
* Defines the editing form for the randomsamatch question type.
*
}
}
-?>
+
-<?php // $Id$
+<?php
/////////////////////
/// RANDOMSAMATCH ///
echo $OUTPUT->notification("Couldn't get question options (id=$response[0])!");
return false;
}
-
+
// Now we overwrite the $question->options->answers field to only
// *one* (the first) correct answer. This loop can be deleted to
// take all answers into account (i.e. put them all into the
} else {
$categorylist = $question->category;
}
-
+
$question->options->subquestions = $this->get_sa_candidates($categorylist);
foreach ($question->options->subquestions as $key => $wrappedquestion) {
if (!$QTYPES[$wrappedquestion->qtype]
->get_question_options($wrappedquestion)) {
return false;
}
-
+
// Now we overwrite the $question->options->answers field to only
// *one* (the first) correct answer. This loop can be deleted to
// take all answers into account (i.e. put them all into the
//// INITIATION - Without this line the question type is not in use... ///
//////////////////////////////////////////////////////////////////////////
question_register_questiontype(new question_randomsamatch_qtype());
-?>
+
-<?PHP // $Id$
+<?php
$plugin->version = 2006042800;
$plugin->requires = 2007101000;
-?>
+
-<?php // $Id$
+<?php
-// This file keeps track of upgrades to
+// This file keeps track of upgrades to
// the shortanswer qtype plugin
//
// Sometimes, changes between versions involve
$dbman = $DB->get_manager();
$result = true;
-/// And upgrade begins here. For each one, you'll need one
-/// block of code similar to the next one. Please, delete
+/// And upgrade begins here. For each one, you'll need one
+/// block of code similar to the next one. Please, delete
/// this comment lines once this file start handling proper
/// upgrade code.
return $result;
}
-?>
+
<div class="prompt">
<?php echo get_string("answer", "quiz").': '; ?>
</div>
- <?php if ($question->qtype == 'numerical' || $question->qtype == 'calculated' || $question->qtype == 'calculatedsimple' ){
+ <?php if ($question->qtype == 'numerical' || $question->qtype == 'calculated' || $question->qtype == 'calculatedsimple' ){
include("$CFG->dirroot/question/type/numerical/display.html");?>
<?php }else {?>
<div class="answer">
-<?php // $Id$
+<?php
/**
* Defines the editing form for the shortanswer question type.
*
return 'shortanswer';
}
}
-?>
\ No newline at end of file
-<?php // $Id$
+<?php
///////////////////
/// SHORTANSWER ///
if ($options->feedback) {
$class = question_get_feedback_class(0);
$feedbackimg = question_get_feedback_image(0);
- //this is OK for the first answer with a good response
+ //this is OK for the first answer with a good response
foreach($question->options->answers as $answer) {
if ($this->test_response($question, $state, $answer)) {
}
// let student know wether the answer was correct
- $class = question_get_feedback_class($state->last_graded->raw_grade /
+ $class = question_get_feedback_class($state->last_graded->raw_grade /
$question->maxgrade);
echo '<div class="correctness ' . $class . '">' . get_string($class, 'quiz');
if ($correctanswer && ($class == 'partiallycorrect' || $class == 'incorrect')) {
// A penalty was applied so display it
echo ' '.$grade->numerical;
//print_string('gradingdetailspenalty', 'quiz', question_format_grade($cmoptions, $this->raw_unitpenalty));
- echo ' ';
+ echo ' ';
print_string('gradingdetailspenalty', 'quiz', question_format_grade($cmoptions, $state->last_graded->penalty));
} else {
/* No penalty was applied even though the answer was
//// INITIATION - Without this line the question type is not in use... ///
//////////////////////////////////////////////////////////////////////////
question_register_questiontype(new question_shortanswer_qtype());
-?>
+
-<?php // $Id$
+<?php
/**
* Unit tests for (some of) question/type/shortanswer/questiontype.php.
*
}
}
-?>
+
-<?PHP // $Id$
+<?php
$plugin->version = 2006032200;
$plugin->requires = 2007101000;
-?>
+
-<?php // $Id$
+<?php
///////////////////////////////////////////////////////////////////////////
// //
}
}
-?>
+
-<?php // $Id$
+<?php
-// This file keeps track of upgrades to
+// This file keeps track of upgrades to
// the truefalse qtype plugin
//
// Sometimes, changes between versions involve
$dbman = $DB->get_manager();
$result = true;
-/// And upgrade begins here. For each one, you'll need one
-/// block of code similar to the next one. Please, delete
+/// And upgrade begins here. For each one, you'll need one
+/// block of code similar to the next one. Please, delete
/// this comment lines once this file start handling proper
/// upgrade code.
return $result;
}
-?>
+
<div class="ablock clearfix">
<div class="prompt">
- <?php print_string('answer', 'quiz') ?>:
+ <?php print_string('answer', 'quiz') ?>:
</div>
<div class="answer">
-<?php // $Id$
+<?php
require_once($CFG->dirroot.'/question/type/edit_question_form.php');
/**
* Defines the editing form for the thruefalse question type.
return 'truefalse';
}
}
-?>
\ No newline at end of file
-<?php // $Id$
+<?php
/////////////////
/// TRUEFALSE ///
//// INITIATION - Without this line the question type is not in use... ///
//////////////////////////////////////////////////////////////////////////
question_register_questiontype(new question_truefalse_qtype());
-?>
+
-<?PHP // $Id$
+<?php
$plugin->version = 2006032200;
$plugin->requires = 2007101000;
-?>
+
-<?php // $Id$
+<?php
/**
* This file contains dtabase upgrade code that is called from lib/db/upgrade.php,
* and also check methods that can be used for pre-install checks via
return $DB->execute("UPDATE {question} SET parent = id WHERE qtype = 'random' AND parent <> id");
}
-?>
+
-/* $Id$ */
-
/*************************************************
***
*** pda