mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 20:42:22 +02:00
Merge branch 'MDL-57487-master' of git://github.com/sarjona/moodle
This commit is contained in:
commit
90b01a0015
@ -2906,121 +2906,6 @@ class core_course_external extends external_api {
|
||||
return self::get_course_module_returns();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns description of method parameters
|
||||
*
|
||||
* @deprecated since 3.3
|
||||
* @todo The final deprecation of this function will take place in Moodle 3.7 - see MDL-57487.
|
||||
* @return external_function_parameters
|
||||
* @since Moodle 3.2
|
||||
*/
|
||||
public static function get_activities_overview_parameters() {
|
||||
return new external_function_parameters(
|
||||
array(
|
||||
'courseids' => new external_multiple_structure(new external_value(PARAM_INT, 'Course id.')),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return activities overview for the given courses.
|
||||
*
|
||||
* @deprecated since 3.3
|
||||
* @todo The final deprecation of this function will take place in Moodle 3.7 - see MDL-57487.
|
||||
* @param array $courseids a list of course ids
|
||||
* @return array of warnings and the activities overview
|
||||
* @since Moodle 3.2
|
||||
* @throws moodle_exception
|
||||
*/
|
||||
public static function get_activities_overview($courseids) {
|
||||
global $USER;
|
||||
|
||||
// Parameter validation.
|
||||
$params = self::validate_parameters(self::get_activities_overview_parameters(), array('courseids' => $courseids));
|
||||
$courseoverviews = array();
|
||||
|
||||
list($courses, $warnings) = external_util::validate_courses($params['courseids']);
|
||||
|
||||
if (!empty($courses)) {
|
||||
// Add lastaccess to each course (required by print_overview function).
|
||||
// We need the complete user data, the ws server does not load a complete one.
|
||||
$user = get_complete_user_data('id', $USER->id);
|
||||
foreach ($courses as $course) {
|
||||
if (isset($user->lastcourseaccess[$course->id])) {
|
||||
$course->lastaccess = $user->lastcourseaccess[$course->id];
|
||||
} else {
|
||||
$course->lastaccess = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$overviews = array();
|
||||
if ($modules = get_plugin_list_with_function('mod', 'print_overview')) {
|
||||
foreach ($modules as $fname) {
|
||||
$fname($courses, $overviews);
|
||||
}
|
||||
}
|
||||
|
||||
// Format output.
|
||||
foreach ($overviews as $courseid => $modules) {
|
||||
$courseoverviews[$courseid]['id'] = $courseid;
|
||||
$courseoverviews[$courseid]['overviews'] = array();
|
||||
|
||||
foreach ($modules as $modname => $overviewtext) {
|
||||
$courseoverviews[$courseid]['overviews'][] = array(
|
||||
'module' => $modname,
|
||||
'overviewtext' => $overviewtext // This text doesn't need formatting.
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$result = array(
|
||||
'courses' => $courseoverviews,
|
||||
'warnings' => $warnings
|
||||
);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns description of method result value
|
||||
*
|
||||
* @deprecated since 3.3
|
||||
* @todo The final deprecation of this function will take place in Moodle 3.7 - see MDL-57487.
|
||||
* @return external_description
|
||||
* @since Moodle 3.2
|
||||
*/
|
||||
public static function get_activities_overview_returns() {
|
||||
return new external_single_structure(
|
||||
array(
|
||||
'courses' => new external_multiple_structure(
|
||||
new external_single_structure(
|
||||
array(
|
||||
'id' => new external_value(PARAM_INT, 'Course id'),
|
||||
'overviews' => new external_multiple_structure(
|
||||
new external_single_structure(
|
||||
array(
|
||||
'module' => new external_value(PARAM_PLUGIN, 'Module name'),
|
||||
'overviewtext' => new external_value(PARAM_RAW, 'Overview text'),
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
), 'List of courses'
|
||||
),
|
||||
'warnings' => new external_warnings()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Marking the method as deprecated.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function get_activities_overview_is_deprecated() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns description of method parameters
|
||||
*
|
||||
|
@ -2194,50 +2194,6 @@ class core_course_externallib_testcase extends externallib_advanced_testcase {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get_activities_overview
|
||||
*/
|
||||
public function test_get_activities_overview() {
|
||||
global $USER;
|
||||
|
||||
$this->resetAfterTest();
|
||||
$course1 = self::getDataGenerator()->create_course();
|
||||
$course2 = self::getDataGenerator()->create_course();
|
||||
|
||||
// Create a viewer user.
|
||||
$viewer = self::getDataGenerator()->create_user((object) array('trackforums' => 1));
|
||||
$this->getDataGenerator()->enrol_user($viewer->id, $course1->id);
|
||||
$this->getDataGenerator()->enrol_user($viewer->id, $course2->id);
|
||||
|
||||
// Create two forums - one in each course.
|
||||
$record = new stdClass();
|
||||
$record->course = $course1->id;
|
||||
$forum1 = self::getDataGenerator()->create_module('forum', (object) array('course' => $course1->id));
|
||||
$forum2 = self::getDataGenerator()->create_module('forum', (object) array('course' => $course2->id));
|
||||
|
||||
$this->setAdminUser();
|
||||
// A standard post in the forum.
|
||||
$record = new stdClass();
|
||||
$record->course = $course1->id;
|
||||
$record->userid = $USER->id;
|
||||
$record->forum = $forum1->id;
|
||||
$this->getDataGenerator()->get_plugin_generator('mod_forum')->create_discussion($record);
|
||||
|
||||
$this->setUser($viewer->id);
|
||||
$courses = array($course1->id , $course2->id);
|
||||
|
||||
$result = core_course_external::get_activities_overview($courses);
|
||||
$this->assertDebuggingCalledCount(8);
|
||||
$result = external_api::clean_returnvalue(core_course_external::get_activities_overview_returns(), $result);
|
||||
|
||||
// There should be one entry for course1, and no others.
|
||||
$this->assertCount(1, $result['courses']);
|
||||
$this->assertEquals($course1->id, $result['courses'][0]['id']);
|
||||
// Check expected overview data for the module.
|
||||
$this->assertEquals('forum', $result['courses'][0]['overviews'][0]['module']);
|
||||
$this->assertContains('1 total unread', $result['courses'][0]['overviews'][0]['overviewtext']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get_user_navigation_options
|
||||
*/
|
||||
|
@ -1,6 +1,10 @@
|
||||
This files describes API changes in /course/*,
|
||||
information provided here is intended especially for developers.
|
||||
|
||||
=== 3.8 ===
|
||||
* The following functions have been finally deprecated and can not be used any more:
|
||||
- core_course_external::get_activities_overview
|
||||
|
||||
=== 3.7 ===
|
||||
|
||||
* The course pattern function in course_summary_exporter::get_course_pattern has been moved to $OUTPUT->get_generated_image_for_id.
|
||||
@ -10,7 +14,6 @@ information provided here is intended especially for developers.
|
||||
* External function core_course_external::get_course_contents now returns a new contentsinfo field with summary files information.
|
||||
* External function core_course_external::get_course_contents now returns an additional field "tags" returning the content tags.
|
||||
|
||||
|
||||
=== 3.6 ===
|
||||
|
||||
* External function core_course_external::get_course_public_information now returns the roles and the primary role of course
|
||||
|
@ -529,15 +529,6 @@ $functions = array(
|
||||
'type' => 'write',
|
||||
'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE),
|
||||
),
|
||||
'core_course_get_activities_overview' => array(
|
||||
'classname' => 'core_course_external',
|
||||
'methodname' => 'get_activities_overview',
|
||||
'classpath' => 'course/externallib.php',
|
||||
'description' => '** DEPRECATED ** Please do not call this function any more.
|
||||
Return activities overview for the given courses.',
|
||||
'type' => 'read',
|
||||
'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE),
|
||||
),
|
||||
'core_course_get_user_navigation_options' => array(
|
||||
'classname' => 'core_course_external',
|
||||
'methodname' => 'get_user_navigation_options',
|
||||
|
@ -155,7 +155,6 @@ $string['downloadselectedsubmissions'] = 'Download selected submissions';
|
||||
$string['duedate'] = 'Due date';
|
||||
$string['duedatecolon'] = 'Due date: {$a}';
|
||||
$string['duedate_help'] = 'This is when the assignment is due. Submissions will still be allowed after this date, but any assignments submitted after this date will be marked as late. Set an assignment cut-off date to prevent submissions after a certain date.';
|
||||
$string['duedateno'] = 'No due date';
|
||||
$string['duplicateoverride'] = 'Duplicate override';
|
||||
$string['submissionempty'] = 'Nothing was submitted';
|
||||
$string['submissionmodified'] = 'You have existing submission data. Please leave this page and try again.';
|
||||
@ -351,14 +350,12 @@ $string['moreusers'] = '{$a} more...';
|
||||
$string['multipleteams'] = 'Member of more than one group';
|
||||
$string['multipleteams_desc'] = 'The assignment requires submission in groups. You are a member of more than one group. To be able to submit you must be a member of only one group. Please contact your teacher to change your group membership.';
|
||||
$string['multipleteamsgrader'] = 'Member of more than one group, so unable to make submissions.';
|
||||
$string['mysubmission'] = 'My submission: ';
|
||||
$string['newsubmissions'] = 'Assignments submitted';
|
||||
$string['noattempt'] = 'No attempt';
|
||||
$string['noclose'] = 'No close date';
|
||||
$string['nofilters'] = 'No filters';
|
||||
$string['nofiles'] = 'No files. ';
|
||||
$string['nograde'] = 'No grade. ';
|
||||
$string['nolatesubmissions'] = 'No late submissions accepted. ';
|
||||
$string['nomoresubmissionsaccepted'] = 'Only allowed for participants who have been granted an extension';
|
||||
$string['none'] = 'None';
|
||||
$string['noonlinesubmissions'] = 'This assignment does not require you to submit anything online';
|
||||
@ -366,13 +363,11 @@ $string['noopen'] = 'No open date';
|
||||
$string['nooverridedata'] = 'You must override at least one of the assignment settings.';
|
||||
$string['nosavebutnext'] = 'Next';
|
||||
$string['nosubmission'] = 'Nothing has been submitted for this assignment';
|
||||
$string['nosubmissionsacceptedafter'] = 'No submissions accepted after ';
|
||||
$string['noteam'] = 'Not a member of any group';
|
||||
$string['noteam_desc'] = 'This assignment requires submission in groups. You are not a member of any group, so you cannot create a submission. Please contact your teacher to be added to a group.';
|
||||
$string['noteamgrader'] = 'Not a member of any group, so unable to make submissions.';
|
||||
$string['notgraded'] = 'Not graded';
|
||||
$string['notgradedyet'] = 'Not graded yet';
|
||||
$string['notsubmittedyet'] = 'Not submitted yet';
|
||||
$string['notifications'] = 'Notifications';
|
||||
$string['nousersselected'] = 'No users selected';
|
||||
$string['nousers'] = 'No users';
|
||||
@ -527,7 +522,6 @@ $string['submissionreceiptsmall'] = 'You have submitted your assignment submissi
|
||||
$string['submissionslocked'] = 'This assignment is not accepting submissions';
|
||||
$string['submissionslockedshort'] = 'Submission changes not allowed';
|
||||
$string['submissions'] = 'Submissions';
|
||||
$string['submissionsnotgraded'] = 'Submissions not graded: {$a}';
|
||||
$string['submissionsclosed'] = 'Submissions closed';
|
||||
$string['submissionsettings'] = 'Submission settings';
|
||||
$string['submissionstatement'] = 'Submission statement';
|
||||
@ -614,3 +608,11 @@ $string['viewsubmissiongradingtable'] = 'View submission grading table.';
|
||||
$string['viewrevealidentitiesconfirm'] = 'View reveal student identities confirmation page.';
|
||||
$string['workflowfilter'] = 'Workflow filter';
|
||||
$string['xofy'] = '{$a->x} of {$a->y}';
|
||||
|
||||
// Deprecated since Moodle 3.8.
|
||||
$string['duedateno'] = 'No due date';
|
||||
$string['mysubmission'] = 'My submission: ';
|
||||
$string['nolatesubmissions'] = 'No late submissions accepted. ';
|
||||
$string['nosubmissionsacceptedafter'] = 'No submissions accepted after ';
|
||||
$string['notsubmittedyet'] = 'Not submitted yet';
|
||||
$string['submissionsnotgraded'] = 'Submissions not graded: {$a}';
|
||||
|
@ -0,0 +1,6 @@
|
||||
duedateno,mod_assign
|
||||
mysubmission,mod_assign
|
||||
nolatesubmissions,mod_assign
|
||||
nosubmissionsacceptedafter,mod_assign
|
||||
notsubmittedyet,mod_assign
|
||||
submissionsnotgraded,mod_assign
|
@ -560,315 +560,24 @@ function assign_page_type_list($pagetype, $parentcontext, $currentcontext) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Print an overview of all assignments
|
||||
* for the courses.
|
||||
*
|
||||
* @deprecated since 3.3
|
||||
* @todo The final deprecation of this function will take place in Moodle 3.7 - see MDL-57487.
|
||||
* @param mixed $courses The list of courses to print the overview for
|
||||
* @param array $htmlarray The array of html to return
|
||||
* @return true
|
||||
* @deprecated since Moodle 3.3, when the block_course_overview block was removed.
|
||||
*/
|
||||
function assign_print_overview($courses, &$htmlarray) {
|
||||
global $CFG, $DB;
|
||||
|
||||
debugging('The function assign_print_overview() is now deprecated.', DEBUG_DEVELOPER);
|
||||
|
||||
if (empty($courses) || !is_array($courses) || count($courses) == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!$assignments = get_all_instances_in_courses('assign', $courses)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$assignmentids = array();
|
||||
|
||||
// Do assignment_base::isopen() here without loading the whole thing for speed.
|
||||
foreach ($assignments as $key => $assignment) {
|
||||
$time = time();
|
||||
$isopen = false;
|
||||
if ($assignment->duedate) {
|
||||
$duedate = false;
|
||||
if ($assignment->cutoffdate) {
|
||||
$duedate = $assignment->cutoffdate;
|
||||
}
|
||||
if ($duedate) {
|
||||
$isopen = ($assignment->allowsubmissionsfromdate <= $time && $time <= $duedate);
|
||||
} else {
|
||||
$isopen = ($assignment->allowsubmissionsfromdate <= $time);
|
||||
}
|
||||
}
|
||||
if ($isopen) {
|
||||
$assignmentids[] = $assignment->id;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($assignmentids)) {
|
||||
// No assignments to look at - we're done.
|
||||
return true;
|
||||
}
|
||||
|
||||
// Definitely something to print, now include the constants we need.
|
||||
require_once($CFG->dirroot . '/mod/assign/locallib.php');
|
||||
|
||||
$strduedate = get_string('duedate', 'assign');
|
||||
$strcutoffdate = get_string('nosubmissionsacceptedafter', 'assign');
|
||||
$strnolatesubmissions = get_string('nolatesubmissions', 'assign');
|
||||
$strduedateno = get_string('duedateno', 'assign');
|
||||
$strassignment = get_string('modulename', 'assign');
|
||||
|
||||
// We do all possible database work here *outside* of the loop to ensure this scales.
|
||||
list($sqlassignmentids, $assignmentidparams) = $DB->get_in_or_equal($assignmentids);
|
||||
|
||||
$mysubmissions = null;
|
||||
$unmarkedsubmissions = null;
|
||||
|
||||
foreach ($assignments as $assignment) {
|
||||
|
||||
// Do not show assignments that are not open.
|
||||
if (!in_array($assignment->id, $assignmentids)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$context = context_module::instance($assignment->coursemodule);
|
||||
|
||||
// Does the submission status of the assignment require notification?
|
||||
if (has_capability('mod/assign:submit', $context, null, false)) {
|
||||
// Does the submission status of the assignment require notification?
|
||||
$submitdetails = assign_get_mysubmission_details_for_print_overview($mysubmissions, $sqlassignmentids,
|
||||
$assignmentidparams, $assignment);
|
||||
} else {
|
||||
$submitdetails = false;
|
||||
}
|
||||
|
||||
if (has_capability('mod/assign:grade', $context, null, false)) {
|
||||
// Does the grading status of the assignment require notification ?
|
||||
$gradedetails = assign_get_grade_details_for_print_overview($unmarkedsubmissions, $sqlassignmentids,
|
||||
$assignmentidparams, $assignment, $context);
|
||||
} else {
|
||||
$gradedetails = false;
|
||||
}
|
||||
|
||||
if (empty($submitdetails) && empty($gradedetails)) {
|
||||
// There is no need to display this assignment as there is nothing to notify.
|
||||
continue;
|
||||
}
|
||||
|
||||
$dimmedclass = '';
|
||||
if (!$assignment->visible) {
|
||||
$dimmedclass = ' class="dimmed"';
|
||||
}
|
||||
$href = $CFG->wwwroot . '/mod/assign/view.php?id=' . $assignment->coursemodule;
|
||||
$basestr = '<div class="assign overview">' .
|
||||
'<div class="name">' .
|
||||
$strassignment . ': '.
|
||||
'<a ' . $dimmedclass .
|
||||
'title="' . $strassignment . '" ' .
|
||||
'href="' . $href . '">' .
|
||||
format_string($assignment->name) .
|
||||
'</a></div>';
|
||||
if ($assignment->duedate) {
|
||||
$userdate = userdate($assignment->duedate);
|
||||
$basestr .= '<div class="info">' . $strduedate . ': ' . $userdate . '</div>';
|
||||
} else {
|
||||
$basestr .= '<div class="info">' . $strduedateno . '</div>';
|
||||
}
|
||||
if ($assignment->cutoffdate) {
|
||||
if ($assignment->cutoffdate == $assignment->duedate) {
|
||||
$basestr .= '<div class="info">' . $strnolatesubmissions . '</div>';
|
||||
} else {
|
||||
$userdate = userdate($assignment->cutoffdate);
|
||||
$basestr .= '<div class="info">' . $strcutoffdate . ': ' . $userdate . '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
// Show only relevant information.
|
||||
if (!empty($submitdetails)) {
|
||||
$basestr .= $submitdetails;
|
||||
}
|
||||
|
||||
if (!empty($gradedetails)) {
|
||||
$basestr .= $gradedetails;
|
||||
}
|
||||
$basestr .= '</div>';
|
||||
|
||||
if (empty($htmlarray[$assignment->course]['assign'])) {
|
||||
$htmlarray[$assignment->course]['assign'] = $basestr;
|
||||
} else {
|
||||
$htmlarray[$assignment->course]['assign'] .= $basestr;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
function assign_print_overview() {
|
||||
throw new coding_exception('assign_print_overview() can not be used any more and is obsolete.');
|
||||
}
|
||||
|
||||
/**
|
||||
* This api generates html to be displayed to students in print overview section, related to their submission status of the given
|
||||
* assignment.
|
||||
*
|
||||
* @deprecated since 3.3
|
||||
* @todo The final deprecation of this function will take place in Moodle 3.7 - see MDL-57487.
|
||||
* @param array $mysubmissions list of submissions of current user indexed by assignment id.
|
||||
* @param string $sqlassignmentids sql clause used to filter open assignments.
|
||||
* @param array $assignmentidparams sql params used to filter open assignments.
|
||||
* @param stdClass $assignment current assignment
|
||||
*
|
||||
* @return bool|string html to display , false if nothing needs to be displayed.
|
||||
* @throws coding_exception
|
||||
* @deprecated since Moodle 3.3, when the block_course_overview block was removed.
|
||||
*/
|
||||
function assign_get_mysubmission_details_for_print_overview(&$mysubmissions, $sqlassignmentids, $assignmentidparams,
|
||||
$assignment) {
|
||||
global $USER, $DB;
|
||||
|
||||
debugging('The function assign_get_mysubmission_details_for_print_overview() is now deprecated.', DEBUG_DEVELOPER);
|
||||
|
||||
if ($assignment->nosubmissions) {
|
||||
// Offline assignment. No need to display alerts for offline assignments.
|
||||
return false;
|
||||
}
|
||||
|
||||
$strnotsubmittedyet = get_string('notsubmittedyet', 'assign');
|
||||
|
||||
if (!isset($mysubmissions)) {
|
||||
|
||||
// Get all user submissions, indexed by assignment id.
|
||||
$dbparams = array_merge(array($USER->id), $assignmentidparams, array($USER->id));
|
||||
$mysubmissions = $DB->get_records_sql('SELECT a.id AS assignment,
|
||||
a.nosubmissions AS nosubmissions,
|
||||
g.timemodified AS timemarked,
|
||||
g.grader AS grader,
|
||||
g.grade AS grade,
|
||||
s.status AS status
|
||||
FROM {assign} a, {assign_submission} s
|
||||
LEFT JOIN {assign_grades} g ON
|
||||
g.assignment = s.assignment AND
|
||||
g.userid = ? AND
|
||||
g.attemptnumber = s.attemptnumber
|
||||
WHERE a.id ' . $sqlassignmentids . ' AND
|
||||
s.latest = 1 AND
|
||||
s.assignment = a.id AND
|
||||
s.userid = ?', $dbparams);
|
||||
}
|
||||
|
||||
$submitdetails = '';
|
||||
$submitdetails .= '<div class="details">';
|
||||
$submitdetails .= get_string('mysubmission', 'assign');
|
||||
$submission = false;
|
||||
|
||||
if (isset($mysubmissions[$assignment->id])) {
|
||||
$submission = $mysubmissions[$assignment->id];
|
||||
}
|
||||
|
||||
if ($submission && $submission->status == ASSIGN_SUBMISSION_STATUS_SUBMITTED) {
|
||||
// A valid submission already exists, no need to notify students about this.
|
||||
return false;
|
||||
}
|
||||
|
||||
// We need to show details only if a valid submission doesn't exist.
|
||||
if (!$submission ||
|
||||
!$submission->status ||
|
||||
$submission->status == ASSIGN_SUBMISSION_STATUS_DRAFT ||
|
||||
$submission->status == ASSIGN_SUBMISSION_STATUS_NEW
|
||||
) {
|
||||
$submitdetails .= $strnotsubmittedyet;
|
||||
} else {
|
||||
$submitdetails .= get_string('submissionstatus_' . $submission->status, 'assign');
|
||||
}
|
||||
if ($assignment->markingworkflow) {
|
||||
$workflowstate = $DB->get_field('assign_user_flags', 'workflowstate', array('assignment' =>
|
||||
$assignment->id, 'userid' => $USER->id));
|
||||
if ($workflowstate) {
|
||||
$gradingstatus = 'markingworkflowstate' . $workflowstate;
|
||||
} else {
|
||||
$gradingstatus = 'markingworkflowstate' . ASSIGN_MARKING_WORKFLOW_STATE_NOTMARKED;
|
||||
}
|
||||
} else if (!empty($submission->grade) && $submission->grade !== null && $submission->grade >= 0) {
|
||||
$gradingstatus = ASSIGN_GRADING_STATUS_GRADED;
|
||||
} else {
|
||||
$gradingstatus = ASSIGN_GRADING_STATUS_NOT_GRADED;
|
||||
}
|
||||
$submitdetails .= ', ' . get_string($gradingstatus, 'assign');
|
||||
$submitdetails .= '</div>';
|
||||
return $submitdetails;
|
||||
function assign_get_mysubmission_details_for_print_overview() {
|
||||
throw new coding_exception('assign_get_mysubmission_details_for_print_overview() can not be used any more and is obsolete.');
|
||||
}
|
||||
|
||||
/**
|
||||
* This api generates html to be displayed to teachers in print overview section, related to the grading status of the given
|
||||
* assignment's submissions.
|
||||
*
|
||||
* @deprecated since 3.3
|
||||
* @todo The final deprecation of this function will take place in Moodle 3.7 - see MDL-57487.
|
||||
* @param array $unmarkedsubmissions list of submissions of that are currently unmarked indexed by assignment id.
|
||||
* @param string $sqlassignmentids sql clause used to filter open assignments.
|
||||
* @param array $assignmentidparams sql params used to filter open assignments.
|
||||
* @param stdClass $assignment current assignment
|
||||
* @param context $context context of the assignment.
|
||||
*
|
||||
* @return bool|string html to display , false if nothing needs to be displayed.
|
||||
* @throws coding_exception
|
||||
* @deprecated since Moodle 3.3, when the block_course_overview block was removed.
|
||||
*/
|
||||
function assign_get_grade_details_for_print_overview(&$unmarkedsubmissions, $sqlassignmentids, $assignmentidparams,
|
||||
$assignment, $context) {
|
||||
global $DB;
|
||||
|
||||
debugging('The function assign_get_grade_details_for_print_overview() is now deprecated.', DEBUG_DEVELOPER);
|
||||
|
||||
if (!isset($unmarkedsubmissions)) {
|
||||
// Build up and array of unmarked submissions indexed by assignment id/ userid
|
||||
// for use where the user has grading rights on assignment.
|
||||
$dbparams = array_merge(array(ASSIGN_SUBMISSION_STATUS_SUBMITTED), $assignmentidparams);
|
||||
$rs = $DB->get_recordset_sql('SELECT s.assignment as assignment,
|
||||
s.userid as userid,
|
||||
s.id as id,
|
||||
s.status as status,
|
||||
g.timemodified as timegraded
|
||||
FROM {assign_submission} s
|
||||
LEFT JOIN {assign_grades} g ON
|
||||
s.userid = g.userid AND
|
||||
s.assignment = g.assignment AND
|
||||
g.attemptnumber = s.attemptnumber
|
||||
LEFT JOIN {assign} a ON
|
||||
a.id = s.assignment
|
||||
WHERE
|
||||
( g.timemodified is NULL OR
|
||||
s.timemodified >= g.timemodified OR
|
||||
g.grade IS NULL OR
|
||||
(g.grade = -1 AND
|
||||
a.grade < 0)) AND
|
||||
s.timemodified IS NOT NULL AND
|
||||
s.status = ? AND
|
||||
s.latest = 1 AND
|
||||
s.assignment ' . $sqlassignmentids, $dbparams);
|
||||
|
||||
$unmarkedsubmissions = array();
|
||||
foreach ($rs as $rd) {
|
||||
$unmarkedsubmissions[$rd->assignment][$rd->userid] = $rd->id;
|
||||
}
|
||||
$rs->close();
|
||||
}
|
||||
|
||||
// Count how many people can submit.
|
||||
$submissions = 0;
|
||||
if ($students = get_enrolled_users($context, 'mod/assign:view', 0, 'u.id')) {
|
||||
foreach ($students as $student) {
|
||||
if (isset($unmarkedsubmissions[$assignment->id][$student->id])) {
|
||||
$submissions++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($submissions) {
|
||||
$urlparams = array('id' => $assignment->coursemodule, 'action' => 'grading');
|
||||
$url = new moodle_url('/mod/assign/view.php', $urlparams);
|
||||
$gradedetails = '<div class="details">' .
|
||||
'<a href="' . $url . '">' .
|
||||
get_string('submissionsnotgraded', 'assign', $submissions) .
|
||||
'</a></div>';
|
||||
return $gradedetails;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
function assign_get_grade_details_for_print_overview() {
|
||||
throw new coding_exception('assign_get_grade_details_for_print_overview() can not be used any more and is obsolete.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -128,8 +128,6 @@ trait mod_assign_test_generator {
|
||||
]);
|
||||
|
||||
// Bump all timecreated and timemodified for this user back.
|
||||
// The old assign_print_overview function includes submissions which have been graded where the grade modified
|
||||
// date matches the submission modified date.
|
||||
$DB->execute('UPDATE {assign_submission} SET timecreated = timecreated - 1, timemodified = timemodified - 1 WHERE userid = :userid',
|
||||
['userid' => $student->id]);
|
||||
|
||||
|
@ -46,139 +46,6 @@ class mod_assign_lib_testcase extends advanced_testcase {
|
||||
// Use the generator helper.
|
||||
use mod_assign_test_generator;
|
||||
|
||||
public function test_assign_print_overview() {
|
||||
global $DB;
|
||||
|
||||
$this->resetAfterTest();
|
||||
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
$teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
|
||||
$student = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
||||
|
||||
$this->setAdminUser();
|
||||
|
||||
// Assignment with default values.
|
||||
$firstassign = $this->create_instance($course, ['name' => 'First Assignment']);
|
||||
|
||||
// Assignment with submissions.
|
||||
$secondassign = $this->create_instance($course, [
|
||||
'name' => 'Assignment with submissions',
|
||||
'duedate' => time(),
|
||||
'attemptreopenmethod' => ASSIGN_ATTEMPT_REOPEN_METHOD_MANUAL,
|
||||
'maxattempts' => 3,
|
||||
'submissiondrafts' => 1,
|
||||
'assignsubmission_onlinetext_enabled' => 1,
|
||||
]);
|
||||
$this->add_submission($student, $secondassign);
|
||||
$this->submit_for_grading($student, $secondassign);
|
||||
$this->mark_submission($teacher, $secondassign, $student, 50.0);
|
||||
|
||||
// Past assignments should not show up.
|
||||
$pastassign = $this->create_instance($course, [
|
||||
'name' => 'Past Assignment',
|
||||
'duedate' => time() - DAYSECS - 1,
|
||||
'cutoffdate' => time() - DAYSECS,
|
||||
'nosubmissions' => 0,
|
||||
'assignsubmission_onlinetext_enabled' => 1,
|
||||
]);
|
||||
|
||||
// Open assignments should show up only if relevant.
|
||||
$openassign = $this->create_instance($course, [
|
||||
'name' => 'Open Assignment',
|
||||
'duedate' => time(),
|
||||
'cutoffdate' => time() + DAYSECS,
|
||||
'nosubmissions' => 0,
|
||||
'assignsubmission_onlinetext_enabled' => 1,
|
||||
]);
|
||||
$pastsubmission = $pastassign->get_user_submission($student->id, true);
|
||||
$opensubmission = $openassign->get_user_submission($student->id, true);
|
||||
|
||||
// Check the overview as the different users.
|
||||
// For students , open assignments should show only when there are no valid submissions.
|
||||
$this->setUser($student);
|
||||
$overview = array();
|
||||
$courses = $DB->get_records('course', array('id' => $course->id));
|
||||
assign_print_overview($courses, $overview);
|
||||
$this->assertDebuggingCalledCount(3);
|
||||
$this->assertEquals(1, count($overview));
|
||||
$this->assertRegExp('/.*Open Assignment.*/', $overview[$course->id]['assign']); // No valid submission.
|
||||
$this->assertNotRegExp('/.*First Assignment.*/', $overview[$course->id]['assign']); // Has valid submission.
|
||||
|
||||
// And now submit the submission.
|
||||
$opensubmission->status = ASSIGN_SUBMISSION_STATUS_SUBMITTED;
|
||||
$openassign->testable_update_submission($opensubmission, $student->id, true, false);
|
||||
|
||||
$overview = array();
|
||||
assign_print_overview($courses, $overview);
|
||||
$this->assertDebuggingCalledCount(3);
|
||||
$this->assertEquals(0, count($overview));
|
||||
|
||||
$this->setUser($teacher);
|
||||
$overview = array();
|
||||
assign_print_overview($courses, $overview);
|
||||
$this->assertDebuggingCalledCount(3);
|
||||
$this->assertEquals(1, count($overview));
|
||||
// Submissions without a grade.
|
||||
$this->assertRegExp('/.*Open Assignment.*/', $overview[$course->id]['assign']);
|
||||
$this->assertNotRegExp('/.*Assignment with submissions.*/', $overview[$course->id]['assign']);
|
||||
|
||||
$this->setUser($teacher);
|
||||
$overview = array();
|
||||
assign_print_overview($courses, $overview);
|
||||
$this->assertDebuggingCalledCount(3);
|
||||
$this->assertEquals(1, count($overview));
|
||||
// Submissions without a grade.
|
||||
$this->assertRegExp('/.*Open Assignment.*/', $overview[$course->id]['assign']);
|
||||
$this->assertNotRegExp('/.*Assignment with submissions.*/', $overview[$course->id]['assign']);
|
||||
|
||||
// Let us grade a submission.
|
||||
$this->setUser($teacher);
|
||||
$data = new stdClass();
|
||||
$data->grade = '50.0';
|
||||
$openassign->testable_apply_grade_to_user($data, $student->id, 0);
|
||||
|
||||
// The assign_print_overview expects the grade date to be after the submission date.
|
||||
$graderecord = $DB->get_record('assign_grades', array('assignment' => $openassign->get_instance()->id,
|
||||
'userid' => $student->id, 'attemptnumber' => 0));
|
||||
$graderecord->timemodified += 1;
|
||||
$DB->update_record('assign_grades', $graderecord);
|
||||
|
||||
$overview = array();
|
||||
assign_print_overview($courses, $overview);
|
||||
// Now assignment 4 should not show up.
|
||||
$this->assertDebuggingCalledCount(3);
|
||||
$this->assertEmpty($overview);
|
||||
|
||||
$this->setUser($teacher);
|
||||
$overview = array();
|
||||
assign_print_overview($courses, $overview);
|
||||
$this->assertDebuggingCalledCount(3);
|
||||
// Now assignment 4 should not show up.
|
||||
$this->assertEmpty($overview);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that assign_print_overview does not return any assignments which are Open Offline.
|
||||
*/
|
||||
public function test_assign_print_overview_open_offline() {
|
||||
$this->resetAfterTest();
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
$student = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
||||
|
||||
$this->setAdminUser();
|
||||
$openassign = $this->create_instance($course, [
|
||||
'duedate' => time() + DAYSECS,
|
||||
'cutoffdate' => time() + (DAYSECS * 2),
|
||||
]);
|
||||
|
||||
$this->setUser($student);
|
||||
$overview = [];
|
||||
assign_print_overview([$course], $overview);
|
||||
|
||||
$this->assertDebuggingCalledCount(1);
|
||||
$this->assertEquals(0, count($overview));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that assign_print_recent_activity shows ungraded submitted assignments.
|
||||
*/
|
||||
|
@ -1136,44 +1136,10 @@ function chat_get_post_actions() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since 3.3
|
||||
* @todo The final deprecation of this function will take place in Moodle 3.7 - see MDL-57487.
|
||||
* @global object
|
||||
* @global object
|
||||
* @param array $courses
|
||||
* @param array $htmlarray Passed by reference
|
||||
* @deprecated since Moodle 3.3, when the block_course_overview block was removed.
|
||||
*/
|
||||
function chat_print_overview($courses, &$htmlarray) {
|
||||
global $USER, $CFG;
|
||||
|
||||
debugging('The function chat_print_overview() is now deprecated.', DEBUG_DEVELOPER);
|
||||
|
||||
if (empty($courses) || !is_array($courses) || count($courses) == 0) {
|
||||
return array();
|
||||
}
|
||||
|
||||
if (!$chats = get_all_instances_in_courses('chat', $courses)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$strchat = get_string('modulename', 'chat');
|
||||
$strnextsession = get_string('nextsession', 'chat');
|
||||
|
||||
foreach ($chats as $chat) {
|
||||
if ($chat->chattime and $chat->schedule) { // A chat is scheduled.
|
||||
$str = '<div class="chat overview"><div class="name">'.
|
||||
$strchat.': <a '.($chat->visible ? '' : ' class="dimmed"').
|
||||
' href="'.$CFG->wwwroot.'/mod/chat/view.php?id='.$chat->coursemodule.'">'.
|
||||
$chat->name.'</a></div>';
|
||||
$str .= '<div class="info">'.$strnextsession.': '.userdate($chat->chattime).'</div></div>';
|
||||
|
||||
if (empty($htmlarray[$chat->course]['chat'])) {
|
||||
$htmlarray[$chat->course]['chat'] = $str;
|
||||
} else {
|
||||
$htmlarray[$chat->course]['chat'] .= $str;
|
||||
}
|
||||
}
|
||||
}
|
||||
function chat_print_overview() {
|
||||
throw new coding_exception('chat_print_overview() can not be used any more and is obsolete.');
|
||||
}
|
||||
|
||||
|
||||
|
@ -46,14 +46,12 @@ $string['atleastoneoption'] = 'You need to provide at least one possible answer.
|
||||
$string['full'] = '(Full)';
|
||||
$string['havetologin'] = 'You have to log in before you can submit your choice';
|
||||
$string['choice'] = 'Choice';
|
||||
$string['choiceactivityname'] = 'Choice: {$a}';
|
||||
$string['choice:addinstance'] = 'Add a new choice';
|
||||
$string['choiceclose'] = 'Allow responses until';
|
||||
$string['choice:deleteresponses'] = 'Modify and delete responses';
|
||||
$string['choice:downloadresponses'] = 'Download responses';
|
||||
$string['choicefull'] = 'One or more of the options you have selected have already been filled. Your response has not been saved. Please make another selection.';
|
||||
$string['choice:choose'] = 'Record a choice';
|
||||
$string['choicecloseson'] = 'Choice closes on {$a}';
|
||||
$string['choicename'] = 'Choice name';
|
||||
$string['choiceopen'] = 'Allow responses from';
|
||||
$string['choiceoptions'] = 'Choice options';
|
||||
@ -147,4 +145,7 @@ $string['viewchoices'] = 'View choices';
|
||||
$string['withselected'] = 'With selected';
|
||||
$string['userchoosethisoption'] = 'Users who chose this option';
|
||||
$string['yourselection'] = 'Your selection';
|
||||
$string['skipresultgraph'] = 'Skip result graph';
|
||||
|
||||
// Deprecated since Moodle 3.8.
|
||||
$string['choiceactivityname'] = 'Choice: {$a}';
|
||||
$string['choicecloseson'] = 'Choice closes on {$a}';
|
||||
|
@ -1 +1,2 @@
|
||||
skipresultgraph,mod_choice
|
||||
choiceactivityname,mod_choice
|
||||
choicecloseson,mod_choice
|
@ -922,83 +922,10 @@ function choice_page_type_list($pagetype, $parentcontext, $currentcontext) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints choice summaries on MyMoodle Page
|
||||
*
|
||||
* Prints choice name, due date and attempt information on
|
||||
* choice activities that have a deadline that has not already passed
|
||||
* and it is available for completing.
|
||||
*
|
||||
* @deprecated since 3.3
|
||||
* @todo The final deprecation of this function will take place in Moodle 3.7 - see MDL-57487.
|
||||
* @uses CONTEXT_MODULE
|
||||
* @param array $courses An array of course objects to get choice instances from.
|
||||
* @param array $htmlarray Store overview output array( course ID => 'choice' => HTML output )
|
||||
* @deprecated since Moodle 3.3, when the block_course_overview block was removed.
|
||||
*/
|
||||
function choice_print_overview($courses, &$htmlarray) {
|
||||
global $USER, $DB, $OUTPUT;
|
||||
|
||||
debugging('The function choice_print_overview() is now deprecated.', DEBUG_DEVELOPER);
|
||||
|
||||
if (empty($courses) || !is_array($courses) || count($courses) == 0) {
|
||||
return;
|
||||
}
|
||||
if (!$choices = get_all_instances_in_courses('choice', $courses)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$now = time();
|
||||
foreach ($choices as $choice) {
|
||||
if ($choice->timeclose != 0 // If this choice is scheduled.
|
||||
and $choice->timeclose >= $now // And the deadline has not passed.
|
||||
and ($choice->timeopen == 0 or $choice->timeopen <= $now)) { // And the choice is available.
|
||||
|
||||
// Visibility.
|
||||
$class = (!$choice->visible) ? 'dimmed' : '';
|
||||
|
||||
// Link to activity.
|
||||
$url = new moodle_url('/mod/choice/view.php', array('id' => $choice->coursemodule));
|
||||
$url = html_writer::link($url, format_string($choice->name), array('class' => $class));
|
||||
$str = $OUTPUT->box(get_string('choiceactivityname', 'choice', $url), 'name');
|
||||
|
||||
// Deadline.
|
||||
$str .= $OUTPUT->box(get_string('choicecloseson', 'choice', userdate($choice->timeclose)), 'info');
|
||||
|
||||
// Display relevant info based on permissions.
|
||||
if (has_capability('mod/choice:readresponses', context_module::instance($choice->coursemodule))) {
|
||||
$attempts = $DB->count_records_sql('SELECT COUNT(DISTINCT userid) FROM {choice_answers} WHERE choiceid = ?',
|
||||
[$choice->id]);
|
||||
$url = new moodle_url('/mod/choice/report.php', ['id' => $choice->coursemodule]);
|
||||
$str .= $OUTPUT->box(html_writer::link($url, get_string('viewallresponses', 'choice', $attempts)), 'info');
|
||||
|
||||
} else if (has_capability('mod/choice:choose', context_module::instance($choice->coursemodule))) {
|
||||
// See if the user has submitted anything.
|
||||
$answers = $DB->count_records('choice_answers', array('choiceid' => $choice->id, 'userid' => $USER->id));
|
||||
if ($answers > 0) {
|
||||
// User has already selected an answer, nothing to show.
|
||||
$str = '';
|
||||
} else {
|
||||
// User has not made a selection yet.
|
||||
$str .= $OUTPUT->box(get_string('notanswered', 'choice'), 'info');
|
||||
}
|
||||
} else {
|
||||
// Does not have permission to do anything on this choice activity.
|
||||
$str = '';
|
||||
}
|
||||
|
||||
// Make sure we have something to display.
|
||||
if (!empty($str)) {
|
||||
// Generate the containing div.
|
||||
$str = $OUTPUT->box($str, 'choice overview');
|
||||
|
||||
if (empty($htmlarray[$choice->course]['choice'])) {
|
||||
$htmlarray[$choice->course]['choice'] = $str;
|
||||
} else {
|
||||
$htmlarray[$choice->course]['choice'] .= $str;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
function choice_print_overview() {
|
||||
throw new coding_exception('choice_print_overview() can not be used any more and is obsolete.');
|
||||
}
|
||||
|
||||
|
||||
|
@ -1 +1,3 @@
|
||||
inpagereplysubject,mod_forum
|
||||
overviewnumpostssince,mod_forum
|
||||
overviewnumunread,mod_forum
|
||||
|
@ -438,8 +438,6 @@ $string['numberofreplies'] = 'Number of replies: {$a}';
|
||||
$string['olderdiscussions'] = 'Older discussions';
|
||||
$string['oldertopics'] = 'Older topics';
|
||||
$string['oldpostdays'] = 'Read after days';
|
||||
$string['overviewnumpostssince'] = '{$a} posts since last login';
|
||||
$string['overviewnumunread'] = '{$a} total unread';
|
||||
$string['page-mod-forum-x'] = 'Any forum module page';
|
||||
$string['page-mod-forum-view'] = 'Forum module main page';
|
||||
$string['page-mod-forum-discuss'] = 'Forum module discussion thread page';
|
||||
@ -675,3 +673,5 @@ $string['forumbodydeleted'] = 'The content of this forum post has been removed a
|
||||
|
||||
// Deprecated since Moodle 3.8.
|
||||
$string['inpagereplysubject'] = 'Re: {$a}';
|
||||
$string['overviewnumpostssince'] = '{$a} posts since last login';
|
||||
$string['overviewnumunread'] = '{$a} total unread';
|
||||
|
@ -540,44 +540,10 @@ function forum_user_complete($course, $user, $mod, $forum) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the forum discussions according to groups membership and config.
|
||||
*
|
||||
* @deprecated since 3.3
|
||||
* @todo The final deprecation of this function will take place in Moodle 3.7 - see MDL-57487.
|
||||
* @since Moodle 2.8, 2.7.1, 2.6.4
|
||||
* @param array $discussions Discussions with new posts array
|
||||
* @return array Forums with the number of new posts
|
||||
* @deprecated since Moodle 3.3, when the block_course_overview block was removed.
|
||||
*/
|
||||
function forum_filter_user_groups_discussions($discussions) {
|
||||
|
||||
debugging('The function forum_filter_user_groups_discussions() is now deprecated.', DEBUG_DEVELOPER);
|
||||
|
||||
// Group the remaining discussions posts by their forumid.
|
||||
$filteredforums = array();
|
||||
|
||||
// Discard not visible groups.
|
||||
foreach ($discussions as $discussion) {
|
||||
|
||||
// Course data is already cached.
|
||||
$instances = get_fast_modinfo($discussion->course)->get_instances();
|
||||
$forum = $instances['forum'][$discussion->forum];
|
||||
|
||||
// Continue if the user should not see this discussion.
|
||||
if (!forum_is_user_group_discussion($forum, $discussion->groupid)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Grouping results by forum.
|
||||
if (empty($filteredforums[$forum->instance])) {
|
||||
$filteredforums[$forum->instance] = new stdClass();
|
||||
$filteredforums[$forum->instance]->id = $forum->id;
|
||||
$filteredforums[$forum->instance]->count = 0;
|
||||
}
|
||||
$filteredforums[$forum->instance]->count += $discussion->count;
|
||||
|
||||
}
|
||||
|
||||
return $filteredforums;
|
||||
function forum_filter_user_groups_discussions() {
|
||||
throw new coding_exception('forum_filter_user_groups_discussions() can not be used any more and is obsolete.');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -607,155 +573,10 @@ function forum_is_user_group_discussion(cm_info $cm, $discussiongroupid) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since 3.3
|
||||
* @todo The final deprecation of this function will take place in Moodle 3.7 - see MDL-57487.
|
||||
* @global object
|
||||
* @global object
|
||||
* @global object
|
||||
* @param array $courses
|
||||
* @param array $htmlarray
|
||||
* @deprecated since Moodle 3.3, when the block_course_overview block was removed.
|
||||
*/
|
||||
function forum_print_overview($courses,&$htmlarray) {
|
||||
global $USER, $CFG, $DB, $SESSION;
|
||||
|
||||
debugging('The function forum_print_overview() is now deprecated.', DEBUG_DEVELOPER);
|
||||
|
||||
if (empty($courses) || !is_array($courses) || count($courses) == 0) {
|
||||
return array();
|
||||
}
|
||||
|
||||
if (!$forums = get_all_instances_in_courses('forum',$courses)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Courses to search for new posts
|
||||
$coursessqls = array();
|
||||
$params = array();
|
||||
foreach ($courses as $course) {
|
||||
|
||||
// If the user has never entered into the course all posts are pending
|
||||
if ($course->lastaccess == 0) {
|
||||
$coursessqls[] = '(d.course = ?)';
|
||||
$params[] = $course->id;
|
||||
|
||||
// Only posts created after the course last access
|
||||
} else {
|
||||
$coursessqls[] = '(d.course = ? AND p.created > ?)';
|
||||
$params[] = $course->id;
|
||||
$params[] = $course->lastaccess;
|
||||
}
|
||||
}
|
||||
$params[] = $USER->id;
|
||||
$coursessql = implode(' OR ', $coursessqls);
|
||||
|
||||
$sql = "SELECT d.id, d.forum, d.course, d.groupid, COUNT(*) as count "
|
||||
.'FROM {forum_discussions} d '
|
||||
.'JOIN {forum_posts} p ON p.discussion = d.id '
|
||||
."WHERE ($coursessql) "
|
||||
.'AND p.deleted <> 1 '
|
||||
.'AND p.userid != ? '
|
||||
.'AND (d.timestart <= ? AND (d.timeend = 0 OR d.timeend > ?)) '
|
||||
.'GROUP BY d.id, d.forum, d.course, d.groupid '
|
||||
.'ORDER BY d.course, d.forum';
|
||||
$params[] = time();
|
||||
$params[] = time();
|
||||
|
||||
// Avoid warnings.
|
||||
if (!$discussions = $DB->get_records_sql($sql, $params)) {
|
||||
$discussions = array();
|
||||
}
|
||||
|
||||
$forumsnewposts = forum_filter_user_groups_discussions($discussions);
|
||||
|
||||
// also get all forum tracking stuff ONCE.
|
||||
$trackingforums = array();
|
||||
foreach ($forums as $forum) {
|
||||
if (forum_tp_can_track_forums($forum)) {
|
||||
$trackingforums[$forum->id] = $forum;
|
||||
}
|
||||
}
|
||||
|
||||
if (count($trackingforums) > 0) {
|
||||
$cutoffdate = isset($CFG->forum_oldpostdays) ? (time() - ($CFG->forum_oldpostdays*24*60*60)) : 0;
|
||||
$sql = 'SELECT d.forum,d.course,COUNT(p.id) AS count '.
|
||||
' FROM {forum_posts} p '.
|
||||
' JOIN {forum_discussions} d ON p.discussion = d.id '.
|
||||
' LEFT JOIN {forum_read} r ON r.postid = p.id AND r.userid = ? WHERE p.deleted <> 1 AND (';
|
||||
$params = array($USER->id);
|
||||
|
||||
foreach ($trackingforums as $track) {
|
||||
$sql .= '(d.forum = ? AND (d.groupid = -1 OR d.groupid = 0 OR d.groupid = ?)) OR ';
|
||||
$params[] = $track->id;
|
||||
if (isset($SESSION->currentgroup[$track->course])) {
|
||||
$groupid = $SESSION->currentgroup[$track->course];
|
||||
} else {
|
||||
// get first groupid
|
||||
$groupids = groups_get_all_groups($track->course, $USER->id);
|
||||
if ($groupids) {
|
||||
reset($groupids);
|
||||
$groupid = key($groupids);
|
||||
$SESSION->currentgroup[$track->course] = $groupid;
|
||||
} else {
|
||||
$groupid = 0;
|
||||
}
|
||||
unset($groupids);
|
||||
}
|
||||
$params[] = $groupid;
|
||||
}
|
||||
$sql = substr($sql,0,-3); // take off the last OR
|
||||
$sql .= ') AND p.modified >= ? AND r.id is NULL ';
|
||||
$sql .= 'AND (d.timestart < ? AND (d.timeend = 0 OR d.timeend > ?)) ';
|
||||
$sql .= 'GROUP BY d.forum,d.course';
|
||||
$params[] = $cutoffdate;
|
||||
$params[] = time();
|
||||
$params[] = time();
|
||||
|
||||
if (!$unread = $DB->get_records_sql($sql, $params)) {
|
||||
$unread = array();
|
||||
}
|
||||
} else {
|
||||
$unread = array();
|
||||
}
|
||||
|
||||
if (empty($unread) and empty($forumsnewposts)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$strforum = get_string('modulename','forum');
|
||||
|
||||
foreach ($forums as $forum) {
|
||||
$str = '';
|
||||
$count = 0;
|
||||
$thisunread = 0;
|
||||
$showunread = false;
|
||||
// either we have something from logs, or trackposts, or nothing.
|
||||
if (array_key_exists($forum->id, $forumsnewposts) && !empty($forumsnewposts[$forum->id])) {
|
||||
$count = $forumsnewposts[$forum->id]->count;
|
||||
}
|
||||
if (array_key_exists($forum->id,$unread)) {
|
||||
$thisunread = $unread[$forum->id]->count;
|
||||
$showunread = true;
|
||||
}
|
||||
if ($count > 0 || $thisunread > 0) {
|
||||
$str .= '<div class="overview forum"><div class="name">'.$strforum.': <a title="'.$strforum.'" href="'.$CFG->wwwroot.'/mod/forum/view.php?f='.$forum->id.'">'.
|
||||
$forum->name.'</a></div>';
|
||||
$str .= '<div class="info"><span class="postsincelogin">';
|
||||
$str .= get_string('overviewnumpostssince', 'forum', $count)."</span>";
|
||||
if (!empty($showunread)) {
|
||||
$str .= '<div class="unreadposts">'.get_string('overviewnumunread', 'forum', $thisunread).'</div>';
|
||||
}
|
||||
$str .= '</div></div>';
|
||||
}
|
||||
if (!empty($str)) {
|
||||
if (!array_key_exists($forum->course,$htmlarray)) {
|
||||
$htmlarray[$forum->course] = array();
|
||||
}
|
||||
if (!array_key_exists('forum',$htmlarray[$forum->course])) {
|
||||
$htmlarray[$forum->course]['forum'] = ''; // initialize, avoid warnings
|
||||
}
|
||||
$htmlarray[$forum->course]['forum'] .= $str;
|
||||
}
|
||||
}
|
||||
function forum_print_overview() {
|
||||
throw new coding_exception('forum_print_overview() can not be used any more and is obsolete.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2524,273 +2524,6 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
$this->assertArrayHasKey('forumdiscussions', $nodes->getValue($tree));
|
||||
}
|
||||
|
||||
public function test_print_overview() {
|
||||
$this->resetAfterTest();
|
||||
$course1 = self::getDataGenerator()->create_course();
|
||||
$course2 = self::getDataGenerator()->create_course();
|
||||
|
||||
// Create an author user.
|
||||
$author = self::getDataGenerator()->create_user();
|
||||
$this->getDataGenerator()->enrol_user($author->id, $course1->id);
|
||||
$this->getDataGenerator()->enrol_user($author->id, $course2->id);
|
||||
|
||||
// Create a viewer user.
|
||||
$viewer = self::getDataGenerator()->create_user((object) array('trackforums' => 1));
|
||||
$this->getDataGenerator()->enrol_user($viewer->id, $course1->id);
|
||||
$this->getDataGenerator()->enrol_user($viewer->id, $course2->id);
|
||||
|
||||
// Create two forums - one in each course.
|
||||
$record = new stdClass();
|
||||
$record->course = $course1->id;
|
||||
$forum1 = self::getDataGenerator()->create_module('forum', (object) array('course' => $course1->id));
|
||||
$forum2 = self::getDataGenerator()->create_module('forum', (object) array('course' => $course2->id));
|
||||
|
||||
// A standard post in the forum.
|
||||
$record = new stdClass();
|
||||
$record->course = $course1->id;
|
||||
$record->userid = $author->id;
|
||||
$record->forum = $forum1->id;
|
||||
$this->getDataGenerator()->get_plugin_generator('mod_forum')->create_discussion($record);
|
||||
|
||||
$this->setUser($viewer->id);
|
||||
$courses = array(
|
||||
$course1->id => clone $course1,
|
||||
$course2->id => clone $course2,
|
||||
);
|
||||
|
||||
foreach ($courses as $courseid => $course) {
|
||||
$courses[$courseid]->lastaccess = 0;
|
||||
}
|
||||
$results = array();
|
||||
forum_print_overview($courses, $results);
|
||||
$this->assertDebuggingCalledCount(2);
|
||||
|
||||
// There should be one entry for course1, and no others.
|
||||
$this->assertCount(1, $results);
|
||||
|
||||
// There should be one entry for a forum in course1.
|
||||
$this->assertCount(1, $results[$course1->id]);
|
||||
$this->assertArrayHasKey('forum', $results[$course1->id]);
|
||||
}
|
||||
|
||||
public function test_print_overview_groups() {
|
||||
$this->resetAfterTest();
|
||||
$course1 = self::getDataGenerator()->create_course();
|
||||
$group1 = $this->getDataGenerator()->create_group(array('courseid' => $course1->id));
|
||||
$group2 = $this->getDataGenerator()->create_group(array('courseid' => $course1->id));
|
||||
|
||||
// Create an author user.
|
||||
$author = self::getDataGenerator()->create_user();
|
||||
$this->getDataGenerator()->enrol_user($author->id, $course1->id);
|
||||
|
||||
// Create two viewer users - one in each group.
|
||||
$viewer1 = self::getDataGenerator()->create_user((object) array('trackforums' => 1));
|
||||
$this->getDataGenerator()->enrol_user($viewer1->id, $course1->id);
|
||||
$this->getDataGenerator()->create_group_member(array('userid' => $viewer1->id, 'groupid' => $group1->id));
|
||||
|
||||
$viewer2 = self::getDataGenerator()->create_user((object) array('trackforums' => 1));
|
||||
$this->getDataGenerator()->enrol_user($viewer2->id, $course1->id);
|
||||
$this->getDataGenerator()->create_group_member(array('userid' => $viewer2->id, 'groupid' => $group2->id));
|
||||
|
||||
// Create a forum.
|
||||
$record = new stdClass();
|
||||
$record->course = $course1->id;
|
||||
$forum1 = self::getDataGenerator()->create_module('forum', (object) array(
|
||||
'course' => $course1->id,
|
||||
'groupmode' => SEPARATEGROUPS,
|
||||
));
|
||||
|
||||
// A post in the forum for group1.
|
||||
$record = new stdClass();
|
||||
$record->course = $course1->id;
|
||||
$record->userid = $author->id;
|
||||
$record->forum = $forum1->id;
|
||||
$record->groupid = $group1->id;
|
||||
$this->getDataGenerator()->get_plugin_generator('mod_forum')->create_discussion($record);
|
||||
|
||||
$course1->lastaccess = 0;
|
||||
$courses = array($course1->id => $course1);
|
||||
|
||||
// As viewer1 (same group as post).
|
||||
$this->setUser($viewer1->id);
|
||||
$results = array();
|
||||
forum_print_overview($courses, $results);
|
||||
$this->assertDebuggingCalledCount(2);
|
||||
|
||||
// There should be one entry for course1.
|
||||
$this->assertCount(1, $results);
|
||||
|
||||
// There should be one entry for a forum in course1.
|
||||
$this->assertCount(1, $results[$course1->id]);
|
||||
$this->assertArrayHasKey('forum', $results[$course1->id]);
|
||||
|
||||
$this->setUser($viewer2->id);
|
||||
$results = array();
|
||||
forum_print_overview($courses, $results);
|
||||
$this->assertDebuggingCalledCount(2);
|
||||
|
||||
// There should be one entry for course1.
|
||||
$this->assertCount(0, $results);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider print_overview_timed_provider
|
||||
*/
|
||||
public function test_print_overview_timed($config, $hasresult) {
|
||||
$this->resetAfterTest();
|
||||
$course1 = self::getDataGenerator()->create_course();
|
||||
|
||||
// Create an author user.
|
||||
$author = self::getDataGenerator()->create_user();
|
||||
$this->getDataGenerator()->enrol_user($author->id, $course1->id);
|
||||
|
||||
// Create a viewer user.
|
||||
$viewer = self::getDataGenerator()->create_user((object) array('trackforums' => 1));
|
||||
$this->getDataGenerator()->enrol_user($viewer->id, $course1->id);
|
||||
|
||||
// Create a forum.
|
||||
$record = new stdClass();
|
||||
$record->course = $course1->id;
|
||||
$forum1 = self::getDataGenerator()->create_module('forum', (object) array('course' => $course1->id));
|
||||
|
||||
// A timed post with a timestart in the past (24 hours ago).
|
||||
$record = new stdClass();
|
||||
$record->course = $course1->id;
|
||||
$record->userid = $author->id;
|
||||
$record->forum = $forum1->id;
|
||||
if (isset($config['timestartmodifier'])) {
|
||||
$record->timestart = time() + $config['timestartmodifier'];
|
||||
}
|
||||
if (isset($config['timeendmodifier'])) {
|
||||
$record->timeend = time() + $config['timeendmodifier'];
|
||||
}
|
||||
$this->getDataGenerator()->get_plugin_generator('mod_forum')->create_discussion($record);
|
||||
|
||||
$course1->lastaccess = 0;
|
||||
$courses = array($course1->id => $course1);
|
||||
|
||||
// As viewer, check the forum_print_overview result.
|
||||
$this->setUser($viewer->id);
|
||||
$results = array();
|
||||
forum_print_overview($courses, $results);
|
||||
$this->assertDebuggingCalledCount(2);
|
||||
|
||||
if ($hasresult) {
|
||||
// There should be one entry for course1.
|
||||
$this->assertCount(1, $results);
|
||||
|
||||
// There should be one entry for a forum in course1.
|
||||
$this->assertCount(1, $results[$course1->id]);
|
||||
$this->assertArrayHasKey('forum', $results[$course1->id]);
|
||||
} else {
|
||||
// There should be no entries for any course.
|
||||
$this->assertCount(0, $results);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider print_overview_timed_provider
|
||||
*/
|
||||
public function test_print_overview_timed_groups($config, $hasresult) {
|
||||
$this->resetAfterTest();
|
||||
$course1 = self::getDataGenerator()->create_course();
|
||||
$group1 = $this->getDataGenerator()->create_group(array('courseid' => $course1->id));
|
||||
$group2 = $this->getDataGenerator()->create_group(array('courseid' => $course1->id));
|
||||
|
||||
// Create an author user.
|
||||
$author = self::getDataGenerator()->create_user();
|
||||
$this->getDataGenerator()->enrol_user($author->id, $course1->id);
|
||||
|
||||
// Create two viewer users - one in each group.
|
||||
$viewer1 = self::getDataGenerator()->create_user((object) array('trackforums' => 1));
|
||||
$this->getDataGenerator()->enrol_user($viewer1->id, $course1->id);
|
||||
$this->getDataGenerator()->create_group_member(array('userid' => $viewer1->id, 'groupid' => $group1->id));
|
||||
|
||||
$viewer2 = self::getDataGenerator()->create_user((object) array('trackforums' => 1));
|
||||
$this->getDataGenerator()->enrol_user($viewer2->id, $course1->id);
|
||||
$this->getDataGenerator()->create_group_member(array('userid' => $viewer2->id, 'groupid' => $group2->id));
|
||||
|
||||
// Create a forum.
|
||||
$record = new stdClass();
|
||||
$record->course = $course1->id;
|
||||
$forum1 = self::getDataGenerator()->create_module('forum', (object) array(
|
||||
'course' => $course1->id,
|
||||
'groupmode' => SEPARATEGROUPS,
|
||||
));
|
||||
|
||||
// A post in the forum for group1.
|
||||
$record = new stdClass();
|
||||
$record->course = $course1->id;
|
||||
$record->userid = $author->id;
|
||||
$record->forum = $forum1->id;
|
||||
$record->groupid = $group1->id;
|
||||
if (isset($config['timestartmodifier'])) {
|
||||
$record->timestart = time() + $config['timestartmodifier'];
|
||||
}
|
||||
if (isset($config['timeendmodifier'])) {
|
||||
$record->timeend = time() + $config['timeendmodifier'];
|
||||
}
|
||||
$this->getDataGenerator()->get_plugin_generator('mod_forum')->create_discussion($record);
|
||||
|
||||
$course1->lastaccess = 0;
|
||||
$courses = array($course1->id => $course1);
|
||||
|
||||
// As viewer1 (same group as post).
|
||||
$this->setUser($viewer1->id);
|
||||
$results = array();
|
||||
forum_print_overview($courses, $results);
|
||||
$this->assertDebuggingCalledCount(2);
|
||||
|
||||
if ($hasresult) {
|
||||
// There should be one entry for course1.
|
||||
$this->assertCount(1, $results);
|
||||
|
||||
// There should be one entry for a forum in course1.
|
||||
$this->assertCount(1, $results[$course1->id]);
|
||||
$this->assertArrayHasKey('forum', $results[$course1->id]);
|
||||
} else {
|
||||
// There should be no entries for any course.
|
||||
$this->assertCount(0, $results);
|
||||
}
|
||||
|
||||
$this->setUser($viewer2->id);
|
||||
$results = array();
|
||||
forum_print_overview($courses, $results);
|
||||
$this->assertDebuggingCalledCount(2);
|
||||
|
||||
// There should be one entry for course1.
|
||||
$this->assertCount(0, $results);
|
||||
}
|
||||
|
||||
public function print_overview_timed_provider() {
|
||||
return array(
|
||||
'timestart_past' => array(
|
||||
'discussionconfig' => array(
|
||||
'timestartmodifier' => -86000,
|
||||
),
|
||||
'hasresult' => true,
|
||||
),
|
||||
'timestart_future' => array(
|
||||
'discussionconfig' => array(
|
||||
'timestartmodifier' => 86000,
|
||||
),
|
||||
'hasresult' => false,
|
||||
),
|
||||
'timeend_past' => array(
|
||||
'discussionconfig' => array(
|
||||
'timeendmodifier' => -86000,
|
||||
),
|
||||
'hasresult' => false,
|
||||
),
|
||||
'timeend_future' => array(
|
||||
'discussionconfig' => array(
|
||||
'timeendmodifier' => 86000,
|
||||
),
|
||||
'hasresult' => true,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test test_pinned_discussion_with_group.
|
||||
*/
|
||||
|
4
mod/lesson/lang/en/deprecated.txt
Normal file
4
mod/lesson/lang/en/deprecated.txt
Normal file
@ -0,0 +1,4 @@
|
||||
additionalattemptsremaining,mod_lesson
|
||||
lessoncloseson,mod_lesson
|
||||
lessonname,mod_lesson
|
||||
xattempts,mod_lesson
|
@ -55,7 +55,6 @@ $string['addmultichoice'] = 'Create a Multichoice question page';
|
||||
$string['addnewgroupoverride'] = 'Add group override';
|
||||
$string['addnewuseroverride'] = 'Add user override';
|
||||
$string['addnumerical'] = 'Create a Numerical question page';
|
||||
$string['additionalattemptsremaining'] = 'Completed, You can re-attempt this lesson';
|
||||
$string['addpage'] = 'Add a page';
|
||||
$string['addshortanswer'] = 'Create a Short answer question page';
|
||||
$string['addtruefalse'] = 'Create a True/false question page';
|
||||
@ -284,14 +283,12 @@ $string['lesson:grade'] = 'Grade lesson essay questions';
|
||||
$string['lessonclosed'] = 'This lesson closed on {$a}.';
|
||||
$string['lessoncloses'] = 'Lesson closes';
|
||||
$string['lessoneventcloses'] = '{$a} closes';
|
||||
$string['lessoncloseson'] = 'Lesson closes on {$a}';
|
||||
$string['lesson:edit'] = 'Edit a lesson activity';
|
||||
$string['lessonformating'] = 'Lesson formatting';
|
||||
$string['lesson:manage'] = 'Manage a lesson activity';
|
||||
$string['lesson:manageoverrides'] = 'Manage lesson overrides';
|
||||
$string['lesson:view'] = 'View lesson activity';
|
||||
$string['lesson:viewreports'] = 'View lesson reports';
|
||||
$string['lessonname'] = 'Lesson: {$a}';
|
||||
$string['lessonmenu'] = 'Lesson menu';
|
||||
$string['lessonnotready'] = 'This lesson is not ready to be taken. Please contact your {$a}.';
|
||||
$string['lessonnotready2'] = 'This lesson is not ready to be taken.';
|
||||
@ -584,10 +581,14 @@ $string['whatdofirst'] = 'What would you like to do first?';
|
||||
$string['wronganswerjump'] = 'Wrong answer jump';
|
||||
$string['wronganswerscore'] = 'Wrong answer score';
|
||||
$string['wrongresponse'] = 'Wrong response';
|
||||
$string['xattempts'] = '{$a} attempts';
|
||||
$string['youhaveseen'] = 'You have seen more than one page of this lesson already.<br />Do you want to start at the last page you saw?';
|
||||
$string['youranswer'] = 'Your answer';
|
||||
$string['yourcurrentgradeis'] = 'Your current grade is {$a}';
|
||||
$string['yourcurrentgradeisoutof'] = 'Your current grade is {$a->grade} out of {$a->total}';
|
||||
$string['youshouldview'] = 'You should answer at least: {$a}';
|
||||
|
||||
// Deprecated since Moodle 3.8.
|
||||
$string['additionalattemptsremaining'] = 'Completed, You can re-attempt this lesson';
|
||||
$string['lessoncloseson'] = 'Lesson closes on {$a}';
|
||||
$string['lessonname'] = 'Lesson: {$a}';
|
||||
$string['xattempts'] = '{$a} attempts';
|
||||
|
@ -553,185 +553,10 @@ function lesson_user_complete($course, $user, $mod, $lesson) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints lesson summaries on MyMoodle Page
|
||||
*
|
||||
* Prints lesson name, due date and attempt information on
|
||||
* lessons that have a deadline that has not already passed
|
||||
* and it is available for taking.
|
||||
*
|
||||
* @deprecated since 3.3
|
||||
* @todo The final deprecation of this function will take place in Moodle 3.7 - see MDL-57487.
|
||||
* @global object
|
||||
* @global stdClass
|
||||
* @global object
|
||||
* @uses CONTEXT_MODULE
|
||||
* @param array $courses An array of course objects to get lesson instances from
|
||||
* @param array $htmlarray Store overview output array( course ID => 'lesson' => HTML output )
|
||||
* @return void
|
||||
* @deprecated since Moodle 3.3, when the block_course_overview block was removed.
|
||||
*/
|
||||
function lesson_print_overview($courses, &$htmlarray) {
|
||||
global $USER, $CFG, $DB, $OUTPUT;
|
||||
|
||||
debugging('The function lesson_print_overview() is now deprecated.', DEBUG_DEVELOPER);
|
||||
|
||||
if (!$lessons = get_all_instances_in_courses('lesson', $courses)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get all of the current users attempts on all lessons.
|
||||
$params = array($USER->id);
|
||||
$sql = 'SELECT lessonid, userid, count(userid) as attempts
|
||||
FROM {lesson_grades}
|
||||
WHERE userid = ?
|
||||
GROUP BY lessonid, userid';
|
||||
$allattempts = $DB->get_records_sql($sql, $params);
|
||||
$completedattempts = array();
|
||||
foreach ($allattempts as $myattempt) {
|
||||
$completedattempts[$myattempt->lessonid] = $myattempt->attempts;
|
||||
}
|
||||
|
||||
// Get the current course ID.
|
||||
$listoflessons = array();
|
||||
foreach ($lessons as $lesson) {
|
||||
$listoflessons[] = $lesson->id;
|
||||
}
|
||||
// Get the last page viewed by the current user for every lesson in this course.
|
||||
list($insql, $inparams) = $DB->get_in_or_equal($listoflessons, SQL_PARAMS_NAMED);
|
||||
$dbparams = array_merge($inparams, array('userid' => $USER->id));
|
||||
|
||||
// Get the lesson attempts for the user that have the maximum 'timeseen' value.
|
||||
$select = "SELECT l.id, l.timeseen, l.lessonid, l.userid, l.retry, l.pageid, l.answerid as nextpageid, p.qtype ";
|
||||
$from = "FROM {lesson_attempts} l
|
||||
JOIN (
|
||||
SELECT idselect.lessonid, idselect.userid, MAX(idselect.id) AS id
|
||||
FROM {lesson_attempts} idselect
|
||||
JOIN (
|
||||
SELECT lessonid, userid, MAX(timeseen) AS timeseen
|
||||
FROM {lesson_attempts}
|
||||
WHERE userid = :userid
|
||||
AND lessonid $insql
|
||||
GROUP BY userid, lessonid
|
||||
) timeselect
|
||||
ON timeselect.timeseen = idselect.timeseen
|
||||
AND timeselect.userid = idselect.userid
|
||||
AND timeselect.lessonid = idselect.lessonid
|
||||
GROUP BY idselect.userid, idselect.lessonid
|
||||
) aid
|
||||
ON l.id = aid.id
|
||||
JOIN {lesson_pages} p
|
||||
ON l.pageid = p.id ";
|
||||
$lastattempts = $DB->get_records_sql($select . $from, $dbparams);
|
||||
|
||||
// Now, get the lesson branches for the user that have the maximum 'timeseen' value.
|
||||
$select = "SELECT l.id, l.timeseen, l.lessonid, l.userid, l.retry, l.pageid, l.nextpageid, p.qtype ";
|
||||
$from = str_replace('{lesson_attempts}', '{lesson_branch}', $from);
|
||||
$lastbranches = $DB->get_records_sql($select . $from, $dbparams);
|
||||
|
||||
$lastviewed = array();
|
||||
foreach ($lastattempts as $lastattempt) {
|
||||
$lastviewed[$lastattempt->lessonid] = $lastattempt;
|
||||
}
|
||||
|
||||
// Go through the branch times and record the 'timeseen' value if it doesn't exist
|
||||
// for the lesson, or replace it if it exceeds the current recorded time.
|
||||
foreach ($lastbranches as $lastbranch) {
|
||||
if (!isset($lastviewed[$lastbranch->lessonid])) {
|
||||
$lastviewed[$lastbranch->lessonid] = $lastbranch;
|
||||
} else if ($lastviewed[$lastbranch->lessonid]->timeseen < $lastbranch->timeseen) {
|
||||
$lastviewed[$lastbranch->lessonid] = $lastbranch;
|
||||
}
|
||||
}
|
||||
|
||||
// Since we have lessons in this course, now include the constants we need.
|
||||
require_once($CFG->dirroot . '/mod/lesson/locallib.php');
|
||||
|
||||
$now = time();
|
||||
foreach ($lessons as $lesson) {
|
||||
if ($lesson->deadline != 0 // The lesson has a deadline
|
||||
and $lesson->deadline >= $now // And it is before the deadline has been met
|
||||
and ($lesson->available == 0 or $lesson->available <= $now)) { // And the lesson is available
|
||||
|
||||
// Visibility.
|
||||
$class = (!$lesson->visible) ? 'dimmed' : '';
|
||||
|
||||
// Context.
|
||||
$context = context_module::instance($lesson->coursemodule);
|
||||
|
||||
// Link to activity.
|
||||
$url = new moodle_url('/mod/lesson/view.php', array('id' => $lesson->coursemodule));
|
||||
$url = html_writer::link($url, format_string($lesson->name, true, array('context' => $context)), array('class' => $class));
|
||||
$str = $OUTPUT->box(get_string('lessonname', 'lesson', $url), 'name');
|
||||
|
||||
// Deadline.
|
||||
$str .= $OUTPUT->box(get_string('lessoncloseson', 'lesson', userdate($lesson->deadline)), 'info');
|
||||
|
||||
// Attempt information.
|
||||
if (has_capability('mod/lesson:manage', $context)) {
|
||||
// This is a teacher, Get the Number of user attempts.
|
||||
$attempts = $DB->count_records('lesson_grades', array('lessonid' => $lesson->id));
|
||||
$str .= $OUTPUT->box(get_string('xattempts', 'lesson', $attempts), 'info');
|
||||
$str = $OUTPUT->box($str, 'lesson overview');
|
||||
} else {
|
||||
// This is a student, See if the user has at least started the lesson.
|
||||
if (isset($lastviewed[$lesson->id]->timeseen)) {
|
||||
// See if the user has finished this attempt.
|
||||
if (isset($completedattempts[$lesson->id]) &&
|
||||
($completedattempts[$lesson->id] == ($lastviewed[$lesson->id]->retry + 1))) {
|
||||
// Are additional attempts allowed?
|
||||
if ($lesson->retake) {
|
||||
// User can retake the lesson.
|
||||
$str .= $OUTPUT->box(get_string('additionalattemptsremaining', 'lesson'), 'info');
|
||||
$str = $OUTPUT->box($str, 'lesson overview');
|
||||
} else {
|
||||
// User has completed the lesson and no retakes are allowed.
|
||||
$str = '';
|
||||
}
|
||||
|
||||
} else {
|
||||
// The last attempt was not finished or the lesson does not contain questions.
|
||||
// See if the last page viewed was a branchtable.
|
||||
require_once($CFG->dirroot . '/mod/lesson/pagetypes/branchtable.php');
|
||||
if ($lastviewed[$lesson->id]->qtype == LESSON_PAGE_BRANCHTABLE) {
|
||||
// See if the next pageid is the end of lesson.
|
||||
if ($lastviewed[$lesson->id]->nextpageid == LESSON_EOL) {
|
||||
// The last page viewed was the End of Lesson.
|
||||
if ($lesson->retake) {
|
||||
// User can retake the lesson.
|
||||
$str .= $OUTPUT->box(get_string('additionalattemptsremaining', 'lesson'), 'info');
|
||||
$str = $OUTPUT->box($str, 'lesson overview');
|
||||
} else {
|
||||
// User has completed the lesson and no retakes are allowed.
|
||||
$str = '';
|
||||
}
|
||||
|
||||
} else {
|
||||
// The last page viewed was NOT the end of lesson.
|
||||
$str .= $OUTPUT->box(get_string('notyetcompleted', 'lesson'), 'info');
|
||||
$str = $OUTPUT->box($str, 'lesson overview');
|
||||
}
|
||||
|
||||
} else {
|
||||
// Last page was a question page, so the attempt is not completed yet.
|
||||
$str .= $OUTPUT->box(get_string('notyetcompleted', 'lesson'), 'info');
|
||||
$str = $OUTPUT->box($str, 'lesson overview');
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
// User has not yet started this lesson.
|
||||
$str .= $OUTPUT->box(get_string('nolessonattempts', 'lesson'), 'info');
|
||||
$str = $OUTPUT->box($str, 'lesson overview');
|
||||
}
|
||||
}
|
||||
if (!empty($str)) {
|
||||
if (empty($htmlarray[$lesson->course]['lesson'])) {
|
||||
$htmlarray[$lesson->course]['lesson'] = $str;
|
||||
} else {
|
||||
$htmlarray[$lesson->course]['lesson'] .= $str;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function lesson_print_overview() {
|
||||
throw new coding_exception('lesson_print_overview() can not be used any more and is obsolete.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1 @@
|
||||
numattemptsmade,mod_quiz
|
@ -558,7 +558,6 @@ $string['notyetviewed'] = 'Not yet viewed';
|
||||
$string['notyourattempt'] = 'This is not your attempt!';
|
||||
$string['noview'] = 'Logged-in user is not allowed to view this quiz';
|
||||
$string['numattempts'] = '{$a->studentnum} {$a->studentstring} have made {$a->attemptnum} attempts';
|
||||
$string['numattemptsmade'] = '{$a} attempts made on this quiz';
|
||||
$string['numberabbr'] = '#';
|
||||
$string['numerical'] = 'Numerical';
|
||||
$string['numquestionsx'] = 'Questions: {$a}';
|
||||
@ -989,3 +988,6 @@ $string['wronguse'] = 'You can not use this page like that';
|
||||
$string['xhtml'] = 'XHTML';
|
||||
$string['youneedtoenrol'] = 'You need to enrol in this course before you can attempt this quiz';
|
||||
$string['yourfinalgradeis'] = 'Your final grade for this quiz is {$a}.';
|
||||
|
||||
// Deprecated since Moodle 3.8.
|
||||
$string['numattemptsmade'] = '{$a} attempts made on this quiz';
|
||||
|
@ -1576,103 +1576,10 @@ function quiz_reset_userdata($data) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints quiz summaries on MyMoodle Page
|
||||
*
|
||||
* @deprecated since 3.3
|
||||
* @todo The final deprecation of this function will take place in Moodle 3.7 - see MDL-57487.
|
||||
* @param array $courses
|
||||
* @param array $htmlarray
|
||||
* @deprecated since Moodle 3.3, when the block_course_overview block was removed.
|
||||
*/
|
||||
function quiz_print_overview($courses, &$htmlarray) {
|
||||
global $USER, $CFG;
|
||||
|
||||
debugging('The function quiz_print_overview() is now deprecated.', DEBUG_DEVELOPER);
|
||||
|
||||
// These next 6 Lines are constant in all modules (just change module name).
|
||||
if (empty($courses) || !is_array($courses) || count($courses) == 0) {
|
||||
return array();
|
||||
}
|
||||
|
||||
if (!$quizzes = get_all_instances_in_courses('quiz', $courses)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the quizzes attempts.
|
||||
$attemptsinfo = [];
|
||||
$quizids = [];
|
||||
foreach ($quizzes as $quiz) {
|
||||
$quizids[] = $quiz->id;
|
||||
$attemptsinfo[$quiz->id] = ['count' => 0, 'hasfinished' => false];
|
||||
}
|
||||
$attempts = quiz_get_user_attempts($quizids, $USER->id);
|
||||
foreach ($attempts as $attempt) {
|
||||
$attemptsinfo[$attempt->quiz]['count']++;
|
||||
$attemptsinfo[$attempt->quiz]['hasfinished'] = true;
|
||||
}
|
||||
unset($attempts);
|
||||
|
||||
// Fetch some language strings outside the main loop.
|
||||
$strquiz = get_string('modulename', 'quiz');
|
||||
$strnoattempts = get_string('noattempts', 'quiz');
|
||||
|
||||
// We want to list quizzes that are currently available, and which have a close date.
|
||||
// This is the same as what the lesson does, and the dabate is in MDL-10568.
|
||||
$now = time();
|
||||
foreach ($quizzes as $quiz) {
|
||||
if ($quiz->timeclose >= $now && $quiz->timeopen < $now) {
|
||||
$str = '';
|
||||
|
||||
// Now provide more information depending on the uers's role.
|
||||
$context = context_module::instance($quiz->coursemodule);
|
||||
if (has_capability('mod/quiz:viewreports', $context)) {
|
||||
// For teacher-like people, show a summary of the number of student attempts.
|
||||
// The $quiz objects returned by get_all_instances_in_course have the necessary $cm
|
||||
// fields set to make the following call work.
|
||||
$str .= '<div class="info">' . quiz_num_attempt_summary($quiz, $quiz, true) . '</div>';
|
||||
|
||||
} else if (has_any_capability(array('mod/quiz:reviewmyattempts', 'mod/quiz:attempt'), $context)) { // Student
|
||||
// For student-like people, tell them how many attempts they have made.
|
||||
|
||||
if (isset($USER->id)) {
|
||||
if ($attemptsinfo[$quiz->id]['hasfinished']) {
|
||||
// The student's last attempt is finished.
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($attemptsinfo[$quiz->id]['count'] > 0) {
|
||||
$str .= '<div class="info">' .
|
||||
get_string('numattemptsmade', 'quiz', $attemptsinfo[$quiz->id]['count']) . '</div>';
|
||||
} else {
|
||||
$str .= '<div class="info">' . $strnoattempts . '</div>';
|
||||
}
|
||||
|
||||
} else {
|
||||
$str .= '<div class="info">' . $strnoattempts . '</div>';
|
||||
}
|
||||
|
||||
} else {
|
||||
// For ayone else, there is no point listing this quiz, so stop processing.
|
||||
continue;
|
||||
}
|
||||
|
||||
// Give a link to the quiz, and the deadline.
|
||||
$html = '<div class="quiz overview">' .
|
||||
'<div class="name">' . $strquiz . ': <a ' .
|
||||
($quiz->visible ? '' : ' class="dimmed"') .
|
||||
' href="' . $CFG->wwwroot . '/mod/quiz/view.php?id=' .
|
||||
$quiz->coursemodule . '">' .
|
||||
$quiz->name . '</a></div>';
|
||||
$html .= '<div class="info">' . get_string('quizcloseson', 'quiz',
|
||||
userdate($quiz->timeclose)) . '</div>';
|
||||
$html .= $str;
|
||||
$html .= '</div>';
|
||||
if (empty($htmlarray[$quiz->course]['quiz'])) {
|
||||
$htmlarray[$quiz->course]['quiz'] = $html;
|
||||
} else {
|
||||
$htmlarray[$quiz->course]['quiz'] .= $html;
|
||||
}
|
||||
}
|
||||
}
|
||||
function quiz_print_overview() {
|
||||
throw new coding_exception('quiz_print_overview() can not be used any more and is obsolete.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
1
mod/scorm/lang/en/deprecated.txt
Normal file
1
mod/scorm/lang/en/deprecated.txt
Normal file
@ -0,0 +1 @@
|
||||
duedate,mod_scorm
|
@ -121,7 +121,6 @@ $string['displaydesc'] = 'Whether to display the SCORM package in a new window.'
|
||||
$string['displaysettings'] = 'Display settings';
|
||||
$string['dnduploadscorm'] = 'Add a SCORM package';
|
||||
$string['domxml'] = 'DOMXML external library';
|
||||
$string['duedate'] = 'Due date';
|
||||
$string['element'] = 'Element';
|
||||
$string['enter'] = 'Enter';
|
||||
$string['entercourse'] = 'Enter course';
|
||||
@ -444,3 +443,6 @@ $string['whatgradedesc'] = 'Whether the highest, average (mean), first or last c
|
||||
$string['width'] = 'Width';
|
||||
$string['window'] = 'Window';
|
||||
$string['youmustselectastatus'] = 'You must select a status to require';
|
||||
|
||||
// Deprecated since Moodle 3.8.
|
||||
$string['duedate'] = 'Due date';
|
||||
|
@ -1101,59 +1101,10 @@ function scorm_debug_log_remove($type, $scoid) {
|
||||
}
|
||||
|
||||
/**
|
||||
* writes overview info for course_overview block - displays upcoming scorm objects that have a due date
|
||||
*
|
||||
* @deprecated since 3.3
|
||||
* @todo The final deprecation of this function will take place in Moodle 3.7 - see MDL-57487.
|
||||
* @param object $type - type of log(aicc,scorm12,scorm13) used as prefix for filename
|
||||
* @param array $htmlarray
|
||||
* @return mixed
|
||||
* @deprecated since Moodle 3.3, when the block_course_overview block was removed.
|
||||
*/
|
||||
function scorm_print_overview($courses, &$htmlarray) {
|
||||
global $USER, $CFG;
|
||||
|
||||
debugging('The function scorm_print_overview() is now deprecated.', DEBUG_DEVELOPER);
|
||||
|
||||
if (empty($courses) || !is_array($courses) || count($courses) == 0) {
|
||||
return array();
|
||||
}
|
||||
|
||||
if (!$scorms = get_all_instances_in_courses('scorm', $courses)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$strscorm = get_string('modulename', 'scorm');
|
||||
$strduedate = get_string('duedate', 'scorm');
|
||||
|
||||
foreach ($scorms as $scorm) {
|
||||
$time = time();
|
||||
$showattemptstatus = false;
|
||||
if ($scorm->timeopen) {
|
||||
$isopen = ($scorm->timeopen <= $time && $time <= $scorm->timeclose);
|
||||
}
|
||||
if ($scorm->displayattemptstatus == SCORM_DISPLAY_ATTEMPTSTATUS_ALL ||
|
||||
$scorm->displayattemptstatus == SCORM_DISPLAY_ATTEMPTSTATUS_MY) {
|
||||
$showattemptstatus = true;
|
||||
}
|
||||
if ($showattemptstatus || !empty($isopen) || !empty($scorm->timeclose)) {
|
||||
$str = html_writer::start_div('scorm overview').html_writer::div($strscorm. ': '.
|
||||
html_writer::link($CFG->wwwroot.'/mod/scorm/view.php?id='.$scorm->coursemodule, $scorm->name,
|
||||
array('title' => $strscorm, 'class' => $scorm->visible ? '' : 'dimmed')), 'name');
|
||||
if ($scorm->timeclose) {
|
||||
$str .= html_writer::div($strduedate.': '.userdate($scorm->timeclose), 'info');
|
||||
}
|
||||
if ($showattemptstatus) {
|
||||
require_once($CFG->dirroot.'/mod/scorm/locallib.php');
|
||||
$str .= html_writer::div(scorm_get_attempt_status($USER, $scorm), 'details');
|
||||
}
|
||||
$str .= html_writer::end_div();
|
||||
if (empty($htmlarray[$scorm->course]['scorm'])) {
|
||||
$htmlarray[$scorm->course]['scorm'] = $str;
|
||||
} else {
|
||||
$htmlarray[$scorm->course]['scorm'] .= $str;
|
||||
}
|
||||
}
|
||||
}
|
||||
function scorm_print_overview() {
|
||||
throw new coding_exception('scorm_print_overview() can not be used any more and is obsolete.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,6 +1,10 @@
|
||||
This files describes API changes in /mod/* - activity modules,
|
||||
information provided here is intended especially for developers.
|
||||
|
||||
=== 3.8 ===
|
||||
|
||||
* The final deprecation of xxx_print_overview() callback means that this function will no longer be called.
|
||||
|
||||
=== 3.6 ===
|
||||
|
||||
* The final deprecation of xxx_get_types() callback means that this function will no longer be called.
|
||||
@ -44,7 +48,8 @@ information provided here is intended especially for developers.
|
||||
- isexternalfile (if is a file reference to a external repository)
|
||||
- repositorytype (the repository name in case is a external file)
|
||||
Those fields are VALUE_OPTIONAL for backwards compatibility.
|
||||
* The block_course_overview has been removed and the related core module *_print_overview functions have been deprecated.
|
||||
* The block_course_overview has been removed and the related core module
|
||||
*_print_overview functions have been deprecated.
|
||||
* The block_myoverview has replaced block_course_overview to provide better information to students. To support this,
|
||||
actions can now be attached to calendar events. Documentation for the following new API callbacks introduced in
|
||||
MDL-55611 can be found at https://docs.moodle.org/dev/Calendar_API. The 3 new callbacks are:
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$version = 2019061400.00; // YYYYMMDD = weekly release date of this DEV branch.
|
||||
$version = 2019061400.01; // YYYYMMDD = weekly release date of this DEV branch.
|
||||
// RR = release increments - 00 in DEV branches.
|
||||
// .XX = incremental changes.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user