improved coding style - mostly variable initialisation + some fixing and spelling
This commit is contained in:
@@ -133,6 +133,7 @@ if ($result->nodefaultresponse) {
|
||||
if ($canmanage) {
|
||||
// This is the warning msg for teachers to inform them that cluster and unseen does not work while logged in as a teacher
|
||||
if(lesson_display_teacher_warning($lesson)) {
|
||||
$warningvars = new object();
|
||||
$warningvars->cluster = get_string("clusterjump", "lesson");
|
||||
$warningvars->unseen = get_string("unseenpageinbranch", "lesson");
|
||||
$lesson->add_message(get_string("teacherjumpwarning", "lesson", $warningvars));
|
||||
|
||||
@@ -53,7 +53,7 @@ function lesson_20_migrate_moddata_mixture($courseid, $path) {
|
||||
|
||||
if ($item->isFile()) {
|
||||
if (!$item->isReadable()) {
|
||||
echo $OUTPUT->notification(" File not readable, skipping: ".$courseid.$pathname.$item->getFilename());
|
||||
echo $OUTPUT->notification(" File not readable, skipping: ".$courseid.$path.$item->getFilename());
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -105,6 +105,7 @@ switch ($mode) {
|
||||
$gradeinfo = lesson_grade($lesson, $attempt->retry, $attempt->userid);
|
||||
|
||||
// Set and update
|
||||
$updategrade = new object();
|
||||
$updategrade->id = $grade->id;
|
||||
$updategrade->grade = $gradeinfo->grade;
|
||||
$DB->update_record('lesson_grades', $updategrade);
|
||||
|
||||
@@ -57,6 +57,7 @@ function lesson_save_question_options($question, $lesson) {
|
||||
$manager = lesson_page_type_manager::get($lesson);
|
||||
|
||||
$timenow = time();
|
||||
$result = new object();
|
||||
switch ($question->qtype) {
|
||||
case LESSON_PAGE_SHORTANSWER:
|
||||
|
||||
@@ -145,7 +146,7 @@ function lesson_save_question_options($question, $lesson) {
|
||||
if (isset($question->feedbacktrue)) {
|
||||
$answer->response = $question->feedbacktrue;
|
||||
}
|
||||
$true->id = $DB->insert_record("lesson_answers", $answer);
|
||||
$DB->insert_record("lesson_answers", $answer);
|
||||
|
||||
// the lie
|
||||
$answer = new stdClass;
|
||||
@@ -160,7 +161,7 @@ function lesson_save_question_options($question, $lesson) {
|
||||
if (isset($question->feedbackfalse)) {
|
||||
$answer->response = $question->feedbackfalse;
|
||||
}
|
||||
$false->id = $DB->insert_record("lesson_answers", $answer);
|
||||
$DB->insert_record("lesson_answers", $answer);
|
||||
|
||||
break;
|
||||
|
||||
@@ -252,8 +253,7 @@ function lesson_save_question_options($question, $lesson) {
|
||||
// first answer contains the correct answer jump
|
||||
$answer->jumpto = LESSON_NEXTPAGE;
|
||||
}
|
||||
$subquestion->id = $DB->insert_record("lesson_answers", $answer);
|
||||
$subquestions[] = $subquestion->id;
|
||||
$subquestions[] = $DB->insert_record("lesson_answers", $answer);
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,6 +137,7 @@ function lesson_create_objects($pageobjects, $lessonid) {
|
||||
$branchtable = new stdClass;
|
||||
|
||||
// all pages have this info
|
||||
$page = new object();
|
||||
$page->lessonid = $lessonid;
|
||||
$page->prevpageid = 0;
|
||||
$page->nextpageid = 0;
|
||||
@@ -148,6 +149,7 @@ function lesson_create_objects($pageobjects, $lessonid) {
|
||||
$page->timemodified = 0;
|
||||
|
||||
// all answers are the same
|
||||
$answer = new object();
|
||||
$answer->lessonid = $lessonid;
|
||||
$answer->jumpto = LESSON_NEXTPAGE;
|
||||
$answer->grade = 0;
|
||||
@@ -186,7 +188,7 @@ function lesson_create_objects($pageobjects, $lessonid) {
|
||||
$imagetag = str_replace("'", '"', $imagetag); // imgstyle
|
||||
$page->contents .= $imagetag;
|
||||
}
|
||||
// go through the contents array and put <p> tags around each element and strip out \n which I have found to be uneccessary
|
||||
// go through the contents array and put <p> tags around each element and strip out \n which I have found to be unneccessary
|
||||
foreach ($pageobject->contents as $content) {
|
||||
$content = str_replace("\n", '', $content);
|
||||
$content = str_replace("\r", '', $content);
|
||||
|
||||
@@ -79,7 +79,7 @@ function lesson_display_teacher_warning($lesson) {
|
||||
// get all of the lesson answers
|
||||
$params = array ("lessonid" => $lesson->id);
|
||||
if (!$lessonanswers = $DB->get_records_select("lesson_answers", "lessonid = :lessonid", $params)) {
|
||||
// no answers, then not useing cluster or unseen
|
||||
// no answers, then not using cluster or unseen
|
||||
return false;
|
||||
}
|
||||
// just check for the first one that fulfills the requirements
|
||||
|
||||
@@ -155,6 +155,8 @@ class lesson_page_type_multichoice extends lesson_page {
|
||||
}
|
||||
}
|
||||
}
|
||||
$correctpageid = null;
|
||||
$wrongpageid = null;
|
||||
// this is for custom scores. If score on answer is positive, it is correct
|
||||
if ($this->lesson->custom) {
|
||||
$ncorrect = 0;
|
||||
|
||||
@@ -38,6 +38,8 @@ function removedoublecr($filename) {
|
||||
$outfile = $filearray;
|
||||
}
|
||||
|
||||
$outarray = array();
|
||||
|
||||
foreach ($outfile as $line) {
|
||||
// remove leading and trailing whitespace
|
||||
trim($line);
|
||||
|
||||
+2
-1
@@ -429,6 +429,7 @@ if ($pageid != LESSON_EOL) {
|
||||
$a->total = $lesson->grade;
|
||||
$lessoncontent .= $lessonoutput->paragraph(get_string("yourcurrentgradeisoutof", "lesson", $a), 'center');
|
||||
|
||||
$grade = new object();
|
||||
$grade->lessonid = $lesson->id;
|
||||
$grade->userid = $USER->id;
|
||||
$grade->grade = $gradeinfo->grade;
|
||||
@@ -450,7 +451,7 @@ if ($pageid != LESSON_EOL) {
|
||||
} else {
|
||||
if ($lesson->timed) {
|
||||
if ($outoftime == 'normal') {
|
||||
$grade = new stdClass;
|
||||
$grade = new object();;
|
||||
$grade->lessonid = $lesson->id;
|
||||
$grade->userid = $USER->id;
|
||||
$grade->grade = 0;
|
||||
|
||||
Reference in New Issue
Block a user