mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
changed lesson_calculate_ongoing_score function and added some comments
This commit is contained in:
parent
db22702089
commit
b986908256
1 changed files with 31 additions and 28 deletions
|
@ -48,13 +48,13 @@ if (!defined("LESSON_SHORTANSWER")) {
|
||||||
if (!defined("LESSON_TRUEFALSE")) {
|
if (!defined("LESSON_TRUEFALSE")) {
|
||||||
define("LESSON_TRUEFALSE", "2");
|
define("LESSON_TRUEFALSE", "2");
|
||||||
}
|
}
|
||||||
if (!defined("LESSON_MULTICHOICE")) {
|
if (!defined("LESSON_MULTICHOICE")) { // if you change the value of this (WHICH YOU SHOULDNT) then you need to change it in restorelib.php as well
|
||||||
define("LESSON_MULTICHOICE", "3");
|
define("LESSON_MULTICHOICE", "3");
|
||||||
}
|
}
|
||||||
if (!defined("LESSON_RANDOM")) {
|
if (!defined("LESSON_RANDOM")) {
|
||||||
define("LESSON_RANDOM", "4");
|
define("LESSON_RANDOM", "4");
|
||||||
}
|
}
|
||||||
if (!defined("LESSON_MATCHING")) {
|
if (!defined("LESSON_MATCHING")) { // if you change the value of this (WHICH YOU SHOULDNT) then you need to change it in restorelib.php as well
|
||||||
define("LESSON_MATCHING", "5");
|
define("LESSON_MATCHING", "5");
|
||||||
}
|
}
|
||||||
if (!defined("LESSON_RANDOMSAMATCH")) {
|
if (!defined("LESSON_RANDOMSAMATCH")) {
|
||||||
|
@ -882,26 +882,34 @@ function lesson_is_page_in_cluster($pages, $pageid) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************/
|
/*******************************************************************/
|
||||||
function lesson_print_tree_menu($lessonid, $pageid, $id) {
|
function lesson_print_tree_menu($lessonid, $pageid, $id, $showpages=false) {
|
||||||
// prints the contents of the left menu
|
// prints the contents of the left menu
|
||||||
|
|
||||||
if(!$pages = get_records_select("lesson_pages", "lessonid = $lessonid")) {
|
if(!$pages = get_records_select("lesson_pages", "lessonid = $lessonid")) {
|
||||||
error("Error: could not find lesson pages");
|
error("Error: could not find lesson pages");
|
||||||
}
|
}
|
||||||
while ($pageid != 0) {
|
while ($pageid != 0) {
|
||||||
lesson_print_tree_link_menu($pages[$pageid], $id);
|
lesson_print_tree_link_menu($pages[$pageid], $id, true);
|
||||||
$pageid = $pages[$pageid]->nextpageid;
|
$pageid = $pages[$pageid]->nextpageid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************/
|
/*******************************************************************/
|
||||||
function lesson_print_tree_link_menu($page, $id) {
|
function lesson_print_tree_link_menu($page, $id, $showpages=false) {
|
||||||
// prints the actual link for the left menu
|
// prints the actual link for the left menu
|
||||||
|
|
||||||
if ($page->qtype == LESSON_BRANCHTABLE && !$page->display) {
|
if ($page->qtype == LESSON_BRANCHTABLE && !$page->display) {
|
||||||
return false;
|
return false;
|
||||||
|
} elseif ($page->qtype != LESSON_BRANCHTABLE) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*elseif ($page->qtype != LESSON_BRANCHTABLE && !$showpages) {
|
||||||
|
return false;
|
||||||
|
} elseif (!in_array($page->qtype, $LESSON_QUESTION_TYPE)) {
|
||||||
|
return false;
|
||||||
|
}*/
|
||||||
|
|
||||||
// set up some variables NoticeFix changed whole function
|
// set up some variables NoticeFix changed whole function
|
||||||
$output = "";
|
$output = "";
|
||||||
$close = false;
|
$close = false;
|
||||||
|
@ -910,15 +918,13 @@ function lesson_print_tree_link_menu($page, $id) {
|
||||||
|
|
||||||
if($page->id == $_REQUEST['pageid']) {
|
if($page->id == $_REQUEST['pageid']) {
|
||||||
$close=true;
|
$close=true;
|
||||||
$output.="<div class='active'><em>";
|
$output.="<strong>";
|
||||||
}
|
}
|
||||||
if (($page->qtype!=LESSON_BRANCHTABLE)||($page->qtype==LESSON_ENDOFBRANCH)||($page->qtype==21)) {
|
|
||||||
$output .= "";
|
|
||||||
} else {
|
|
||||||
$output .= "<li><a href=\"view.php?id=$id&action=navigation&pageid=$page->id\">".$title."</a></li>\n";
|
$output .= "<li><a href=\"view.php?id=$id&action=navigation&pageid=$page->id\">".$title."</a></li>\n";
|
||||||
}
|
|
||||||
if($close) {
|
if($close) {
|
||||||
$output.="</em></div>";
|
$output.="</strong>";
|
||||||
}
|
}
|
||||||
echo $output;
|
echo $output;
|
||||||
|
|
||||||
|
@ -986,18 +992,12 @@ function lesson_print_tree($pageid, $lessonid, $cmid, $pixpath) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************/
|
/*******************************************************************/
|
||||||
function lesson_calculate_ongoing_score($lesson, $USER) {
|
function lesson_calculate_ongoing_score($lesson, $userid, $retries, $return=false) {
|
||||||
// this calculates and prints the ongoing score for students
|
// this calculates and prints the ongoing score for students
|
||||||
|
|
||||||
// get the number of retries
|
|
||||||
if (!$retries = count_records("lesson_grades", "lessonid", $lesson->id, "userid", $USER->id)) {
|
|
||||||
$retries = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$lesson->custom) {
|
if (!$lesson->custom) {
|
||||||
$ncorrect = 0;
|
$ncorrect = 0;
|
||||||
if ($pagesanswered = get_records_select("lesson_attempts", "lessonid = $lesson->id AND
|
if ($pagesanswered = get_records_select("lesson_attempts", "lessonid = $lesson->id AND
|
||||||
userid = $USER->id AND retry = $retries order by timeseen")) {
|
userid = $userid AND retry = $retries order by timeseen")) {
|
||||||
|
|
||||||
foreach ($pagesanswered as $pageanswered) {
|
foreach ($pagesanswered as $pageanswered) {
|
||||||
if (@!array_key_exists($pageanswered->pageid, $temp)) {
|
if (@!array_key_exists($pageanswered->pageid, $temp)) {
|
||||||
|
@ -1025,7 +1025,7 @@ function lesson_calculate_ongoing_score($lesson, $USER) {
|
||||||
$score = 0;
|
$score = 0;
|
||||||
$currenthigh = 0;
|
$currenthigh = 0;
|
||||||
if ($useranswers = get_records_select("lesson_attempts", "lessonid = $lesson->id AND
|
if ($useranswers = get_records_select("lesson_attempts", "lessonid = $lesson->id AND
|
||||||
userid = $USER->id AND retry = $retries", "timeseen")) {
|
userid = $userid AND retry = $retries", "timeseen")) {
|
||||||
|
|
||||||
foreach ($useranswers as $useranswer) {
|
foreach ($useranswers as $useranswer) {
|
||||||
if (@!array_key_exists($useranswer->pageid, $temp)) {
|
if (@!array_key_exists($useranswer->pageid, $temp)) {
|
||||||
|
@ -1081,13 +1081,16 @@ function lesson_calculate_ongoing_score($lesson, $USER) {
|
||||||
} elseif ($score < 0) {
|
} elseif ($score < 0) {
|
||||||
$score = 0;
|
$score = 0;
|
||||||
}
|
}
|
||||||
|
if ($return) {
|
||||||
|
return $score;
|
||||||
|
} else {
|
||||||
$ongoingoutput->grade = $lesson->grade;
|
$ongoingoutput->grade = $lesson->grade;
|
||||||
$ongoingoutput->score = $score;
|
$ongoingoutput->score = $score;
|
||||||
$ongoingoutput->currenthigh = $currenthigh;
|
$ongoingoutput->currenthigh = $currenthigh;
|
||||||
print_simple_box(get_string("ongoingcustom", "lesson", $ongoingoutput), "center");
|
print_simple_box(get_string("ongoingcustom", "lesson", $ongoingoutput), "center");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*******************************************************************/
|
/*******************************************************************/
|
||||||
function lesson_qtype_menu($qtypes, $selected="", $link="", $onclick="") {
|
function lesson_qtype_menu($qtypes, $selected="", $link="", $onclick="") {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue