This commit is contained in:
Eloy Lafuente (stronk7) 2015-06-09 20:32:10 +02:00
commit 094356a954
2 changed files with 51 additions and 49 deletions

View file

@ -106,7 +106,9 @@ class behat_calendar extends behat_base {
* @return Given[] * @return Given[]
*/ */
public function i_hover_over_today_in_the_calendar() { public function i_hover_over_today_in_the_calendar() {
$todaysday = trim(strftime('%e')); // For window's compatibility, using %d and not %e.
$todaysday = trim(strftime('%d'));
$todaysday = ltrim($todaysday, '0');
return $this->i_hover_over_day_of_this_month_in_calendar($todaysday); return $this->i_hover_over_day_of_this_month_in_calendar($todaysday);
} }
} }

View file

@ -42,28 +42,6 @@ $currentgroup = groups_get_activity_group($cm, true);
$context = context_module::instance($cm->id); $context = context_module::instance($cm->id);
require_capability('mod/lesson:viewreports', $context); require_capability('mod/lesson:viewreports', $context);
// Only load students if there attempts for this lesson.
if ($attempts = $DB->record_exists('lesson_attempts', array('lessonid' => $lesson->id))) {
list($esql, $params) = get_enrolled_sql($context, '', $currentgroup, true);
list($sort, $sortparams) = users_order_by_sql('u');
$params['lessonid'] = $lesson->id;
$ufields = user_picture::fields('u');
$sql = "SELECT DISTINCT $ufields
FROM {user} u
JOIN {lesson_attempts} a ON u.id = a.userid
JOIN ($esql) ue ON ue.id = a.userid
WHERE a.lessonid = :lessonid
ORDER BY $sort";
$students = $DB->get_recordset_sql($sql, $params);
if (!$students->valid()) {
$nothingtodisplay = true;
}
} else {
$nothingtodisplay = true;
}
$url = new moodle_url('/mod/lesson/report.php', array('id'=>$id)); $url = new moodle_url('/mod/lesson/report.php', array('id'=>$id));
$url->param('action', $action); $url->param('action', $action);
if ($pageid !== null) { if ($pageid !== null) {
@ -77,32 +55,6 @@ if ($action == 'reportoverview') {
$lessonoutput = $PAGE->get_renderer('mod_lesson'); $lessonoutput = $PAGE->get_renderer('mod_lesson');
$attempts = $DB->get_recordset('lesson_attempts', array('lessonid' => $lesson->id), 'timeseen');
if (!$attempts->valid()) {
$nothingtodisplay = true;
}
if (! $grades = $DB->get_records('lesson_grades', array('lessonid' => $lesson->id), 'completed')) {
$grades = array();
}
if (! $times = $DB->get_records('lesson_timer', array('lessonid' => $lesson->id), 'starttime')) {
$times = array();
}
if ($nothingtodisplay) {
echo $lessonoutput->header($lesson, $cm, $action, false, null, get_string('nolessonattempts', 'lesson'));
if (!empty($currentgroup)) {
$groupname = groups_get_group_name($currentgroup);
echo $OUTPUT->notification(get_string('nolessonattemptsgroup', 'lesson', $groupname));
} else {
echo $OUTPUT->notification(get_string('nolessonattempts', 'lesson'));
}
groups_print_activity_menu($cm, $url);
echo $OUTPUT->footer();
exit();
}
if ($action === 'delete') { if ($action === 'delete') {
/// Process any form data before fetching attempts, grades and times /// Process any form data before fetching attempts, grades and times
if (has_capability('mod/lesson:edit', $context) and $form = data_submitted() and confirm_sesskey()) { if (has_capability('mod/lesson:edit', $context) and $form = data_submitted() and confirm_sesskey()) {
@ -163,6 +115,54 @@ if ($action === 'delete') {
/************************************************************************** /**************************************************************************
this action is for default view and overview view this action is for default view and overview view
**************************************************************************/ **************************************************************************/
// Only load students if there attempts for this lesson.
if ($attempts = $DB->record_exists('lesson_attempts', array('lessonid' => $lesson->id))) {
list($esql, $params) = get_enrolled_sql($context, '', $currentgroup, true);
list($sort, $sortparams) = users_order_by_sql('u');
$params['lessonid'] = $lesson->id;
$ufields = user_picture::fields('u');
$sql = "SELECT DISTINCT $ufields
FROM {user} u
JOIN {lesson_attempts} a ON u.id = a.userid
JOIN ($esql) ue ON ue.id = a.userid
WHERE a.lessonid = :lessonid
ORDER BY $sort";
$students = $DB->get_recordset_sql($sql, $params);
if (!$students->valid()) {
$student->close();
$nothingtodisplay = true;
}
} else {
$nothingtodisplay = true;
}
if ($nothingtodisplay) {
echo $lessonoutput->header($lesson, $cm, $action, false, null, get_string('nolessonattempts', 'lesson'));
if (!empty($currentgroup)) {
$groupname = groups_get_group_name($currentgroup);
echo $OUTPUT->notification(get_string('nolessonattemptsgroup', 'lesson', $groupname));
} else {
echo $OUTPUT->notification(get_string('nolessonattempts', 'lesson'));
}
groups_print_activity_menu($cm, $url);
echo $OUTPUT->footer();
exit();
}
// We have attempts and students, let's prepare all the information.
$attempts = $DB->get_recordset('lesson_attempts', array('lessonid' => $lesson->id), 'timeseen');
if (! $grades = $DB->get_records('lesson_grades', array('lessonid' => $lesson->id), 'completed')) {
$grades = array();
}
if (! $times = $DB->get_records('lesson_timer', array('lessonid' => $lesson->id), 'starttime')) {
$times = array();
}
echo $lessonoutput->header($lesson, $cm, $action, false, null, get_string('overview', 'lesson')); echo $lessonoutput->header($lesson, $cm, $action, false, null, get_string('overview', 'lesson'));
groups_print_activity_menu($cm, $url); groups_print_activity_menu($cm, $url);