MDL-20636 Fix new stdClass -> stdClass(), and trailing whitespace.

This commit is contained in:
Tim Hunt
2011-02-21 18:10:19 +00:00
parent aa9bdbe31c
commit 0ff4bd0877
73 changed files with 291 additions and 296 deletions
+5 -5
View File
@@ -336,7 +336,7 @@ function get_grade_options() {
arsort($gradeoptionsfull, SORT_NUMERIC);
// construct return object
$grades = new stdClass;
$grades = new stdClass();
$grades->gradeoptions = $gradeoptions;
$grades->gradeoptionsfull = $gradeoptionsfull;
@@ -593,7 +593,7 @@ function question_delete_course_category($category, $newcategory, $feedback=true
}
$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');
@@ -1112,7 +1112,7 @@ function question_make_default_categories($contexts) {
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);
@@ -1296,7 +1296,7 @@ function get_import_export_formats($type) {
*/
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'));
@@ -1484,7 +1484,7 @@ function question_edit_url($context) {
* 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) {
+1 -1
View File
@@ -1164,7 +1164,7 @@ abstract class quiz_nav_panel_base {
$qnostring = 'questionnonavinfo';
}
$a = new stdClass;
$a = new stdClass();
$a->number = $number;
$a->attributes = implode(' ', $attributes);
+1 -1
View File
@@ -400,7 +400,7 @@ if ($node) {
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);
+6 -6
View File
@@ -143,7 +143,7 @@ function quiz_add_quiz_question($id, $quiz, $page = 0) {
$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));
@@ -189,7 +189,7 @@ function quiz_add_random_questions($quiz, $addonpage, $categoryid, $number, $inc
$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)) {
@@ -777,7 +777,7 @@ function quiz_print_randomquestion(&$question, &$pageurl, &$quiz, $quiz_qbanktoo
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);
@@ -803,7 +803,7 @@ function quiz_print_randomquestion(&$question, &$pageurl, &$quiz, $quiz_qbanktoo
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);
@@ -943,7 +943,7 @@ function quiz_question_tostring(&$question, $showicon = false, $showquestiontext
}
$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,
@@ -1107,7 +1107,7 @@ class quiz_question_bank_view extends question_bank_view {
}
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">' .
+1 -1
View File
@@ -169,7 +169,7 @@ foreach ($quizzes as $quiz) {
$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);
+10 -14
View File
@@ -300,8 +300,6 @@ function quiz_update_effective_access($quiz, $userid) {
/**
* Delete all the attempts belonging to a quiz.
*
* @global stdClass
* @global object
* @param object $quiz The quiz object.
*/
function quiz_delete_all_attempts($quiz) {
@@ -370,7 +368,7 @@ function quiz_user_outline($course, $user, $mod, $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;
@@ -802,7 +800,7 @@ function quiz_get_recent_mod_activity(&$activities, &$index, $timestart,
$options = quiz_get_review_options($quiz, $attempt, $context);
$tmpactivity = new stdClass;
$tmpactivity = new stdClass();
$tmpactivity->type = 'quiz';
$tmpactivity->cmid = $cm->id;
@@ -1003,7 +1001,7 @@ function quiz_after_add_or_update($quiz) {
$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'];
@@ -1049,7 +1047,7 @@ function quiz_update_events($quiz, $override = null) {
// 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
@@ -1066,7 +1064,7 @@ function quiz_update_events($quiz, $override = null) {
$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;
@@ -1080,7 +1078,7 @@ function quiz_update_events($quiz, $override = null) {
// 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) {
@@ -1090,7 +1088,7 @@ function quiz_update_events($quiz, $override = null) {
$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 {
@@ -1460,8 +1458,6 @@ function quiz_supports($feature) {
}
/**
* @global object
* @global stdClass
* @return array all other caps used in module
*/
function quiz_get_extra_capabilities() {
@@ -1479,9 +1475,9 @@ 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;
+11 -11
View File
@@ -85,7 +85,7 @@ function quiz_create_attempt($quiz, $attemptnumber, $lastattempt, $timenow, $isp
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;
@@ -424,7 +424,7 @@ function quiz_feedback_for_grade($grade, $quiz, $context) {
}
// 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);
@@ -761,7 +761,7 @@ function quiz_update_all_final_grades($quiz) {
$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;
@@ -769,7 +769,7 @@ function quiz_update_all_final_grades($quiz) {
$DB->insert_record('quiz_grades', $toinsert);
} else {
$toupdate = new stdClass;
$toupdate = new stdClass();
$toupdate->id = $changedgrade->id;
$toupdate->grade = $changedgrade->newgrade;
$toupdate->timemodified = $timenow;
@@ -868,7 +868,7 @@ function quiz_upgrade_states($attempt) {
// 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);
@@ -1075,8 +1075,8 @@ function quiz_get_review_options($quiz, $attempt, $context) {
*/
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;
@@ -1164,7 +1164,7 @@ function quiz_get_slot_for_question($quiz, $questionid) {
/**
* 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
*/
@@ -1205,7 +1205,7 @@ function quiz_send_confirmation($a) {
* 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()
*/
@@ -1293,7 +1293,7 @@ function quiz_send_notification_emails($course, $quiz, $attempt, $context, $cm)
// 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;
@@ -1407,7 +1407,7 @@ class mod_quiz_display_options extends question_display_options {
/**
* 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.
+4 -4
View File
@@ -346,7 +346,7 @@ class quiz_grading_report extends quiz_default_report {
$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;
@@ -355,7 +355,7 @@ class quiz_grading_report extends quiz_default_report {
// 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));
@@ -366,7 +366,7 @@ class quiz_grading_report extends quiz_default_report {
$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;
@@ -410,7 +410,7 @@ class quiz_grading_report extends quiz_default_report {
}
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;
+1 -1
View File
@@ -105,7 +105,7 @@ class quiz_report_overview_table extends quiz_attempt_report_table {
$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;
}
+1 -1
View File
@@ -353,7 +353,7 @@ class quiz_overview_report extends quiz_attempt_report {
$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);
+2 -2
View File
@@ -86,7 +86,7 @@ function quiz_report_unindex($datum) {
/**
* 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;
@@ -275,7 +275,7 @@ function quiz_report_feedback_for_grade($grade, $quizid, $context) {
}
// 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);
+1 -1
View File
@@ -66,7 +66,7 @@ class question_reportlib_test extends UnitTestCase {
}
function test_quiz_report_scale_summarks_as_percentage() {
$quiz = new stdClass;
$quiz = new stdClass();
$quiz->sumgrades = 10;
$quiz->decimalpoints = 2;
+1 -1
View File
@@ -68,7 +68,7 @@ class quiz_statistics_question_stats {
* @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;
+8 -8
View File
@@ -349,7 +349,7 @@ class quiz_statistics_report extends quiz_default_report {
}
foreach ($responesstats->responseclasses as $partid => $partclasses) {
$rowdata = new stdClass;
$rowdata = new stdClass();
$rowdata->part = $partid;
foreach ($partclasses as $responseclassid => $responseclass) {
$rowdata->responseclass = $responseclass->responseclass;
@@ -556,11 +556,11 @@ class quiz_statistics_report extends quiz_default_report {
*/
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();
@@ -612,13 +612,13 @@ class quiz_statistics_report extends quiz_default_report {
$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;
@@ -642,7 +642,7 @@ class quiz_statistics_report extends quiz_default_report {
}
$summarksavg = $usingattempts->total / $usingattempts->countrecs;
$quizstats = new stdClass;
$quizstats = new stdClass();
$quizstats->allattempts = $useallattempts;
$quizstats->firstattemptscount = $firstattempts->countrecs;
$quizstats->allattemptscount = $allattempts->countrecs;
@@ -674,7 +674,7 @@ class quiz_statistics_report extends quiz_default_report {
//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
@@ -953,7 +953,7 @@ class quiz_statistics_report extends quiz_default_report {
}
// Generate the output.
$a = new stdClass;
$a = new stdClass();
$a->lastcalculated = format_time(time() - $quizstats->timemodified);
$a->count = $count;
@@ -51,9 +51,8 @@ class quiz_statistics_response_analyser {
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();
@@ -137,7 +136,7 @@ class quiz_statistics_response_analyser {
$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;
@@ -195,7 +194,7 @@ class quiz_statistics_response_analyser {
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;
+2 -2
View File
@@ -194,7 +194,7 @@ if ($options->marks && quiz_has_grades($quiz)) {
} 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">' .
@@ -202,7 +202,7 @@ if ($options->marks && quiz_has_grades($quiz)) {
}
// 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) {
+46 -46
View File
@@ -40,14 +40,14 @@ require_once($CFG->dirroot . '/mod/quiz/locallib.php');
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));
@@ -66,9 +66,9 @@ class simple_rules_test extends UnitTestCase {
}
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
@@ -97,14 +97,14 @@ class simple_rules_test extends UnitTestCase {
}
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)));
@@ -126,14 +126,14 @@ class simple_rules_test extends UnitTestCase {
*/
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);
@@ -153,14 +153,14 @@ class open_close_date_access_rule_test extends UnitTestCase {
}
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);
@@ -179,14 +179,14 @@ class open_close_date_access_rule_test extends UnitTestCase {
}
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);
@@ -211,14 +211,14 @@ class open_close_date_access_rule_test extends UnitTestCase {
}
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);
@@ -261,17 +261,17 @@ class open_close_date_access_rule_test extends UnitTestCase {
*/
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);
@@ -293,17 +293,17 @@ class inter_attempt_delay_access_rule_test extends UnitTestCase {
}
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);
@@ -328,17 +328,17 @@ class inter_attempt_delay_access_rule_test extends UnitTestCase {
}
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);
@@ -371,17 +371,17 @@ class inter_attempt_delay_access_rule_test extends UnitTestCase {
}
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);
@@ -421,17 +421,17 @@ class inter_attempt_delay_access_rule_test extends UnitTestCase {
}
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;
@@ -486,14 +486,14 @@ class inter_attempt_delay_access_rule_test extends UnitTestCase {
*/
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'));
@@ -512,14 +512,14 @@ class securewindow_access_rule_test extends UnitTestCase {
// 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());
@@ -536,16 +536,16 @@ class securewindow_access_rule_test extends UnitTestCase {
*/
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);
@@ -556,7 +556,7 @@ class quiz_access_manager_test extends UnitTestCase {
$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)),
+3 -3
View File
@@ -39,7 +39,7 @@ require_once($CFG->dirroot . '/mod/quiz/lib.php');
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));
@@ -52,7 +52,7 @@ class quiz_lib_test extends UnitTestCase {
}
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));
@@ -62,7 +62,7 @@ class quiz_lib_test extends UnitTestCase {
}
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));
+2 -2
View File
@@ -100,7 +100,7 @@ class quiz_locallib_test extends UnitTestCase {
}
function test_quiz_rescale_grade() {
$quiz = new stdClass;
$quiz = new stdClass();
$quiz->decimalpoints = 2;
$quiz->questiondecimalpoints = 3;
$quiz->grade = 10;
@@ -115,7 +115,7 @@ class quiz_locallib_test extends UnitTestCase {
}
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));
@@ -40,7 +40,7 @@ require_once($CFG->dirroot . '/mod/quiz/locallib.php');
*/
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;
+2 -2
View File
@@ -310,13 +310,13 @@ if ($numattempts && $gradecolumn && !is_null($mygrade)) {
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);
+1 -1
View File
@@ -47,7 +47,7 @@ class qbehaviour_adaptive_renderer extends qbehaviour_renderer {
}
// 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();
+2 -2
View File
@@ -450,7 +450,7 @@ abstract class question_behaviour {
* @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;
@@ -466,7 +466,7 @@ abstract class question_behaviour {
* @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);
+1 -1
View File
@@ -95,7 +95,7 @@ abstract class qbehaviour_renderer extends plugin_renderer_base {
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);
+1 -1
View File
@@ -323,7 +323,7 @@ class question_category_object {
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');
+6 -6
View File
@@ -497,7 +497,7 @@ class question_bank_creator_name_column extends question_bank_column_base {
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);
@@ -534,7 +534,7 @@ class question_bank_modifier_name_column extends question_bank_column_base {
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);
@@ -718,7 +718,7 @@ class question_bank_question_text_row extends question_bank_row_base {
protected $formatoptions;
protected function init() {
$this->formatoptions = new stdClass;
$this->formatoptions = new stdClass();
$this->formatoptions->noclean = true;
$this->formatoptions->para = false;
}
@@ -1152,7 +1152,7 @@ class question_bank_view {
}
protected function print_category_info($category) {
$formatoptions = new stdClass;
$formatoptions = new stdClass();
$formatoptions->noclean = true;
$formatoptions->overflowdiv = true;
echo '<div class="boxaligncenter">';
@@ -1233,7 +1233,7 @@ class question_bank_view {
$category = $this->get_current_category($categoryandcontext);
$cmoptions = new stdClass;
$cmoptions = new stdClass();
$cmoptions->hasattempts = !empty($this->quizhasattempts);
$strselectall = get_string("selectall", "quiz");
@@ -1723,7 +1723,7 @@ function print_qtype_to_add_option($qtype) {
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">' .
+7 -7
View File
@@ -58,7 +58,7 @@ class question_engine_data_mapper {
* @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());
@@ -77,7 +77,7 @@ class question_engine_data_mapper {
* @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());
@@ -102,7 +102,7 @@ class question_engine_data_mapper {
*/
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());
@@ -113,7 +113,7 @@ class question_engine_data_mapper {
$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);
@@ -361,7 +361,7 @@ ORDER BY
$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;
@@ -591,7 +591,7 @@ ORDER BY
* @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());
@@ -608,7 +608,7 @@ ORDER BY
* @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();
+1 -1
View File
@@ -669,7 +669,7 @@ class question_usage_by_activity {
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;
}
+2 -2
View File
@@ -178,7 +178,7 @@ class core_question_renderer extends plugin_renderer_base {
$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);
@@ -336,7 +336,7 @@ class core_question_renderer extends plugin_renderer_base {
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,
+3 -3
View File
@@ -309,7 +309,7 @@ abstract class testing_db_record_builder {
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];
}
@@ -448,7 +448,7 @@ class qbehaviour_walkthrough_test_base extends UnitTestCase {
}
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)) . '/');
@@ -467,7 +467,7 @@ class qbehaviour_walkthrough_test_base extends UnitTestCase {
}
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);
+1 -1
View File
@@ -765,7 +765,7 @@ abstract class qbehaviour_converter {
}
/**
* @param stdClass $question a question definition
* @param object $question a question definition
* @return qtype_updater
*/
protected function make_qtype_updater() {
+1 -1
View File
@@ -837,7 +837,7 @@ class qformat_default {
*/
function format_question_text($question) {
global $DB;
$formatoptions = new stdClass;
$formatoptions = new stdClass();
$formatoptions->noclean = true;
$formatoptions->para = false;
if (empty($question->questiontextformat)) {
+1 -1
View File
@@ -265,7 +265,7 @@ class qformat_blackboard_six extends qformat_default {
// 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'];
+15 -15
View File
@@ -171,7 +171,7 @@ class qformat_xml extends qformat_default {
// 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'];
@@ -182,7 +182,7 @@ class qformat_xml extends qformat_default {
$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;
@@ -198,7 +198,7 @@ class qformat_xml extends qformat_default {
$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'];
@@ -239,7 +239,7 @@ class qformat_xml extends qformat_default {
$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'];
@@ -252,14 +252,14 @@ class qformat_xml extends qformat_default {
$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;
@@ -322,7 +322,7 @@ class qformat_xml extends qformat_default {
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,
@@ -335,7 +335,7 @@ class qformat_xml extends qformat_default {
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['#']);
@@ -433,7 +433,7 @@ class qformat_xml extends qformat_default {
$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'];
@@ -476,7 +476,7 @@ class qformat_xml extends qformat_default {
$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'];
@@ -511,7 +511,7 @@ class qformat_xml extends qformat_default {
}
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));
@@ -627,7 +627,7 @@ class qformat_xml extends qformat_default {
$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'];
@@ -787,7 +787,7 @@ class qformat_xml extends qformat_default {
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'];
@@ -847,7 +847,7 @@ class qformat_xml extends qformat_default {
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'];
@@ -894,7 +894,7 @@ class qformat_xml extends qformat_default {
* </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;
@@ -42,7 +42,7 @@ class qformat_xml_test extends UnitTestCase {
public function make_test_question() {
global $USER;
$q = new stdClass;
$q = new stdClass();
$q->id = 0;
$q->contextid = 0;
$q->category = 0;
@@ -136,7 +136,7 @@ class qformat_xml_test extends UnitTestCase {
END;
$questionxml = xmlize($xml);
$qo = new stdClass;
$qo = new stdClass();
$importer = new qformat_xml();
$importer->import_hints($qo, $questionxml['question']);
@@ -162,7 +162,7 @@ END;
END;
$questionxml = xmlize($xml);
$qo = new stdClass;
$qo = new stdClass();
$importer = new qformat_xml();
$importer->import_hints($qo, $questionxml['question'], true, true);
@@ -180,7 +180,7 @@ END;
END;
$questionxml = xmlize($xml);
$qo = new stdClass;
$qo = new stdClass();
$importer = new qformat_xml();
$importer->import_hints($qo, $questionxml['question']);
@@ -208,7 +208,7 @@ END;
$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.';
@@ -222,7 +222,7 @@ END;
}
public function test_export_description() {
$qdata = new stdClass;
$qdata = new stdClass();
$qdata->id = 123;
$qdata->contextid = 0;
$qdata->qtype = 'description';
@@ -279,7 +279,7 @@ END;
$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.';
@@ -293,7 +293,7 @@ END;
}
public function test_export_essay() {
$qdata = new stdClass;
$qdata = new stdClass();
$qdata->id = 123;
$qdata->contextid = 0;
$qdata->qtype = 'essay';
@@ -393,7 +393,7 @@ END;
$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.';
@@ -422,7 +422,7 @@ END;
}
public function test_export_match() {
$qdata = new stdClass;
$qdata = new stdClass();
$qdata->id = 123;
$qdata->contextid = 0;
$qdata->qtype = 'match';
@@ -436,7 +436,7 @@ END;
$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;
@@ -607,7 +607,7 @@ END;
$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?';
@@ -644,7 +644,7 @@ END;
}
public function test_export_multichoice() {
$qdata = new stdClass;
$qdata = new stdClass();
$qdata->id = 123;
$qdata->contextid = 0;
$qdata->qtype = 'multichoice';
@@ -658,7 +658,7 @@ END;
$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';
@@ -789,7 +789,7 @@ END;
$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?';
@@ -814,7 +814,7 @@ END;
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';
@@ -919,7 +919,7 @@ END;
$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.';
@@ -940,7 +940,7 @@ END;
}
public function test_export_shortanswer() {
$qdata = new stdClass;
$qdata = new stdClass();
$qdata->id = 123;
$qdata->contextid = 0;
$qdata->qtype = 'shortanswer';
@@ -1040,7 +1040,7 @@ END;
$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.';
@@ -1058,7 +1058,7 @@ END;
}
public function test_export_truefalse() {
$qdata = new stdClass;
$qdata = new stdClass();
$qdata->id = 12;
$qdata->contextid = 0;
$qdata->qtype = 'truefalse';
+2 -2
View File
@@ -107,7 +107,7 @@ if ($id) {
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;
@@ -135,7 +135,7 @@ if (!$category = $DB->get_record('question_categories', array('id' => $question-
}
// 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);
@@ -196,8 +196,8 @@ class question_edit_calculated_form extends question_edit_form {
$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');
+18 -18
View File
@@ -116,7 +116,7 @@ class question_calculated_qtype extends default_questiontype {
$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;
}
@@ -142,7 +142,7 @@ class question_calculated_qtype extends default_questiontype {
$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
@@ -193,7 +193,7 @@ class question_calculated_qtype extends default_questiontype {
$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];
@@ -221,7 +221,7 @@ class question_calculated_qtype extends default_questiontype {
// Set up the options object
if (!$options = array_shift($oldoptions)) {
$options = new stdClass;
$options = new stdClass();
}
$options->question = $question->id;
$options->answer = $answer->id;
@@ -305,13 +305,13 @@ class question_calculated_qtype extends default_questiontype {
$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 ;
@@ -362,7 +362,7 @@ class question_calculated_qtype extends default_questiontype {
}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 ){
@@ -1213,7 +1213,7 @@ class question_calculated_qtype extends default_questiontype {
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;
@@ -1222,7 +1222,7 @@ class question_calculated_qtype extends default_questiontype {
}
//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()) {
@@ -1297,7 +1297,7 @@ class question_calculated_qtype extends default_questiontype {
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();
@@ -1353,7 +1353,7 @@ class question_calculated_qtype extends default_questiontype {
}
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();
@@ -1510,7 +1510,7 @@ class question_calculated_qtype extends default_questiontype {
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));
@@ -1573,7 +1573,7 @@ class question_calculated_qtype extends default_questiontype {
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;
@@ -1635,7 +1635,7 @@ class question_calculated_qtype extends default_questiontype {
}
// 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);
@@ -1703,7 +1703,7 @@ class question_calculated_qtype extends default_questiontype {
}// 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);
@@ -1735,7 +1735,7 @@ class question_calculated_qtype extends default_questiontype {
}
// 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);
@@ -1767,7 +1767,7 @@ class question_calculated_qtype extends default_questiontype {
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 );
@@ -1793,7 +1793,7 @@ class question_calculated_qtype extends default_questiontype {
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 {
@@ -242,8 +242,8 @@ class question_edit_calculatedmulti_form extends question_edit_form {
* $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');
@@ -52,7 +52,7 @@ class question_calculatedmulti_qtype extends question_calculated_qtype {
$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;
@@ -110,7 +110,7 @@ class question_calculatedmulti_qtype extends question_calculated_qtype {
$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];
@@ -139,7 +139,7 @@ class question_calculatedmulti_qtype extends question_calculated_qtype {
// Set up the options object
if (!$options = array_shift($oldoptions)) {
$options = new stdClass;
$options = new stdClass();
}
$options->question = $question->id;
$options->answer = $answer->id;
@@ -199,7 +199,7 @@ class question_calculatedmulti_qtype extends question_calculated_qtype {
} 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 ){
@@ -384,7 +384,7 @@ class question_calculatedmulti_qtype extends question_calculated_qtype {
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();
@@ -178,7 +178,7 @@ class question_edit_calculatedsimple_form extends question_edit_form {
$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;
@@ -202,7 +202,7 @@ class question_edit_calculatedsimple_form extends question_edit_form {
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;
@@ -238,7 +238,7 @@ class question_edit_calculatedsimple_form extends question_edit_form {
$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);
@@ -374,7 +374,7 @@ class question_edit_calculatedsimple_form extends question_edit_form {
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();
@@ -386,7 +386,7 @@ class question_edit_calculatedsimple_form extends question_edit_form {
$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,',')){
@@ -399,13 +399,13 @@ class question_edit_calculatedsimple_form extends question_edit_form {
//$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);
@@ -70,7 +70,7 @@ class question_calculatedsimple_qtype extends question_calculated_qtype {
$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];
@@ -98,7 +98,7 @@ class question_calculatedsimple_qtype extends question_calculated_qtype {
// Set up the options object
if (!$options = array_shift($oldoptions)) {
$options = new stdClass;
$options = new stdClass();
}
$options->question = $question->id;
$options->answer = $answer->id;
@@ -158,7 +158,7 @@ class question_calculatedsimple_qtype extends question_calculated_qtype {
}
$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);
+2 -2
View File
@@ -47,7 +47,7 @@ class qtype_ddwtos extends qtype_gapselect_base {
}
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);
@@ -174,7 +174,7 @@ class qtype_ddwtos extends qtype_gapselect_base {
$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['#'])) {
@@ -59,7 +59,7 @@ class qtype_ddwtos_test extends UnitTestCase {
protected function get_test_question_data() {
global $USER;
$dd = new stdClass;
$dd = new stdClass();
$dd->id = 0;
$dd->category = 0;
$dd->contextid = 0;
@@ -196,7 +196,7 @@ class qtype_ddwtos_test extends UnitTestCase {
$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]].';
@@ -345,7 +345,7 @@ class qtype_ddwtos_test extends UnitTestCase {
$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-->';
@@ -385,7 +385,7 @@ class qtype_ddwtos_test extends UnitTestCase {
}
public function test_xml_export() {
$qdata = new stdClass;
$qdata = new stdClass();
$qdata->id = 123;
$qdata->contextid = 0;
$qdata->qtype = 'ddwtos';
@@ -44,7 +44,7 @@ class qtype_essay_test extends UnitTestCase {
}
protected function get_test_question_data() {
$q = new stdClass;
$q = new stdClass();
$q->id = 1;
return $q;
+1 -1
View File
@@ -158,7 +158,7 @@ class qtype_gapselect extends qtype_gapselect_base {
$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['#'])) {
@@ -61,7 +61,7 @@ class qtype_gapselect_test extends UnitTestCase {
protected function get_test_question_data() {
global $USER;
$gapselect = new stdClass;
$gapselect = new stdClass();
$gapselect->id = 0;
$gapselect->category = 0;
$gapselect->contextid = 0;
@@ -197,7 +197,7 @@ class qtype_gapselect_test extends UnitTestCase {
$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]].';
@@ -227,7 +227,7 @@ class qtype_gapselect_test extends UnitTestCase {
}
public function test_xml_export() {
$qdata = new stdClass;
$qdata = new stdClass();
$qdata->id = 123;
$qdata->contextid = 0;
$qdata->qtype = 'gapselect';
+1 -1
View File
@@ -116,7 +116,7 @@ class qtype_match_edit_form extends question_edit_form {
$errors['subanswers['.$key.']'] = get_string('nomatchinganswerforq', 'qtype_match', $trimmedquestion);
}
}
$numberqanda = new stdClass;
$numberqanda = new stdClass();
$numberqanda->q = 2;
$numberqanda->a = 3;
if ($questioncount < 1){
+2 -2
View File
@@ -47,7 +47,7 @@ class qtype_match extends question_type {
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');
@@ -67,7 +67,7 @@ class qtype_match extends question_type {
// 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))) {
@@ -49,7 +49,7 @@ class qtype_match_test extends UnitTestCase {
protected function get_test_question_data() {
global $USER;
$q = new stdClass;
$q = new stdClass();
$q->id = 0;
$q->name = 'Matching question';
$q->category = 0;
@@ -32,7 +32,7 @@ require_once(dirname(__FILE__) . '/../question.php');
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;
@@ -191,7 +191,7 @@ class question_edit_multianswer_form extends question_edit_form {
$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));
+8 -8
View File
@@ -84,7 +84,7 @@ class embedded_cloze_qtype extends default_questiontype {
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
@@ -147,7 +147,7 @@ class embedded_cloze_qtype extends default_questiontype {
}
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))) {
@@ -280,7 +280,7 @@ class embedded_cloze_qtype extends default_questiontype {
$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;
@@ -383,7 +383,7 @@ class embedded_cloze_qtype extends default_questiontype {
// 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;
}
@@ -495,7 +495,7 @@ class embedded_cloze_qtype extends default_questiontype {
$checked = 'checked="checked"';
$chosen = true;
}
$a = new stdClass;
$a = new stdClass();
$a->id = $question->name_prefix . $mcanswer->id;
$a->class = '';
$a->feedbackimg = '';
@@ -576,7 +576,7 @@ class embedded_cloze_qtype extends default_questiontype {
break;
default:
$a = new stdClass;
$a = new stdClass();
$a->type = $wrapped->qtype ;
$a->sub = $positionkey;
print_error('unknownquestiontypeofsubquestion', 'qtype_multianswer','',$a);
@@ -763,7 +763,7 @@ define("ANSWER_REGEX_ALTERNATIVES", 9);
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'] = '';
@@ -774,7 +774,7 @@ function qtype_multianswer_extract_question($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'] = '';
@@ -48,7 +48,7 @@ class qtype_multichoice_test extends UnitTestCase {
}
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);
+1 -1
View File
@@ -184,7 +184,7 @@
$aid = $question->id ;
$a = new stdClass;
$a = new stdClass();
$a->id = $question->name_prefix."unit" ;//. "2"
$a->class = '' ;
$a->feedbackimg = '';
+7 -7
View File
@@ -244,12 +244,12 @@ class question_numerical_qtype extends qtype_shortanswer {
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);
@@ -310,7 +310,7 @@ class question_numerical_qtype extends qtype_shortanswer {
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));
@@ -328,7 +328,7 @@ class question_numerical_qtype extends qtype_shortanswer {
// 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];
@@ -426,7 +426,7 @@ class question_numerical_qtype extends qtype_shortanswer {
$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;
@@ -848,12 +848,12 @@ class question_numerical_qtype extends qtype_shortanswer {
// 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);
@@ -56,7 +56,7 @@ class question_numerical_qtype_test extends UnitTestCase {
}
function test_get_tolerance_interval() {
$answer = new stdClass;
$answer = new stdClass();
$answer->tolerance = 0.01;
$answer->tolerancetype = 'relative';
$answer->answer = 1.0;
@@ -64,7 +64,7 @@ class question_numerical_qtype_test extends UnitTestCase {
$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;
@@ -72,7 +72,7 @@ class question_numerical_qtype_test extends UnitTestCase {
$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;
@@ -80,7 +80,7 @@ class question_numerical_qtype_test extends UnitTestCase {
$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;
@@ -88,21 +88,21 @@ class question_numerical_qtype_test extends UnitTestCase {
$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;
+2 -2
View File
@@ -51,7 +51,7 @@ if ($mform->is_cancelled()){
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;
}
@@ -64,7 +64,7 @@ if ($mform->is_cancelled()){
}
// Prepare defaults.
$defaults = new stdClass;
$defaults = new stdClass();
$defaults->engineid = $engineid;
if ($engineid) {
$engine = qtype_opaque_load_engine_def($engineid);
+1 -1
View File
@@ -436,7 +436,7 @@ function qtype_opaque_update_state(question_attempt $qa, question_attempt_step $
$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;
@@ -41,7 +41,7 @@ class qtype_opaque_locallib_test extends UnitTestCase {
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(
@@ -51,7 +51,7 @@ class qtype_opaque_locallib_test extends UnitTestCase {
'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(
@@ -109,7 +109,7 @@ class qtype_opaque_test extends UnitTestCase {
$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();
@@ -149,7 +149,7 @@ class qtype_opaque_test extends UnitTestCase {
$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 = '';
@@ -172,7 +172,7 @@ class qtype_opaque_test extends UnitTestCase {
$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');
@@ -217,7 +217,7 @@ class qtype_opaque_test extends UnitTestCase {
$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 = '';
@@ -242,14 +242,14 @@ class qtype_opaque_test extends UnitTestCase {
$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';
@@ -61,12 +61,12 @@ class qtype_oumultiresponse_test_helper {
/**
* Get the question data, as it would be loaded by get_question_options, for
* the question returned by {@link make_an_oumultiresponse_two_of_four()}.
* @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;
@@ -121,9 +121,9 @@ class qtype_oumultiresponse_question_test extends UnitTestCase {
}
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;
@@ -83,7 +83,7 @@ class qtype_oumultiresponse_test extends UnitTestCase {
}
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);
@@ -98,7 +98,7 @@ class qtype_oumultiresponse_test extends UnitTestCase {
}
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),
@@ -179,7 +179,7 @@ class qtype_oumultiresponse_test extends UnitTestCase {
$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?';
@@ -299,7 +299,7 @@ class qtype_oumultiresponse_test extends UnitTestCase {
$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>';
+2 -2
View File
@@ -242,7 +242,7 @@ abstract class question_definition {
*/
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);
@@ -255,7 +255,7 @@ abstract class question_definition {
* @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);
+4 -4
View File
@@ -435,12 +435,12 @@ class question_type {
$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;
@@ -449,7 +449,7 @@ class question_type {
}
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;
@@ -1086,7 +1086,7 @@ class question_type {
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 {
+2 -2
View File
@@ -137,7 +137,7 @@ class qtype_random extends question_type {
}
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);
@@ -156,7 +156,7 @@ class qtype_random extends question_type {
// 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;
+3 -3
View File
@@ -258,14 +258,14 @@ class question_randomsamatch_qtype extends qtype_match {
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;
@@ -314,7 +314,7 @@ class question_randomsamatch_qtype extends qtype_match {
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);
+1 -1
View File
@@ -135,7 +135,7 @@ abstract class qtype_renderer extends plugin_renderer_base {
* @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)) {
+1 -1
View File
@@ -57,7 +57,7 @@ class qtype_shortanswer extends question_type {
public function save_question_options($question) {
global $DB;
$result = new stdClass;
$result = new stdClass();
$context = $question->context;
@@ -50,7 +50,7 @@ class qtype_shortanswer_test extends UnitTestCase {
}
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);
@@ -96,7 +96,7 @@ class question_first_matching_answer_grading_strategy_test extends UnitTestCase
*/
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;
@@ -107,7 +107,7 @@ class question_hint_test extends UnitTestCase {
}
public function test_with_parts() {
$row = new stdClass;
$row = new stdClass();
$row->id = 123;
$row->hint = 'A hint';
$row->hintformat = FORMAT_HTML;
@@ -56,7 +56,7 @@ class qtype_truefalse_test extends UnitTestCase {
}
public function test_get_possible_responses() {
$q = new stdClass;
$q = new stdClass();
$q->id = 1;
$q->options->trueanswer = 1;
$q->options->falseanswer = 2;