arsort($gradeoptionsfull, SORT_NUMERIC);
// construct return object
- $grades = new stdClass;
+ $grades = new stdClass();
$grades->gradeoptions = $gradeoptions;
$grades->gradeoptionsfull = $gradeoptionsfull;
}
$DB->set_field('question_categories', 'contextid', $newcontext->id, array('contextid'=>$context->id));
if ($feedback) {
- $a = new stdClass;
+ $a = new stdClass();
$a->oldplace = print_context_name($context);
$a->newplace = print_context_name($newcontext);
echo $OUTPUT->notification(get_string('movedquestionsandcategories', 'question', $a), 'notifysuccess');
foreach ($contexts as $key => $context) {
if (!$exists = $DB->record_exists("question_categories", array('contextid'=>$context->id))) {
// Otherwise, we need to make one
- $category = new stdClass;
+ $category = new stdClass();
$contextname = print_context_name($context, false, true);
$category->name = get_string('defaultfor', 'question', $contextname);
$category->info = get_string('defaultinfofor', 'question', $contextname);
*/
function question_default_export_filename($course, $category) {
// We build a string that is an appropriate name (questions) from the lang pack,
- // then the corse shortname, then the question category name, then a timestamp.
+ // then the corse shortname, then the question category name, then a timestamp.
$base = clean_filename(get_string('exportfilename', 'question'));
* Adds question bank setting links to the given navigation node if caps are met.
*
* @param navigation_node $navigationnode The navigation node to add the question branch to
- * @param stdClass $context
+ * @param object $context
* @return navigation_node Returns the question branch that was added
*/
function question_extend_settings_navigation(navigation_node $navigationnode, $context) {
$qnostring = 'questionnonavinfo';
}
- $a = new stdClass;
+ $a = new stdClass();
$a->number = $number;
$a->attributes = implode(' ', $attributes);
echo $OUTPUT->header();
// Initialise the JavaScript.
-$quizeditconfig = new stdClass;
+$quizeditconfig = new stdClass();
$quizeditconfig->url = $thispageurl->out(true, array('qbanktool' => '0'));
$quizeditconfig->dialoglisteners = array();
$numberoflisteners = max(quiz_number_of_pages($quiz->questions), 1);
$DB->set_field('quiz', 'questions', $quiz->questions, array('id' => $quiz->id));
// Add the new question instance.
- $instance = new stdClass;
+ $instance = new stdClass();
$instance->quiz = $quiz->id;
$instance->question = $id;
$instance->grade = $DB->get_field('question', 'defaultmark', array('id' => $id));
$form->defaultmark = 1;
$form->hidden = 1;
$form->stamp = make_unique_id_code(); // Set the unique code (not to be changed)
- $question = new stdClass;
+ $question = new stdClass();
$question->qtype = 'random';
$question = question_bank::get_qtype('random')->save_question($question, $form);
if (!isset($question->id)) {
print_random_option_icon($question);
echo ' ' . get_string('randomfromcategory', 'quiz') . '</div>';
- $a = new stdClass;
+ $a = new stdClass();
$a->arrow = $OUTPUT->rarrow();
$strshowcategorycontents = get_string('showcategorycontents', 'quiz', $a);
echo '<br />';
// Embed the link into the string with instructions
- $a = new stdClass;
+ $a = new stdClass();
$a->catname = '<strong>' . $category->name . '</strong>';
$a->link = $linkcategorycontents;
echo get_string('addnewquestionsqbank', 'quiz', $a);
}
$result .= shorten_text(format_string($question->name), 200) . '</span>';
if ($showquestiontext) {
- $formatoptions = new stdClass;
+ $formatoptions = new stdClass();
$formatoptions->noclean = true;
$formatoptions->para = false;
$questiontext = strip_tags(format_text($question->questiontext,
}
protected function print_category_info($category) {
- $formatoptions = new stdClass;
+ $formatoptions = new stdClass();
$formatoptions->noclean = true;
$strcategory = get_string('category', 'quiz');
echo '<div class="categoryinfo"><div class="categorynamefieldcontainer">' .
$feedback = '';
if ($quiz->grade && array_key_exists($quiz->id, grades)) {
if ($alloptions->marks) {
- $a = new stdClass;
+ $a = new stdClass();
$a->grade = quiz_format_grade($quiz, $grades[$quiz->id]);
$a->maxgrade = quiz_format_grade($quiz, $quiz->grade);
$grade = get_string('outofshort', 'quiz', $a);
/**
* Delete all the attempts belonging to a quiz.
*
- * @global stdClass
- * @global object
* @param object $quiz The quiz object.
*/
function quiz_delete_all_attempts($quiz) {
$grade = reset($grades->items[0]->grades);
}
- $result = new stdClass;
+ $result = new stdClass();
$result->info = get_string('grade') . ': ' . $grade->str_long_grade;
$result->time = $grade->dategraded;
return $result;
$options = quiz_get_review_options($quiz, $attempt, $context);
- $tmpactivity = new stdClass;
+ $tmpactivity = new stdClass();
$tmpactivity->type = 'quiz';
$tmpactivity->cmid = $cm->id;
$DB->delete_records('quiz_feedback', array('quizid' => $quiz->id));
for ($i = 0; $i <= $quiz->feedbackboundarycount; $i++) {
- $feedback = new stdClass;
+ $feedback = new stdClass();
$feedback->quizid = $quiz->id;
$feedback->feedbacktext = $quiz->feedbacktext[$i]['text'];
$feedback->feedbacktextformat = $quiz->feedbacktext[$i]['format'];
// need to add all the overrides
$overrides = $DB->get_records('quiz_overrides', array('quiz' => $quiz->id));
// as well as the original quiz (empty override)
- $overrides[] = new stdClass;
+ $overrides[] = new stdClass();
}
else {
// Just do the one override
$addopen = empty($current->id) || !empty($current->timeopen);
$addclose = empty($current->id) || !empty($current->timeclose);
- $event = new stdClass;
+ $event = new stdClass();
$event->description = $quiz->intro;
$event->courseid = ($userid) ? 0 : $quiz->course; // Events module won't show user events when the courseid is nonzero
$event->groupid = $groupid;
// Determine the event name
if ($groupid) {
- $params = new stdClass;
+ $params = new stdClass();
$params->quiz = $quiz->name;
$params->group = groups_get_group_name($groupid);
if ($params->group === false) {
$eventname = get_string('overridegroupeventname', 'quiz', $params);
}
else if ($userid) {
- $params = new stdClass;
+ $params = new stdClass();
$params->quiz = $quiz->name;
$eventname = get_string('overrideusereventname', 'quiz', $params);
} else {
}
/**
- * @global object
- * @global stdClass
* @return array all other caps used in module
*/
function quiz_get_extra_capabilities() {
* available
*
* @param navigation_node $quiznode The quiz node within the global navigation
- * @param stdClass $course The course object returned from the DB
- * @param stdClass $module The module object returned from the DB
- * @param stdClass $cm The course module instance returned from the DB
+ * @param object $course The course object returned from the DB
+ * @param object $module The module object returned from the DB
+ * @param object $cm The course module instance returned from the DB
*/
function quiz_extend_navigation($quiznode, $course, $module, $cm) {
global $CFG;
if ($attemptnumber == 1 || !$quiz->attemptonlast) {
/// We are not building on last attempt so create a new attempt.
- $attempt = new stdClass;
+ $attempt = new stdClass();
$attempt->quiz = $quiz->id;
$attempt->userid = $USER->id;
$attempt->preview = 0;
}
// Clean the text, ready for display.
- $formatoptions = new stdClass;
+ $formatoptions = new stdClass();
$formatoptions->noclean = true;
$feedbacktext = file_rewrite_pluginfile_urls($feedback->feedbacktext, 'pluginfile.php', $context->id, 'mod_quiz', 'feedback', $feedback->id);
$feedbacktext = format_text($feedbacktext, $feedback->feedbacktextformat, $formatoptions);
$todelete[] = $changedgrade->userid;
} else if (is_null($changedgrade->grade)) {
- $toinsert = new stdClass;
+ $toinsert = new stdClass();
$toinsert->quiz = $quiz->id;
$toinsert->userid = $changedgrade->userid;
$toinsert->timemodified = $timenow;
$DB->insert_record('quiz_grades', $toinsert);
} else {
- $toupdate = new stdClass;
+ $toupdate = new stdClass();
$toupdate->id = $changedgrade->id;
$toupdate->grade = $changedgrade->newgrade;
$toupdate->timemodified = $timenow;
// Actually we only do this for states whose question is actually listed in $attempt->layout.
// We do not do it for states associated to wrapped questions like for example the questions
// used by a RANDOM question
- $session = new stdClass;
+ $session = new stdClass();
$session->attemptid = $attempt->uniqueid;
$questionlist = quiz_questions_in_quiz($attempt->layout);
$params = array($attempt->uniqueid);
*/
function quiz_get_combined_reviewoptions($quiz, $attempts) {
$fields = array('marks', 'feedback', 'generalfeedback', 'rightanswer', 'overallfeedback');
- $someoptions = new stdClass;
- $alloptions = new stdClass;
+ $someoptions = new stdClass();
+ $alloptions = new stdClass();
foreach ($fields as $field) {
$someoptions->$field = false;
$alloptions->$field = true;
/**
* Sends confirmation email to the student taking the course
*
- * @param stdClass $a associative array of replaceable fields for the templates
+ * @param object $a associative array of replaceable fields for the templates
*
* @return bool|string result of events_triger
*/
* Sends notification messages to the interested parties that assign the role capability
*
* @param object $recipient user object of the intended recipient
- * @param stdClass $a associative array of replaceable fields for the templates
+ * @param object $a associative array of replaceable fields for the templates
*
* @return bool|string result of events_triger()
*/
// if something to send, then build $a
if (! empty($userstonotify) or $sendconfirm) {
- $a = new stdClass;
+ $a = new stdClass();
// course info
$a->coursename = $course->fullname;
$a->courseshortname = $course->shortname;
/**
* Set up the various options from the quiz settings, and a time constant.
- * @param stdClass $quiz the quiz settings.
+ * @param object $quiz the quiz settings.
* @param integer $one of the {@link DURING}, {@link IMMEDIATELY_AFTER},
* {@link LATER_WHILE_OPEN} or {@link AFTER_CLOSE} constants.
* @return mod_quiz_display_options set up appropriately.
$mform = new quiz_grading_settings($hidden, $counts, $shownames, $showidnumbers);
// Tell the form the current settings.
- $settings = new stdClass;
+ $settings = new stdClass();
$settings->grade = $grade;
$settings->pagesize = $pagesize;
$settings->order = $order;
// Print the heading and form.
echo question_engine::initialise_js();
- $a = new stdClass;
+ $a = new stdClass();
$a->number = $this->questions[$slot]->number;
$a->questionname = format_string($counts->name);
echo $OUTPUT->heading(get_string('gradingquestionx', 'quiz_grading', $a));
$mform->display();
// Paging info.
- $a = new stdClass;
+ $a = new stdClass();
$a->from = $page * $pagesize + 1;
$a->to = min(($page + 1) * $pagesize, $count);
$a->of = $count;
}
protected function get_question_heading($attempt, $shownames, $showidnumbers) {
- $a = new stdClass;
+ $a = new stdClass();
$a->attempt = $attempt->attempt;
$a->fullname = fullname($attempt);
$a->idnumber = $attempt->idnumber;
$record = $gradeaverages[$question->slot];
$record->grade = quiz_rescale_grade($record->averagefraction * $question->maxmark, $this->quiz, false);
} else {
- $record = new stdClass;
+ $record = new stdClass();
$record->grade = null;
$record->numaveraged = null;
}
$finished = $attempt->timefinish > 0;
foreach ($slots as $slot) {
- $qqr = new stdClass;
+ $qqr = new stdClass();
$qqr->oldfraction = $quba->get_question_fraction($slot);
$quba->regrade_question($slot, $finished);
/**
* Get the slots of real questions (not descriptions) in this quiz, in order.
* @param object $quiz the quiz.
- * @return array of slot => $question object with fields ->slot, ->id, ->maxmark, ->number, ->length.
+ * @return array of slot => $question object with fields ->slot, ->id, ->maxmark, ->number, ->length.
*/
function quiz_report_get_significant_questions($quiz) {
global $DB;
}
// Clean the text, ready for display.
- $formatoptions = new stdClass;
+ $formatoptions = new stdClass();
$formatoptions->noclean = true;
$feedbacktext = file_rewrite_pluginfile_urls($feedbacktext, 'pluginfile.php', $context->id, 'mod_quiz', 'feedback', $feedbackid);
$feedbacktext = format_text($feedbacktext, $feedbacktextformat, $formatoptions);
}
function test_quiz_report_scale_summarks_as_percentage() {
- $quiz = new stdClass;
+ $quiz = new stdClass();
$quiz->sumgrades = 10;
$quiz->decimalpoints = 2;
* @return object ready to hold all the question statistics.
*/
protected function make_blank_question_stats() {
- $stats = new stdClass;
+ $stats = new stdClass();
$stats->slot = null;
$stats->s = 0;
$stats->totalmarks = 0;
}
foreach ($responesstats->responseclasses as $partid => $partclasses) {
- $rowdata = new stdClass;
+ $rowdata = new stdClass();
$rowdata->part = $partid;
foreach ($partclasses as $responseclassid => $responseclass) {
$rowdata->responseclass = $responseclass->responseclass;
*/
protected function get_emtpy_stats($questions, $firstattemptscount = 0,
$allattemptscount = 0) {
- $quizstats = new stdClass;
+ $quizstats = new stdClass();
$quizstats->firstattemptscount = $firstattemptscount;
$quizstats->allattemptscount = $allattemptscount;
- $qstats = new stdClass;
+ $qstats = new stdClass();
$qstats->questions = $questions;
$qstats->subquestions = array();
$qstats->responses = array();
$firstattempts = $attempttotals[1];
$firstattempts->average = $firstattempts->total / $firstattempts->countrecs;
} else {
- $firstattempts = new stdClass;
+ $firstattempts = new stdClass();
$firstattempts->countrecs = 0;
$firstattempts->total = 0;
$firstattempts->average = '-';
}
- $allattempts = new stdClass;
+ $allattempts = new stdClass();
if (isset($attempttotals[0])) {
$allattempts->countrecs = $firstattempts->countrecs + $attempttotals[0]->countrecs;
$allattempts->total = $firstattempts->total + $attempttotals[0]->total;
}
$summarksavg = $usingattempts->total / $usingattempts->countrecs;
- $quizstats = new stdClass;
+ $quizstats = new stdClass();
$quizstats->allattempts = $useallattempts;
$quizstats->firstattemptscount = $firstattempts->countrecs;
$quizstats->allattemptscount = $allattempts->countrecs;
//fetch sum of squared, cubed and power 4d
//differences between marks and mean mark
$mean = $usingattempts->total / $s;
- $sql = "SELECT
+ $sql = "SELECT
SUM(POWER((quiza.sumgrades - $mean),2)) AS power2,
SUM(POWER((quiza.sumgrades - $mean),3)) AS power3,
SUM(POWER((quiza.sumgrades - $mean),4)) AS power4
}
// Generate the output.
- $a = new stdClass;
+ $a = new stdClass();
$a->lastcalculated = format_time(time() - $quizstats->timemodified);
$a->count = $count;
public $responses = array();
/**
- * @var array An array of
- * $this->fractions[$subpartid][$responseclassid] is an object with two
- * fields, ->responseclass and ->fraction.
+ * @var array $this->fractions[$subpartid][$responseclassid] is an object
+ * with two fields, ->responseclass and ->fraction.
*/
public $responseclasses = array();
$partresponses = $qa->classify_response();
foreach ($partresponses as $subpartid => $partresponse) {
if (!isset($this->responses[$subpartid][$partresponse->responseclassid][$partresponse->response])) {
- $resp = new stdClass;
+ $resp = new stdClass();
$resp->count = 0;
if (!is_null($partresponse->fraction)) {
$resp->fraction = $partresponse->fraction;
foreach ($this->responses as $subpartid => $partdata) {
foreach ($partdata as $responseclassid => $classdata) {
foreach ($classdata as $response => $data) {
- $row = new stdClass;
+ $row = new stdClass();
$row->quizstatisticsid = $quizstatisticsid;
$row->questionid = $this->questiondata->id;
$row->subqid = $subpartid;
} else {
// Show raw marks only if they are different from the grade (like on the view page).
if ($quiz->grade != $quiz->sumgrades) {
- $a = new stdClass;
+ $a = new stdClass();
$a->grade = quiz_format_grade($quiz, $attempt->sumgrades);
$a->maxgrade = quiz_format_grade($quiz, $quiz->sumgrades);
$rows[] = '<tr><th scope="row" class="cell">' . get_string('marks', 'quiz') . '</th><td class="cell">' .
}
// Now the scaled grade.
- $a = new stdClass;
+ $a = new stdClass();
$a->grade = '<b>' . quiz_format_grade($quiz, $grade) . '</b>';
$a->maxgrade = quiz_format_grade($quiz, $quiz->grade);
if ($quiz->grade != 100) {
class simple_rules_test extends UnitTestCase {
public static $includecoverage = array('mod/quiz/locallib.php');
function test_num_attempts_access_rule() {
- $quiz = new stdClass;
+ $quiz = new stdClass();
$quiz->attempts = 3;
$quiz->questions = '';
- $cm = new stdClass;
+ $cm = new stdClass();
$cm->id = 0;
$quizobj = new quiz($quiz, $cm, null);
$rule = new num_attempts_access_rule($quizobj, 0);
- $attempt = new stdClass;
+ $attempt = new stdClass();
$this->assertEqual($rule->description(), get_string('attemptsallowedn', 'quiz', 3));
}
function test_ipaddress_access_rule() {
- $quiz = new stdClass;
- $attempt = new stdClass;
- $cm = new stdClass;
+ $quiz = new stdClass();
+ $attempt = new stdClass();
+ $cm = new stdClass();
$cm->id = 0;
// Test the allowed case by getting the user's IP address. However, this
}
function test_time_limit_access_rule() {
- $quiz = new stdClass;
+ $quiz = new stdClass();
$quiz->timelimit = 3600;
$quiz->questions = '';
- $cm = new stdClass;
+ $cm = new stdClass();
$cm->id = 0;
$quizobj = new quiz($quiz, $cm, null);
$rule = new time_limit_access_rule($quizobj, 10000);
- $attempt = new stdClass;
+ $attempt = new stdClass();
$this->assertEqual($rule->description(), get_string('quiztimelimit', 'quiz', format_time(3600)));
*/
class open_close_date_access_rule_test extends UnitTestCase {
function test_no_dates() {
- $quiz = new stdClass;
+ $quiz = new stdClass();
$quiz->timeopen = 0;
$quiz->timeclose = 0;
$quiz->questions = '';
- $cm = new stdClass;
+ $cm = new stdClass();
$cm->id = 0;
$quizobj = new quiz($quiz, $cm, null);
- $attempt = new stdClass;
+ $attempt = new stdClass();
$attempt->preview = 0;
$rule = new open_close_date_access_rule($quizobj, 10000);
}
function test_start_date() {
- $quiz = new stdClass;
+ $quiz = new stdClass();
$quiz->timeopen = 10000;
$quiz->timeclose = 0;
$quiz->questions = '';
- $cm = new stdClass;
+ $cm = new stdClass();
$cm->id = 0;
$quizobj = new quiz($quiz, $cm, null);
- $attempt = new stdClass;
+ $attempt = new stdClass();
$attempt->preview = 0;
$rule = new open_close_date_access_rule($quizobj, 9999);
}
function test_close_date() {
- $quiz = new stdClass;
+ $quiz = new stdClass();
$quiz->timeopen = 0;
$quiz->timeclose = 20000;
$quiz->questions = '';
- $cm = new stdClass;
+ $cm = new stdClass();
$cm->id = 0;
$quizobj = new quiz($quiz, $cm, null);
- $attempt = new stdClass;
+ $attempt = new stdClass();
$attempt->preview = 0;
$rule = new open_close_date_access_rule($quizobj, 20000);
}
function test_both_dates() {
- $quiz = new stdClass;
+ $quiz = new stdClass();
$quiz->timeopen = 10000;
$quiz->timeclose = 20000;
$quiz->questions = '';
- $cm = new stdClass;
+ $cm = new stdClass();
$cm->id = 0;
$quizobj = new quiz($quiz, $cm, null);
- $attempt = new stdClass;
+ $attempt = new stdClass();
$attempt->preview = 0;
$rule = new open_close_date_access_rule($quizobj, 9999);
*/
class inter_attempt_delay_access_rule_test extends UnitTestCase {
function test_just_first_delay() {
- $quiz = new stdClass;
+ $quiz = new stdClass();
$quiz->attempts = 3;
$quiz->timelimit = 0;
$quiz->delay1 = 1000;
$quiz->delay2 = 0;
$quiz->timeclose = 0;
$quiz->questions = '';
- $cm = new stdClass;
+ $cm = new stdClass();
$cm->id = 0;
$quizobj = new quiz($quiz, $cm, null);
- $attempt = new stdClass;
+ $attempt = new stdClass();
$attempt->timefinish = 10000;
$rule = new inter_attempt_delay_access_rule($quizobj, 10000);
}
function test_just_second_delay() {
- $quiz = new stdClass;
+ $quiz = new stdClass();
$quiz->attempts = 5;
$quiz->timelimit = 0;
$quiz->delay1 = 0;
$quiz->delay2 = 1000;
$quiz->timeclose = 0;
$quiz->questions = '';
- $cm = new stdClass;
+ $cm = new stdClass();
$cm->id = 0;
$quizobj = new quiz($quiz, $cm, null);
- $attempt = new stdClass;
+ $attempt = new stdClass();
$attempt->timefinish = 10000;
$rule = new inter_attempt_delay_access_rule($quizobj, 10000);
}
function test_just_both_delays() {
- $quiz = new stdClass;
+ $quiz = new stdClass();
$quiz->attempts = 5;
$quiz->timelimit = 0;
$quiz->delay1 = 2000;
$quiz->delay2 = 1000;
$quiz->timeclose = 0;
$quiz->questions = '';
- $cm = new stdClass;
+ $cm = new stdClass();
$cm->id = 0;
$quizobj = new quiz($quiz, $cm, null);
- $attempt = new stdClass;
+ $attempt = new stdClass();
$attempt->timefinish = 10000;
$rule = new inter_attempt_delay_access_rule($quizobj, 10000);
}
function test_with_close_date() {
- $quiz = new stdClass;
+ $quiz = new stdClass();
$quiz->attempts = 5;
$quiz->timelimit = 0;
$quiz->delay1 = 2000;
$quiz->delay2 = 1000;
$quiz->timeclose = 15000;
$quiz->questions = '';
- $cm = new stdClass;
+ $cm = new stdClass();
$cm->id = 0;
$quizobj = new quiz($quiz, $cm, null);
- $attempt = new stdClass;
+ $attempt = new stdClass();
$attempt->timefinish = 13000;
$rule = new inter_attempt_delay_access_rule($quizobj, 10000);
}
function test_time_limit_and_overdue() {
- $quiz = new stdClass;
+ $quiz = new stdClass();
$quiz->attempts = 5;
$quiz->timelimit = 100;
$quiz->delay1 = 2000;
$quiz->delay2 = 1000;
$quiz->timeclose = 0;
$quiz->questions = '';
- $cm = new stdClass;
+ $cm = new stdClass();
$cm->id = 0;
$quizobj = new quiz($quiz, $cm, null);
- $attempt = new stdClass;
+ $attempt = new stdClass();
$attempt->timestart = 9900;
$attempt->timefinish = 10100;
*/
class password_access_rule_test extends UnitTestCase {
function test_password_access_rule() {
- $quiz = new stdClass;
+ $quiz = new stdClass();
$quiz->password = 'frog';
$quiz->questions = '';
- $cm = new stdClass;
+ $cm = new stdClass();
$cm->id = 0;
$quizobj = new quiz($quiz, $cm, null);
$rule = new password_access_rule($quizobj, 0);
- $attempt = new stdClass;
+ $attempt = new stdClass();
$this->assertFalse($rule->prevent_access());
$this->assertEqual($rule->description(), get_string('requirepasswordmessage', 'quiz'));
// Nothing very testable in this class, just test that it obeys the general access rule contact.
function test_securewindow_access_rule() {
- $quiz = new stdClass;
+ $quiz = new stdClass();
$quiz->popup = 1;
$quiz->questions = '';
- $cm = new stdClass;
+ $cm = new stdClass();
$cm->id = 0;
$quizobj = new quiz($quiz, $cm, null);
$rule = new securewindow_access_rule($quizobj, 0);
- $attempt = new stdClass;
+ $attempt = new stdClass();
$this->assertFalse($rule->prevent_access());
$this->assertFalse($rule->description());
*/
class quiz_access_manager_test extends UnitTestCase {
public function test_cannot_review_message() {
- $quiz = new stdClass;
+ $quiz = new stdClass();
$quiz->reviewattempt = 0x10010;
$quiz->timeclose = 0;
$quiz->attempts = 0;
$quiz->questions = '1,2,0,3,4,0';
- $cm = new stdClass;
+ $cm = new stdClass();
$cm->id = 123;
- $quizobj = new quiz($quiz, $cm, new stdClass, false);
+ $quizobj = new quiz($quiz, $cm, new stdClass(), false);
$am = new quiz_access_manager($quizobj, time(), false);
$closetime = time() + 10000;
$quiz->timeclose = $closetime;
- $quizobj = new quiz($quiz, $cm, new stdClass, false);
+ $quizobj = new quiz($quiz, $cm, new stdClass(), false);
$am = new quiz_access_manager($quizobj, time(), false);
$this->assertEqual(get_string('noreviewuntil', 'quiz', userdate($closetime)),
class quiz_lib_test extends UnitTestCase {
public static $includecoverage = array('mod/quiz/lib.php');
function test_quiz_has_grades() {
- $quiz = new stdClass;
+ $quiz = new stdClass();
$quiz->grade = '100.0000';
$quiz->sumgrades = '100.0000';
$this->assertTrue(quiz_has_grades($quiz));
}
function test_quiz_format_grade() {
- $quiz = new stdClass;
+ $quiz = new stdClass();
$quiz->decimalpoints = 2;
$this->assertEqual(quiz_format_grade($quiz, 0.12345678), format_float(0.12, 2));
$this->assertEqual(quiz_format_grade($quiz, 0), format_float(0, 2));
}
function test_quiz_format_question_grade() {
- $quiz = new stdClass;
+ $quiz = new stdClass();
$quiz->decimalpoints = 2;
$quiz->questiondecimalpoints = 2;
$this->assertEqual(quiz_format_question_grade($quiz, 0.12345678), format_float(0.12, 2));
}
function test_quiz_rescale_grade() {
- $quiz = new stdClass;
+ $quiz = new stdClass();
$quiz->decimalpoints = 2;
$quiz->questiondecimalpoints = 3;
$quiz->grade = 10;
}
public function test_quiz_get_slot_for_question() {
- $quiz = new stdClass;
+ $quiz = new stdClass();
$quiz->questions = '1,2,0,7,0';
$this->assertEqual(1, quiz_get_slot_for_question($quiz, 1));
$this->assertEqual(3, quiz_get_slot_for_question($quiz, 7));
*/
class mod_quiz_display_options_test extends UnitTestCase {
function test_num_attempts_access_rule() {
- $quiz = new stdClass;
+ $quiz = new stdClass();
$quiz->decimalpoints = 2;
$quiz->questiondecimalpoints = -1;
$quiz->reviewattempt = 0x11110;
if ($overallstats) {
if ($moreattempts) {
- $a = new stdClass;
+ $a = new stdClass();
$a->method = quiz_get_grading_option_name($quiz->grademethod);
$a->mygrade = quiz_format_grade($quiz, $mygrade);
$a->quizgrade = quiz_format_grade($quiz, $quiz->grade);
$resultinfo .= $OUTPUT->heading(get_string('gradesofar', 'quiz', $a), 2, 'main');
} else {
- $a = new stdClass;
+ $a = new stdClass();
$a->grade = quiz_format_grade($quiz, $mygrade);
$a->maxgrade = quiz_format_grade($quiz, $quiz->grade);
$a = get_string('outofshort', 'quiz', $a);
}
// Display the grading details from the last graded state
- $mark = new stdClass;
+ $mark = new stdClass();
$mark->max = $qa->format_max_mark($options->markdp);
$actualmark = $gradedstep->get_fraction() * $qa->get_max_mark();
* @return string the comment, ready to be output.
*/
public function format_comment($comment = null, $commentformat = null) {
- $formatoptions = new stdClass;
+ $formatoptions = new stdClass();
$formatoptions->noclean = true;
$formatoptions->para = false;
* @param unknown_type $step
*/
protected function summarise_manual_comment($step) {
- $a = new stdClass;
+ $a = new stdClass();
if ($step->has_behaviour_var('comment')) {
$a->comment = shorten_text(html_to_text($this->format_comment(
$step->get_behaviour_var('comment')), 0, false), 200);
if (!is_null($currentmark)) {
$attributes['value'] = $qa->format_fraction_as_mark($currentmark / $maxmark, $options->markdp);
}
- $a = new stdClass;
+ $a = new stdClass();
$a->max = $qa->format_max_mark($options->markdp);
$a->mark = html_writer::empty_tag('input', $attributes);
public function display_move_form($questionsincategory, $category){
global $OUTPUT;
- $vars = new stdClass;
+ $vars = new stdClass();
$vars->name = $category->name;
$vars->count = $questionsincategory;
echo $OUTPUT->box(get_string('categorymove', 'quiz', $vars), 'generalbox boxaligncenter');
protected function display_content($question, $rowclasses) {
if (!empty($question->creatorfirstname) && !empty($question->creatorlastname)) {
- $u = new stdClass;
+ $u = new stdClass();
$u->firstname = $question->creatorfirstname;
$u->lastname = $question->creatorlastname;
echo fullname($u);
protected function display_content($question, $rowclasses) {
if (!empty($question->modifierfirstname) && !empty($question->modifierlastname)) {
- $u = new stdClass;
+ $u = new stdClass();
$u->firstname = $question->modifierfirstname;
$u->lastname = $question->modifierlastname;
echo fullname($u);
protected $formatoptions;
protected function init() {
- $this->formatoptions = new stdClass;
+ $this->formatoptions = new stdClass();
$this->formatoptions->noclean = true;
$this->formatoptions->para = false;
}
}
protected function print_category_info($category) {
- $formatoptions = new stdClass;
+ $formatoptions = new stdClass();
$formatoptions->noclean = true;
$formatoptions->overflowdiv = true;
echo '<div class="boxaligncenter">';
$category = $this->get_current_category($categoryandcontext);
- $cmoptions = new stdClass;
+ $cmoptions = new stdClass();
$cmoptions->hasattempts = !empty($this->quizhasattempts);
$strselectall = get_string("selectall", "quiz");
echo '<label for="qtype_' . $qtype->name() . '">';
echo '<input type="radio" name="qtype" id="qtype_' . $qtype->name() . '" value="' . $qtype->name() . '" />';
echo '<span class="qtypename">';
- $fakequestion = new stdClass;
+ $fakequestion = new stdClass();
$fakequestion->qtype = $qtype->name();
print_question_icon($fakequestion);
echo $qtype->menu_name() . '</span><span class="qtypesummary">' .
* @param question_usage_by_activity $quba the usage to store.
*/
public function insert_questions_usage_by_activity(question_usage_by_activity $quba) {
- $record = new stdClass;
+ $record = new stdClass();
$record->contextid = $quba->get_owning_context()->id;
$record->component = addslashes($quba->get_owning_component());
$record->preferredbehaviour = addslashes($quba->get_preferred_behaviour());
* @param question_attempt $qa the question attempt to store.
*/
public function insert_question_attempt(question_attempt $qa) {
- $record = new stdClass;
+ $record = new stdClass();
$record->questionusageid = $qa->get_usage_id();
$record->slot = $qa->get_slot();
$record->behaviour = addslashes($qa->get_behaviour_name());
*/
public function insert_question_attempt_step(question_attempt_step $step,
$questionattemptid, $seq) {
- $record = new stdClass;
+ $record = new stdClass();
$record->questionattemptid = $questionattemptid;
$record->sequencenumber = $seq;
$record->state = addslashes('' . $step->get_state());
$record->id = $this->db->insert_record('question_attempt_steps', $record);
foreach ($step->get_all_data() as $name => $value) {
- $data = new stdClass;
+ $data = new stdClass();
$data->attemptstepid = $record->id;
$data->name = addslashes($name);
$data->value = addslashes($value);
$index = $row->slot . ',' . $row->questionid;
if (!array_key_exists($index, $results)) {
- $res = new stdClass;
+ $res = new stdClass();
$res->slot = $row->slot;
$res->questionid = $row->questionid;
$res->name = $row->name;
* @param question_usage_by_activity $quba the usage that has changed.
*/
public function update_questions_usage_by_activity(question_usage_by_activity $quba) {
- $record = new stdClass;
+ $record = new stdClass();
$record->id = $quba->get_id();
$record->contextid = $quba->get_owning_context()->id;
$record->component = addslashes($quba->get_owning_component());
* @param question_attempt $qa the question attempt that has changed.
*/
public function update_question_attempt(question_attempt $qa) {
- $record = new stdClass;
+ $record = new stdClass();
$record->id = $qa->get_database_id();
$record->maxmark = $qa->get_max_mark();
$record->minfraction = $qa->get_min_fraction();
return $this->preferredbehaviour;
}
- /** @return stdClass the context this usage belongs to. */
+ /** @return object the context this usage belongs to. */
public function get_owning_context() {
return $this->context;
}
$summary = get_string('markedoutofmax', 'question', $qa->format_max_mark($options->markdp));
} else {
- $a = new stdClass;
+ $a = new stdClass();
$a->mark = $qa->format_mark($options->markdp);
$a->max = $qa->format_max_mark($options->markdp);
$summary = get_string('markoutofmax', 'question', $a);
new popup_action('click', $url, 'reviewquestion', array('width' => 450, 'height' => 650)),
array('title' => get_string('reviewresponse', 'quiz')));
}
- $user = new stdClass;
+ $user = new stdClass();
$user->id = $step->get_user_id();
$row = array(
$stepno,
if (count($row) != count($columns)) {
throw new Exception("Row contains the wrong number of fields.");
}
- $rec = new stdClass;
+ $rec = new stdClass();
foreach ($columns as $i => $name) {
$rec->$name = $row[$i];
}
}
protected function get_contains_num_parts_correct($num) {
- $a = new stdClass;
+ $a = new stdClass();
$a->num = $num;
return new PatternExpectation('/<div class="numpartscorrect">' .
preg_quote(get_string('yougotnright', 'question', $a)) . '/');
}
protected function get_contains_mark_summary($mark) {
- $a = new stdClass;
+ $a = new stdClass();
$a->mark = format_float($mark, $this->displayoptions->markdp);
$a->max = format_float($this->quba->get_question_max_mark($this->slot),
$this->displayoptions->markdp);
}
/**
- * @param stdClass $question a question definition
+ * @param object $question a question definition
* @return qtype_updater
*/
protected function make_qtype_updater() {
*/
function format_question_text($question) {
global $DB;
- $formatoptions = new stdClass;
+ $formatoptions = new stdClass();
$formatoptions->noclean = true;
$formatoptions->para = false;
if (empty($question->questiontextformat)) {
// the object created is NOT a moodle question object
function create_raw_question($quest) {
- $question = new StdClass;
+ $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'];
// restore files in questiontext
$files = $this->getpath($question, array('#', 'questiontext', 0, '#','file'), array(), false);
foreach ($files as $file) {
- $data = new stdclass;
+ $data = new stdClass();
$data->content = $file['#'];
$data->encoding = $file['@']['encoding'];
$data->name = $file['@']['name'];
$filedata = $this->getpath($question, array('#', 'image_base64', '0', '#'), null, false);
$filename = $this->getpath($question, array('#', 'image', '0', '#'), null, false);
if ($filedata && $filename) {
- $data = new stdclass;
+ $data = new stdClass();
$data->content = $filedata;
$data->encoding = 'base64';
$data->name = $filename;
$this->getpath($question, array('#', 'generalfeedback', 0, '@', 'format'), 'moodle_auto_format'));
$files = $this->getpath($question, array('#', 'generalfeedback', 0, '#', 'file'), array(), false);
foreach ($files as $file) {
- $data = new stdclass;
+ $data = new stdClass();
$data->content = $file['#'];
$data->encoding = $file['@']['encoding'];
$data->name = $file['@']['name'];
$answerfiles = array();
$files = $this->getpath($answer, array('#', 'answer', 0, '#', 'file'), array());
foreach ($files as $file) {
- $data = new stdclass;
+ $data = new stdClass();
$data->content = $file['#'];
$data->name = $file['@']['name'];
$data->encoding = $file['@']['encoding'];
$feedbackfiles = array();
$files = $this->getpath($answer, array('#', 'feedback', 0, '#', 'file'), array());
foreach ($files as $file) {
- $data = new stdclass;
+ $data = new stdClass();
$data->content = $file['#'];
$data->name = $file['@']['name'];
$data->encoding = $file['@']['encoding'];
$feedbackfiles[] = $data;
}
- $ans = new stdclass;
+ $ans = new stdClass();
$ans->answer = array();
$ans->answer['text'] = $answertext;
if (array_key_exists('hintcontent', $hintxml['#'])) {
// Backwards compatibility:
- $hint = new stdClass;
+ $hint = new stdClass();
$hint->hint = $this->getpath($hintxml,
array('#', 'hintcontent', 0, '#', 'text' ,0, '#'), '', true);
$hint->shownumcorrect = $this->getpath($hintxml,
return $hint;
}
- $hint = new stdClass;
+ $hint = new stdClass();
$hint->hint = $this->getpath($hintxml, array('#', 'text', 0 , '#'), '', true);
$hint->shownumcorrect = array_key_exists('shownumcorrect', $hintxml['#']);
$hint->clearwrong = array_key_exists('clearwrong', $hintxml['#']);
$this->getpath($questions, array('#', 'generalfeedback', 0, '@', 'format'), 'moodle_auto_format'));
$files = $this->getpath($questions, array('#', 'generalfeedback', 0, '#', 'file'), array(), false);
foreach ($files as $file) {
- $data = new stdclass;
+ $data = new stdClass();
$data->content = $file['#'];
$data->encoding = $file['@']['encoding'];
$data->name = $file['@']['name'];
$feedbackfiles = $this->getpath($answer, array('#', 'feedback', 0, '#', 'file'), array());
$files = array();
foreach ($feedbackfiles as $file) {
- $data = new stdclass;
+ $data = new stdClass();
$data->content = $file['#'];
$data->encoding = $file['@']['encoding'];
$data->name = $file['@']['name'];
}
if ($warning) {
- $a = new stdClass;
+ $a = new stdClass();
$a->questiontext = $qo->questiontext;
$a->answer = get_string($qo->correctanswer ? 'true' : 'false', 'quiz');
echo $OUTPUT->notification(get_string('truefalseimporterror', 'quiz', $a));
$files = $this->getpath($instructions, array('0', '#', 'file'), array());
$qo->instructions['files'] = array();
foreach ($files as $file) {
- $data = new stdclass;
+ $data = new stdClass();
$data->content = $file['#'];
$data->encoding = $file['@']['encoding'];
$data->name = $file['@']['name'];
array('0', '#', 'file'), array());
$qo->instructions['files'] = array();
foreach ($files as $file) {
- $data = new stdclass;
+ $data = new stdClass();
$data->content = $file['#'];
$data->encoding = $file['@']['encoding'];
$data->name = $file['@']['name'];
array('0', '#', 'file'), array());
$qo->instructions['files'] = array();
foreach ($files as $file) {
- $data = new stdclass;
+ $data = new stdClass();
$data->content = $file['#'];
$data->encoding = $file['@']['encoding'];
$data->name = $file['@']['name'];
* </question>
*/
function import_category($question) {
- $qo = new stdClass;
+ $qo = new stdClass();
$qo->qtype = 'category';
$qo->category = $this->import_text($question['#']['category'][0]['#']['text']);
return $qo;
public function make_test_question() {
global $USER;
- $q = new stdClass;
+ $q = new stdClass();
$q->id = 0;
$q->contextid = 0;
$q->category = 0;
END;
$questionxml = xmlize($xml);
- $qo = new stdClass;
+ $qo = new stdClass();
$importer = new qformat_xml();
$importer->import_hints($qo, $questionxml['question']);
END;
$questionxml = xmlize($xml);
- $qo = new stdClass;
+ $qo = new stdClass();
$importer = new qformat_xml();
$importer->import_hints($qo, $questionxml['question'], true, true);
END;
$questionxml = xmlize($xml);
- $qo = new stdClass;
+ $qo = new stdClass();
$importer = new qformat_xml();
$importer->import_hints($qo, $questionxml['question']);
$importer = new qformat_xml();
$q = $importer->import_description($xmldata['question']);
- $expectedq = new stdClass;
+ $expectedq = new stdClass();
$expectedq->qtype = 'description';
$expectedq->name = 'A description';
$expectedq->questiontext = 'The question text.';
}
public function test_export_description() {
- $qdata = new stdClass;
+ $qdata = new stdClass();
$qdata->id = 123;
$qdata->contextid = 0;
$qdata->qtype = 'description';
$importer = new qformat_xml();
$q = $importer->import_essay($xmldata['question']);
- $expectedq = new stdClass;
+ $expectedq = new stdClass();
$expectedq->qtype = 'essay';
$expectedq->name = 'An essay';
$expectedq->questiontext = 'Write something.';
}
public function test_export_essay() {
- $qdata = new stdClass;
+ $qdata = new stdClass();
$qdata->id = 123;
$qdata->contextid = 0;
$qdata->qtype = 'essay';
$importer = new qformat_xml();
$q = $importer->import_matching($xmldata['question']);
- $expectedq = new stdClass;
+ $expectedq = new stdClass();
$expectedq->qtype = 'match';
$expectedq->name = 'Matching question';
$expectedq->questiontext = 'Match the upper and lower case letters.';
}
public function test_export_match() {
- $qdata = new stdClass;
+ $qdata = new stdClass();
$qdata->id = 123;
$qdata->contextid = 0;
$qdata->qtype = 'match';
$qdata->penalty = 0.3333333;
$qdata->hidden = 0;
- $qdata->options = new stdClass;
+ $qdata->options = new stdClass();
$qdata->options->shuffleanswers = 1;
$qdata->options->correctfeedback = 'Well done.';
$qdata->options->correctfeedbackformat = FORMAT_HTML;
$importer = new qformat_xml();
$q = $importer->import_multichoice($xmldata['question']);
- $expectedq = new stdClass;
+ $expectedq = new stdClass();
$expectedq->qtype = 'multichoice';
$expectedq->name = 'Multiple choice question';
$expectedq->questiontext = 'Which are the even numbers?';
}
public function test_export_multichoice() {
- $qdata = new stdClass;
+ $qdata = new stdClass();
$qdata->id = 123;
$qdata->contextid = 0;
$qdata->qtype = 'multichoice';
$qdata->penalty = 0.3333333;
$qdata->hidden = 0;
- $qdata->options = new stdClass;
+ $qdata->options = new stdClass();
$qdata->options->single = 0;
$qdata->options->shuffleanswers = 0;
$qdata->options->answernumbering = 'abc';
$importer = new qformat_xml();
$q = $importer->import_numerical($xmldata['question']);
- $expectedq = new stdClass;
+ $expectedq = new stdClass();
$expectedq->qtype = 'numerical';
$expectedq->name = 'Numerical question';
$expectedq->questiontext = 'What is the answer?';
public function test_export_numerical() {
question_bank::load_question_definition_classes('numerical');
- $qdata = new stdClass;
+ $qdata = new stdClass();
$qdata->id = 123;
$qdata->contextid = 0;
$qdata->qtype = 'numerical';
$importer = new qformat_xml();
$q = $importer->import_shortanswer($xmldata['question']);
- $expectedq = new stdClass;
+ $expectedq = new stdClass();
$expectedq->qtype = 'shortanswer';
$expectedq->name = 'Short answer question';
$expectedq->questiontext = 'Fill in the gap in this sequence: Alpha, ________, Gamma.';
}
public function test_export_shortanswer() {
- $qdata = new stdClass;
+ $qdata = new stdClass();
$qdata->id = 123;
$qdata->contextid = 0;
$qdata->qtype = 'shortanswer';
$importer = new qformat_xml();
$q = $importer->import_truefalse($xmldata['question']);
- $expectedq = new stdClass;
+ $expectedq = new stdClass();
$expectedq->qtype = 'truefalse';
$expectedq->name = 'True false question';
$expectedq->questiontext = 'The answer is true.';
}
public function test_export_truefalse() {
- $qdata = new stdClass;
+ $qdata = new stdClass();
$qdata->id = 12;
$qdata->contextid = 0;
$qdata->qtype = 'truefalse';
get_question_options($question, true);
} else if ($categoryid && $qtype) { // only for creating new questions
- $question = new stdClass;
+ $question = new stdClass();
$question->category = $categoryid;
$question->qtype = $qtype;
}
// Check permissions
-$question->formoptions = new stdClass;
+$question->formoptions = new stdClass();
$categorycontext = get_context_instance_by_id($category->contextid);
$addpermission = has_capability('moodle/question:add', $categorycontext);
$qu->category =$this->_form->_elements[$this->_form->_elementIndex['category']]->_values[0];
but is coded using existing functions
*/
- $qu = new stdClass;
- $el = new stdClass;
+ $qu = new stdClass();
+ $el = new stdClass();
/* no need to call elementExists() here */
if ($this->_form->elementExists('category')){
$el=$this->_form->getElement('category');
$n = 0;
foreach( $items as $ii){
$n++;
- $def->items[$n] = new stdClass;
+ $def->items[$n] = new stdClass();
$def->items[$n]->itemnumber=$ii->itemnumber;
$def->items[$n]->value=$ii->value;
}
$options = $DB->get_record("question_calculated_options", array("question" => $question->id));
if (!$options) {
$update = false;
- $options = new stdClass;
+ $options = new stdClass();
$options->question = $question->id;
}
// as used only by calculated
$dataanswer = $dataanswer['text'];
}
if ( trim($dataanswer) != '' ) {
- $answer = new stdClass;
+ $answer = new stdClass();
$answer->question = $question->id;
$answer->answer = trim($dataanswer);
$answer->fraction = $question->fraction[$key];
// Set up the options object
if (!$options = array_shift($oldoptions)) {
- $options = new stdClass;
+ $options = new stdClass();
}
$options->question = $question->id;
$options->answer = $answer->id;
$datasetdef->id = $DB->insert_record( 'question_dataset_definitions', $datasetdef);
}
// Create relation to the dataset:
- $questiondataset = new stdClass;
+ $questiondataset = new stdClass();
$questiondataset->question = $question->id;
$questiondataset->datasetdefinition = $datasetdef->id;
$DB->insert_record('question_datasets', $questiondataset);
if ($todo=='create'){ // add the items
foreach ($dataset->datasetitem as $dataitem ){
- $datasetitem = new stdClass;
+ $datasetitem = new stdClass();
$datasetitem->definition=$datasetdef->id ;
$datasetitem->itemnumber = $dataitem->itemnumber ;
$datasetitem->value = $dataitem->value ;
}else {
// i.e records is true so test coherence
$coherence = true ;
- $a = new stdClass ;
+ $a = new stdClass() ;
$a->qid = $question->id ;
$a->qcat = $question->category ;
foreach($records as $def ){
if (isset($datasetdefs[$defid]->items[$numberadded]) ){
// in case of regenerate it modifies the already existing record
if ( $defregenerate ) {
- $datasetitem = new stdClass;
+ $datasetitem = new stdClass();
$datasetitem->id = $datasetdefs[$defid]->items[$numberadded]->id;
$datasetitem->definition = $datasetdef->id ;
$datasetitem->itemnumber = $numberadded;
}
//if not regenerate do nothing as there is already a record
} else {
- $datasetitem = new stdClass;
+ $datasetitem = new stdClass();
$datasetitem->definition = $datasetdef->id ;
$datasetitem->itemnumber = $numberadded;
if ($this->supports_dataset_item_generation()) {
function comment_on_datasetitems($qtypeobj, $questionid, $questiontext, $answers, $data, $number) {
global $DB, $QTYPES;
- $comment = new stdClass;
+ $comment = new stdClass();
$comment->stranswers = array();
$comment->outsidelimit = false ;
$comment->answers = array();
}
function multichoice_comment_on_datasetitems($questionid, $questiontext, $answers,$data, $number) {
global $DB;
- $comment = new stdClass;
+ $comment = new stdClass();
$comment->stranswers = array();
$comment->outsidelimit = false ;
$comment->answers = array();
foreach ($dataset as $name => $value) {
$val = $value ;
if(! is_numeric($val)){
- $a = new stdClass;
+ $a = new stdClass();
$a->name = '{'.$name.'}' ;
$a->value = $value ;
echo $OUTPUT->notification(get_string('notvalidnumber','qtype_calculated',$a));
if (!isset($datasetdefs[$dataset])) {
//make new datasetdef
list($type, $category, $name) = explode('-', $dataset, 3);
- $datasetdef = new stdClass;
+ $datasetdef = new stdClass();
$datasetdef->type = $type;
$datasetdef->name = $name;
$datasetdef->category = $category;
}
// Create relation to this dataset:
- $questiondataset = new stdClass;
+ $questiondataset = new stdClass();
$questiondataset->question = $form->id;
$questiondataset->datasetdefinition = $datasetdef->id;
$DB->insert_record('question_datasets', $questiondataset);
}// end of copy the datasetdef
// Create relation to the new question with this
// copy as new datasetdef from the initial question
- $questiondataset = new stdClass;
+ $questiondataset = new stdClass();
$questiondataset->question = $form->id;
$questiondataset->datasetdefinition = $datasetdef->id;
$DB->insert_record('question_datasets', $questiondataset);
}
// Create relation to this dataset:
- $questiondataset = new stdClass;
+ $questiondataset = new stdClass();
$questiondataset->question = $form->id;
$questiondataset->datasetdefinition = $datasetdef->id;
$DB->insert_record('question_datasets', $questiondataset);
FROM {question_dataset_definitions} d, {question_dataset_items} i, {question_datasets} q
WHERE q.question = ? AND q.datasetdefinition = d.id AND d.id = i.definition AND i.itemnumber = ?
ORDER by i.id DESC ", array($question->id, $datasetitem))) {
- $a = new stdClass;
+ $a = new stdClass();
$a->id = $question->id;
$a->item = $datasetitem ;
print_error('cannotgetdsfordependent', 'question', '', $a );
if (!isset($form->id) || $form->id == 0 ){
$key = "$type-0-$name";
$options[$key] = get_string($prefix."newlocal$type", $langfile);
- $currentdatasetdef = new stdClass;
+ $currentdatasetdef = new stdClass();
$currentdatasetdef->type = '0';
}else {
* $qu->category =$this->_form->_elements[$this->_form->_elementIndex['category']]->_values[0];
* but is coded using existing functions
*/
- $qu = new stdClass;
- $el = new stdClass;
+ $qu = new stdClass();
+ $el = new stdClass();
/* no need to call elementExists() here */
if ($this->_form->elementExists('category')){
$el=$this->_form->getElement('category');
$options = $DB->get_record("question_calculated_options", array("question" => $question->id));
if (!$options) {
$update = false;
- $options = new stdClass;
+ $options = new stdClass();
$options->question = $question->id;
}
$options->synchronize = $question->synchronize;
$dataanswer = $dataanswer['text'];
}
if ( trim($dataanswer) != '' ) {
- $answer = new stdClass;
+ $answer = new stdClass();
$answer->question = $question->id;
$answer->answer = trim($dataanswer);
$answer->fraction = $question->fraction[$key];
// Set up the options object
if (!$options = array_shift($oldoptions)) {
- $options = new stdClass;
+ $options = new stdClass();
}
$options->question = $question->id;
$options->answer = $answer->id;
} else {
// i.e records is true so test coherence
$coherence = true ;
- $a = new stdClass ;
+ $a = new stdClass() ;
$a->qid = $question->id ;
$a->qcat = $question->category ;
foreach($records as $def ){
function comment_on_datasetitems($qtypeobj,$questionid,$questiontext, $answers,$data, $number) { //multichoice_
global $DB;
- $comment = new stdClass;
+ $comment = new stdClass();
$comment->stranswers = array();
$comment->outsidelimit = false ;
$comment->answers = array();
$sizeofolddef = sizeof($olddef);
for($key = 1; $key <= $sizeofolddef; $key++) {
$def = $olddef[$key] ;
- $this->datasetdefs[$def]= new stdClass ;
+ $this->datasetdefs[$def]= new stdClass() ;
$this->datasetdefs[$def]->type = 1;
$this->datasetdefs[$def]->category = 0;
// $this->datasets[$key]->name = $datasetname;
foreach ($mandatorydatasets as $datasetname) {
if (!isset($this->datasetdefs["1-0-$datasetname"])) {
$key = "1-0-$datasetname";
- $this->datasetdefs[$key]=new stdClass ;//"1-0-$datasetname";
+ $this->datasetdefs[$key]=new stdClass() ;//"1-0-$datasetname";
$this->datasetdefs[$key]->type = 1;
$this->datasetdefs[$key]->category = 0;
$this->datasetdefs[$key]->name = $datasetname;
$datasetdef->itemcount = $maxnumber;
unset($datasetdef->items);
for ($numberadded =1 ; $numberadded <= $maxnumber; $numberadded++){
- $datasetitem = new stdClass;
+ $datasetitem = new stdClass();
$datasetitem->itemnumber = $numberadded;
$datasetitem->id = 0;
$datasetitem->value = $this->qtypeobj->generate_dataset_item($datasetdef->options);
for ($itemnumber = $this->noofitems; $itemnumber >= 1; $itemnumber--){
$data = array();
$numbererrors = array() ;
- $comment = new stdClass;
+ $comment = new stdClass();
$comment->stranswers = array();
$comment->outsidelimit = false ;
$comment->answers = array();
$data[$datasetdef->name] = $datasetdef->items[$itemnumber]->value;
$this->formdata["number[$j]"] = $number = $datasetdef->items[$itemnumber]->value;
if(! is_numeric($number)){
- $a = new stdClass;
+ $a = new stdClass();
$a->name = '{'.$datasetdef->name.'}' ;
$a->value = $datasetdef->items[$itemnumber]->value ;
if (stristr($number,',')){
//$comment->outsidelimit = false ;
}
}else if( stristr($number,'x')){ // hexa will pass the test
- $a = new stdClass;
+ $a = new stdClass();
$a->name = '{'.$datasetdef->name.'}' ;
$a->value = $datasetdef->items[$itemnumber]->value ;
$this->numbererrors['number['.$j.']']= get_string('hexanotallowed','qtype_calculated',$a);
$numbererrors .= $this->numbererrors['number['.$j.']']."<br />";
} else if( is_nan($number)){
- $a = new stdClass;
+ $a = new stdClass();
$a->name = '{'.$datasetdef->name.'}' ;
$a->value = $datasetdef->items[$itemnumber]->value ;
$this->numbererrors["number[$j]"]= get_string('notvalidnumber','qtype_calculated',$a);
$dataanswer = $dataanswer['text'];
}
if ( trim($dataanswer) != '' ) {
- $answer = new stdClass;
+ $answer = new stdClass();
$answer->question = $question->id;
$answer->answer = trim($dataanswer);
$answer->fraction = $question->fraction[$key];
// Set up the options object
if (!$options = array_shift($oldoptions)) {
- $options = new stdClass;
+ $options = new stdClass();
}
$options->question = $question->id;
$options->answer = $answer->id;
}
$datasetdef->id = $DB->insert_record('question_dataset_definitions', $datasetdef);
$datasetdefs[]= clone($datasetdef);
- $questiondataset = new stdClass;
+ $questiondataset = new stdClass();
$questiondataset->question = $question->id;
$questiondataset->datasetdefinition = $datasetdef->id;
$DB->insert_record('question_datasets', $questiondataset);
}
protected function choice_options_to_feedback($choice){
- $output = new stdClass;
+ $output = new stdClass();
$output->draggroup = $choice['choicegroup'];
$output->infinite = !empty($choice['infinite']);
return serialize($output);
$mul_info = $ddwtos[$i];
//Now, build the question_ddwtos record structure
- $ddwtos = new stdClass;
+ $ddwtos = new stdClass();
$ddwtos->questionid = $new_question_id;
$ddwtos->shuffleanswers = isset($mul_info['#']['SHUFFLEANSWERS']['0']['#'])?backup_todb($mul_info['#']['SHUFFLEANSWERS']['0']['#']):'';
if (array_key_exists("CORRECTFEEDBACK", $mul_info['#'])) {
protected function get_test_question_data() {
global $USER;
- $dd = new stdClass;
+ $dd = new stdClass();
$dd->id = 0;
$dd->category = 0;
$dd->contextid = 0;
$q = $importer->try_importing_using_qtypes(
$xmldata['question'], null, null, 'ddwtos');
- $expectedq = new stdClass;
+ $expectedq = new stdClass();
$expectedq->qtype = 'ddwtos';
$expectedq->name = 'A drag-and-drop question';
$expectedq->questiontext = 'Put these in order: [[1]], [[2]], [[3]].';
$q = $importer->try_importing_using_qtypes(
$xmldata['question'], null, null, 'ddwtos');
- $expectedq = new stdClass;
+ $expectedq = new stdClass();
$expectedq->qtype = 'ddwtos';
$expectedq->name = 'QDandD1 Base definition';
$expectedq->questiontext = '<p>Drag and drop the words from the list below to fill the blank spaces and correctly complete the sentence.</p><p>At 25°C all aqueous basic solutions have [[1]] ion concentrations less than [[8]]<br />mol litre<sup>-1</sup> and pH values [[9]] than [[6]].</p><!--DONOTCLEAN-->';
}
public function test_xml_export() {
- $qdata = new stdClass;
+ $qdata = new stdClass();
$qdata->id = 123;
$qdata->contextid = 0;
$qdata->qtype = 'ddwtos';
}
protected function get_test_question_data() {
- $q = new stdClass;
+ $q = new stdClass();
$q->id = 1;
return $q;
$mul_info = $gapselects[$i];
//Now, build the question_gapselect record structure
- $gapselect = new stdClass;
+ $gapselect = new stdClass();
$gapselect->questionid = $new_question_id;
$gapselect->shuffleanswers = isset($mul_info['#']['SHUFFLEANSWERS']['0']['#'])?backup_todb($mul_info['#']['SHUFFLEANSWERS']['0']['#']):'';
if (array_key_exists("CORRECTFEEDBACK", $mul_info['#'])) {
protected function get_test_question_data() {
global $USER;
- $gapselect = new stdClass;
+ $gapselect = new stdClass();
$gapselect->id = 0;
$gapselect->category = 0;
$gapselect->contextid = 0;
$q = $importer->try_importing_using_qtypes(
$xmldata['question'], null, null, 'gapselect');
- $expectedq = new stdClass;
+ $expectedq = new stdClass();
$expectedq->qtype = 'gapselect';
$expectedq->name = 'A select missing words question';
$expectedq->questiontext = 'Put these in order: [[1]], [[2]], [[3]].';
}
public function test_xml_export() {
- $qdata = new stdClass;
+ $qdata = new stdClass();
$qdata->id = 123;
$qdata->contextid = 0;
$qdata->qtype = 'gapselect';
$errors['subanswers['.$key.']'] = get_string('nomatchinganswerforq', 'qtype_match', $trimmedquestion);
}
}
- $numberqanda = new stdClass;
+ $numberqanda = new stdClass();
$numberqanda->q = 2;
$numberqanda->a = 3;
if ($questioncount < 1){
function save_question_options($question) {
global $DB;
$context = $question->context;
- $result = new stdClass;
+ $result = new stdClass();
$oldsubquestions = $DB->get_records('question_match_sub',
array('question' => $question->id), 'id ASC');
// Update an existing subquestion if possible.
$subquestion = array_shift($oldsubquestions);
if (!$subquestion) {
- $subquestion = new stdClass;
+ $subquestion = new stdClass();
// Determine a unique random code
$subquestion->code = rand(1, 999999999);
while ($DB->record_exists('question_match_sub', array('code' => $subquestion->code, 'question' => $question->id))) {
protected function get_test_question_data() {
global $USER;
- $q = new stdClass;
+ $q = new stdClass();
$q->id = 0;
$q->name = 'Matching question';
$q->category = 0;
class qtype_missing_test extends UnitTestCase {
protected function get_unknown_questiondata() {
- $questiondata = new stdClass;
+ $questiondata = new stdClass();
$questiondata->id = 0;
$questiondata->category = 0;
$questiondata->contextid = 0;
$diff = $countsubquestions - $countsavedsubquestions;
$mform->addElement('static', 'alert1', "<strong>".get_string('questionsadded','qtype_multianswer')."</strong>","<strong>".get_string('questionsmore','qtype_multianswer',$diff)."</strong>");
}
- $a = new stdClass ;
+ $a = new stdClass() ;
$a->nb_of_quiz = $this->nb_of_quiz;
$a->nb_of_attempts = $this->nb_of_attempts;
$mform->addElement('header', 'additemhdr2', get_string('questionusedinquiz','qtype_multianswer',$a));
function save_question_options($question) {
global $QTYPES, $DB;
- $result = new stdClass;
+ $result = new stdClass();
// This function needs to be able to handle the case where the existing set of wrapped
// questions does not match the new set of wrapped questions so that some need to be
}
if (!empty($sequence)) {
- $multianswer = new stdClass;
+ $multianswer = new stdClass();
$multianswer->question = $question->id;
$multianswer->sequence = implode(',', $sequence);
if ($oldid = $DB->get_field('question_multianswer', 'id', array('question' => $question->id))) {
$readonly = empty($options->readonly) ? '' : 'readonly="readonly"';
$disabled = empty($options->readonly) ? '' : 'disabled="disabled"';
- $formatoptions = new stdClass;
+ $formatoptions = new stdClass();
$formatoptions->noclean = true;
$formatoptions->para = false;
$nameprefix = $question->name_prefix;
// Set up a default chosenanswer so that all non-empty wrong
// answers are highlighted red
if (empty($chosenanswer) && $response != '') {
- $chosenanswer = new stdClass;
+ $chosenanswer = new stdClass();
$chosenanswer->fraction = 0.0;
}
$checked = 'checked="checked"';
$chosen = true;
}
- $a = new stdClass;
+ $a = new stdClass();
$a->id = $question->name_prefix . $mcanswer->id;
$a->class = '';
$a->feedbackimg = '';
break;
default:
- $a = new stdClass;
+ $a = new stdClass();
$a->type = $wrapped->qtype ;
$a->sub = $positionkey;
print_error('unknownquestiontypeofsubquestion', 'qtype_multianswer','',$a);
function qtype_multianswer_extract_question($text) {
// $text is an array [text][format][itemid]
- $question = new stdClass;
+ $question = new stdClass();
$question->qtype = 'multianswer';
$question->questiontext = $text;
$question->generalfeedback['text'] = '';
$question->defaultgrade = 0; // Will be increased for each answer norm
for ($positionkey=1; preg_match('/'.ANSWER_REGEX.'/', $question->questiontext['text'], $answerregs); ++$positionkey ) {
- $wrapped = new stdClass;
+ $wrapped = new stdClass();
$wrapped->generalfeedback['text'] = '';
$wrapped->generalfeedback['format'] = '1';
$wrapped->generalfeedback['itemid'] = '';
}
protected function get_test_question_data() {
- $q = new stdClass;
+ $q = new stdClass();
$q->id = 1;
$q->options->single = true;
$q->options->answers[1] = (object) array('answer' => 'frog', 'fraction' => 1);
$aid = $question->id ;
- $a = new stdClass;
+ $a = new stdClass();
$a->id = $question->name_prefix."unit" ;//. "2"
$a->class = '' ;
$a->feedbackimg = '';
function save_numerical_options($question) {
global $DB;
- $result = new stdClass;
+ $result = new stdClass();
$update = true ;
$options = $DB->get_record('question_numerical_options', array('question' => $question->id));
if (!$options) {
- $options = new stdClass;
+ $options = new stdClass();
$options->question = $question->id;
$options->instructions = '';
$options->id = $DB->insert_record('question_numerical_options', $options);
function save_numerical_units($question) {
global $DB;
- $result = new stdClass;
+ $result = new stdClass();
// Delete the units previously saved for this question.
$DB->delete_records('question_numerical_units', array('question' => $question->id));
// Discard any unit which doesn't specify the unit or the multiplier
if (!empty($question->multiplier[$i]) && !empty($question->unit[$i])&& !array_key_exists($question->unit[$i],$unitalreadyinsert)) {
$unitalreadyinsert[$question->unit[$i]] = 1 ;
- $units[$i] = new stdClass;
+ $units[$i] = new stdClass();
$units[$i]->question = $question->id;
$units[$i]->multiplier = $this->apply_unit($question->multiplier[$i], array());
$units[$i]->unit = $question->unit[$i];
$context = $this->get_context_by_category_id($question->category);
$readonly = empty($options->readonly) ? '' : 'readonly="readonly"';
- $formatoptions = new stdClass;
+ $formatoptions = new stdClass();
$formatoptions->noclean = true;
$formatoptions->para = false;
$nameprefix = $question->name_prefix;
// ULPGC ecastro
function get_all_responses(&$question, &$state) {
- $result = new stdClass;
+ $result = new stdClass();
$answers = array();
$unit = $this->get_default_numerical_unit($question);
if (is_array($question->options->answers)) {
foreach ($question->options->answers as $aid=>$answer) {
- $r = new stdClass;
+ $r = new stdClass();
$r->answer = $answer->answer;
$r->credit = $answer->fraction;
$this->get_tolerance_interval($answer);
}
function test_get_tolerance_interval() {
- $answer = new stdClass;
+ $answer = new stdClass();
$answer->tolerance = 0.01;
$answer->tolerancetype = 'relative';
$answer->answer = 1.0;
$this->assertWithinMargin($answer->min, 0.99, $this->tolerance);
$this->assertWithinMargin($answer->max, 1.01, $this->tolerance);
- $answer = new stdClass;
+ $answer = new stdClass();
$answer->tolerance = 0.01;
$answer->tolerancetype = 'relative';
$answer->answer = 10.0;
$this->assertWithinMargin($answer->min, 9.9, $this->tolerance);
$this->assertWithinMargin($answer->max, 10.1, $this->tolerance);
- $answer = new stdClass;
+ $answer = new stdClass();
$answer->tolerance = 0.01;
$answer->tolerancetype = 'nominal';
$answer->answer = 1.0;
$this->assertWithinMargin($answer->min, 0.99, $this->tolerance);
$this->assertWithinMargin($answer->max, 1.01, $this->tolerance);
- $answer = new stdClass;
+ $answer = new stdClass();
$answer->tolerance = 2.0;
$answer->tolerancetype = 'nominal';
$answer->answer = 10.0;
$this->assertWithinMargin($answer->min, 8, $this->tolerance);
$this->assertWithinMargin($answer->max, 12, $this->tolerance);
- $answer = new stdClass; // Test default tolerance 0.
+ $answer = new stdClass(); // Test default tolerance 0.
$answer->tolerancetype = 'nominal';
$answer->answer = 0.0;
$this->qtype->get_tolerance_interval($answer);
$this->assertWithinMargin($answer->min, 0, $this->tolerance);
$this->assertWithinMargin($answer->max, 0, $this->tolerance);
- $answer = new stdClass; // Test default type nominal.
+ $answer = new stdClass(); // Test default type nominal.
$answer->tolerance = 1.0;
$answer->answer = 1.0;
$this->qtype->get_tolerance_interval($answer);
$this->assertWithinMargin($answer->min, 0, $this->tolerance);
$this->assertWithinMargin($answer->max, 2, $this->tolerance);
- $answer = new stdClass;
+ $answer = new stdClass();
$answer->tolerance = 1.0;
$answer->tolerancetype = 'geometric';
$answer->answer = 1.0;
redirect(new moodle_url('/question/type/opaque/engines.php'));
} else if ($data = $mform->get_data()){
- $engine = new stdClass;
+ $engine = new stdClass();
if (!empty($data->engineid)) {
$engine->id = $data->engineid;
}
}
// Prepare defaults.
-$defaults = new stdClass;
+$defaults = new stdClass();
$defaults->engineid = $engineid;
if ($engineid) {
$engine = qtype_opaque_load_engine_def($engineid);
$question->remoteid, $question->remoteversion);
if ($cachestatus == 'empty') {
- $SESSION->cached_opaque_state = new stdClass;
+ $SESSION->cached_opaque_state = new stdClass();
$opaquestate = $SESSION->cached_opaque_state;
$opaquestate->qaid = $qa->get_database_id();
$opaquestate->remoteid = $question->remoteid;
function test_is_same_engine() {
$manager = new qtype_opaque_engine_manager();
- $engine1 = new stdClass;
+ $engine1 = new stdClass();
$engine1->name = 'OpenMark live servers';
$engine1->passkey = '';
$engine1->questionengines = array(
'https://ltsweb1.open.ac.uk/openmark/!question',
'https://ltsweb2.open.ac.uk/openmark/!question');
- $engine2 = new stdClass;
+ $engine2 = new stdClass();
$engine2->name = 'OpenMark live servers';
$engine2->passkey = '';
$engine2->questionengines = array(
$manager = new qtype_opaque_engine_manager_mock();
question_bank::get_qtype('opaque')->set_engine_manager($manager);
- $engine = new stdClass;
+ $engine = new stdClass();
$engine->name = 'A question engine';
$engine->questionengines = array('http://example.com/');
$engine->questionbanks = array();
$q = $importer->try_importing_using_qtypes(
$xmldata['question'], null, null, 'opaque');
- $expectedq = new stdClass;
+ $expectedq = new stdClass();
$expectedq->qtype = 'opaque';
$expectedq->name = 'An Opaque question';
$expectedq->questiontext = '';
$manager = new qtype_opaque_engine_manager_mock();
question_bank::get_qtype('opaque')->set_engine_manager($manager);
- $engine = new stdClass;
+ $engine = new stdClass();
$engine->name = 'A question engine';
$engine->questionengines = array('http://example.com/qe2', 'http://example.com/qe1');
$engine->questionbanks = array('http://example.com/qb');
$q = $importer->try_importing_using_qtypes(
$xmldata['question'], null, null, 'opaque');
- $expectedq = new stdClass;
+ $expectedq = new stdClass();
$expectedq->qtype = 'opaque';
$expectedq->name = 'An Opaque question';
$expectedq->questiontext = '';
$manager = new qtype_opaque_engine_manager_mock();
question_bank::get_qtype('opaque')->set_engine_manager($manager);
- $engine = new stdClass;
+ $engine = new stdClass();
$engine->name = 'A question engine';
$engine->questionengines = array('http://example.com/');
$engine->questionbanks = array();
$engine->passkey = 'secret';
$manager->add_test_engine(123, $engine);
- $qdata = new stdClass;
+ $qdata = new stdClass();
$qdata->id = 321;
$qdata->contextid = -666;
$qdata->qtype = 'opaque';
/**
* Get the question data, as it would be loaded by get_question_options, for
* the question returned by {@link make_an_oumultiresponse_two_of_four()}.
- * @return stdClass
+ * @return object
*/
public static function get_question_data() {
global $USER;
- $qdata = new stdClass;
+ $qdata = new stdClass();
$qdata->id = 0;
$qdata->contextid = 0;
$qdata->category = 0;
}
function test_grade_computation() {
- $right = new stdClass;
+ $right = new stdClass();
$right->fraction = 1.0;
- $wrong = new stdClass;
+ $wrong = new stdClass();
$wrong->fraction = 0.0;
$penalty = 0.3333333;
}
public function test_get_possible_responses() {
- $q = new stdClass;
+ $q = new stdClass();
$q->id = 1;
$q->options->answers[1] = (object) array('answer' => 'frog', 'fraction' => 1);
$q->options->answers[2] = (object) array('answer' => 'toad', 'fraction' => 1);
}
public function test_get_random_guess_score() {
- $questiondata = new stdClass;
+ $questiondata = new stdClass();
$questiondata->options->answers = array(
1 => new question_answer(1, 'A', 1, '', FORMAT_HTML),
2 => new question_answer(2, 'B', 0, '', FORMAT_HTML),
$q = $importer->try_importing_using_qtypes(
$xmldata['question'], null, null, 'oumultiresponse');
- $expectedq = new stdClass;
+ $expectedq = new stdClass();
$expectedq->qtype = 'oumultiresponse';
$expectedq->name = 'OU multiple response question';
$expectedq->questiontext = 'Which are the odd numbers?';
$q = $importer->try_importing_using_qtypes(
$xmldata['question'], null, null, 'oumultiresponse');
- $expectedq = new stdClass;
+ $expectedq = new stdClass();
$expectedq->qtype = 'oumultiresponse';
$expectedq->name = '008 OUMR feedback test';
$expectedq->questiontext = '<p>OUMR question.</p><p>Right answers are eighta and eightb.</p>';
*/
public function format_text($text, $qa, $component, $filearea, $itemid, $clean = false) {
// TODO format.
- $formatoptions = new stdClass;
+ $formatoptions = new stdClass();
$formatoptions->noclean = !$clean;
$formatoptions->para = false;
$text = $qa->rewrite_pluginfile_urls($text, $component, $filearea, $itemid);
* @param string $text The HTML to reduce to plain text.
*/
public function html_to_text($text) {
- $formatoptions = new stdClass;
+ $formatoptions = new stdClass();
$formatoptions->noclean = true;
return html_to_text(format_text($text, $this->questiontextformat, $formatoptions),
0, false);
$options = $DB->get_record($question_extension_table, array($questionidcolname => $question->id));
if (!$options) {
$function = 'insert_record';
- $options = new stdClass;
+ $options = new stdClass();
$options->$questionidcolname = $question->id;
}
foreach ($extra_question_fields as $field) {
if (!isset($question->$field)) {
- $result = new stdClass;
+ $result = new stdClass();
$result->error = "No data for field $field when saving " .
$this->name() . ' question id ' . $question->id;
return $result;
}
if (!$DB->{$function}($question_extension_table, $options)) {
- $result = new stdClass;
+ $result = new stdClass();
$result->error = 'Could not save question options for ' .
$this->name() . ' question id ' . $question->id;
return $result;
function import_file($context, $component, $filearea, $itemid, $file) {
$fs = get_file_storage();
- $record = new stdclass;
+ $record = new stdClass();
if (is_object($context)) {
$record->contextid = $context->id;
} else {
}
protected function set_selected_question_name($question, $randomname) {
- $a = new stdClass;
+ $a = new stdClass();
$a->randomname = $randomname;
$a->questionname = $question->name;
$question->name = get_string('selectedby', 'qtype_random', $a);
// No options, as such, but we set the parent field to the question's
// own id. Setting the parent field has the effect of hiding this
// question in various places.
- $updateobject = new stdClass;
+ $updateobject = new stdClass();
$updateobject->id = $question->id;
$updateobject->parent = $question->id;
foreach($answer->options->answers as $ans ){
$answer->answertext = $ans->answer ;
}
- $r = new stdClass;
+ $r = new stdClass();
$r->answer = $answer->questiontext . ": " . $answer->answertext;
$r->credit = 1;
$answers[$aid] = $r;
}
}
}
- $result = new stdClass;
+ $result = new stdClass();
$result->id = $question->id;
$result->responses = $answers;
return $result;
if ($answer->questiontext) {
$ans = array_shift($answer->options->answers);
$answer->answertext = $ans->answer ;
- $r = new stdClass;
+ $r = new stdClass();
$r->answer = $answer->questiontext . ": " . $answer->answertext;
$r->credit = 1;
$answers[$question->id][$subqid] = array($ans->id => $r);
* @return string HTML fragment.
*/
protected function num_parts_correct(question_attempt $qa) {
- $a = new stdClass;
+ $a = new stdClass();
list($a->num, $a->outof) = $qa->get_question()->get_num_parts_right(
$qa->get_last_qt_data());
if (is_null($a->outof)) {
public function save_question_options($question) {
global $DB;
- $result = new stdClass;
+ $result = new stdClass();
$context = $question->context;
}
protected function get_test_question_data() {
- $q = new stdClass;
+ $q = new stdClass();
$q->id = 1;
$q->options->answers[1] = (object) array('answer' => 'frog', 'fraction' => 1);
$q->options->answers[2] = (object) array('answer' => '*', 'fraction' => 0.1);
*/
class question_hint_test extends UnitTestCase {
public function test_basic() {
- $row = new stdClass;
+ $row = new stdClass();
$row->id = 123;
$row->hint = 'A hint';
$row->hintformat = FORMAT_HTML;
}
public function test_with_parts() {
- $row = new stdClass;
+ $row = new stdClass();
$row->id = 123;
$row->hint = 'A hint';
$row->hintformat = FORMAT_HTML;
}
public function test_get_possible_responses() {
- $q = new stdClass;
+ $q = new stdClass();
$q->id = 1;
$q->options->trueanswer = 1;
$q->options->falseanswer = 2;