array/object initialization
This commit is contained in:
@@ -51,7 +51,7 @@ class quiz_default_format {
|
||||
$count++;
|
||||
|
||||
echo "<hr><p><b>$count</b>. ".stripslashes($question->questiontext)."</p>";
|
||||
unset($newpage);
|
||||
$newpage = new stdClass;
|
||||
$newpage->lessonid = $lesson->id;
|
||||
$newpage->qtype = $question->qtype;
|
||||
switch ($question->qtype) {
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
$strdeadline = get_string("deadline", "lesson");
|
||||
$strweek = get_string("week");
|
||||
$strtopic = get_string("topic");
|
||||
$table = new stdClass;
|
||||
|
||||
if ($course->format == "weeks") {
|
||||
$table->head = array ($strweek, $strname, $strgrade, $strdeadline);
|
||||
|
||||
+20
-14
@@ -137,7 +137,7 @@ function lesson_save_question_options($question) {
|
||||
// Insert all the new answers
|
||||
foreach ($question->answer as $key => $dataanswer) {
|
||||
if ($dataanswer != "") {
|
||||
unset($answer);
|
||||
$answer = new stdClass;
|
||||
$answer->lessonid = $question->lessonid;
|
||||
$answer->pageid = $question->id;
|
||||
if ($question->fraction[$key] >=0.5) {
|
||||
@@ -176,7 +176,7 @@ function lesson_save_question_options($question) {
|
||||
// for each answer store the pair of min and max values even if they are the same
|
||||
foreach ($question->answer as $key => $dataanswer) {
|
||||
if ($dataanswer != "") {
|
||||
unset($answer);
|
||||
$answer = new stdClass;
|
||||
$answer->lessonid = $question->lessonid;
|
||||
$answer->pageid = $question->id;
|
||||
$answer->jumpto = LESSON_NEXTPAGE;
|
||||
@@ -225,7 +225,7 @@ function lesson_save_question_options($question) {
|
||||
}
|
||||
|
||||
// the lie
|
||||
unset($answer);
|
||||
$answer = new stdClass;
|
||||
$answer->lessonid = $question->lessonid;
|
||||
$answer->pageid = $question->id;
|
||||
$answer->timecreated = $timenow;
|
||||
@@ -255,7 +255,7 @@ function lesson_save_question_options($question) {
|
||||
// Insert all the new answers
|
||||
foreach ($question->answer as $key => $dataanswer) {
|
||||
if ($dataanswer != "") {
|
||||
unset($answer);
|
||||
$answer = new stdClass;
|
||||
$answer->lessonid = $question->lessonid;
|
||||
$answer->pageid = $question->id;
|
||||
$answer->timecreated = $timenow;
|
||||
@@ -313,7 +313,7 @@ function lesson_save_question_options($question) {
|
||||
foreach ($question->subquestions as $key => $questiontext) {
|
||||
$answertext = $question->subanswers[$key]; echo $answertext; echo "<br>"; exit;
|
||||
if (!empty($questiontext) and !empty($answertext)) {
|
||||
unset($answer);
|
||||
$answer = new stdClass;
|
||||
$answer->lessonid = $question->lessonid;
|
||||
$answer->pageid = $question->id;
|
||||
$answer->timecreated = $timenow;
|
||||
@@ -382,7 +382,7 @@ function lesson_save_question_options($question) {
|
||||
return $result;
|
||||
}
|
||||
} else { // This is a completely new answer
|
||||
unset($multianswer);
|
||||
$multianswer = new stdClass;
|
||||
$multianswer->question = $question->id;
|
||||
$multianswer->positionkey = $dataanswer->positionkey;
|
||||
$multianswer->norm = $dataanswer->norm;
|
||||
@@ -610,7 +610,8 @@ function lesson_cluster_jump($lesson, $user, $pageid) {
|
||||
}
|
||||
|
||||
$pageid = $lessonpages[$pageid]->nextpageid; // move down from the cluster page
|
||||
|
||||
|
||||
$clusterpages = array();
|
||||
while (true) { // now load all the pages into the cluster that are not already inside of a branch table.
|
||||
if ($lessonpages[$pageid]->qtype == LESSON_ENDOFCLUSTER) {
|
||||
// store the endofcluster page's jump
|
||||
@@ -636,6 +637,7 @@ function lesson_cluster_jump($lesson, $user, $pageid) {
|
||||
}
|
||||
|
||||
// filter out the ones we have seen
|
||||
$unseen = array();
|
||||
foreach ($clusterpages as $clusterpage) {
|
||||
if ($clusterpage->qtype == LESSON_BRANCHTABLE) { // if branchtable, check to see if any pages inside have been viewed
|
||||
$branchpages = lesson_pages_in_branch($lessonpages, $clusterpage->id); // get the pages in the branchtable
|
||||
@@ -657,7 +659,7 @@ function lesson_cluster_jump($lesson, $user, $pageid) {
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($unseen)) { // if not set, then use exitjump, otherwise find out next page/branch
|
||||
if (count($unseen) > 0) { // it does not contain elements, then use exitjump, otherwise find out next page/branch
|
||||
$nextpage = $unseen[rand(0, count($unseen)-1)];
|
||||
} else {
|
||||
return $exitjump; // seen all there is to see, leave the cluster
|
||||
@@ -732,13 +734,14 @@ function lesson_unseen_question_jump($lesson, $user, $pageid) {
|
||||
$pagesinbranch = lesson_pages_in_branch($lessonpages, $pageid);
|
||||
|
||||
// this foreach loop stores all the pages that are within the branch table but are not in the $seenpages array
|
||||
$unseen = array();
|
||||
foreach($pagesinbranch as $page) {
|
||||
if (!in_array($page->id, $seenpages)) {
|
||||
$unseen[] = $page->id;
|
||||
}
|
||||
}
|
||||
|
||||
if(!isset($unseen)) {
|
||||
if(count($unseen) == 0) {
|
||||
if(isset($pagesinbranch)) {
|
||||
$temp = end($pagesinbranch);
|
||||
$nextpage = $temp->nextpageid; // they have seen all the pages in the branch, so go to EOB/next branch table/EOL
|
||||
@@ -795,14 +798,14 @@ function lesson_unseen_branch_jump($lesson, $user) {
|
||||
}
|
||||
$pageid = $lessonpages[$pageid]->nextpageid;
|
||||
}
|
||||
|
||||
$unseen = array();
|
||||
foreach ($branchtables as $branchtable) {
|
||||
// load all of the unseen branch tables into unseen
|
||||
if (!array_key_exists($branchtable, $seen)) {
|
||||
$unseen[] = $branchtable;
|
||||
}
|
||||
}
|
||||
if (isset($unseen)) {
|
||||
if (count($unseen) > 0) {
|
||||
return $unseen[rand(0, count($unseen)-1)]; // returns a random page id for the next page
|
||||
} else {
|
||||
return LESSON_EOL; // has viewed all of the branch tables
|
||||
@@ -831,7 +834,7 @@ function lesson_random_question_jump($lesson, $pageid) {
|
||||
// get the pages within the branch
|
||||
$pagesinbranch = lesson_pages_in_branch($lessonpages, $pageid);
|
||||
|
||||
if(!isset($pagesinbranch)) {
|
||||
if(count($pagesinbranch) == 0) {
|
||||
// there are no pages inside the branch, so return the next page
|
||||
return $lessonpages[$pageid]->nextpageid;
|
||||
} else {
|
||||
@@ -1002,12 +1005,13 @@ function lesson_print_tree($pageid, $lessonid, $cmid, $pixpath) {
|
||||
function lesson_calculate_ongoing_score($lesson, $userid, $retries, $return=false) {
|
||||
// this calculates and prints the ongoing score for students
|
||||
if (!$lesson->custom) {
|
||||
$ncorrect = 0;
|
||||
$ncorrect = 0;
|
||||
$temp = array();
|
||||
if ($pagesanswered = get_records_select("lesson_attempts", "lessonid = $lesson->id AND
|
||||
userid = $userid AND retry = $retries order by timeseen")) {
|
||||
|
||||
foreach ($pagesanswered as $pageanswered) {
|
||||
if (@!array_key_exists($pageanswered->pageid, $temp)) {
|
||||
if (!array_key_exists($pageanswered->pageid, $temp)) {
|
||||
$temp[$pageanswered->pageid] = array($pageanswered->correct, 1);
|
||||
} else {
|
||||
if ($temp[$pageanswered->pageid][1] < $lesson->maxattempts) {
|
||||
@@ -1028,6 +1032,7 @@ function lesson_calculate_ongoing_score($lesson, $userid, $retries, $return=fals
|
||||
if ($return) {
|
||||
return $thegrade;
|
||||
} else {
|
||||
$output = new stdClass;
|
||||
$output->correct = $ncorrect;
|
||||
$output->viewed = $nviewed;
|
||||
print_simple_box(get_string("ongoingnormal", "lesson", $output), "center");
|
||||
@@ -1092,6 +1097,7 @@ function lesson_calculate_ongoing_score($lesson, $userid, $retries, $return=fals
|
||||
return $thegrade;
|
||||
} else {
|
||||
// not taking into account essay questions... may want to?
|
||||
$ongoingoutput = new stdClass;
|
||||
$ongoingoutput->score = $score;
|
||||
$ongoingoutput->currenthigh = $bestscore;
|
||||
print_simple_box(get_string("ongoingcustom", "lesson", $ongoingoutput), "center");
|
||||
|
||||
+23
-7
@@ -128,7 +128,8 @@ if ($form->mode == "add") {
|
||||
<tr>
|
||||
<td align="right"><b><?php print_string("timed", "lesson"); ?>:</b></td>
|
||||
<td>
|
||||
<?PHP
|
||||
<?PHP
|
||||
$options = array();
|
||||
$options[0] = get_string("no"); $options[1] = get_string("yes");
|
||||
choose_from_menu($options, "timed", $form->timed, "");
|
||||
helpbutton("timed", get_string("timed", "lesson"), "lesson");
|
||||
@@ -148,6 +149,7 @@ if ($form->mode == "add") {
|
||||
<td align="right"><b><?php print_string("maximumnumberofanswersbranches", "lesson") ?>:</b></td>
|
||||
<td>
|
||||
<?php
|
||||
$numbers = array();
|
||||
for ($i=20; $i>1; $i--) {
|
||||
$numbers[$i] = $i;
|
||||
}
|
||||
@@ -166,7 +168,8 @@ if ($form->mode == "add") {
|
||||
<tr>
|
||||
<td align="right"><b><?php print_string("practice", "lesson"); ?>:</b></td>
|
||||
<td>
|
||||
<?PHP
|
||||
<?PHP
|
||||
$options = array();
|
||||
$options[0] = get_string("no"); $options[1] = get_string("yes");
|
||||
choose_from_menu($options, "practice", $form->practice, "");
|
||||
helpbutton("practice", get_string("practice", "lesson"), "lesson");
|
||||
@@ -177,7 +180,8 @@ if ($form->mode == "add") {
|
||||
<tr>
|
||||
<td align="right"><b><?php print_string("customscoring", "lesson"); ?>:</b></td>
|
||||
<td>
|
||||
<?PHP
|
||||
<?PHP
|
||||
$options = array();
|
||||
$options[0] = get_string("no"); $options[1] = get_string("yes");
|
||||
choose_from_menu($options, "custom", $form->custom, "");
|
||||
helpbutton("custom", get_string("customscoring", "lesson"), "lesson");
|
||||
@@ -189,6 +193,7 @@ if ($form->mode == "add") {
|
||||
<td align="right"><b><?php print_string("maximumgrade") ?>:</b></td>
|
||||
<td>
|
||||
<?php
|
||||
$grades = array();
|
||||
for ($i=100; $i>=0; $i--) {
|
||||
$grades[$i] = $i;
|
||||
}
|
||||
@@ -201,7 +206,8 @@ if ($form->mode == "add") {
|
||||
<tr>
|
||||
<td align="right"><b><?php print_string("canretake", "lesson", $course->student) ?>:</b></td>
|
||||
<td>
|
||||
<?PHP
|
||||
<?PHP
|
||||
$options = array();
|
||||
$options[0] = get_string("no"); $options[1] = get_string("yes");
|
||||
choose_from_menu($options, "retake", $form->retake, "");
|
||||
helpbutton("retake", get_string("canretake", "lesson", $course->student), "lesson");
|
||||
@@ -213,6 +219,7 @@ if ($form->mode == "add") {
|
||||
<td align="right"><b><?php print_string("handlingofretakes", "lesson") ?>:</b></td>
|
||||
<td>
|
||||
<?PHP
|
||||
$options = array();
|
||||
$options[0] = get_string("usemean", "lesson"); $options[1] = get_string("usemaximum", "lesson");
|
||||
choose_from_menu($options, "usemaxgrade", $form->usemaxgrade, "");
|
||||
helpbutton("handlingofretakes", get_string("handlingofretakes", "lesson"), "lesson");
|
||||
@@ -224,6 +231,7 @@ if ($form->mode == "add") {
|
||||
<td align="right"><b><?php print_string("ongoing", "lesson"); ?>:</b></td>
|
||||
<td>
|
||||
<?php
|
||||
$options = array();
|
||||
$options[0] = get_string("no"); $options[1] = get_string("yes");
|
||||
choose_from_menu($options, "ongoing", $form->ongoing, "");
|
||||
helpbutton("ongoing", get_string("ongoing", "lesson"), "lesson");
|
||||
@@ -241,6 +249,7 @@ if ($form->mode == "add") {
|
||||
<td align="right"><b><?php print_string("modattempts", "lesson"); ?>:</b></td>
|
||||
<td>
|
||||
<?PHP
|
||||
$options = array();
|
||||
$options[0] = get_string("no"); $options[1] = get_string("yes");
|
||||
choose_from_menu($options, "modattempts", $form->modattempts, "");
|
||||
helpbutton("modattempts", get_string("modattempts", "lesson"), "lesson");
|
||||
@@ -252,6 +261,7 @@ if ($form->mode == "add") {
|
||||
<td align="right"><b><?php print_string("displayreview", "lesson"); ?>:</b></td>
|
||||
<td>
|
||||
<?php
|
||||
$options = array();
|
||||
$options[0] = get_string("no"); $options[1] = get_string("yes");
|
||||
choose_from_menu($options, "review", $form->review, "");
|
||||
helpbutton("review", get_string("displayreview", "lesson"), "lesson");
|
||||
@@ -263,7 +273,7 @@ if ($form->mode == "add") {
|
||||
<td align="right"><b><?php print_string("maximumnumberofattempts", "lesson") ?>:</b></td>
|
||||
<td>
|
||||
<?php
|
||||
unset($numbers);
|
||||
$numbers = array();
|
||||
for ($i=10; $i>0; $i--) {
|
||||
$numbers[$i] = $i;
|
||||
}
|
||||
@@ -287,7 +297,7 @@ if ($form->mode == "add") {
|
||||
<td align="right"><b><?php print_string("minimumnumberofquestions", "lesson") ?>:</b></td>
|
||||
<td>
|
||||
<?php
|
||||
unset($numbers);
|
||||
$numbers = array();
|
||||
for ($i=100; $i>=0; $i--) {
|
||||
$numbers[$i] = $i;
|
||||
}
|
||||
@@ -301,7 +311,7 @@ if ($form->mode == "add") {
|
||||
<td align="right"><b><?php print_string("numberofpagestoshow", "lesson") ?>:</b></td>
|
||||
<td>
|
||||
<?php
|
||||
unset($numbers);
|
||||
$numbers = array();
|
||||
for ($i=100; $i>=0; $i--) {
|
||||
$numbers[$i] = $i;
|
||||
}
|
||||
@@ -321,6 +331,7 @@ if ($form->mode == "add") {
|
||||
<td align="right"><b><?php print_string("slideshow", "lesson"); ?>:</b></td>
|
||||
<td>
|
||||
<?PHP
|
||||
$options = array();
|
||||
$options[0] = get_string("no"); $options[1] = get_string("yes");
|
||||
choose_from_menu($options, "slideshow", $form->slideshow, "");
|
||||
helpbutton("slideshow", get_string("slideshow", "lesson"), "lesson");
|
||||
@@ -357,6 +368,7 @@ if ($form->mode == "add") {
|
||||
<td align="right"><b><?php print_string("displayleftmenu", "lesson"); ?>:</b></td>
|
||||
<td>
|
||||
<?PHP
|
||||
$options = array();
|
||||
$options[0] = get_string("no"); $options[1] = get_string("yes");
|
||||
choose_from_menu($options, "displayleft", $form->displayleft, "");
|
||||
helpbutton("displayleft", get_string("displayleftmenu", "lesson"), "lesson");
|
||||
@@ -374,6 +386,7 @@ if ($form->mode == "add") {
|
||||
<td align="right"><b><?php print_string("usepassword", "lesson"); ?>:</b></td>
|
||||
<td>
|
||||
<?PHP
|
||||
$options = array();
|
||||
$options[0] = get_string("no"); $options[1] = get_string("yes");
|
||||
choose_from_menu($options, "usepassword", $form->usepassword, "");
|
||||
helpbutton("usepassword", get_string("usepassword", "lesson"), "lesson");
|
||||
@@ -417,6 +430,7 @@ if ($form->mode == "add") {
|
||||
<td align="right"><b><?php print_string("treeview", "lesson"); ?>:</b></td>
|
||||
<td>
|
||||
<?PHP
|
||||
$options = array();
|
||||
$options[0] = get_string("no"); $options[1] = get_string("yes");
|
||||
choose_from_menu($options, "tree", $form->tree, "");
|
||||
helpbutton("tree", get_string("treeview", "lesson"), "lesson");
|
||||
@@ -428,6 +442,7 @@ if ($form->mode == "add") {
|
||||
<td align="right"><b><?php print_string("displayhighscores", "lesson"); ?>:</b></td>
|
||||
<td>
|
||||
<?PHP
|
||||
$options = array();
|
||||
$options[0] = get_string("no"); $options[1] = get_string("yes");
|
||||
choose_from_menu($options, "highscores", $form->highscores, "");
|
||||
helpbutton("highscores", get_string("displayhighscores", "lesson"), "lesson");
|
||||
@@ -447,6 +462,7 @@ if ($form->mode == "add") {
|
||||
<td align="right"><b><?php print_string("lessondefault", "lesson"); ?>:</b></td>
|
||||
<td>
|
||||
<?PHP
|
||||
$options = array();
|
||||
$options[0] = get_string("no"); $options[1] = get_string("yes");
|
||||
choose_from_menu($options, "lessondefault", $form->lessondefault, "");
|
||||
helpbutton("lessondefault", get_string("lessondefault", "lesson"), "lesson");
|
||||
|
||||
@@ -61,6 +61,7 @@ function importmodifiedaikenstyle($filename) {
|
||||
$lines = file($filename);
|
||||
$answer_found = 0;
|
||||
$responses = 0;
|
||||
$outlines = array();
|
||||
foreach ($lines as $line) {
|
||||
// strip leading and trailing whitespace
|
||||
$line = trim($line);
|
||||
|
||||
Reference in New Issue
Block a user