MDL-15112 lesson dml conversion

This commit is contained in:
jerome 2008-06-09 02:08:59 +00:00
parent abcbc61296
commit e57bc529da
4 changed files with 10 additions and 24 deletions

View File

@ -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'));
}

View File

@ -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

View File

@ -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

View File

@ -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");
}