From 18a2a0cb3a60d7a0111fdd24e557b9a89d2edccf Mon Sep 17 00:00:00 2001 From: sam_marshall Date: Tue, 29 Jul 2008 17:22:47 +0000 Subject: [PATCH] MDL-15498: Completion: added support for basic completion-on-view and on grade (where applicable) to assignment, choice, data, glossary, lesson, and resource. --- mod/assignment/lib.php | 12 +++++++++++- mod/assignment/view.php | 5 ++++- mod/choice/lib.php | 10 ++++++++++ mod/choice/view.php | 4 +++- mod/data/lib.php | 11 +++++++++++ mod/data/view.php | 4 ++++ mod/glossary/lib.php | 12 ++++++++++++ mod/glossary/view.php | 4 +++- mod/lesson/lib.php | 12 ++++++++++++ mod/lesson/view.php | 3 +++ mod/resource/lib.php | 11 +++++++++++ mod/resource/view.php | 6 +++++- 12 files changed, 89 insertions(+), 5 deletions(-) diff --git a/mod/assignment/lib.php b/mod/assignment/lib.php index 6e81b15ba2..799bfa16c9 100644 --- a/mod/assignment/lib.php +++ b/mod/assignment/lib.php @@ -3180,5 +3180,15 @@ class assignment_portfolio_caller extends portfolio_module_caller_base { } } - +/** + * @param string $feature FEATURE_xx constant for requested feature + * @return mixed True if module supports feature, null if doesn't know + */ +function assignment_supports($feature) { + switch($feature) { + case FEATURE_COMPLETION_TRACKS_VIEWS: return true; + case FEATURE_GRADE_HAS_GRADE: return true; + default: return null; + } +} ?> diff --git a/mod/assignment/view.php b/mod/assignment/view.php index f12de92d52..ced9277537 100644 --- a/mod/assignment/view.php +++ b/mod/assignment/view.php @@ -36,6 +36,9 @@ $assignmentclass = "assignment_$assignment->assignmenttype"; $assignmentinstance = new $assignmentclass($cm->id, $assignment, $cm, $course); - $assignmentinstance->view(); // Actually display the assignment! +/// Mark as viewed + $completion=new completion_info($course); + $completion->set_module_viewed($cm); + $assignmentinstance->view(); // Actually display the assignment! ?> diff --git a/mod/choice/lib.php b/mod/choice/lib.php index 8d9191918e..890eb8a13c 100644 --- a/mod/choice/lib.php +++ b/mod/choice/lib.php @@ -749,4 +749,14 @@ function chice_get_extra_capabilities() { return array('moodle/site:accessallgroups'); } +/** + * @param string $feature FEATURE_xx constant for requested feature + * @return mixed True if module supports feature, null if doesn't know + */ +function choice_supports($feature) { + switch($feature) { + case FEATURE_COMPLETION_TRACKS_VIEWS: return true; + default: return null; + } +} ?> diff --git a/mod/choice/view.php b/mod/choice/view.php index ded6d8197a..1344b71a27 100644 --- a/mod/choice/view.php +++ b/mod/choice/view.php @@ -166,5 +166,7 @@ print_footer($course); - +/// Mark as viewed + $completion=new completion_info($course); + $completion->set_module_viewed($cm); ?> diff --git a/mod/data/lib.php b/mod/data/lib.php index 0bf97254cf..a6df608290 100755 --- a/mod/data/lib.php +++ b/mod/data/lib.php @@ -2270,4 +2270,15 @@ function data_get_extra_capabilities() { return array('moodle/site:accessallgroups', 'moodle/site:viewfullnames'); } +/** + * @param string $feature FEATURE_xx constant for requested feature + * @return mixed True if module supports feature, null if doesn't know + */ +function data_supports($feature) { + switch($feature) { + case FEATURE_COMPLETION_TRACKS_VIEWS: return true; + case FEATURE_GRADE_HAS_GRADE: return true; + default: return null; + } +} ?> diff --git a/mod/data/view.php b/mod/data/view.php index 983893c4bc..c28b1fb889 100755 --- a/mod/data/view.php +++ b/mod/data/view.php @@ -661,4 +661,8 @@ } print_footer($course); + +/// Mark as viewed + $completion=new completion_info($course); + $completion->set_module_viewed($cm); ?> diff --git a/mod/glossary/lib.php b/mod/glossary/lib.php index aa9d3eb205..6bc4f52a13 100644 --- a/mod/glossary/lib.php +++ b/mod/glossary/lib.php @@ -2306,4 +2306,16 @@ function glossary_get_extra_capabilities() { return array('moodle/site:accessallgroups', 'moodle/site:viewfullnames', 'moodle/site:trustcontent'); } +/** + * @param string $feature FEATURE_xx constant for requested feature + * @return mixed True if module supports feature, null if doesn't know + */ +function glossary_supports($feature) { + switch($feature) { + case FEATURE_COMPLETION_TRACKS_VIEWS: return true; + case FEATURE_GRADE_HAS_GRADE: return true; + default: return null; + } +} + ?> diff --git a/mod/glossary/view.php b/mod/glossary/view.php index 31b8dfced1..0641a3c8f6 100644 --- a/mod/glossary/view.php +++ b/mod/glossary/view.php @@ -518,7 +518,9 @@ glossary_print_tabbed_table_end(); /// Finish the page - print_footer($course); +/// Mark as viewed + $completion=new completion_info($course); + $completion->set_module_viewed($cm); ?> diff --git a/mod/lesson/lib.php b/mod/lesson/lib.php index b1bbc30e79..0dc9ed2f4e 100644 --- a/mod/lesson/lib.php +++ b/mod/lesson/lib.php @@ -705,4 +705,16 @@ function lesson_get_extra_capabilities() { return array('moodle/site:accessallgroups'); } +/** + * @param string $feature FEATURE_xx constant for requested feature + * @return mixed True if module supports feature, null if doesn't know + */ +function lesson_supports($feature) { + switch($feature) { + case FEATURE_COMPLETION_TRACKS_VIEWS: return true; + case FEATURE_GRADE_HAS_GRADE: return true; + default: return null; + } +} + ?> diff --git a/mod/lesson/view.php b/mod/lesson/view.php index fb45236cdb..1b7802871f 100644 --- a/mod/lesson/view.php +++ b/mod/lesson/view.php @@ -1031,4 +1031,7 @@ /// Finish the page print_footer($course); +/// Mark as viewed + $completion=new completion_info($course); + $completion->set_module_viewed($cm); ?> diff --git a/mod/resource/lib.php b/mod/resource/lib.php index 02d2dc71b2..1a28119889 100644 --- a/mod/resource/lib.php +++ b/mod/resource/lib.php @@ -752,4 +752,15 @@ class resource_portfolio_caller extends portfolio_module_caller_base { } } +/** + * @param string $feature FEATURE_xx constant for requested feature + * @return mixed True if module supports feature, null if doesn't know + */ +function resource_supports($feature) { + switch($feature) { + case FEATURE_COMPLETION_TRACKS_VIEWS: return true; + default: return null; + } +} + ?> diff --git a/mod/resource/view.php b/mod/resource/view.php index d83e1ad7f8..c603c1ce18 100644 --- a/mod/resource/view.php +++ b/mod/resource/view.php @@ -37,6 +37,10 @@ $resourceclass = 'resource_'.$resource->type; $resourceinstance = new $resourceclass($cm->id); - $resourceinstance->display(); + // Mark activity viewed before we display it because some resource types + // do not return from display() + $completion=new completion_info($course); + $completion->set_module_viewed($cm); + $resourceinstance->display(); ?> -- 2.39.5