mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 14:27:22 +01:00
MDL-15112 lesson dml conversion
This commit is contained in:
parent
abcbc61296
commit
e57bc529da
@ -32,10 +32,8 @@
|
||||
list($usql, $parameters) = $DB->get_in_or_equal(array_keys($pages));
|
||||
if ($essayattempts = $DB->get_records_select('lesson_attempts', 'pageid $usql', $parameters)) {
|
||||
// Get all the users who have taken this lesson, order by their last name
|
||||
$paras = array();
|
||||
$paras["lessonid"] = $lesson->id;
|
||||
if (!empty($CFG->enablegroupings) && !empty($cm->groupingid)) {
|
||||
$paras["groupinid"] = $cm->groupingid;
|
||||
$params["groupinid"] = $cm->groupingid;
|
||||
$sql = "SELECT DISTINCT u.*
|
||||
FROM {lesson_attempts} a
|
||||
INNER JOIN {user} u ON u.id = a.userid
|
||||
@ -51,7 +49,7 @@
|
||||
u.id = a.userid
|
||||
ORDER BY u.lastname";
|
||||
}
|
||||
if (!$users = $DB->get_records_sql($sql, $paras)) {
|
||||
if (!$users = $DB->get_records_sql($sql, $params)) {
|
||||
$mode = 'none'; // not displaying anything
|
||||
lesson_set_message(get_string('noonehasanswered', 'lesson'));
|
||||
}
|
||||
|
@ -53,16 +53,16 @@
|
||||
if ($mode == 'add') {
|
||||
break;
|
||||
}
|
||||
$params = array ("lessonid" => $lesson->id);
|
||||
$params = array ("lessonid" => $lesson->id, "userid" => $USER->id);
|
||||
if (!$grades = $DB->get_records_select('lesson_grades', "lessonid = :lessonid", $params, 'completed')) {
|
||||
print_error('Error: could not find grades');
|
||||
}
|
||||
$paremeters = array ("lessonid" => $lesson->id, "userid" => $USER->id);
|
||||
|
||||
if (!$newgrade = $DB->get_record_sql("SELECT *
|
||||
FROM {lesson_grades}
|
||||
WHERE lessonid = :lessonid
|
||||
AND userid = :userid
|
||||
ORDER BY completed DESC", $paremeters, true)) {
|
||||
ORDER BY completed DESC", $params, true)) {
|
||||
print_error('Error: could not find newest grade');
|
||||
}
|
||||
|
||||
@ -72,7 +72,6 @@
|
||||
}
|
||||
|
||||
// Find out if we need to delete any records
|
||||
$params = array ("lessonid" => $lesson->id);
|
||||
if ($highscores = $DB->get_records_sql("SELECT h.*, g.grade
|
||||
FROM {lesson_grades} g, {lesson_high_scores} h
|
||||
WHERE h.gradeid = g.id
|
||||
|
@ -325,26 +325,18 @@ function lesson_cron () {
|
||||
function lesson_get_user_grades($lesson, $userid=0) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$params = array();
|
||||
$params = array("lessonid" => $lesson->id);
|
||||
|
||||
if (isset($userid)) {
|
||||
$params["userid"] = $userid;
|
||||
$user = "AND u.id = :userid";
|
||||
}
|
||||
else {
|
||||
$user="";
|
||||
}
|
||||
|
||||
if (isset($fuser)) {
|
||||
$params["userid"] = $userid;
|
||||
$fuser = "AND uu.id = :userid";
|
||||
}
|
||||
else {
|
||||
$user="";
|
||||
$fuser="";
|
||||
}
|
||||
|
||||
$params["lessonid"] = $lesson->id;
|
||||
|
||||
if ($lesson->retake) {
|
||||
if ($lesson->usemaxgrade) {
|
||||
$sql = "SELECT u.id, u.id AS userid, MAX(g.grade) AS rawgrade
|
||||
|
@ -1081,8 +1081,7 @@ function lesson_cluster_jump($lessonid, $userid, $pageid) {
|
||||
}
|
||||
|
||||
// get the lesson pages
|
||||
$parameters = array ("lessonid" => $lessonid);
|
||||
if (!$lessonpages = $DB->get_records_select("lesson_pages", "lessonid = :lessonid", $parameters)) {
|
||||
if (!$lessonpages = $DB->get_records_select("lesson_pages", "lessonid = :lessonid", $params)) {
|
||||
print_error("Error: could not find records in lesson_pages table");
|
||||
}
|
||||
// find the start of the cluster
|
||||
@ -1213,8 +1212,7 @@ function lesson_unseen_question_jump($lesson, $user, $pageid) {
|
||||
}
|
||||
|
||||
// get the lesson pages
|
||||
$parameters = array ("lessonid" => $lesson);
|
||||
if (!$lessonpages = $DB->get_records_select("lesson_pages", "lessonid = :lessonid", $parameters)) {
|
||||
if (!$lessonpages = $DB->get_records_select("lesson_pages", "lessonid = :lessonid", $params)) {
|
||||
print_error("Error: could not find records in lesson_pages table");
|
||||
}
|
||||
|
||||
@ -1279,8 +1277,7 @@ function lesson_unseen_branch_jump($lessonid, $userid) {
|
||||
}
|
||||
|
||||
// get the lesson pages
|
||||
$parameters = array ("lessonid" => $lessonid);
|
||||
if (!$lessonpages = $DB->get_records_select("lesson_pages", "lessonid = :lessonid", $parameters)) {
|
||||
if (!$lessonpages = $DB->get_records_select("lesson_pages", "lessonid = :lessonid", $params)) {
|
||||
print_error("Error: could not find records in lesson_pages table");
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user