Merge branch 'MDL-57630-m' of https://github.com/micaherne/moodle
authorAndrew Nicols <andrew@nicols.co.uk>
Thu, 2 Feb 2017 01:18:17 +0000 (09:18 +0800)
committerAndrew Nicols <andrew@nicols.co.uk>
Thu, 2 Feb 2017 01:18:17 +0000 (09:18 +0800)
502 files changed:
.eslintignore
.gherkin-lintrc [new file with mode: 0644]
.stylelintignore
Gruntfile.js
admin/templates/setting_configmultiselect_optgroup.mustache [new file with mode: 0644]
admin/templates/setting_configselect_optgroup.mustache [new file with mode: 0644]
admin/tool/behat/cli/run.php
admin/tool/behat/cli/util.php
admin/tool/behat/cli/util_single_run.php
admin/tool/behat/tests/behat/get_and_set_fields.feature
admin/tool/behat/tests/behat/list_steps.feature
admin/tool/cohortroles/classes/api.php
admin/tool/cohortroles/tests/api_test.php
admin/tool/langimport/classes/output/langimport_page.php [new file with mode: 0644]
admin/tool/langimport/classes/output/renderer.php [new file with mode: 0644]
admin/tool/langimport/index.php
admin/tool/langimport/styles.css
admin/tool/langimport/templates/langimport.mustache [new file with mode: 0644]
admin/tool/langimport/tests/behat/manage_langpacks.feature
admin/tool/lp/classes/course_competencies_form_element.php
admin/tool/lp/classes/course_competency_rule_form_element.php
admin/tool/lp/classes/external.php
admin/tool/lp/classes/external/competency_path_exporter.php
admin/tool/lp/classes/external/competency_summary_exporter.php
admin/tool/lp/classes/external/course_competency_statistics_exporter.php
admin/tool/lp/classes/external/path_node_exporter.php
admin/tool/lp/classes/external/template_statistics_exporter.php
admin/tool/lp/classes/external/user_competency_summary_exporter.php
admin/tool/lp/classes/external/user_competency_summary_in_course_exporter.php
admin/tool/lp/classes/external/user_competency_summary_in_plan_exporter.php
admin/tool/lp/classes/external/user_evidence_competency_summary_exporter.php
admin/tool/lp/classes/external/user_evidence_summary_exporter.php
admin/tool/lp/classes/form/competency.php
admin/tool/lp/classes/form/competency_framework.php
admin/tool/lp/classes/form/framework_autocomplete.php
admin/tool/lp/classes/form/plan.php
admin/tool/lp/classes/form/template.php
admin/tool/lp/classes/form/template_cohorts.php
admin/tool/lp/classes/form/template_plans.php
admin/tool/lp/classes/form/user_evidence.php
admin/tool/lp/classes/output/competency_plan_navigation.php
admin/tool/lp/classes/output/competency_summary.php
admin/tool/lp/classes/output/course_competencies_page.php
admin/tool/lp/classes/output/plan_page.php
admin/tool/lp/classes/output/template_cohorts_table.php
admin/tool/lp/classes/output/template_competencies_page.php
admin/tool/lp/classes/output/template_plans_table.php
admin/tool/lp/classes/output/user_competency_course_navigation.php
admin/tool/lp/classes/output/user_competency_summary.php
admin/tool/lp/classes/output/user_competency_summary_in_course.php
admin/tool/lp/classes/output/user_competency_summary_in_plan.php
admin/tool/lp/classes/page_helper.php
admin/tool/lp/competencies.php
admin/tool/lp/db/renamedclasses.php [new file with mode: 0644]
admin/tool/lp/editcompetency.php
admin/tool/lp/editcompetencyframework.php
admin/tool/lp/editplan.php
admin/tool/lp/edittemplate.php
admin/tool/lp/lib.php
admin/tool/lp/plan.php
admin/tool/lp/template_cohorts.php
admin/tool/lp/template_plans.php
admin/tool/lp/templatecompetencies.php
admin/tool/lp/tests/behat/framework_crud.feature
admin/tool/lp/tests/behat/plan_workflow.feature
admin/tool/lp/tests/behat/user_evidence_crud.feature
admin/tool/lp/tests/externallib_test.php
admin/tool/lp/upgrade.txt
admin/tool/lp/user_competency.php
admin/tool/lp/user_competency_in_course.php
admin/tool/lp/user_competency_in_plan.php
admin/tool/lp/user_evidence.php
admin/tool/lp/user_evidence_edit.php
admin/tool/lpimportcsv/classes/form/export.php
admin/tool/lpimportcsv/classes/framework_exporter.php
admin/tool/lpimportcsv/classes/framework_importer.php
admin/tool/lpimportcsv/index.php
admin/tool/lpimportcsv/tests/import_test.php
admin/tool/lpmigrate/classes/framework_mapper.php
admin/tool/lpmigrate/tests/processor_test.php
admin/tool/mobile/classes/api.php
admin/tool/mobile/classes/external.php
admin/tool/mobile/lang/en/tool_mobile.php
admin/tool/mobile/settings.php
admin/tool/mobile/tests/externallib_test.php
admin/tool/mobile/version.php
admin/upgrade.txt
auth/cas/config.html
auth/classes/external.php
auth/email/classes/external.php
auth/ldap/auth.php
auth/ldap/config.html
auth/ldap/lang/en/auth_ldap.php
badges/classes/external.php
badges/mybackpack.php
badges/mybadges.php
badges/tests/behat/award_badge.feature
blocks/activity_results/tests/behat/addblockinactivity.feature
blocks/activity_results/tests/behat/addunconfiguredblock.feature
blocks/activity_results/tests/behat/addunsupportedactivity.feature
blocks/activity_results/tests/behat/highscoreswithoutgroups.feature
blocks/activity_results/tests/behat/highscoreswithscales.feature
blocks/activity_results/tests/behat/highscoreswithscalesandgroups.feature
blocks/activity_results/tests/behat/highscoreswithseperategroups.feature
blocks/activity_results/tests/behat/highscoreswithvisiblegroups.feature
blocks/activity_results/tests/behat/lowscoreswithoutgroups.feature
blocks/activity_results/tests/behat/lowscoreswithscales.feature
blocks/activity_results/tests/behat/lowscoreswithscalesandgroups.feature
blocks/activity_results/tests/behat/lowscoreswithseperategroups.feature
blocks/activity_results/tests/behat/lowscoreswithvisiblegroups.feature
blocks/blog_menu/tests/behat/block_blog_menu_course.feature
blocks/calendar_upcoming/tests/behat/block_calendar_upcoming_dashboard.feature
blocks/completionstatus/tests/behat/block_completionstatus_manual_other.feature
blocks/course_overview/tests/behat/quiz_overview.feature
blocks/glossary_random/tests/behat/glossary_random_frontpage.feature
blocks/html/tests/behat/multiple_instances.feature
blocks/lp/classes/output/competencies_to_review_page.php
blocks/lp/classes/output/plans_to_review_page.php
blocks/lp/classes/output/summary.php
blocks/online_users/tests/behat/block_online_users_dashboard.feature
blocks/online_users/tests/behat/block_online_users_frontpage.feature
blocks/private_files/tests/behat/block_private_files_activity.feature
blocks/private_files/tests/behat/block_private_files_course.feature
blocks/private_files/tests/behat/block_private_files_dashboard.feature
blocks/private_files/tests/behat/block_private_files_frontpage.feature
blocks/rss_client/block_rss_client.php
blocks/rss_client/classes/output/footer.php
blocks/rss_client/lang/en/block_rss_client.php
blocks/rss_client/managefeeds.php
blocks/rss_client/templates/footer.mustache
blocks/search_forums/tests/behat/block_search_forums_course.feature
blocks/search_forums/tests/behat/block_search_forums_frontpage.feature
blocks/section_links/tests/behat/block_section_links_course.feature
blog/tests/behat/delete.feature
cache/classes/loaders.php
cache/stores/redis/addinstanceform.php
cache/stores/redis/lang/en/cachestore_redis.php
cache/stores/redis/lib.php
cache/stores/redis/settings.php
cache/stores/static/lib.php
cache/stores/static/tests/static_test.php
cache/tests/cache_test.php
calendar/tests/behat/calendar.feature
cohort/classes/external/cohort_summary_exporter.php [moved from admin/tool/lp/classes/external/cohort_summary_exporter.php with 88% similarity]
cohort/tests/behat/access_visible_cohorts.feature
comment/classes/external/comment_area_exporter.php [moved from competency/classes/external/comment_area_exporter.php with 96% similarity]
comment/comment.js
comment/lib.php
competency/classes/api.php
competency/classes/competency.php
competency/classes/competency_framework.php
competency/classes/competency_rule.php
competency/classes/competency_rule_all.php
competency/classes/competency_rule_points.php
competency/classes/course_competency.php
competency/classes/course_competency_settings.php
competency/classes/course_module_competency.php
competency/classes/evidence.php
competency/classes/external.php
competency/classes/external/competency_exporter.php
competency/classes/external/competency_framework_exporter.php
competency/classes/external/course_competency_exporter.php
competency/classes/external/course_competency_settings_exporter.php
competency/classes/external/course_module_competency_exporter.php
competency/classes/external/evidence_exporter.php
competency/classes/external/performance_helper.php [new file with mode: 0644]
competency/classes/external/plan_competency_exporter.php
competency/classes/external/plan_exporter.php
competency/classes/external/related_competency_exporter.php
competency/classes/external/template_competency_exporter.php
competency/classes/external/template_exporter.php
competency/classes/external/user_competency_course_exporter.php
competency/classes/external/user_competency_exporter.php
competency/classes/external/user_competency_plan_exporter.php
competency/classes/external/user_evidence_competency_exporter.php
competency/classes/external/user_evidence_exporter.php
competency/classes/invalid_persistent_exception.php
competency/classes/persistent.php
competency/classes/plan.php
competency/classes/plan_competency.php
competency/classes/related_competency.php
competency/classes/template.php
competency/classes/template_cohort.php
competency/classes/template_competency.php
competency/classes/user_competency.php
competency/classes/user_competency_course.php
competency/classes/user_competency_plan.php
competency/classes/user_evidence.php
competency/lib.php
competency/tests/api_test.php
competency/tests/competency_rule_test.php
competency/tests/competency_test.php
competency/tests/course_competency_settings_test.php
competency/tests/course_competency_test.php
competency/tests/event_test.php
competency/tests/external_test.php
competency/tests/generator/lib.php
competency/tests/generator_test.php
competency/tests/hooks_test.php
competency/tests/lib_test.php
competency/tests/performance_helper_test.php [new file with mode: 0644]
competency/tests/plan_test.php
competency/tests/task_test.php
competency/tests/template_test.php
competency/tests/user_evidence_competency_test.php
competency/upgrade.txt [new file with mode: 0644]
completion/classes/external.php
completion/tests/behat/behat_completion.php
completion/tests/behat/enable_manual_complete_mark.feature
composer.json
composer.lock
config-dist.php
course/classes/external/course_module_summary_exporter.php [moved from admin/tool/lp/classes/external/course_module_summary_exporter.php with 94% similarity]
course/classes/external/course_summary_exporter.php [moved from admin/tool/lp/classes/external/course_summary_exporter.php with 94% similarity]
course/dndupload.js
course/externallib.php
course/format/social/tests/behat/social_adjust_discussion_count.feature
course/tests/behat/category_change_visibility.feature
course/tests/behat/course_search.feature
course/tests/behat/force_group_mode.feature
course/tests/behat/view_subfolders_inline.feature
course/tests/courselib_test.php
course/tests/externallib_test.php
course/upgrade.txt
enrol/lti/classes/helper.php
enrol/lti/classes/manage_table.php
enrol/lti/db/install.xml
enrol/lti/db/upgrade.php
enrol/lti/index.php
enrol/lti/lang/en/deprecated.txt
enrol/lti/lang/en/enrol_lti.php
enrol/lti/templates/copy_grid.mustache
enrol/lti/version.php
enrol/manual/ajax.php
enrol/manual/manage.php
enrol/self/lib.php
files/classes/external/stored_file_exporter.php [moved from competency/classes/external/stored_file_exporter.php with 96% similarity]
files/tests/behat/add_custom_file_type.feature
grade/report/grader/lib.php
grade/report/grader/tests/behat/ajax_grader.feature
grade/report/grader/tests/behat/switch_views.feature
grade/report/overview/classes/external.php
grade/report/user/externallib.php
grade/report/user/tests/behat/view_usereport.feature
grade/tests/behat/behat_grade.php
grade/tests/behat/grade_calculated_grade_items.feature
grade/tests/behat/grade_item_validation.feature
grade/tests/behat/grade_letter_boundary_20160518.feature
grade/tests/behat/grade_natural_normalisation.feature
grade/tests/report_graderlib_test.php
install/lang/ar/error.php
install/lang/es_mx_kids/langconfig.php
install/lang/fa/error.php
install/lang/fa/install.php
install/lang/lv/error.php
install/lang/lv/install.php
install/lang/lv/moodle.php
install/lang/mn/moodle.php
lib/accesslib.php
lib/adminlib.php
lib/amd/build/permissionmanager.min.js
lib/amd/build/tag.min.js
lib/amd/src/permissionmanager.js
lib/amd/src/tag.js
lib/behat/classes/behat_command.php
lib/behat/classes/behat_config_manager.php
lib/behat/classes/behat_config_util.php
lib/behat/classes/util.php
lib/behat/lib.php
lib/classes/event/competency_created.php
lib/classes/event/competency_deleted.php
lib/classes/event/competency_evidence_created.php
lib/classes/event/competency_framework_created.php
lib/classes/event/competency_framework_deleted.php
lib/classes/event/competency_framework_updated.php
lib/classes/event/competency_framework_viewed.php
lib/classes/event/competency_plan_approved.php
lib/classes/event/competency_plan_completed.php
lib/classes/event/competency_plan_created.php
lib/classes/event/competency_plan_deleted.php
lib/classes/event/competency_plan_reopened.php
lib/classes/event/competency_plan_review_request_cancelled.php
lib/classes/event/competency_plan_review_requested.php
lib/classes/event/competency_plan_review_started.php
lib/classes/event/competency_plan_review_stopped.php
lib/classes/event/competency_plan_unapproved.php
lib/classes/event/competency_plan_unlinked.php
lib/classes/event/competency_plan_updated.php
lib/classes/event/competency_plan_viewed.php
lib/classes/event/competency_template_created.php
lib/classes/event/competency_template_deleted.php
lib/classes/event/competency_template_updated.php
lib/classes/event/competency_template_viewed.php
lib/classes/event/competency_updated.php
lib/classes/event/competency_user_competency_plan_viewed.php
lib/classes/event/competency_user_competency_rated.php
lib/classes/event/competency_user_competency_rated_in_course.php
lib/classes/event/competency_user_competency_rated_in_plan.php
lib/classes/event/competency_user_competency_review_request_cancelled.php
lib/classes/event/competency_user_competency_review_requested.php
lib/classes/event/competency_user_competency_review_started.php
lib/classes/event/competency_user_competency_review_stopped.php
lib/classes/event/competency_user_competency_viewed.php
lib/classes/event/competency_user_competency_viewed_in_course.php
lib/classes/event/competency_user_competency_viewed_in_plan.php
lib/classes/event/competency_user_evidence_created.php
lib/classes/event/competency_user_evidence_deleted.php
lib/classes/event/competency_user_evidence_updated.php
lib/classes/event/competency_viewed.php
lib/classes/external/exporter.php [moved from competency/classes/external/exporter.php with 84% similarity]
lib/classes/external/persistent_exporter.php [moved from competency/classes/external/persistent_exporter.php with 83% similarity]
lib/classes/form/persistent.php [moved from admin/tool/lp/classes/form/persistent.php with 85% similarity]
lib/classes/invalid_persistent_exception.php [new file with mode: 0644]
lib/classes/persistent.php [new file with mode: 0644]
lib/classes/session/redis.php
lib/db/renamedclasses.php
lib/editor/atto/plugins/accessibilityhelper/tests/behat/accessibilityhelper.feature
lib/editor/atto/plugins/align/tests/behat/align.feature
lib/editor/atto/plugins/clear/tests/behat/clear.feature
lib/editor/atto/plugins/collapse/tests/behat/collapse.feature
lib/editor/atto/plugins/equation/yui/build/moodle-atto_equation-button/moodle-atto_equation-button-debug.js
lib/editor/atto/plugins/equation/yui/build/moodle-atto_equation-button/moodle-atto_equation-button-min.js
lib/editor/atto/plugins/equation/yui/build/moodle-atto_equation-button/moodle-atto_equation-button.js
lib/editor/atto/plugins/equation/yui/src/button/js/button.js
lib/editor/atto/plugins/html/tests/behat/html.feature
lib/editor/atto/plugins/link/tests/behat/link.feature
lib/editor/atto/plugins/media/tests/behat/media.feature
lib/editor/atto/plugins/strike/tests/behat/strike.feature
lib/editor/atto/plugins/subscript/tests/behat/subscript.feature
lib/editor/atto/plugins/superscript/tests/behat/superscript.feature
lib/editor/atto/plugins/title/tests/behat/title.feature
lib/editor/atto/plugins/underline/tests/behat/underline.feature
lib/editor/atto/yui/build/moodle-editor_atto-editor/moodle-editor_atto-editor-debug.js
lib/editor/atto/yui/build/moodle-editor_atto-editor/moodle-editor_atto-editor-min.js
lib/editor/atto/yui/build/moodle-editor_atto-editor/moodle-editor_atto-editor.js
lib/editor/atto/yui/src/editor/js/clean.js
lib/enrollib.php
lib/filestorage/file_storage.php
lib/filestorage/tests/file_storage_test.php
lib/form/button.php
lib/formslib.php
lib/javascript-static.js
lib/ldaplib.php
lib/moodlelib.php
lib/navigationlib.php
lib/outputrenderers.php
lib/outputrequirementslib.php
lib/phpunit/classes/util.php
lib/setup.php
lib/templates/login.mustache
lib/tests/accesslib_test.php
lib/tests/behat/behat_deprecated.php
lib/tests/behat/behat_hooks.php
lib/tests/exporter_test.php [moved from competency/tests/exporter_test.php with 53% similarity]
lib/tests/persistent_test.php [moved from competency/tests/persistent_test.php with 64% similarity]
lib/upgrade.txt
media/player/videojs/amd/build/Youtube-lazy.min.js [new file with mode: 0644]
media/player/videojs/amd/build/Youtube.min.js [deleted file]
media/player/videojs/amd/build/loader.min.js
media/player/videojs/amd/build/video-lazy.min.js [moved from media/player/videojs/amd/build/video.min.js with 100% similarity]
media/player/videojs/amd/src/Youtube-lazy.js [moved from media/player/videojs/amd/src/Youtube.js with 99% similarity]
media/player/videojs/amd/src/loader.js
media/player/videojs/amd/src/video-lazy.js [moved from media/player/videojs/amd/src/video.js with 100% similarity]
media/player/videojs/classes/plugin.php
media/player/videojs/readme_moodle.txt
media/player/videojs/thirdpartylibs.xml
message/tests/api_test.php
message/tests/behat/manage_contacts.feature
mod/assign/amd/build/participant_selector.min.js
mod/assign/amd/src/participant_selector.js
mod/assign/classes/output/grading_app.php
mod/assign/externallib.php
mod/assign/feedback/editpdf/tests/behat/view_previous_annotations.feature
mod/assign/feedback/offline/locallib.php
mod/assign/gradingtable.php
mod/assign/lang/en/assign.php
mod/assign/lib.php
mod/assign/locallib.php
mod/assign/renderable.php
mod/assign/renderer.php
mod/assign/tests/behat/display_error_message_onbadformat.feature
mod/assign/tests/behat/submit_without_group.feature
mod/assign/tests/lib_test.php
mod/book/classes/external.php
mod/book/tests/behat/show_hide_chapters.feature
mod/chat/classes/external.php
mod/choice/classes/external.php
mod/choice/tests/behat/block_editing.feature
mod/data/classes/external.php
mod/data/tests/behat/required_entries.feature
mod/feedback/item/captcha/lib.php
mod/feedback/item/feedback_item_class.php
mod/feedback/item/label/lib.php
mod/feedback/item/multichoice/lib.php
mod/feedback/item/multichoicerated/lib.php
mod/feedback/yui/dragdrop/dragdrop.js
mod/folder/classes/external.php
mod/folder/db/services.php
mod/folder/tests/externallib_test.php
mod/folder/version.php
mod/forum/backup/moodle2/restore_forum_stepslib.php
mod/forum/classes/output/big_search_form.php
mod/forum/externallib.php
mod/forum/forum.js [deleted file]
mod/forum/lib.php
mod/forum/templates/big_search_form.mustache
mod/forum/tests/behat/discussion_subscriptions.feature
mod/forum/tests/behat/post_to_multiple_groups.feature
mod/forum/tests/externallib_test.php
mod/forum/tests/lib_test.php
mod/forum/upgrade.txt
mod/glossary/classes/external.php
mod/glossary/tests/behat/prevent_duplicate_entries.feature
mod/glossary/tests/external_test.php
mod/imscp/classes/external.php
mod/label/classes/external.php [new file with mode: 0644]
mod/label/db/services.php [new file with mode: 0644]
mod/label/tests/externallib_test.php [new file with mode: 0644]
mod/label/version.php
mod/lesson/report.php
mod/lesson/tests/behat/import_images.feature
mod/lesson/tests/behat/lesson_edit_cluster.feature
mod/lesson/tests/behat/lesson_group_override.feature
mod/lesson/tests/behat/lesson_practice.feature
mod/lesson/tests/behat/lesson_with_clusters.feature
mod/lesson/tests/behat/lesson_with_subcluster.feature
mod/lti/tests/behat/contentitemregistration.feature
mod/page/classes/external.php
mod/page/db/services.php
mod/page/tests/externallib_test.php
mod/page/version.php
mod/quiz/classes/external.php
mod/quiz/report/attemptsreport_table.php
mod/quiz/report/overview/tests/report_test.php
mod/quiz/tests/behat/attempt_basic.feature
mod/quiz/tests/behat/attempt_require_previous.feature
mod/quiz/tests/behat/editing_section_headings.feature
mod/quiz/tests/behat/editing_set_marks_no_attempts.feature
mod/quiz/tests/behat/editing_set_marks_with_attempts.feature
mod/quiz/tests/behat/quiz_reset.feature
mod/resource/classes/external.php
mod/resource/db/services.php
mod/resource/lib.php
mod/resource/tests/externallib_test.php
mod/resource/tests/lib_test.php
mod/resource/version.php
mod/scorm/datamodels/aicc.js
mod/scorm/datamodels/scorm_12.js
mod/scorm/datamodels/scorm_12.php
mod/scorm/datamodels/scorm_13.js
mod/scorm/lib.php
mod/scorm/locallib.php
mod/scorm/report/basic/classes/report.php
mod/scorm/report/interactions/classes/report.php
mod/scorm/report/objectives/classes/report.php
mod/scorm/tests/behat/completion_condition_require_status.feature
mod/scorm/tests/behat/multisco_review_mode.feature [new file with mode: 0644]
mod/scorm/view.php
mod/survey/classes/external.php
mod/url/classes/external.php
mod/url/db/services.php
mod/url/tests/externallib_test.php
mod/url/version.php
mod/wiki/tests/behat/collaborative_individual.feature
mod/wiki/tests/behat/wiki_search.feature
mod/workshop/locallib.php
mod/workshop/tests/behat/workshop_assessment.feature
npm-shrinkwrap.json
package.json
question/engine/questionattempt.php
question/engine/tests/walkthrough_test.php [new file with mode: 0644]
question/tests/behat/copy_questions.feature
question/type/ddmarker/tests/behat/preview.feature
question/type/description/tests/behat/add.feature
question/type/essay/tests/behat/export.feature
question/type/gapselect/tests/behat/import_test.feature
question/type/shortanswer/tests/behat/preview.feature
question/type/truefalse/tests/behat/add.feature
report/competency/classes/external.php
report/competency/classes/output/report.php
report/competency/classes/output/user_course_navigation.php
report/loglive/tests/behat/loglive_report.feature
repository/manage_instances.php
theme/boost/classes/output/core_renderer.php
theme/boost/config.php
theme/boost/scss/moodle/core.scss
theme/boost/scss/moodle/modules.scss
theme/boost/templates/core/login.mustache
theme/boost/templates/core/tabtree.mustache
theme/boost/templates/core_admin/setting_configmultiselect_optgroup.mustache [new file with mode: 0644]
theme/boost/templates/core_admin/setting_configselect_optgroup.mustache [new file with mode: 0644]
theme/boost/templates/core_form/element-template.mustache
theme/boost/templates/mod_forum/big_search_form.mustache
theme/bootstrapbase/renderers/core_renderer.php
theme/upgrade.txt
theme/yui_combo.php
user/classes/external/user_summary_exporter.php [moved from competency/classes/external/user_summary_exporter.php with 83% similarity]
user/files.php
user/index.php
user/selector/lib.php
user/tests/behat/view_preferences_page.feature
version.php

index fe5da7b..452b0df 100644 (file)
@@ -56,7 +56,8 @@ lib/amd/src/chartjs-lazy.js
 lib/maxmind/GeoIp2/
 lib/maxmind/MaxMind/
 lib/ltiprovider/
-media/player/videojs/amd/src/
+media/player/videojs/amd/src/video-lazy.js
+media/player/videojs/amd/src/Youtube-lazy.js
 media/player/videojs/videojs/
 mod/assign/feedback/editpdf/fpdi/
 repository/s3/S3.php
diff --git a/.gherkin-lintrc b/.gherkin-lintrc
new file mode 100644 (file)
index 0000000..9439956
--- /dev/null
@@ -0,0 +1,20 @@
+{
+  "indentation": ["on",{
+    "Feature": 0,
+    "Background": 2,
+    "Scenario": 2,
+    "Step": 4,
+    "given": 4,
+    "and": 4
+  }],
+  "no-dupe-feature-names": "on",
+  "no-dupe-scenario-names": "off",
+  "no-empty-file": "on",
+  "no-files-without-scenarios": "on",
+  "no-multiple-empty-lines": "on",
+  "no-partially-commented-tag-lines": "on",
+  "no-trailing-spaces": "on",
+  "no-unamed-features": "on",
+  "no-unamed-scenarios": "on",
+  "no-scenario-outlines-without-examples": "on"
+}
index cafa933..48f1959 100644 (file)
@@ -57,7 +57,8 @@ lib/amd/src/chartjs-lazy.js
 lib/maxmind/GeoIp2/
 lib/maxmind/MaxMind/
 lib/ltiprovider/
-media/player/videojs/amd/src/
+media/player/videojs/amd/src/video-lazy.js
+media/player/videojs/amd/src/Youtube-lazy.js
 media/player/videojs/videojs/
 mod/assign/feedback/editpdf/fpdi/
 repository/s3/S3.php
index 5852cc4..4cb9e9e 100644 (file)
@@ -106,7 +106,6 @@ module.exports = function(grunt) {
         return libs;
     };
 
-
     // Project configuration.
     grunt.initConfig({
         eslint: {
@@ -171,6 +170,10 @@ module.exports = function(grunt) {
                 files: ['**/yui/src/**/*.js'],
                 tasks: ['yui']
             },
+            gherkinlint: {
+                files: ['**/tests/behat/*.feature'],
+                tasks: ['gherkinlint']
+            }
         },
         shifter: {
             options: {
@@ -178,6 +181,11 @@ module.exports = function(grunt) {
                 paths: [cwd]
             }
         },
+        gherkinlint: {
+            options: {
+                files: ['**/tests/behat/*.feature'],
+            }
+        },
         stylelint: {
             less: {
                 options: {
@@ -318,6 +326,22 @@ module.exports = function(grunt) {
         }, done);
     };
 
+    tasks.gherkinlint = function() {
+        var done = this.async(),
+            options = grunt.config('gherkinlint.options');
+
+        var args = grunt.file.expand(options.files);
+        args.unshift(path.normalize(__dirname + '/node_modules/.bin/gherkin-lint'));
+        grunt.util.spawn({
+            cmd: 'node',
+            args: args,
+            opts: {stdio: 'inherit', env: process.env}
+        }, function(error, result, code) {
+            // Propagate the exit code.
+            done(code);
+        });
+    };
+
     tasks.startup = function() {
         // Are we in a YUI directory?
         if (path.basename(path.resolve(cwd, '../../')) == 'yui') {
@@ -329,6 +353,7 @@ module.exports = function(grunt) {
             // Run them all!.
             grunt.task.run('css');
             grunt.task.run('js');
+            grunt.task.run('gherkinlint');
         }
     };
 
@@ -343,6 +368,7 @@ module.exports = function(grunt) {
           grunt.config('uglify.amd.files', [{expand: true, src: files, rename: uglifyRename}]);
           grunt.config('shifter.options.paths', files);
           grunt.config('stylelint.less.src', files);
+          grunt.config('gherkinlint.options.files', files);
           changedFiles = Object.create(null);
     }, 200);
 
@@ -360,6 +386,7 @@ module.exports = function(grunt) {
 
     // Register JS tasks.
     grunt.registerTask('shifter', 'Run Shifter against the current directory', tasks.shifter);
+    grunt.registerTask('gherkinlint', 'Run gherkinlint against the current directory', tasks.gherkinlint);
     grunt.registerTask('ignorefiles', 'Generate ignore files for linters', tasks.ignorefiles);
     grunt.registerTask('yui', ['eslint:yui', 'shifter']);
     grunt.registerTask('amd', ['eslint:amd', 'uglify']);
diff --git a/admin/templates/setting_configmultiselect_optgroup.mustache b/admin/templates/setting_configmultiselect_optgroup.mustache
new file mode 100644 (file)
index 0000000..9fa61c5
--- /dev/null
@@ -0,0 +1,71 @@
+{{!
+    This file is part of Moodle - http://moodle.org/
+
+    Moodle is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    Moodle is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+}}
+{{!
+    @template core_admin/setting_configmultiselect_optgroup
+
+    Admin multiselect setting template with optgroup support.
+
+    Context variables required for this template:
+    * name - form element name
+    * id - element id
+    * size - element size
+    * options - list of options not grouped
+    * optgroups - list of options grouped containing the group label and for each option: name, value, selected
+
+    Example context (json):
+    {
+        "name": "test",
+        "id": "test0",
+        "size": "3",
+        "options": [
+            { "name": "Option 1", "value": "V", "selected": false },
+            { "name": "Option 2", "value": "V", "selected": true }
+        ],
+        "optgroups": [
+            {
+                "label": "Group 1",
+                "options": [
+                    { "name": "Option 3", "value": "V", "selected": false },
+                    { "name": "Option 4", "value": "V", "selected": true }
+                ]
+            },
+            {
+                "label": "Group 2",
+                "options": [
+                    { "name": "Option 5", "value": "V", "selected": false },
+                    { "name": "Option 6", "value": "V", "selected": true }
+                ]
+            }
+        ]
+    }
+}}
+<div class="form-select">
+    <input type="hidden" name="{{name}}[xxxxx]" value="1">
+    <select id="{{id}}" name="{{name}}[]" size="{{size}}" multiple>
+        {{#options}}
+            <option value="{{value}}" {{#selected}}selected{{/selected}}>{{name}}</option>
+        {{/options}}
+        {{#optgroups}}
+            <optgroup label="{{label}}">
+                {{#options}}
+                    <option value="{{value}}" {{#selected}}selected{{/selected}}>{{name}}</option>
+                {{/options}}
+            </optgroup>
+        {{/optgroups}}
+    </select>
+</div>
+
diff --git a/admin/templates/setting_configselect_optgroup.mustache b/admin/templates/setting_configselect_optgroup.mustache
new file mode 100644 (file)
index 0000000..ea5da12
--- /dev/null
@@ -0,0 +1,68 @@
+{{!
+    This file is part of Moodle - http://moodle.org/
+
+    Moodle is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    Moodle is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+}}
+{{!
+    @template core_admin/setting_configselect_optgroup
+
+    Admin select with optgroup setting template.
+
+    Context variables required for this template:
+    * name - form element name
+    * id - element id
+    * options - list of options (not grouped)
+    * optgroups - list of options grouped containing the group label and for each option: name, value, selected
+
+    Example context (json):
+    {
+        "name": "test",
+        "id": "test0",
+        "options": [
+            { "name": "Option 1", "value": "V", "selected": false },
+            { "name": "Option 2", "value": "V", "selected": false }
+        ],
+        "optgroups": [
+            {
+                "label": "Group 1",
+                "options": [
+                    { "name": "Option 3", "value": "V", "selected": true },
+                    { "name": "Option 4", "value": "V", "selected": false }
+                ]
+            },
+            {
+                "label": "Group 2",
+                "options": [
+                    { "name": "Option 5", "value": "V", "selected": false },
+                    { "name": "Option 6", "value": "V", "selected": false }
+                ]
+            }
+        ]
+    }
+}}
+<div class="form-select defaultsnext">
+    <select id="{{id}}" name="{{name}}">
+        {{#options}}
+            <option value="{{value}}" {{#selected}}selected{{/selected}}>{{name}}</option>
+        {{/options}}
+        {{#optgroups}}
+            <optgroup label="{{label}}">
+                {{#options}}
+                    <option value="{{value}}" {{#selected}}selected{{/selected}}>{{name}}</option>
+                {{/options}}
+            </optgroup>
+        {{/optgroups}}
+    </select>
+</div>
+
index a228caf..63e19d2 100644 (file)
@@ -54,6 +54,7 @@ list($options, $unrecognised) = cli_get_params(
         'fromrun'  => 1,
         'torun'    => 0,
         'single-run' => false,
+        'rerun' => 0,
     ),
     array(
         'h' => 'help',
@@ -77,6 +78,7 @@ Options:
 --replace          Replace args string with run process number, useful for output.
 --fromrun          Execute run starting from (Used for parallel runs on different vms)
 --torun            Execute run till (Used for parallel runs on different vms)
+--rerun            Re-run scenarios that failed during last execution.
 
 -h, --help         Print out this help
 
@@ -91,11 +93,31 @@ if (!empty($options['help'])) {
     exit(0);
 }
 
-$parallelrun = behat_config_manager::get_parallel_test_runs($options['fromrun']);
+$parallelrun = behat_config_manager::get_behat_run_config_value('parallel');
 
-// Default torun is maximum parallel runs.
-if (empty($options['torun'])) {
-    $options['torun'] = $parallelrun;
+// Check if the options provided are valid to run behat.
+if ($parallelrun === false) {
+    // Parallel run should not have fromrun or torun options greater than 1.
+    if (($options['fromrun'] > 1) || ($options['torun'] > 1)) {
+        echo "Test site is not initialized  for parallel run." . PHP_EOL;
+        exit(1);
+    }
+} else {
+    // Ensure fromrun is within limits of initialized test site.
+    if (!empty($options['fromrun']) && ($options['fromrun'] > $parallelrun)) {
+        echo "From run (" . $options['fromrun'] . ") is more than site with parallel runs (" . $parallelrun . ")" . PHP_EOL;
+        exit(1);
+    }
+
+    // Default torun is maximum parallel runs and should be less than equal to parallelruns.
+    if (empty($options['torun'])) {
+        $options['torun'] = $parallelrun;
+    } else {
+        if ($options['torun'] > $parallelrun) {
+            echo "To run (" . $options['torun'] . ") is more than site with parallel runs (" . $parallelrun . ")" . PHP_EOL;
+            exit(1);
+        }
+    }
 }
 
 // Capture signals and ensure we clean symlinks.
@@ -127,7 +149,7 @@ if ($options['profile']) {
         exit(1);
     }
 
-    $extraopts[] = '--profile="' . $profile . '"';
+    $extraopts['profile'] = '--profile="' . $profile . '"';
     // By default, profile tags will be used.
     if (!empty($CFG->behat_config[$profile]['filters']['tags'])) {
         $tags = $CFG->behat_config[$profile]['filters']['tags'];
@@ -137,117 +159,159 @@ if ($options['profile']) {
 // Command line tags have precedence (std behat behavior).
 if ($options['tags']) {
     $tags = $options['tags'];
-    $extraopts[] = '--tags="' . $tags . '"';
+    $extraopts['tags'] = '--tags="' . $tags . '"';
 }
 
 // Add suite option if specified.
 if ($options['suite']) {
-    $extraopts[] = '--suite="' . $options['suite'] . '"';
+    $extraopts['suite'] = '--suite="' . $options['suite'] . '"';
 }
 
 // Feature should be added to last, for behat command.
 if ($options['feature']) {
-    $extraopts[] = $options['feature'];
+    $extraopts['feature'] = $options['feature'];
     // Only run 1 process as process.
     // Feature file is picked from absolute path provided, so no need to check for behat.yml.
     $options['torun'] = $options['fromrun'];
 }
 
 // Set of options to pass to behat.
-$extraopts = implode(' ', $extraopts);
+$extraoptstr = implode(' ', $extraopts);
+
+// If rerun is passed then ensure we just run the failed processes.
+$lastfailedstatus = 0;
+$lasttorun = $options['torun'];
+$lastfromrun = $options['fromrun'];
+if ($options['rerun']) {
+    // Get last combined failed status.
+    $lastfailedstatus = behat_config_manager::get_behat_run_config_value('lastcombinedfailedstatus');
+    $lasttorun = behat_config_manager::get_behat_run_config_value('lasttorun');
+    $lastfromrun = behat_config_manager::get_behat_run_config_value('lastfromrun');
+
+    if ($lastfailedstatus !== false) {
+        $extraoptstr .= ' --rerun';
+    }
 
-// If empty parallelrun then just check with user if it's a run single behat test.
+    // If torun is less than last torun, then just set this to min last to run and similar for fromrun.
+    if ($options['torun'] < $lasttorun) {
+        $options['torun'];
+    }
+    if ($options['fromrun'] > $lastfromrun) {
+        $options['fromrun'];
+    }
+    unset($options['rerun']);
+}
+
+$cmds = array();
+$exitcodes = array();
+$status = 0;
+$verbose = empty($options['verbose']) ? false : true;
+
+// Execute behat run commands.
 if (empty($parallelrun)) {
     $cwd = getcwd();
     chdir(__DIR__);
     $runtestscommand = behat_command::get_behat_command(false, false, true);
     $runtestscommand .= ' --config ' . behat_config_manager::get_behat_cli_config_filepath();
-    $runtestscommand .= ' ' . $extraopts;
+    $runtestscommand .= ' ' . $extraoptstr;
     echo "Running single behat site:" . PHP_EOL;
-    passthru("php $runtestscommand", $code);
+    passthru("php $runtestscommand", $status);
     chdir($cwd);
-    exit($code);
-}
-
-$cmds = array();
-echo "Running " . ($options['torun'] - $options['fromrun'] + 1) . " parallel behat sites:" . PHP_EOL;
-
-for ($i = $options['fromrun']; $i <= $options['torun']; $i++) {
-    $CFG->behatrunprocess = $i;
+} else {
 
-    // Options parameters to be added to each run.
-    $myopts = !empty($options['replace']) ? str_replace($options['replace'], $i, $extraopts) : $extraopts;
+    echo "Running " . ($options['torun'] - $options['fromrun'] + 1) . " parallel behat sites:" . PHP_EOL;
 
-    $behatcommand = behat_command::get_behat_command(false, false, true);
-    $behatconfigpath = behat_config_manager::get_behat_cli_config_filepath($i);
+    for ($i = $options['fromrun']; $i <= $options['torun']; $i++) {
+        $lastfailed = 1 & $lastfailedstatus >> ($i - 1);
 
-    // Command to execute behat run.
-    $cmds[BEHAT_PARALLEL_SITE_NAME . $i] = $behatcommand . ' --config ' . $behatconfigpath . " " . $myopts;
-    echo "[" . BEHAT_PARALLEL_SITE_NAME . $i . "] " . $cmds[BEHAT_PARALLEL_SITE_NAME . $i] . PHP_EOL;
-}
+        // Bypass if not failed in last run.
+        if ($lastfailedstatus && !$lastfailed && ($i <= $lasttorun) && ($i >= $lastfromrun)) {
+            continue;
+        }
 
-if (empty($cmds)) {
-    echo "No commands to execute " . PHP_EOL;
-    exit(1);
-}
+        $CFG->behatrunprocess = $i;
 
-// Create site symlink if necessary.
-if (!behat_config_manager::create_parallel_site_links($options['fromrun'], $options['torun'])) {
-    echo "Check permissions. If on windows, make sure you are running this command as admin" . PHP_EOL;
-    exit(1);
-}
+        // Options parameters to be added to each run.
+        $myopts = !empty($options['replace']) ? str_replace($options['replace'], $i, $extraoptstr) : $extraoptstr;
 
-// Execute all commands, relative to moodle root directory.
-$processes = cli_execute_parallel($cmds, __DIR__ . "/../../../../");
-$stoponfail = empty($options['stop-on-failure']) ? false : true;
+        $behatcommand = behat_command::get_behat_command(false, false, true);
+        $behatconfigpath = behat_config_manager::get_behat_cli_config_filepath($i);
 
-// Print header.
-print_process_start_info($processes);
+        // Command to execute behat run.
+        $cmds[BEHAT_PARALLEL_SITE_NAME . $i] = $behatcommand . ' --config ' . $behatconfigpath . " " . $myopts;
+        echo "[" . BEHAT_PARALLEL_SITE_NAME . $i . "] " . $cmds[BEHAT_PARALLEL_SITE_NAME . $i] . PHP_EOL;
+    }
 
-// Print combined run o/p from processes.
-$exitcodes = print_combined_run_output($processes, $stoponfail);
-$time = round(microtime(true) - $time, 1);
-echo "Finished in " . gmdate("G\h i\m s\s", $time) . PHP_EOL . PHP_EOL;
+    if (empty($cmds)) {
+        echo "No commands to execute " . PHP_EOL;
+        exit(1);
+    }
 
-ksort($exitcodes);
+    // Create site symlink if necessary.
+    if (!behat_config_manager::create_parallel_site_links($options['fromrun'], $options['torun'])) {
+        echo "Check permissions. If on windows, make sure you are running this command as admin" . PHP_EOL;
+        exit(1);
+    }
 
-// Print exit info from each run.
-// Status bits contains pass/fail status of parallel runs.
-$status = 0;
-$processcounter = 0;
-foreach ($exitcodes as $exitcode) {
-    if ($exitcode) {
-        $status |= (1 << $processcounter);
+    // Save torun and from run, so it can be used to detect if it was executed in last run.
+    behat_config_manager::set_behat_run_config_value('lasttorun', $options['torun']);
+    behat_config_manager::set_behat_run_config_value('lastfromrun', $options['fromrun']);
+
+    // Execute all commands, relative to moodle root directory.
+    $processes = cli_execute_parallel($cmds, __DIR__ . "/../../../../");
+    $stoponfail = empty($options['stop-on-failure']) ? false : true;
+
+    // Print header.
+    print_process_start_info($processes);
+
+    // Print combined run o/p from processes.
+    $exitcodes = print_combined_run_output($processes, $stoponfail);
+    // Time to finish run.
+    $time = round(microtime(true) - $time, 1);
+    echo "Finished in " . gmdate("G\h i\m s\s", $time) . PHP_EOL . PHP_EOL;
+    ksort($exitcodes);
+
+    // Print exit info from each run.
+    // Status bits contains pass/fail status of parallel runs.
+    foreach ($exitcodes as $name => $exitcode) {
+        if ($exitcode) {
+            $runno = str_replace(BEHAT_PARALLEL_SITE_NAME, '', $name);
+            $status |= (1 << ($runno - 1));
+        }
     }
-    $processcounter++;
+
+    // Print each process information.
+    print_each_process_info($processes, $verbose, $status);
 }
 
-// Run finished. Show exit code and output from individual process.
-$verbose = empty($options['verbose']) ? false : true;
-$verbose = $verbose || !empty($status);
-
-// Show exit code from each process, if any process failed.
-if ($verbose) {
-    // Echo exit codes.
-    echo "Exit codes for each behat run: " . PHP_EOL;
-    foreach ($exitcodes as $run => $exitcode) {
-        echo $run . ": " . $exitcode . PHP_EOL;
-    }
+// Show exit code from each process, if any process failed and how to rerun failed process.
+if ($verbose || $status) {
+    // Save final exit code containing which run failed.
+    behat_config_manager::set_behat_run_config_value('lastcombinedfailedstatus', $status);
 
     // Show failed re-run commands.
     if ($status) {
-        echo "To re-run failed processes, you can use following commands:" . PHP_EOL;
-        foreach ($cmds as $name => $cmd) {
-            if (!empty($exitcodes[$name])) {
-                echo "[" . $name . "] " . $cmd . PHP_EOL;
+        if (!empty($cmds)) {
+            // Echo exit codes.
+            echo "Exit codes for each behat run: " . PHP_EOL;
+            foreach ($exitcodes as $run => $exitcode) {
+                echo $run . ": " . $exitcode . PHP_EOL;
             }
         }
+
+        echo "To re-run failed processes, you can use following command:" . PHP_EOL;
+        unset($extraopts['fromrun']);
+        unset($extraopts['torun']);
+        $extraopts['rerun'] = '--rerun';
+        if (!empty($options['replace'])) {
+            $extraopts['replace'] =  '--replace="' . $options['replace'] . '"';
+        }
+        $extraoptstr = implode(' ', $extraopts);
+        echo behat_command::get_behat_command(true, true, true) . " " . $extraoptstr . PHP_EOL;
     }
     echo PHP_EOL;
 }
 
-print_each_process_info($processes, $verbose);
-
 // Remove site symlink if necessary.
 behat_config_manager::drop_parallel_site_links();
 
@@ -364,23 +428,47 @@ function print_combined_run_output($processes, $stoponfail = false) {
  * @param array $processes list of processes to loop though.
  * @param bool $verbose Show verbose output for each process.
  */
-function print_each_process_info($processes, $verbose = false) {
+function print_each_process_info($processes, $verbose = false, $status = 0) {
     foreach ($processes as $name => $process) {
         echo "**************** [" . $name . "] ****************" . PHP_EOL;
         if ($verbose) {
             echo $process->getOutput();
             echo $process->getErrorOutput();
-        } else {
-            $op = explode(PHP_EOL, $process->getOutput());
-            foreach ($op as $line) {
-                // Don't print progress .
-                if (trim($line) && (strpos($line, '.') !== 0) && (strpos($line, 'Moodle ') !== 0) &&
-                    (strpos($line, 'Server OS ') !== 0) && (strpos($line, 'Started at ') !== 0) &&
-                    (strpos($line, 'Browser specific fixes ') !== 0)) {
-                    echo $line . PHP_EOL;
-                }
+
+        } else if ($status) {
+            // Only show failed o/p.
+            $runno = str_replace(BEHAT_PARALLEL_SITE_NAME, '', $name);
+            if ((1 << ($runno - 1)) & $status) {
+                echo $process->getOutput();
+                echo $process->getErrorOutput();
+            } else {
+                echo get_status_lines_from_run_op($process);
             }
+
+        } else {
+            echo get_status_lines_from_run_op($process);
         }
         echo PHP_EOL;
     }
 }
+
+/**
+ * Extract status information from behat o/p and return.
+ * @param Symfony\Component\Process\Process $process
+ * @return string
+ */
+function get_status_lines_from_run_op(Symfony\Component\Process\Process $process) {
+    $statusstr = '';
+    $op = explode(PHP_EOL, $process->getOutput());
+    foreach ($op as $line) {
+        // Don't print progress .
+        if (trim($line) && (strpos($line, '.') !== 0) && (strpos($line, 'Moodle ') !== 0) &&
+            (strpos($line, 'Server OS ') !== 0) && (strpos($line, 'Started at ') !== 0) &&
+            (strpos($line, 'Browser specific fixes ') !== 0)) {
+            $statusstr .= $line . PHP_EOL;
+        }
+    }
+
+    return $statusstr;
+}
+
index b157ca7..8efa4ed 100644 (file)
@@ -36,11 +36,7 @@ define('NO_OUTPUT_BUFFERING', true);
 define('IGNORE_COMPONENT_CACHE', true);
 define('ABORT_AFTER_CONFIG', true);
 
-require_once(__DIR__ . '/../../../../config.php');
 require_once(__DIR__ . '/../../../../lib/clilib.php');
-require_once(__DIR__ . '/../../../../lib/behat/lib.php');
-require_once(__DIR__ . '/../../../../lib/behat/classes/behat_command.php');
-require_once(__DIR__ . '/../../../../lib/behat/classes/behat_config_manager.php');
 
 // CLI options.
 list($options, $unrecognized) = cli_get_params(
@@ -103,14 +99,26 @@ if (!empty($options['help'])) {
 
 $cwd = getcwd();
 
+// If Behat parallel site is being initiliased, then define a param to be used to ignore single run install.
+if (!empty($options['parallel'])) {
+    define('BEHAT_PARALLEL_UTIL', true);
+}
+
+require_once(__DIR__ . '/../../../../config.php');
+require_once(__DIR__ . '/../../../../lib/behat/lib.php');
+require_once(__DIR__ . '/../../../../lib/behat/classes/behat_command.php');
+require_once(__DIR__ . '/../../../../lib/behat/classes/behat_config_manager.php');
+
 // For drop option check if parallel site.
 if ((empty($options['parallel'])) && ($options['drop']) || $options['updatesteps']) {
-    // Get parallel run info from first run.
-    $options['parallel'] = behat_config_manager::get_parallel_test_runs($options['fromrun']);
+    $options['parallel'] = behat_config_manager::get_behat_run_config_value('parallel');
 }
 
 // If not a parallel site then open single run.
 if (empty($options['parallel'])) {
+    // Set run config value for single run.
+    behat_config_manager::set_behat_run_config_value('singlerun', 1);
+
     chdir(__DIR__);
     // Check if behat is initialised, if not exit.
     passthru("php util_single_run.php --diag", $status);
@@ -147,6 +155,21 @@ if ($options['diag'] || $options['enable'] || $options['disable']) {
         $status = (bool)$status || (bool)$exitcode;
     }
 
+    // Remove run config file.
+    $behatrunconfigfile = behat_config_manager::get_behat_run_config_file_path();
+    if (file_exists($behatrunconfigfile)) {
+        if (!unlink($behatrunconfigfile)) {
+            behat_error(BEHAT_EXITCODE_PERMISSIONS, 'Can not delete behat run config file');
+        }
+    }
+
+    // Remove test file path.
+    if (file_exists(behat_util::get_test_file_path())) {
+        if (!unlink(behat_util::get_test_file_path())) {
+            behat_error(BEHAT_EXITCODE_PERMISSIONS, 'Can not delete test file enable info');
+        }
+    }
+
 } else if ($options['install']) {
     // This is intensive compared to behat itself so run them in chunk if option maxruns not set.
     if ($options['maxruns']) {
@@ -233,6 +256,19 @@ if ($options['install']) {
 } else if ($options['enable']) {
     echo "Acceptance tests environment enabled on $CFG->behat_wwwroot, to run the tests use:" . PHP_EOL;
     echo behat_command::get_behat_command(true, true);
+
+    // Save fromrun and to run information.
+    if (isset($options['fromrun'])) {
+        behat_config_manager::set_behat_run_config_value('fromrun', $options['fromrun']);
+    }
+
+    if (isset($options['torun'])) {
+        behat_config_manager::set_behat_run_config_value('torun', $options['torun']);
+    }
+    if (isset($options['parallel'])) {
+        behat_config_manager::set_behat_run_config_value('parallel', $options['parallel']);
+    }
+
     echo PHP_EOL;
 
 } else if ($options['disable']) {
index 3d0e2db..2e98656 100644 (file)
@@ -143,7 +143,7 @@ if ($options['run']) {
     $run = $options['run'];
     // If parallel option is not passed, then try get it form config.
     if (!$options['parallel']) {
-        $parallel = behat_config_manager::get_parallel_test_runs();
+        $parallel = behat_config_manager::get_behat_run_config_value('parallel');
     } else {
         $parallel = $options['parallel'];
     }
@@ -176,10 +176,7 @@ if ($options['install']) {
 } else if ($options['enable']) {
     if (!empty($parallel)) {
         // Save parallel site info for enable and install options.
-        $filepath = behat_config_manager::get_parallel_test_file_path();
-        if (!file_put_contents($filepath, $parallel)) {
-            behat_error(BEHAT_EXITCODE_PERMISSIONS, 'File ' . $filepath . ' can not be created');
-        }
+        behat_config_manager::set_behat_run_config_value('behatsiteenabled', 1);
     }
 
     // Enable test mode.
@@ -200,7 +197,7 @@ if ($options['install']) {
     }
 
 } else if ($options['disable']) {
-    behat_util::stop_test_mode();
+    behat_util::stop_test_mode($run);
     // This is only displayed once for parallel install.
     if (empty($run)) {
         mtrace("Acceptance tests environment disabled");
index f9ac3a1..4b467bc 100644 (file)
@@ -125,7 +125,6 @@ Feature: Verify that all form fields values can be get and set
     And I navigate to "Edit settings" node in "Course administration"
     And the field "Course ID number" matches value "Course id number"
 
-
   Scenario: with JS disabled all form fields getters and setters works as expected
 
   @javascript
index 3e4d31e..708a0e7 100644 (file)
@@ -26,4 +26,3 @@ Feature: List the system steps definitions
     Given I set the field "Contains" to "homepage"
     When I press "Filter"
     Then I should see "Opens Moodle homepage."
-
index e610e35..8357e70 100644 (file)
@@ -149,13 +149,13 @@ class api {
         // We build an better structure to loop on.
         $info = array();
         foreach ($all as $cra) {
-            if (!isset($info[$cra->get_userid()])) {
-                $info[$cra->get_userid()] = array();
+            if (!isset($info[$cra->get('userid')])) {
+                $info[$cra->get('userid')] = array();
             }
-            if (!isset($info[$cra->get_userid()][$cra->get_roleid()])) {
-                $info[$cra->get_userid()][$cra->get_roleid()] = array();
+            if (!isset($info[$cra->get('userid')][$cra->get('roleid')])) {
+                $info[$cra->get('userid')][$cra->get('roleid')] = array();
             }
-            array_push($info[$cra->get_userid()][$cra->get_roleid()], $cra->get_cohortid());
+            array_push($info[$cra->get('userid')][$cra->get('roleid')], $cra->get('cohortid'));
         }
         // Then for each user+role combo - find user context in the cohort without a role assigned.
 
index 2fa061b..d276a2f 100644 (file)
@@ -96,10 +96,10 @@ class tool_cohortroles_api_testcase extends advanced_testcase {
             'cohortid' => $this->cohort->id
         );
         $result = api::create_cohort_role_assignment($params);
-        $this->assertNotEmpty($result->get_id());
-        $this->assertEquals($result->get_userid(), $this->userassignto->id);
-        $this->assertEquals($result->get_roleid(), $this->roleid);
-        $this->assertEquals($result->get_cohortid(), $this->cohort->id);
+        $this->assertNotEmpty($result->get('id'));
+        $this->assertEquals($result->get('userid'), $this->userassignto->id);
+        $this->assertEquals($result->get('roleid'), $this->roleid);
+        $this->assertEquals($result->get('cohortid'), $this->cohort->id);
     }
 
     /**
@@ -114,7 +114,7 @@ class tool_cohortroles_api_testcase extends advanced_testcase {
         );
         $result = api::create_cohort_role_assignment($params);
         $this->setUser($this->userassignto);
-        api::delete_cohort_role_assignment($result->get_id());
+        api::delete_cohort_role_assignment($result->get('id'));
     }
 
     /**
@@ -128,7 +128,7 @@ class tool_cohortroles_api_testcase extends advanced_testcase {
             'cohortid' => $this->cohort->id
         );
         $result = api::create_cohort_role_assignment($params);
-        api::delete_cohort_role_assignment($result->get_id() + 1);
+        api::delete_cohort_role_assignment($result->get('id') + 1);
     }
 
     public function test_delete_cohort_role_assignment() {
@@ -139,7 +139,7 @@ class tool_cohortroles_api_testcase extends advanced_testcase {
             'cohortid' => $this->cohort->id
         );
         $result = api::create_cohort_role_assignment($params);
-        $worked = api::delete_cohort_role_assignment($result->get_id());
+        $worked = api::delete_cohort_role_assignment($result->get('id'));
         $this->assertTrue($worked);
     }
 
diff --git a/admin/tool/langimport/classes/output/langimport_page.php b/admin/tool/langimport/classes/output/langimport_page.php
new file mode 100644 (file)
index 0000000..97ff743
--- /dev/null
@@ -0,0 +1,110 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Language import page.
+ *
+ * @package    tool_langimport
+ * @copyright  2016 Jun Pataleta
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+namespace tool_langimport\output;
+defined('MOODLE_INTERNAL') || die();
+
+use moodle_url;
+use renderable;
+use renderer_base;
+use stdClass;
+use templatable;
+
+/**
+ * Language import page class.
+ *
+ * @package    tool_langimport
+ * @copyright  2016 Jun Pataleta
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class langimport_page implements renderable, templatable {
+
+    /** @var array Array of currently installed languages. */
+    protected $installedlanguages;
+
+    /** @var array Array of languages that can be installed. */
+    protected $availablelanguages;
+
+    /** @var moodle_url The URL to be used for uninstalling the selected existing language packs. */
+    protected $uninstallurl;
+
+    /** @var moodle_url The URL to be used for updating the installed language packs. */
+    protected $updateurl;
+
+    /** @var moodle_url The URL to be used for installing the selected language packs to be installed. */
+    protected $installurl;
+
+
+    /**
+     * langimport_page constructor.
+     *
+     * @param array $installedlanguages Array of currently installed languages.
+     * @param array $availablelanguages Array of languages that can be installed.
+     * @param moodle_url $uninstallurl The URL to be used for uninstalling the selected existing language packs.
+     * @param moodle_url $updateurl The URL to be used for updating the installed language packs.
+     * @param moodle_url $installurl The URL to be used for installing the selected language packs to be installed.
+     */
+    public function __construct($installedlanguages, $availablelanguages, $uninstallurl, $updateurl, $installurl) {
+        $this->installedlanguages = $installedlanguages;
+        $this->availablelanguages = $availablelanguages;
+        $this->uninstallurl = $uninstallurl;
+        $this->updateurl = $updateurl;
+        $this->installurl = $installurl;
+    }
+
+    /**
+     * Export the data.
+     *
+     * @param renderer_base $output
+     * @return stdClass
+     */
+    public function export_for_template(renderer_base $output) {
+        $data = new stdClass();
+        $data->uninstallurl = $this->uninstallurl;
+        $data->sesskey = sesskey();
+
+        $data->installedoptions = [];
+        foreach ($this->installedlanguages as $code => $language) {
+            $option = new stdClass();
+            $option->value = $code;
+            $option->text = $language;
+            $data->installedoptions[] = $option;
+        }
+
+        $data->updateurl = $this->updateurl;
+
+        if (!empty($this->availablelanguages)) {
+            $data->toinstalloptions = [];
+            foreach ($this->availablelanguages as $code => $language) {
+                $option = new stdClass();
+                $option->value = $code;
+                $option->text = $language;
+                $data->toinstalloptions[] = $option;
+            }
+            $data->installurl = $this->installurl;
+            $data->caninstall = true;
+        }
+
+        return $data;
+    }
+}
diff --git a/admin/tool/langimport/classes/output/renderer.php b/admin/tool/langimport/classes/output/renderer.php
new file mode 100644 (file)
index 0000000..f74b11e
--- /dev/null
@@ -0,0 +1,50 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Renderers.
+ *
+ * @package    tool_langimport
+ * @copyright  2016 Jun Pataleta
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+namespace tool_langimport\output;
+
+defined('MOODLE_INTERNAL') || die();
+
+use plugin_renderer_base;
+
+/**
+ * Renderer class.
+ *
+ * @package    tool_langimport
+ * @copyright  2016 Jun Pataleta
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class renderer extends plugin_renderer_base {
+
+    /**
+     * Defer to template.
+     *
+     * @param langimport_page $page
+     * @return string
+     */
+    public function render_langimport_page(langimport_page $page) {
+        $data = $page->export_for_template($this);
+        return parent::render_from_template('tool_langimport/langimport', $data);
+    }
+}
index c5f49da..0e98a5d 100644 (file)
@@ -124,23 +124,22 @@ if ($availablelangs = $controller->availablelangs) {
 } else {
     $remote = false;
     $availablelangs = array();
-    echo $OUTPUT->box_start();
     $a = [
         'src' => $controller->lang_pack_url(),
         'dest' => $CFG->dataroot.'/lang/',
     ];
-    print_string('downloadnotavailable', 'tool_langimport', $a);
-    echo $OUTPUT->box_end();
+    $errormessage = get_string('downloadnotavailable', 'tool_langimport', $a);
+    \core\notification::error($errormessage);
 }
 
 if ($controller->info) {
     $info = implode('<br />', $controller->info);
-    echo $OUTPUT->notification($info, 'notifysuccess');
+    \core\notification::success($info);
 }
 
 if ($controller->errors) {
     $info = implode('<br />', $controller->errors);
-    echo $OUTPUT->notification($info, 'notifyproblem');
+    \core\notification::error($info);
 }
 
 if ($missingparents) {
@@ -155,67 +154,29 @@ if ($missingparents) {
             }
         }
         $info = get_string('missinglangparent', 'tool_langimport', $a);
-        echo $OUTPUT->notification($info, 'notifyproblem');
+        \core\notification::error($info);
     }
 }
 
-echo $OUTPUT->box_start();
-
-echo html_writer::start_tag('table');
-echo html_writer::start_tag('tr');
-
-// list of installed languages
-$url = new moodle_url('/admin/tool/langimport/index.php', array('mode' => DELETION_OF_SELECTED_LANG));
-echo html_writer::start_tag('td', array('valign' => 'top'));
-echo html_writer::start_tag('form', array('id' => 'uninstallform', 'action' => $url->out(), 'method' => 'post'));
-echo html_writer::start_tag('fieldset');
-echo html_writer::label(get_string('installedlangs', 'tool_langimport'), 'menuuninstalllang');
-echo html_writer::empty_tag('br');
-echo html_writer::select($installedlangs, 'uninstalllang[]', '', false, array('size' => 15, 'multiple' => 'multiple'));
-echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey()));
-echo html_writer::empty_tag('br');
-echo html_writer::empty_tag('input', array('id' => 'languninstallbutton',
-                                         'type' => 'submit',
-                                         'value' => get_string('uninstall', 'tool_langimport'))
-                            );
-echo html_writer::end_tag('fieldset');
-echo html_writer::end_tag('form');
+$uninstallurl = new moodle_url('/admin/tool/langimport/index.php', array('mode' => DELETION_OF_SELECTED_LANG));
+$updateurl = null;
 if ($remote) {
-    $url = new moodle_url('/admin/tool/langimport/index.php', array('mode' => UPDATE_ALL_LANG));
-    echo html_writer::start_tag('form', array('id' => 'updateform', 'action' => $url->out(), 'method' => 'post'));
-    echo html_writer::tag('fieldset', html_writer::empty_tag('input', array('type' => 'submit', 'value' => get_string('updatelangs','tool_langimport'))));
-    echo html_writer::end_tag('form');
+    $updateurl = new moodle_url('/admin/tool/langimport/index.php', array('mode' => UPDATE_ALL_LANG));
 }
-echo html_writer::end_tag('td');
+$installurl = new moodle_url('/admin/tool/langimport/index.php', array('mode' => INSTALLATION_OF_SELECTED_LANG));
 
-// list of available languages
+// List of available languages.
 $options = array();
 foreach ($availablelangs as $alang) {
     if (!empty($alang[0]) and trim($alang[0]) !== 'en' and !$controller->is_installed_lang($alang[0], $alang[1])) {
         $options[$alang[0]] = $alang[2].' &lrm;('.$alang[0].')&lrm;';
     }
 }
-if (!empty($options)) {
-    echo html_writer::start_tag('td', array('valign' => 'top'));
-    $url = new moodle_url('/admin/tool/langimport/index.php', array('mode' => INSTALLATION_OF_SELECTED_LANG));
-    echo html_writer::start_tag('form', array('id' => 'installform', 'action' => $url->out(), 'method' => 'post'));
-    echo html_writer::start_tag('fieldset');
-    echo html_writer::label(get_string('availablelangs','install'), 'menupack');
-    echo html_writer::empty_tag('br');
-    echo html_writer::select($options, 'pack[]', '', false, array('size' => 15, 'multiple' => 'multiple'));
-    echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey()));
-    echo html_writer::empty_tag('br');
-    echo html_writer::empty_tag('input', array('type' => 'submit', 'value' => get_string('install','tool_langimport')));
-    echo html_writer::end_tag('fieldset');
-    echo html_writer::end_tag('form');
-    echo html_writer::end_tag('td');
-}
 
-echo html_writer::end_tag('tr');
-echo html_writer::end_tag('table');
-echo $OUTPUT->box_end();
+$renderable = new \tool_langimport\output\langimport_page($installedlangs, $options, $uninstallurl, $updateurl, $installurl);
+$output = $PAGE->get_renderer('tool_langimport');
+echo $output->render($renderable);
 
-$uninstallurl = new moodle_url('/admin/tool/langimport/index.php');
 $PAGE->requires->strings_for_js(array('uninstallconfirm', 'uninstall', 'selectlangs', 'noenglishuninstall'),
                                 'tool_langimport');
 $PAGE->requires->yui_module('moodle-core-languninstallconfirm',
@@ -223,4 +184,3 @@ $PAGE->requires->yui_module('moodle-core-languninstallconfirm',
                              array(array('uninstallUrl' => $uninstallurl->out()))
                             );
 echo $OUTPUT->footer();
-die();
index 42d8a69..f23c99b 100644 (file)
@@ -1,9 +1,5 @@
-#page-admin-tool-langimport-index .generalbox table {
+#page-admin-tool-langimport-index .langimport {
     margin: auto;
+    float: none;
     width: 100%;
 }
-
-#page-admin-tool-langimport-index .generalbox,
-#page-admin-tool-langimport-index .generalbox table {
-    text-align: center;
-}
diff --git a/admin/tool/langimport/templates/langimport.mustache b/admin/tool/langimport/templates/langimport.mustache
new file mode 100644 (file)
index 0000000..25dc700
--- /dev/null
@@ -0,0 +1,117 @@
+{{!
+    This file is part of Moodle - http://moodle.org/
+
+    Moodle is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    Moodle is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+}}
+{{!
+    @template tool_langimport/langimport
+
+    Template for the language import page.
+
+    Classes required for JS:
+    * none
+
+    Data attributes required for JS:
+    * none
+
+    Context variables required for this template:
+    * sesskey string The session key.
+    * uninstallurl string The URL for the uninstall action.
+    * updateurl string The URL for the update-language-packs action.
+    * installurl string The URL for the install action.
+    * installedoptions array The list of languages installed.
+    * toinstalloptions array The list of languages to be installed.
+    * caninstall boolean Flag to indicate if there are language packs that can be installed.
+
+    Example context (json):
+    {
+        "sesskey": "sesskey",
+        "uninstallurl": "#",
+        "updateurl": "#",
+        "installurl": "#",
+        "installedoptions": [
+            {
+                "value": "en",
+                "text": "English",
+                "selected": true
+            }
+        ],
+        "toinstalloptions": [
+            {
+                "value": "ja",
+                "text": "Japanese"
+            },
+            {
+                "value": "fr",
+                "text": "French"
+            },
+            {
+                "value": "es",
+                "text": "Spanish"
+            }
+        ],
+        "caninstall": true
+    }
+}}
+<div class="container-fluid langimport">
+    <div class="row row-fluid rtl-compatible">
+        <div class="col-md-{{#caninstall}}6{{/caninstall}}{{^caninstall}}12{{/caninstall}} span{{#caninstall}}6{{/caninstall}}{{^caninstall}}12{{/caninstall}} m-b-1">
+            <form id="uninstallform" action="{{uninstallurl}}" method="post">
+                <fieldset>
+                    <div class="form-group">
+                        <label for="menuuninstalllang">{{#str}}installedlangs, tool_langimport{{/str}}</label>
+                        <select size="15" multiple="multiple" id="menuuninstalllang" class="form-control input-block-level" name="uninstalllang[]">
+                            {{#installedoptions}}
+                                <option value="{{value}}" {{#selected}}selected="selected"{{/selected}}>{{{text}}}‎</option>
+                            {{/installedoptions}}
+                        </select>
+                    </div>
+                    <div class="form-group">
+                        <input type="hidden" name="sesskey" value="{{sesskey}}">
+                        <input id="languninstallbutton" type="submit" value="{{#str}}uninstall, tool_langimport{{/str}}" class="btn btn-default">
+                    </div>
+                </fieldset>
+            </form>
+            {{#updateurl}}
+                <div>
+                    <form id="updateform" action="{{updateurl}}" method="post">
+                        <fieldset>
+                            <input type="submit" value="{{#str}}updatelangs, tool_langimport{{/str}}" class="btn btn-default">
+                        </fieldset>
+                    </form>
+                </div>
+            {{/updateurl}}
+        </div>
+        {{#caninstall}}
+            <div class="col-md-6 span6 m-b-1">
+                <form id="installform" action="{{installurl}}" method="post">
+                    <fieldset>
+                        <div class="form-group">
+                            <label for="menupack">{{#str}}availablelangs, install{{/str}}</label>
+                            <select size="15" multiple="multiple" class="form-control input-block-level" id="menupack" name="pack[]">
+                                {{#toinstalloptions}}
+                                    <option value="{{value}}" {{#selected}}selected="selected"{{/selected}}>{{{text}}}‎</option>
+                                {{/toinstalloptions}}
+                            </select>
+                        </div>
+                        <div class="form-group">
+                            <input type="hidden" name="sesskey" value="{{sesskey}}">
+                            <input type="submit" value="{{#str}}install, tool_langimport{{/str}}" class="btn btn-default">
+                        </div>
+                    </fieldset>
+                </form>
+            </div>
+        {{/caninstall}}
+    </div>
+</div>
index 6d6f0f0..e1b9170 100644 (file)
@@ -4,7 +4,6 @@ Feature: Manage language packs
   As an administrator
   I need to be able to add, update and remove language packs
 
-
   Background:
     Given remote langimport tests are enabled
 
index 4683e64..b7698c8 100644 (file)
@@ -65,7 +65,7 @@ class tool_lp_course_competencies_form_element extends MoodleQuickForm_autocompl
             $current = \core_competency\api::list_course_module_competencies_in_course_module($options['cmid']);
             $ids = array();
             foreach ($current as $coursemodulecompetency) {
-                array_push($ids, $coursemodulecompetency->get_competencyid());
+                array_push($ids, $coursemodulecompetency->get('competencyid'));
             }
             $this->setValue($ids);
         }
@@ -76,10 +76,10 @@ class tool_lp_course_competencies_form_element extends MoodleQuickForm_autocompl
         $context = context_course::instance($courseid);
         foreach ($competencies as $competency) {
             // We don't need to show the description as part of the options, so just set this to null.
-            $competency['competency']->set_description(null);
+            $competency['competency']->set('description', null);
             $exporter = new competency_exporter($competency['competency'], array('context' => $context));
             $templatecontext = array('competency' => $exporter->export($OUTPUT));
-            $id = $competency['competency']->get_id();
+            $id = $competency['competency']->get('id');
             $validoptions[$id] = $OUTPUT->render_from_template('tool_lp/competency_summary', $templatecontext);
         }
         $attributes['tags'] = false;
index 29fc72f..049fe98 100644 (file)
@@ -65,7 +65,7 @@ class tool_lp_course_competency_rule_form_element extends MoodleQuickForm_select
             // forcing them to be all the same for each activity.
             if (!empty($current)) {
                 $one = array_pop($current);
-                $this->setValue($one->get_ruleoutcome());
+                $this->setValue($one->get('ruleoutcome'));
             }
         }
         $validoptions = course_module_competency::get_ruleoutcome_list();
index 59608c5..6af0d41 100644 (file)
@@ -42,12 +42,12 @@ use external_multiple_structure;
 use invalid_parameter_exception;
 use required_capability_exception;
 
-use tool_lp\external\cohort_summary_exporter;
+use core_cohort\external\cohort_summary_exporter;
 use tool_lp\external\competency_path_exporter;
 use tool_lp\external\competency_summary_exporter;
 use tool_lp\external\course_competency_statistics_exporter;
-use tool_lp\external\course_module_summary_exporter;
-use tool_lp\external\course_summary_exporter;
+use core_course\external\course_module_summary_exporter;
+use core_course\external\course_summary_exporter;
 use tool_lp\external\template_statistics_exporter;
 use tool_lp\external\user_competency_summary_exporter;
 use tool_lp\external\user_competency_summary_in_course_exporter;
@@ -66,7 +66,7 @@ use core_competency\external\template_exporter;
 use core_competency\external\user_competency_course_exporter;
 use core_competency\external\user_competency_exporter;
 use core_competency\external\user_competency_plan_exporter;
-use core_competency\external\user_summary_exporter;
+use core_user\external\user_summary_exporter;
 
 /**
  * This is the external API for this tool.
index 1e9e1cf..1dfe496 100644 (file)
@@ -33,7 +33,7 @@ use moodle_url;
  * @copyright  2016 Issam Taboubi <issam.taboubi@umontreal.ca>
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
-class competency_path_exporter extends \core_competency\external\exporter {
+class competency_path_exporter extends \core\external\exporter {
 
     /**
      * Constructor.
@@ -72,7 +72,7 @@ class competency_path_exporter extends \core_competency\external\exporter {
                 'type' => path_node_exporter::read_properties_definition()
             ],
             'pluginbaseurl' => [
-                'type' => PARAM_TEXT
+                'type' => PARAM_URL
             ],
             'pagecontextid' => [
                 'type' => PARAM_INT
@@ -93,8 +93,8 @@ class competency_path_exporter extends \core_competency\external\exporter {
         $i = 1;
         foreach ($this->related['ancestors'] as $competency) {
             $exporter = new path_node_exporter([
-                    'id' => $competency->get_id(),
-                    'name' => $competency->get_idnumber(),
+                    'id' => $competency->get('id'),
+                    'name' => $competency->get('idnumber'),
                     'position' => $i,
                     'first' => $i == 1,
                     'last' => $i == $nodescount
@@ -107,8 +107,8 @@ class competency_path_exporter extends \core_competency\external\exporter {
         }
         $result->ancestors = $ancestors;
         $exporter = new path_node_exporter([
-                'id' => $this->related['framework']->get_id(),
-                'name' => $this->related['framework']->get_shortname(),
+                'id' => $this->related['framework']->get('id'),
+                'name' => $this->related['framework']->get('shortname'),
                 'first' => 0,
                 'last' => 0,
                 'position' => -1
index ff17471..af85059 100644 (file)
@@ -30,6 +30,7 @@ use stdClass;
 use core_competency\competency_framework;
 use core_competency\external\competency_exporter;
 use core_competency\external\competency_framework_exporter;
+use core_course\external\course_summary_exporter;
 
 /**
  * Class for exporting competency data with additional related data.
@@ -37,7 +38,7 @@ use core_competency\external\competency_framework_exporter;
  * @copyright  2015 Damyon Wiese
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
-class competency_summary_exporter extends \core_competency\external\exporter {
+class competency_summary_exporter extends \core\external\exporter {
 
     protected static function define_related() {
         // We cache the context so it does not need to be retrieved from the framework every time.
@@ -115,11 +116,11 @@ class competency_summary_exporter extends \core_competency\external\exporter {
 
         $exporter = new competency_framework_exporter($this->related['framework']);
         $result->framework = $exporter->export($output);
-        $scaleconfiguration = $this->related['framework']->get_scaleconfiguration();
-        $scaleid = $this->related['framework']->get_scaleid();
-        if ($competency->get_scaleid()) {
-            $scaleconfiguration = $competency->get_scaleconfiguration();
-            $scaleid = $competency->get_scaleid();
+        $scaleconfiguration = $this->related['framework']->get('scaleconfiguration');
+        $scaleid = $this->related['framework']->get('scaleid');
+        if ($competency->get('scaleid')) {
+            $scaleconfiguration = $competency->get('scaleconfiguration');
+            $scaleid = $competency->get('scaleid');
         }
         $result->scaleconfiguration = $scaleconfiguration;
         $result->scaleid = $scaleid;
index 1e603e0..15924d2 100644 (file)
@@ -27,6 +27,7 @@ defined('MOODLE_INTERNAL') || die();
 use renderer_base;
 use moodle_url;
 use core_competency\external\competency_exporter;
+use core_competency\external\performance_helper;
 
 /**
  * Class for exporting a course competency statistics summary.
@@ -34,7 +35,7 @@ use core_competency\external\competency_exporter;
  * @copyright  2015 Damyon Wiese
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
-class course_competency_statistics_exporter extends \core_competency\external\exporter {
+class course_competency_statistics_exporter extends \core\external\exporter {
 
     public static function define_properties() {
         return array(
@@ -84,12 +85,9 @@ class course_competency_statistics_exporter extends \core_competency\external\ex
             $proficientcompetencypercentageformatted = format_float($proficientcompetencypercentage);
         }
         $competencies = array();
-        $contextcache = array();
+        $helper = new performance_helper();
         foreach ($this->data->leastproficientcompetencies as $competency) {
-            if (!isset($contextcache[$competency->get_competencyframeworkid()])) {
-                $contextcache[$competency->get_competencyframeworkid()] = $competency->get_context();
-            }
-            $context = $contextcache[$competency->get_competencyframeworkid()];
+            $context = $helper->get_context_from_competency($competency);
             $exporter = new competency_exporter($competency, array('context' => $context));
             $competencies[] = $exporter->export($output);
         }
index 2b25ed2..93ef8cc 100644 (file)
@@ -24,6 +24,7 @@
 namespace tool_lp\external;
 defined('MOODLE_INTERNAL') || die();
 
+use context_system;
 
 /**
  * Class for exporting path_node data.
@@ -31,7 +32,35 @@ defined('MOODLE_INTERNAL') || die();
  * @copyright  2016 Issam Taboubi <issam.taboubi@umontreal.ca>
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
-class path_node_exporter extends \core_competency\external\exporter {
+class path_node_exporter extends \core\external\exporter {
+
+    /**
+     * Constructor - saves the persistent object, and the related objects.
+     *
+     * @param mixed $data The data.
+     * @param array $related Array of relateds.
+     */
+    public function __construct($data, $related = array()) {
+        if (!isset($related['context'])) {
+            // Previous code was automatically using the system context which was not always correct.
+            // We let developers know that they must fix their code without breaking anything,
+            // and fallback on the previous behaviour. This should be removed at a later stage: Moodle 3.5.
+            debugging('Missing related context in path_node_exporter.', DEBUG_DEVELOPER);
+            $related['context'] = context_system::instance();
+        }
+        parent::__construct($data, $related);
+    }
+
+    /**
+     * Return the list of properties.
+     *
+     * @return array
+     */
+    protected static function define_related() {
+        return [
+            'context' => 'context'
+        ];
+    }
 
     /**
      * Return the list of properties.
index e9f401b..3ec92ac 100644 (file)
@@ -27,6 +27,7 @@ defined('MOODLE_INTERNAL') || die();
 use renderer_base;
 use moodle_url;
 use core_competency\external\competency_exporter;
+use core_competency\external\performance_helper;
 
 /**
  * Class for exporting a cohort summary from an stdClass.
@@ -34,7 +35,7 @@ use core_competency\external\competency_exporter;
  * @copyright  2015 Damyon Wiese
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
-class template_statistics_exporter extends \core_competency\external\exporter {
+class template_statistics_exporter extends \core\external\exporter {
 
     public static function define_properties() {
         return array(
@@ -118,12 +119,9 @@ class template_statistics_exporter extends \core_competency\external\exporter {
             $proficientusercompetencyplanpercentageformatted = format_float($proficientusercompetencyplanpercentage);
         }
         $competencies = array();
-        $contextcache = array();
+        $helper = new performance_helper();
         foreach ($this->data->leastproficientcompetencies as $competency) {
-            if (!isset($contextcache[$competency->get_competencyframeworkid()])) {
-                $contextcache[$competency->get_competencyframeworkid()] = $competency->get_context();
-            }
-            $context = $contextcache[$competency->get_competencyframeworkid()];
+            $context = $helper->get_context_from_competency($competency);
             $exporter = new competency_exporter($competency, array('context' => $context));
             $competencies[] = $exporter->export($output);
         }
index b43dde8..229076e 100644 (file)
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 namespace tool_lp\external;
+defined('MOODLE_INTERNAL') || die();
 
 use context_user;
 use renderer_base;
 use stdClass;
-use core_competency\external\comment_area_exporter;
+use core_comment\external\comment_area_exporter;
 use core_competency\external\evidence_exporter;
 use core_competency\external\user_competency_exporter;
 use core_competency\external\user_competency_plan_exporter;
 use core_competency\external\user_competency_course_exporter;
-use core_competency\external\user_summary_exporter;
+use core_user\external\user_summary_exporter;
 use core_competency\user_competency;
 
 /**
@@ -40,7 +41,7 @@ use core_competency\user_competency;
  * @copyright  2015 Damyon Wiese
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
-class user_competency_summary_exporter extends \core_competency\external\exporter {
+class user_competency_summary_exporter extends \core\external\exporter {
 
     protected static function define_related() {
         // We cache the context so it does not need to be retrieved from the framework every time.
@@ -132,9 +133,9 @@ class user_competency_summary_exporter extends \core_competency\external\exporte
         $result->evidence = array();
         if (count($this->related['evidence'])) {
             foreach ($this->related['evidence'] as $evidence) {
-                $actionuserid = $evidence->get_actionuserid();
+                $actionuserid = $evidence->get('actionuserid');
                 if (!empty($actionuserid)) {
-                    $usercache[$evidence->get_actionuserid()] = true;
+                    $usercache[$evidence->get('actionuserid')] = true;
                 }
             }
             $users = array();
@@ -148,11 +149,12 @@ class user_competency_summary_exporter extends \core_competency\external\exporte
             }
 
             foreach ($this->related['evidence'] as $evidence) {
-                $actionuserid = $evidence->get_actionuserid();
+                $actionuserid = $evidence->get('actionuserid');
                 $related = array(
                     'scale' => $scale,
                     'usercompetency' => ($this->related['usercompetency'] ? $this->related['usercompetency'] : null),
                     'usercompetencyplan' => ($this->related['usercompetencyplan'] ? $this->related['usercompetencyplan'] : null),
+                    'context' => $evidence->get_context()
                 );
                 $related['actionuser'] = !empty($actionuserid) ? $usercache[$actionuserid] : null;
                 $exporter = new evidence_exporter($evidence, $related);
index f3be693..d1b7b7f 100644 (file)
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 namespace tool_lp\external;
+defined('MOODLE_INTERNAL') || die();
 
 use core_competency\api;
 use core_competency\user_competency;
+use core_course\external\course_module_summary_exporter;
+use core_course\external\course_summary_exporter;
 use context_course;
 use renderer_base;
 use stdClass;
@@ -35,7 +38,7 @@ use stdClass;
  * @copyright  2015 Damyon Wiese
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
-class user_competency_summary_in_course_exporter extends \core_competency\external\exporter {
+class user_competency_summary_in_course_exporter extends \core\external\exporter {
 
     protected static function define_related() {
         // We cache the context so it does not need to be retrieved from the framework every time.
@@ -80,7 +83,7 @@ class user_competency_summary_in_course_exporter extends \core_competency\extern
         $exporter = new course_summary_exporter($this->related['course'], array('context' => $context));
         $result->course = $exporter->export($output);
 
-        $coursemodules = api::list_course_modules_using_competency($this->related['competency']->get_id(),
+        $coursemodules = api::list_course_modules_using_competency($this->related['competency']->get('id'),
                                                                    $this->related['course']->id);
 
         $fastmodinfo = get_fast_modinfo($this->related['course']->id);
index bf91e34..8b20b4d 100644 (file)
@@ -22,6 +22,7 @@
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 namespace tool_lp\external;
+defined('MOODLE_INTERNAL') || die();
 
 use context_user;
 use renderer_base;
@@ -34,7 +35,7 @@ use core_competency\external\plan_exporter;
  * @copyright  2015 Damyon Wiese
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
-class user_competency_summary_in_plan_exporter extends \core_competency\external\exporter {
+class user_competency_summary_in_plan_exporter extends \core\external\exporter {
 
     protected static function define_related() {
         // We cache the context so it does not need to be retrieved from the framework every time.
index aa97b0b..24500bb 100644 (file)
@@ -22,6 +22,7 @@
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 namespace tool_lp\external;
+defined('MOODLE_INTERNAL') || die();
 
 use moodle_url;
 use renderer_base;
@@ -34,7 +35,7 @@ use core_competency\external\user_competency_exporter;
  * @copyright  2016 Serge Gauthier - <serge.gauthier.2@umontreal.ca>
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
-class user_evidence_competency_summary_exporter extends \core_competency\external\exporter {
+class user_evidence_competency_summary_exporter extends \core\external\exporter {
 
     protected static function define_related() {
         return array('competency' => '\\core_competency\\competency',
index c3851a6..93b2d65 100644 (file)
@@ -26,7 +26,8 @@ defined('MOODLE_INTERNAL') || die();
 
 use moodle_url;
 use renderer_base;
-use core_competency\external\stored_file_exporter;
+use core_files\external\stored_file_exporter;
+use core_competency\external\performance_helper;
 
 /**
  * Class for exporting user evidence with all competencies.
@@ -34,10 +35,10 @@ use core_competency\external\stored_file_exporter;
  * @copyright  2016 Serge Gauthier - <serge.gauthier.2@umontreal.ca>
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
-class user_evidence_summary_exporter extends \core_competency\external\persistent_exporter {
+class user_evidence_summary_exporter extends \core\external\persistent_exporter {
 
     protected static function define_class() {
-        return 'core_competency\\user_evidence';
+        return \core_competency\user_evidence::class;
     }
 
     protected static function define_other_properties() {
@@ -74,7 +75,7 @@ class user_evidence_summary_exporter extends \core_competency\external\persisten
 
     protected function get_other_values(renderer_base $output) {
         $urlshort = '';
-        $url = $this->persistent->get_url();
+        $url = $this->persistent->get('url');
         if (!empty($url)) {
             $murl = new moodle_url($url);
             $shorturl = preg_replace('@^https?://(www\.)?@', '', $murl->out(false));
@@ -91,32 +92,19 @@ class user_evidence_summary_exporter extends \core_competency\external\persisten
         }
 
         $userevidencecompetencies = array();
-        $frameworks = array();
-        $scales = array();
         $usercompetencies = $this->persistent->get_user_competencies();
+        $helper = new performance_helper();
         foreach ($usercompetencies as $usercompetency) {
             $competency = $usercompetency->get_competency();
 
-            // Get the framework.
-            if (!isset($frameworks[$competency->get_competencyframeworkid()])) {
-                $frameworks[$competency->get_competencyframeworkid()] = $competency->get_framework();
-            }
-            $framework = $frameworks[$competency->get_competencyframeworkid()];
-
-            // Get the scale.
-            $scaleid = $competency->get_scaleid();
-            if ($scaleid === null) {
-                $scaleid = $framework->get_scaleid();
-            }
-            if (!isset($scales[$framework->get_scaleid()])) {
-                $scales[$framework->get_scaleid()] = $framework->get_scale();
-            }
-            $scale = $scales[$framework->get_scaleid()];
+            $context = $helper->get_context_from_competency($competency);
+            $framework = $helper->get_framework_from_competency($competency);
+            $scale = $helper->get_scale_from_competency($competency);
 
             $related = array('competency' => $competency,
                              'usercompetency' => $usercompetency,
                              'scale' => $scale,
-                             'context' => $framework->get_context());
+                             'context' => $context);
 
             $userevidencecompetencysummaryexporter = new user_evidence_competency_summary_exporter(null, $related);
 
index 32136bc..0a6e154 100644 (file)
@@ -26,6 +26,7 @@ namespace tool_lp\form;
 defined('MOODLE_INTERNAL') || die();
 
 use stdClass;
+use core\form\persistent;
 
 /**
  * Competency framework form.
@@ -53,26 +54,29 @@ class competency extends persistent {
 
         $mform->addElement('hidden', 'competencyframeworkid');
         $mform->setType('competencyframeworkid', PARAM_INT);
-        $mform->setConstant('competencyframeworkid', $framework->get_id());
+        $mform->setConstant('competencyframeworkid', $framework->get('id'));
 
         $mform->addElement('header', 'generalhdr', get_string('general'));
 
         $mform->addElement('static',
                            'frameworkdesc',
                            get_string('competencyframework', 'tool_lp'),
-                           s($framework->get_shortname()));
+                           s($framework->get('shortname')));
 
         $mform->addElement('hidden', 'parentid', '', array('id' => 'tool_lp_parentcompetency'));
 
         $mform->setType('parentid', PARAM_INT);
-        $mform->setConstant('parentid', ($parent) ? $parent->get_id() : 0);
+        $mform->setConstant('parentid', ($parent) ? $parent->get('id') : 0);
         $parentlevel = ($parent) ? $parent->get_level() : 0;
-        $parentname = ($parent) ? $parent->get_shortname() : get_string('competencyframeworkroot', 'tool_lp');
-        $parentlabel = ($competency->get_id()) ?
-            get_string('taxonomy_parent_' . $framework->get_taxonomy($parentlevel), 'tool_lp') :
-            get_string('parentcompetency', 'tool_lp');
+        $parentname = ($parent) ? $parent->get('shortname') : get_string('competencyframeworkroot', 'tool_lp');
+        $parentlabel = '';
+        if (!empty($competency->get('id'))) {
+            $parentlabel = get_string('taxonomy_parent_' . $framework->get_taxonomy($parentlevel), 'tool_lp');
+        } else {
+            $parentlabel = get_string('parentcompetency', 'tool_lp');
+        }
         $editaction = '';
-        if (!$competency->get_id()) {
+        if (!$competency->get('id')) {
             $icon = $OUTPUT->pix_icon('t/editinline', get_string('parentcompetency_edit', 'tool_lp'));
             $editaction = $OUTPUT->action_link('#', $icon, null, array('id' => 'id_parentcompetencybutton'));
         }
@@ -82,12 +86,12 @@ class competency extends persistent {
                            $parentlabel,
                            "<span id='id_parentdesc'>$parentname</span>&nbsp;".$editaction);
         // Set the picker competency when adding new competency.
-        if (!$competency->get_id()) {
+        if (!$competency->get('id')) {
             // Call the parentcompetency_form init to initialize the competency picker for parent competency.
             $PAGE->requires->js_call_amd('tool_lp/parentcompetency_form', 'init', array('#id_parentcompetencybutton',
                 '#tool_lp_parentcompetency',
                 '#id_parentdesc',
-                $framework->get_id(),
+                $framework->get('id'),
                 $pagecontextid));
         }
 
@@ -123,7 +127,7 @@ class competency extends persistent {
             // configuration requires this field so we only disable it. It is fine as setting the value
             // as a constant will ensure that nobody can change it. And it's validated in the persistent anyway.
             $scaleid->updateAttributes(array('disabled' => 'disabled'));
-            $mform->setConstant('scaleid', $competency->get_scaleid());
+            $mform->setConstant('scaleid', $competency->get('scaleid'));
         }
 
         // Disable short forms.
index 6d4b6bc..6a20db2 100644 (file)
@@ -26,6 +26,7 @@ namespace tool_lp\form;
 defined('MOODLE_INTERNAL') || die();
 
 use stdClass;
+use core\form\persistent;
 
 /**
  * Competency framework form.
@@ -79,7 +80,7 @@ class competency_framework extends persistent {
             // configuration requires this field so we only disable it. It is fine as setting the value
             // as a constant will ensure that nobody can change it. And it's validated in the persistent anyway.
             $scaleid->updateAttributes(array('readonly' => 'readonly'));
-            $mform->setConstant('scaleid', $framework->get_scaleid());
+            $mform->setConstant('scaleid', $framework->get('scaleid'));
         }
 
         $mform->addElement('button', 'scaleconfigbutton', get_string('configurescale', 'tool_lp'));
@@ -148,7 +149,7 @@ class competency_framework extends persistent {
      */
     protected function get_default_data() {
         $data = parent::get_default_data();
-        $data->taxonomies = $this->get_persistent()->get_taxonomies();
+        $data->taxonomies = $this->get_persistent()->get('taxonomies');
         return $data;
     }
 
index 9505332..7237be0 100644 (file)
@@ -109,11 +109,11 @@ class framework_autocomplete extends MoodleQuickForm_autocomplete {
             if (!has_any_capability(array('moodle/competency:competencyview', 'moodle/competency:competencymanage'),
                     $framework->get_context())) {
                 continue;
-            } else if ($this->onlyvisible && !$framework->get_visible()) {
+            } else if ($this->onlyvisible && !$framework->get('visible')) {
                 continue;
             }
-            $this->addOption($framework->get_shortname() . ' ' . $framework->get_idnumber(), $framework->get_id());
-            array_push($toselect, $framework->get_id());
+            $this->addOption($framework->get('shortname') . ' ' . $framework->get('idnumber'), $framework->get('id'));
+            array_push($toselect, $framework->get('id'));
         }
 
         return $this->setSelected($toselect);
index 461f8c2..3ce193d 100644 (file)
@@ -25,6 +25,7 @@
 namespace tool_lp\form;
 defined('MOODLE_INTERNAL') || die();
 
+use core\form\persistent;
 use core_competency\plan as planpersistent;
 use required_capability_exception;
 
@@ -68,7 +69,7 @@ class plan extends persistent {
         // When the plan was already saved then the status can not be changed via this form.
         $status = planpersistent::get_status_list($this->_customdata['userid']);
         $plan = $this->get_persistent();
-        if ($plan->get_id()) {
+        if ($plan->get('id')) {
             // The current status is not selectable (workflow status probably), we just display it.
             $mform->addElement('static', 'staticstatus', get_string('status', 'tool_lp'), $plan->get_statusname());
         } else if (!empty($status) && count($status) > 1) {
index 8922d24..c73b93c 100644 (file)
@@ -25,6 +25,8 @@
 namespace tool_lp\form;
 defined('MOODLE_INTERNAL') || die();
 
+use core\form\persistent;
+
 /**
  * Learning plan template form.
  *
index 438c933..bd61cc7 100644 (file)
@@ -26,6 +26,7 @@ namespace tool_lp\form;
 defined('MOODLE_INTERNAL') || die();
 
 use moodleform;
+use core\form\persistent;
 
 require_once($CFG->libdir . '/formslib.php');
 
index 862a383..54c37e3 100644 (file)
@@ -26,6 +26,7 @@ namespace tool_lp\form;
 defined('MOODLE_INTERNAL') || die();
 
 use moodleform;
+use core\form\persistent;
 
 require_once($CFG->libdir . '/formslib.php');
 
index 74bb0c8..9d9ccf8 100644 (file)
@@ -25,6 +25,8 @@
 namespace tool_lp\form;
 defined('MOODLE_INTERNAL') || die();
 
+use core\form\persistent;
+
 /**
  * User evidence form class.
  *
index 58ab38b..4ff2472 100644 (file)
@@ -27,7 +27,8 @@ use renderable;
 use renderer_base;
 use templatable;
 use context_course;
-use \core_competency\external\competency_exporter;
+use core_competency\external\competency_exporter;
+use core_competency\external\performance_helper;
 use stdClass;
 
 /**
@@ -82,13 +83,9 @@ class competency_plan_navigation implements renderable, templatable {
 
         $plancompetencies = \core_competency\api::list_plan_competencies($data->planid);
         $data->competencies = array();
-        $contextcache = array();
+        $helper = new performance_helper();
         foreach ($plancompetencies as $plancompetency) {
-            $frameworkid = $plancompetency->competency->get_competencyframeworkid();
-            if (!isset($contextcache[$frameworkid])) {
-                $contextcache[$frameworkid] = $plancompetency->competency->get_context();
-            }
-            $context = $contextcache[$frameworkid];
+            $context = $helper->get_context_from_competency($plancompetency->competency);
             $exporter = new competency_exporter($plancompetency->competency, array('context' => $context));
             $competency = $exporter->export($output);
             if ($competency->id == $this->competencyid) {
index 0548002..4977d87 100644 (file)
@@ -63,11 +63,11 @@ class competency_summary implements renderable, templatable {
         $this->competency = $competency;
         $this->framework = $framework;
         if ($includerelated) {
-            $this->relatedcompetencies = api::list_related_competencies($competency->get_id());
+            $this->relatedcompetencies = api::list_related_competencies($competency->get('id'));
         }
 
         if ($includecourses) {
-            $this->courses = api::list_courses_using_competency($competency->get_id());
+            $this->courses = api::list_courses_using_competency($competency->get('id'));
         }
     }
 
index 395561f..eaf7d34 100644 (file)
@@ -35,6 +35,7 @@ use core_competency\api;
 use tool_lp\course_competency_statistics;
 use core_competency\competency;
 use core_competency\course_competency;
+use core_competency\external\performance_helper;
 use core_competency\external\competency_exporter;
 use core_competency\external\course_competency_exporter;
 use core_competency\external\course_competency_settings_exporter;
@@ -42,7 +43,7 @@ use core_competency\external\user_competency_course_exporter;
 use core_competency\external\user_competency_exporter;
 use tool_lp\external\competency_path_exporter;
 use tool_lp\external\course_competency_statistics_exporter;
-use tool_lp\external\course_module_summary_exporter;
+use core_course\external\course_module_summary_exporter;
 
 /**
  * Class containing data for course competencies page
@@ -112,7 +113,6 @@ class course_competencies_page implements renderable, templatable {
         $data->courseid = $this->courseid;
         $data->pagecontextid = $this->context->id;
         $data->competencies = array();
-        $contextcache = array();
 
         $gradable = is_enrolled($this->context, $USER, 'moodle/competency:coursecompetencygradable');
         if ($gradable) {
@@ -126,21 +126,19 @@ class course_competencies_page implements renderable, templatable {
             $ruleoutcomeoptions[$value] = array('value' => $value, 'text' => (string) $text, 'selected' => false);
         }
 
+        $helper = new performance_helper();
         foreach ($this->coursecompetencylist as $coursecompetencyelement) {
             $coursecompetency = $coursecompetencyelement['coursecompetency'];
             $competency = $coursecompetencyelement['competency'];
-            if (!isset($contextcache[$competency->get_competencyframeworkid()])) {
-                $contextcache[$competency->get_competencyframeworkid()] = $competency->get_context();
-            }
-            $context = $contextcache[$competency->get_competencyframeworkid()];
+            $context = $helper->get_context_from_competency($competency);
 
             $compexporter = new competency_exporter($competency, array('context' => $context));
             $ccexporter = new course_competency_exporter($coursecompetency, array('context' => $context));
 
             $ccoutcomeoptions = (array) (object) $ruleoutcomeoptions;
-            $ccoutcomeoptions[$coursecompetency->get_ruleoutcome()]['selected'] = true;
+            $ccoutcomeoptions[$coursecompetency->get('ruleoutcome')]['selected'] = true;
 
-            $coursemodules = api::list_course_modules_using_competency($competency->get_id(), $this->courseid);
+            $coursemodules = api::list_course_modules_using_competency($competency->get('id'), $this->courseid);
 
             $fastmodinfo = get_fast_modinfo($this->courseid);
             $exportedmodules = array();
@@ -152,7 +150,7 @@ class course_competencies_page implements renderable, templatable {
             // Competency path.
             $pathexporter = new competency_path_exporter([
                 'ancestors' => $competency->get_ancestors(),
-                'framework' => $competency->get_framework(),
+                'framework' => $helper->get_framework_from_competency($competency),
                 'context' => $context
             ]);
 
@@ -166,13 +164,13 @@ class course_competencies_page implements renderable, templatable {
             if ($gradable) {
                 $foundusercompetencycourse = false;
                 foreach ($usercompetencycourses as $usercompetencycourse) {
-                    if ($usercompetencycourse->get_competencyid() == $competency->get_id()) {
+                    if ($usercompetencycourse->get('competencyid') == $competency->get('id')) {
                         $foundusercompetencycourse = $usercompetencycourse;
                     }
                 }
                 if ($foundusercompetencycourse) {
                     $related = array(
-                        'scale' => $competency->get_scale()
+                        'scale' => $helper->get_scale_from_competency($competency)
                     );
                     $exporter = new user_competency_course_exporter($foundusercompetencycourse, $related);
                     $onerow['usercompetencycourse'] = $exporter->export($output);
index f490f3b..aa4188c 100644 (file)
@@ -29,6 +29,7 @@ use templatable;
 use stdClass;
 use moodle_url;
 use core_competency\api;
+use core_competency\external\performance_helper;
 use core_competency\plan;
 use core_competency\external\competency_exporter;
 use core_competency\external\plan_exporter;
@@ -62,9 +63,6 @@ class plan_page implements renderable, templatable {
      * @return stdClass
      */
     public function export_for_template(\renderer_base $output) {
-        $frameworks = array();
-        $scales = array();
-
         $planexporter = new plan_exporter($this->plan, array('template' => $this->plan->get_template()));
 
         $data = new stdClass();
@@ -81,40 +79,27 @@ class plan_page implements renderable, templatable {
             $ucexporter = 'core_competency\\external\\user_competency_exporter';
         }
 
+        $helper = new performance_helper();
         $pclist = api::list_plan_competencies($this->plan);
         $proficientcount = 0;
         foreach ($pclist as $pc) {
             $comp = $pc->competency;
             $usercomp = $pc->$ucproperty;
 
-            // Get the framework.
-            if (!isset($frameworks[$comp->get_competencyframeworkid()])) {
-                $frameworks[$comp->get_competencyframeworkid()] = $comp->get_framework();
-            }
-            $framework = $frameworks[$comp->get_competencyframeworkid()];
-
-            // Get the scale.
-            $scaleid = $comp->get_scaleid();
-            $compscale = $comp->get_scale();
-            if ($scaleid === null) {
-                $scaleid = $framework->get_scaleid();
-                $compscale = $framework->get_scale();
-            }
-            if (!isset($scales[$scaleid])) {
-                $scales[$scaleid] = $compscale;
-            }
-            $scale = $scales[$scaleid];
+            $compcontext = $helper->get_context_from_competency($comp);
+            $framework = $helper->get_framework_from_competency($comp);
+            $scale = $helper->get_scale_from_competency($comp);
 
             // Prepare the data.
             $record = new stdClass();
-            $exporter = new competency_exporter($comp, array('context' => $framework->get_context()));
+            $exporter = new competency_exporter($comp, array('context' => $compcontext));
             $record->competency = $exporter->export($output);
 
             // Competency path.
             $exporter = new competency_path_exporter([
                 'ancestors' => $comp->get_ancestors(),
                 'framework' => $framework,
-                'context' => $framework->get_context()
+                'context' => $compcontext
             ]);
             $record->comppath = $exporter->export($output);
 
@@ -122,7 +107,7 @@ class plan_page implements renderable, templatable {
             $record->$ucproperty = $exporter->export($output);
 
             $data->competencies[] = $record;
-            if ($usercomp->get_proficiency()) {
+            if ($usercomp->get('proficiency')) {
                 $proficientcount++;
             }
         }
index bdd68e3..090fd97 100644 (file)
@@ -142,7 +142,7 @@ class template_cohorts_table extends table_sql {
                   FROM {" . \core_competency\template_cohort::TABLE . "} tc
                   JOIN {cohort} c ON c.id = tc.cohortid
                  WHERE tc.templateid = :templateid";
-        $params = array('templateid' => $this->template->get_id());
+        $params = array('templateid' => $this->template->get('id'));
 
         // Add order by if needed.
         if (!$count && $sqlsort = $this->get_sql_sort()) {
index e51b13d..2fb3558 100644 (file)
@@ -34,6 +34,7 @@ use moodle_url;
 use core_competency\external\template_exporter;
 use core_competency\template;
 use core_competency\api;
+use core_competency\external\performance_helper;
 use tool_lp\external\competency_summary_exporter;
 use tool_lp\external\template_statistics_exporter;
 use tool_lp\template_statistics;
@@ -76,7 +77,7 @@ class template_competencies_page implements renderable, templatable {
     public function __construct(template $template, context $pagecontext) {
         $this->pagecontext = $pagecontext;
         $this->template = $template;
-        $this->templatestatistics = new template_statistics($template->get_id());
+        $this->templatestatistics = new template_statistics($template->get('id'));
         $this->competencies = api::list_competencies_in_template($template);
         $this->canmanagecompetencyframeworks = has_capability('moodle/competency:competencymanage', $this->pagecontext);
         $this->canmanagetemplatecompetencies = has_capability('moodle/competency:templatemanage', $this->pagecontext);
@@ -95,20 +96,13 @@ class template_competencies_page implements renderable, templatable {
         $data->template = (new template_exporter($this->template))->export($output);
         $data->pagecontextid = $this->pagecontext->id;
         $data->competencies = array();
-        $contextcache = array();
-        $frameworkcache = array();
+        $helper = new performance_helper();
         foreach ($this->competencies as $competency) {
-            if (!isset($contextcache[$competency->get_competencyframeworkid()])) {
-                $contextcache[$competency->get_competencyframeworkid()] = $competency->get_context();
-            }
-            $context = $contextcache[$competency->get_competencyframeworkid()];
-            if (!isset($frameworkcache[$competency->get_competencyframeworkid()])) {
-                $frameworkcache[$competency->get_competencyframeworkid()] = $competency->get_framework();
-            }
-            $framework = $frameworkcache[$competency->get_competencyframeworkid()];
-
-            $courses = api::list_courses_using_competency($competency->get_id());
-            $relatedcompetencies = api::list_related_competencies($competency->get_id());
+            $context = $helper->get_context_from_competency($competency);
+            $framework = $helper->get_framework_from_competency($competency);
+
+            $courses = api::list_courses_using_competency($competency->get('id'));
+            $relatedcompetencies = api::list_related_competencies($competency->get('id'));
 
             $related = array(
                 'competency' => $competency,
index b495ded..422e62a 100644 (file)
@@ -151,7 +151,7 @@ class template_plans_table extends table_sql {
                   FROM {" . \core_competency\plan::TABLE . "} p
                   JOIN {user} u ON u.id = p.userid
                  WHERE p.templateid = :templateid";
-        $params = array('templateid' => $this->template->get_id());
+        $params = array('templateid' => $this->template->get('id'));
 
         // Add order by if needed.
         if (!$count && $sqlsort = $this->get_sql_sort()) {
index 3d716b5..170dd9e 100644 (file)
@@ -27,8 +27,9 @@ use renderable;
 use renderer_base;
 use templatable;
 use context_course;
-use \core_competency\external\competency_exporter;
-use \core_competency\external\user_summary_exporter;
+use core_competency\external\competency_exporter;
+use core_user\external\user_summary_exporter;
+use core_competency\external\performance_helper;
 use stdClass;
 
 /**
@@ -118,14 +119,9 @@ class user_competency_course_navigation implements renderable, templatable {
 
         $coursecompetencies = \core_competency\api::list_course_competencies($this->courseid);
         $data->competencies = array();
-        $contextcache = array();
+        $helper = new performance_helper();
         foreach ($coursecompetencies as $coursecompetency) {
-            $frameworkid = $coursecompetency['competency']->get_competencyframeworkid();
-            if (!isset($contextcache[$frameworkid])) {
-                $contextcache[$frameworkid] = $coursecompetency['competency']->get_context();
-            }
-            $context = $contextcache[$frameworkid];
-            $coursecompetencycontext = $context;
+            $coursecompetencycontext = $helper->get_context_from_competency($coursecompetency['competency']);
             $exporter = new competency_exporter($coursecompetency['competency'], array('context' => $coursecompetencycontext));
             $competency = $exporter->export($output);
             if ($competency->id == $this->competencyid) {
index f40880b..5368006 100644 (file)
@@ -65,7 +65,7 @@ class user_competency_summary implements renderable, templatable {
      */
     public function export_for_template(renderer_base $output) {
         if (!isset($related['user'])) {
-            $related['user'] = core_user::get_user($this->usercompetency->get_userid());
+            $related['user'] = core_user::get_user($this->usercompetency->get('userid'));
         }
         if (!isset($related['competency'])) {
             $related['competency'] = $this->usercompetency->get_competency();
@@ -75,8 +75,8 @@ class user_competency_summary implements renderable, templatable {
             'usercompetency' => $this->usercompetency,
             'usercompetencyplan' => null,
             'usercompetencycourse' => null,
-            'evidence' => api::list_evidence($this->usercompetency->get_userid(), $this->usercompetency->get_competencyid()),
-            'relatedcompetencies' => api::list_related_competencies($this->usercompetency->get_competencyid())
+            'evidence' => api::list_evidence($this->usercompetency->get('userid'), $this->usercompetency->get('competencyid')),
+            'relatedcompetencies' => api::list_related_competencies($this->usercompetency->get('competencyid'))
         );
         $exporter = new user_competency_summary_exporter(null, $related);
         $data = $exporter->export($output);
index 2abc6f9..cb7f518 100644 (file)
@@ -76,7 +76,7 @@ class user_competency_summary_in_course implements renderable, templatable {
             throw new \invalid_parameter_exception('Invalid params. The competency does not belong to the course.');
         }
 
-        $relatedcompetencies = api::list_related_competencies($competency->get_id());
+        $relatedcompetencies = api::list_related_competencies($competency->get('id'));
         $user = $DB->get_record('user', array('id' => $this->userid));
         $evidence = api::list_evidence_in_course($this->userid, $this->courseid, $this->competencyid);
         $course = $DB->get_record('course', array('id' => $this->courseid));
index e650aa1..f2cd81b 100644 (file)
@@ -74,10 +74,10 @@ class user_competency_summary_in_plan implements renderable, templatable {
             throw new \invalid_parameter_exception('Invalid params. The competency does not belong to the plan.');
         }
 
-        $relatedcompetencies = api::list_related_competencies($competency->get_id());
-        $userid = $plan->get_userid();
+        $relatedcompetencies = api::list_related_competencies($competency->get('id'));
+        $userid = $plan->get('userid');
         $user = $DB->get_record('user', array('id' => $userid));
-        $evidence = api::list_evidence($userid, $this->competencyid, $plan->get_id());
+        $evidence = api::list_evidence($userid, $this->competencyid, $plan->get('id'));
 
         $params = array(
             'competency' => $competency,
index 476339a..03245b5 100644 (file)
@@ -121,7 +121,7 @@ class page_helper {
         $templateurl = null;
         if ($template) {
             $templateurl = new moodle_url('/admin/tool/lp/templatecompetencies.php', [
-                'templateid' => $template->get_id(),
+                'templateid' => $template->get('id'),
                 'pagecontextid' => $pagecontextid
             ]);
         }
@@ -135,7 +135,7 @@ class page_helper {
         $PAGE->set_context($pagecontext);
 
         if (!empty($template)) {
-            $title = format_string($template->get_shortname(), true, array('context' => $context));
+            $title = format_string($template->get('shortname'), true, array('context' => $context));
         } else {
             $title = get_string('templates', 'tool_lp');
         }
@@ -199,7 +199,7 @@ class page_helper {
         $plansurl = new moodle_url('/admin/tool/lp/plans.php', array('userid' => $userid));
         $planurl = null;
         if ($plan) {
-            $planurl = new moodle_url('/admin/tool/lp/plan.php', array('id' => $plan->get_id()));
+            $planurl = new moodle_url('/admin/tool/lp/plan.php', array('id' => $plan->get('id')));
         }
 
         $returnurl = $plansurl;
@@ -218,7 +218,7 @@ class page_helper {
         }
 
         if (!empty($plan)) {
-            $title = format_string($plan->get_name(), true, array('context' => $context));
+            $title = format_string($plan->get('name'), true, array('context' => $context));
         } else {
             $title = get_string('learningplans', 'tool_lp');
         }
@@ -273,7 +273,7 @@ class page_helper {
         $evidencelisturl = new moodle_url('/admin/tool/lp/user_evidence_list.php', array('userid' => $userid));
         $evidenceurl = null;
         if ($evidence) {
-            $evidenceurl = new moodle_url('/admin/tool/lp/user_evidence.php', array('id' => $evidence->get_id()));
+            $evidenceurl = new moodle_url('/admin/tool/lp/user_evidence.php', array('id' => $evidence->get('id')));
         }
 
         $returnurl = $evidencelisturl;
@@ -292,7 +292,7 @@ class page_helper {
         }
 
         if (!empty($evidence)) {
-            $title = format_string($evidence->get_name(), true, array('context' => $context));
+            $title = format_string($evidence->get('name'), true, array('context' => $context));
         } else {
             $title = get_string('userevidence', 'tool_lp');
         }
@@ -352,7 +352,7 @@ class page_helper {
             $url->remove_params(array('id'));
             $PAGE->navbar->add($pagesubtitle, $url);
         } else {
-            $pagetitle = $framework->get_shortname();
+            $pagetitle = $framework->get('shortname');
             $pagesubtitle = get_string('editcompetencyframework', 'tool_lp');
             if ($returntype == 'competencies') {
                 $frameworksurl = new moodle_url('/admin/tool/lp/competencies.php', array(
@@ -417,18 +417,18 @@ class page_helper {
 
         // Set return url.
         $returnurloptions = [
-            'competencyframeworkid' => $framework->get_id(),
+            'competencyframeworkid' => $framework->get('id'),
             'pagecontextid' => $pagecontextid
         ];
         $returnurl = new moodle_url('/admin/tool/lp/competencies.php', $returnurloptions);
-        $PAGE->navbar->add($framework->get_shortname(), $returnurl);
+        $PAGE->navbar->add($framework->get('shortname'), $returnurl);
 
         // Set page layout.
         $PAGE->set_pagelayout('admin');
 
         if (empty($competency)) {
             // Add mode.
-            $title = format_string($framework->get_shortname(), true, ['context' => $pagecontext]);
+            $title = format_string($framework->get('shortname'), true, ['context' => $pagecontext]);
 
             // Set the sub-title for add mode.
             $level = $parent ? $parent->get_level() + 1 : 1;
@@ -436,7 +436,7 @@ class page_helper {
 
         } else {
             // Edit mode.
-            $title = format_string($competency->get_shortname(), true, ['context' => $competency->get_context()]);
+            $title = format_string($competency->get('shortname'), true, ['context' => $competency->get_context()]);
 
             // Add competency name to breadcrumbs, if available.
             $PAGE->navbar->add($title);
index 53c7713..3b5711c 100644 (file)
@@ -41,10 +41,10 @@ if (!\core_competency\competency_framework::can_read_context($context)) {
 }
 
 $title = get_string('competencies', 'core_competency');
-$pagetitle = get_string('competenciesforframework', 'tool_lp', $framework->get_shortname());
+$pagetitle = get_string('competenciesforframework', 'tool_lp', $framework->get('shortname'));
 
 // Set up the page.
-$url = new moodle_url("/admin/tool/lp/competencies.php", array('competencyframeworkid' => $framework->get_id(),
+$url = new moodle_url("/admin/tool/lp/competencies.php", array('competencyframeworkid' => $framework->get('id'),
     'pagecontextid' => $pagecontextid));
 $frameworksurl = new moodle_url('/admin/tool/lp/competencyframeworks.php', array('pagecontextid' => $pagecontextid));
 
@@ -52,7 +52,7 @@ $PAGE->navigation->override_active_url($frameworksurl);
 $PAGE->set_context($pagecontext);
 $PAGE->set_pagelayout('admin');
 $PAGE->set_url($url);
-$PAGE->navbar->add($framework->get_shortname(), $url);
+$PAGE->navbar->add($framework->get('shortname'), $url);
 $PAGE->set_title($title);
 $PAGE->set_heading($title);
 $output = $PAGE->get_renderer('tool_lp');
diff --git a/admin/tool/lp/db/renamedclasses.php b/admin/tool/lp/db/renamedclasses.php
new file mode 100644 (file)
index 0000000..0530f09
--- /dev/null
@@ -0,0 +1,32 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * This file contains renamed classes mappings.
+ *
+ * @package    tool_lp
+ * @copyright  2016 Frédéric Massart - FMCorz.net
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$renamedclasses = array(
+    'tool_lp\\external\\cohort_summary_exporter' => 'core_cohort\\external\\cohort_summary_exporter',
+    'tool_lp\\external\\course_module_summary_exporter' => 'core_course\\external\\course_module_summary_exporter',
+    'tool_lp\\external\\course_summary_exporter' => 'core_course\\external\\course_summary_exporter',
+    'tool_lp\\form\\persistent' => 'core\\form\\persistent',
+);
index cbaa76e..8e34d1c 100644 (file)
@@ -63,7 +63,7 @@ if ($competency) {
 // Get page URL.
 $urloptions = [
     'id' => $id,
-    'competencyframeworkid' => $competencyframework->get_id(),
+    'competencyframeworkid' => $competencyframework->get('id'),
     'parentid' => $parentid,
     'pagecontextid' => $pagecontextid
 ];
index 5ae6cd8..a61cd8b 100644 (file)
@@ -58,7 +58,7 @@ if ($form->is_cancelled()) {
         $framework = \core_competency\api::create_framework($data);
         $frameworkmanageurl = new moodle_url('/admin/tool/lp/competencies.php', array(
             'pagecontextid' => $pagecontextid,
-            'competencyframeworkid' => $framework->get_id()
+            'competencyframeworkid' => $framework->get('id')
         ));
         $messagesuccess = get_string('competencyframeworkcreated', 'tool_lp');
         redirect($frameworkmanageurl, $messagesuccess, 0, \core\output\notification::NOTIFY_SUCCESS);
index 7f8faa9..e1e6509 100644 (file)
@@ -42,7 +42,7 @@ if (empty($id)) {
     $plan = \core_competency\api::read_plan($id);
 
     // The userid parameter must be the same as the owner of the plan.
-    if ($userid != $plan->get_userid()) {
+    if ($userid != $plan->get('userid')) {
         throw new coding_exception('Inconsistency between the userid parameter and the userid of the plan');
     }
 
@@ -81,7 +81,7 @@ $data = $form->get_data();
 if ($data) {
     if (empty($data->id)) {
         $plan = \core_competency\api::create_plan($data);
-        $returnurl = new moodle_url('/admin/tool/lp/plan.php', ['id' => $plan->get_id()]);
+        $returnurl = new moodle_url('/admin/tool/lp/plan.php', ['id' => $plan->get('id')]);
         $returnmsg = get_string('plancreated', 'tool_lp');
     } else {
         \core_competency\api::update_plan($data);
index d596f30..7314b91 100644 (file)
@@ -71,7 +71,7 @@ if ($data) {
     if (empty($data->id)) {
         $template = \core_competency\api::create_template($data);
         $returnurl = new moodle_url('/admin/tool/lp/templatecompetencies.php', [
-            'templateid' => $template->get_id(),
+            'templateid' => $template->get('id'),
             'pagecontextid' => $pagecontextid
         ]);
         $returnmsg = get_string('templatecreated', 'tool_lp');
index aed8874..ff5880e 100644 (file)
@@ -183,7 +183,7 @@ function tool_lp_coursemodule_edit_post_actions($data, $course) {
 
     $existingids = array();
     foreach ($existing as $cmc) {
-        array_push($existingids, $cmc->get_competencyid());
+        array_push($existingids, $cmc->get('competencyid'));
     }
 
     $newids = isset($data->competencies) ? $data->competencies : array();
index fded203..51be779 100644 (file)
@@ -35,7 +35,7 @@ if (isguestuser()) {
 $plan = \core_competency\api::read_plan($id);
 $url = new moodle_url('/admin/tool/lp/plan.php', array('id' => $id));
 
-list($title, $subtitle) = \tool_lp\page_helper::setup_for_plan($plan->get_userid(), $url, $plan);
+list($title, $subtitle) = \tool_lp\page_helper::setup_for_plan($plan->get('userid'), $url, $plan);
 
 $output = $PAGE->get_renderer('tool_lp');
 echo $output->header();
index b92dcd0..5667f3f 100644 (file)
@@ -34,7 +34,7 @@ $template = \core_competency\api::read_template($id);
 $context = $template->get_context();
 $canreadtemplate = $template->can_read();
 $canmanagetemplate = $template->can_manage();
-$duedatereached = $template->get_duedate() > 0 && $template->get_duedate() < time();
+$duedatereached = $template->get('duedate') > 0 && $template->get('duedate') < time();
 
 if (!$canreadtemplate) {
     throw new required_capability_exception($context, 'moodle/competency:templateview', 'nopermissions', '');
@@ -65,10 +65,10 @@ if ($canmanagetemplate && ($data = $form->get_data()) && !empty($data->cohorts))
         $relation = \core_competency\api::create_template_cohort($template, $cohortid);
 
         // Create a plan for each member if template visible, and the due date is not reached, and we didn't reach our limit yet.
-        if ($template->get_visible() && $i < $maxtocreate && !$duedatereached) {
+        if ($template->get('visible') && $i < $maxtocreate && !$duedatereached) {
 
             // Only create a few plans right now.
-            $tocreate = \core_competency\template_cohort::get_missing_plans($template->get_id(), $cohortid);
+            $tocreate = \core_competency\template_cohort::get_missing_plans($template->get('id'), $cohortid);
             if ($i + count($tocreate) <= $maxtocreate) {
                 $i += \core_competency\api::create_plans_from_template_cohort($template, $cohortid);
             } else {
@@ -94,7 +94,7 @@ echo $output->header();
 echo $output->heading($title);
 echo $output->heading($subtitle, 3);
 if ($canmanagetemplate) {
-    if ($template->get_visible() == false) {
+    if ($template->get('visible') == false) {
         // Display message to prevent that cohort will not be synchronzed if the template is hidden.
         echo $output->notify_message(get_string('templatecohortnotsyncedwhilehidden', 'tool_lp'));
     } else if ($duedatereached) {
index 37586b5..5b6ec89 100644 (file)
@@ -51,7 +51,7 @@ $form = new \tool_lp\form\template_plans($url->out(false));
 if ($canmanagetemplate && ($data = $form->get_data()) && !empty($data->users)) {
     $i = 0;
     foreach ($data->users as $userid) {
-        $result = \core_competency\api::create_plan_from_template($template->get_id(), $userid);
+        $result = \core_competency\api::create_plan_from_template($template->get('id'), $userid);
         if ($result) {
             $i++;
         }
@@ -74,10 +74,10 @@ echo $output->heading($subtitle, 3);
 
 // Do not display form when the template is hidden.
 if ($canmanagetemplate) {
-    if (!$template->get_visible()) {
+    if (!$template->get('visible')) {
         // Display message that plan can not be created if the template is hidden.
         echo $output->notify_message(get_string('cannotcreateuserplanswhentemplatehidden', 'tool_lp'));
-    } else if ($template->get_duedate() > 0 && $template->get_duedate() < time() + 900) {
+    } else if ($template->get('duedate') > 0 && $template->get('duedate') < time() + 900) {
         // Prevent the user from creating plans when the due date is passed, or in less than 15 minutes.
         echo $output->notify_message(get_string('cannotcreateuserplanswhentemplateduedateispassed', 'tool_lp'));
     } else {
index a18f216..a3f4a93 100644 (file)
@@ -42,7 +42,7 @@ if (!$template->can_read()) {
 \core_competency\api::template_viewed($template);
 
 // Set up the page.
-$url = new moodle_url('/admin/tool/lp/templatecompetencies.php', array('templateid' => $template->get_id(),
+$url = new moodle_url('/admin/tool/lp/templatecompetencies.php', array('templateid' => $template->get('id'),
     'pagecontextid' => $pagecontextid));
 list($title, $subtitle) = \tool_lp\page_helper::setup_for_template($pagecontextid, $url, $template);
 
index bccf5f7..998a950 100644 (file)
@@ -68,7 +68,7 @@ Feature: Manage competency frameworks
     Then I should not see "Science Year-4"
     And I should not see "sc-y-4"
 
-Scenario: Edit a framework with competencies in user competency
+  Scenario: Edit a framework with competencies in user competency
     Given the following lp "frameworks" exist:
       | shortname | idnumber |
       | Science Year-5 | sc-y-5 |
@@ -98,7 +98,7 @@ Scenario: Edit a framework with competencies in user competency
     And I should see "Science Year-5 Edited"
     And I should see "sc-y-5"
 
-Scenario: Edit a framework with competencies in user competency plan
+  Scenario: Edit a framework with competencies in user competency plan
     Given the following lp "frameworks" exist:
       | shortname | idnumber |
       | Science Year-6 | sc-y-6 |
index bfaf1e0..c98314e 100644 (file)
@@ -179,7 +179,7 @@ Feature: Manage plan workflow
     And I should not see "Active"
     And I log out
 
-Scenario: Manager reopen a complete learning plan
+  Scenario: Manager reopen a complete learning plan
     Given  the following lp "plans" exist:
       | name | user | description | status | reviewer |
       | Test-Plan3 | user1 | Description of plan 3 for user 1 | complete | manager1 |
index 6a46e19..35dbd2b 100644 (file)
@@ -78,4 +78,3 @@ Feature: Manage evidence of prior learning
     Then I should see "List of evidence"
     And I should see "Evidence-6"
     And I should not see "Evidence-5"
-
index 1c85942..d523735 100644 (file)
@@ -423,19 +423,19 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
 
         $f1 = $lpg->create_framework();
 
-        $c1 = $lpg->create_competency(array('competencyframeworkid' => $f1->get_id()));
+        $c1 = $lpg->create_competency(array('competencyframeworkid' => $f1->get('id')));
 
         $tpl = $lpg->create_template();
-        $lpg->create_template_competency(array('templateid' => $tpl->get_id(), 'competencyid' => $c1->get_id()));
+        $lpg->create_template_competency(array('templateid' => $tpl->get('id'), 'competencyid' => $c1->get('id')));
 
-        $plan = $lpg->create_plan(array('userid' => $this->user->id, 'templateid' => $tpl->get_id(), 'name' => 'Evil'));
+        $plan = $lpg->create_plan(array('userid' => $this->user->id, 'templateid' => $tpl->get('id'), 'name' => 'Evil'));
 
-        $uc = $lpg->create_user_competency(array('userid' => $this->user->id, 'competencyid' => $c1->get_id()));
+        $uc = $lpg->create_user_competency(array('userid' => $this->user->id, 'competencyid' => $c1->get('id')));
 
-        $evidence = \core_competency\external::grade_competency_in_plan($plan->get_id(), $c1->get_id(), 1, true);
-        $evidence = \core_competency\external::grade_competency_in_plan($plan->get_id(), $c1->get_id(), 2, true);
+        $evidence = \core_competency\external::grade_competency_in_plan($plan->get('id'), $c1->get('id'), 1, true);
+        $evidence = \core_competency\external::grade_competency_in_plan($plan->get('id'), $c1->get('id'), 2, true);
 
-        $summary = external::data_for_user_competency_summary_in_plan($c1->get_id(), $plan->get_id());
+        $summary = external::data_for_user_competency_summary_in_plan($c1->get('id'), $plan->get('id'));
         $this->assertTrue($summary->usercompetencysummary->cangrade);
         $this->assertEquals('Evil', $summary->plan->name);
         $this->assertEquals('B', $summary->usercompetencysummary->usercompetency->gradename);
@@ -443,6 +443,24 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
         $this->assertEquals('A', $summary->usercompetencysummary->evidence[1]->gradename);
     }
 
+    public function test_data_for_user_competency_summary() {
+        $this->setUser($this->creator);
+
+        $dg = $this->getDataGenerator();
+        $lpg = $dg->get_plugin_generator('core_competency');
+        $f1 = $lpg->create_framework();
+        $c1 = $lpg->create_competency(array('competencyframeworkid' => $f1->get('id')));
+
+        $evidence = \core_competency\external::grade_competency($this->user->id, $c1->get('id'), 1, true);
+        $evidence = \core_competency\external::grade_competency($this->user->id, $c1->get('id'), 2, true);
+
+        $summary = external::data_for_user_competency_summary($this->user->id, $c1->get('id'));
+        $this->assertTrue($summary->cangrade);
+        $this->assertEquals('B', $summary->usercompetency->gradename);
+        $this->assertEquals('B', $summary->evidence[0]->gradename);
+        $this->assertEquals('A', $summary->evidence[1]->gradename);
+    }
+
     /**
      * Search cohorts.
      */
index 4e41971..84c967e 100644 (file)
@@ -1,6 +1,13 @@
 This files describes changes in /admin/tool/lp/* - plugins,
 information provided here is intended especially for developers.
 
+=== 3.3 ===
+
+* Deprecated classes and their new equivalent:
+  - tool_lp\external\cohort_summary_exporter        -> core_cohort\external\cohort_summary_exporter
+  - tool_lp\external\course_summary_exporter        -> core_course\external\course_summary_exporter
+  - tool_lp\external\course_module_summary_exporter -> core_course\external\course_module_summary_exporter
+
 === 3.2 ===
 
 * The icon 'competency.png/svg' has been removed, please use i/competencies instead.
index 51933c1..6d5f357 100644 (file)
@@ -36,7 +36,7 @@ $uc = \core_competency\api::get_user_competency_by_id($id);
 $params = array('id' => $id);
 $url = new moodle_url('/admin/tool/lp/user_competency.php', $params);
 
-$user = core_user::get_user($uc->get_userid());
+$user = core_user::get_user($uc->get('userid'));
 if (!$user || !core_user::is_real_user($user->id)) {
     throw new moodle_exception('invaliduser', 'error');
 }
@@ -47,7 +47,7 @@ $compexporter = new \core_competency\external\competency_exporter($competency, a
 
 $PAGE->set_pagelayout('standard');
 $PAGE->set_url($url);
-$PAGE->navigation->override_active_url(new moodle_url('/admin/tool/lp/plans.php', array('userid' => $uc->get_userid())));
+$PAGE->navigation->override_active_url(new moodle_url('/admin/tool/lp/plans.php', array('userid' => $uc->get('userid'))));
 $PAGE->set_context($uc->get_context());
 if (!$iscurrentuser) {
     $PAGE->navigation->extend_for_user($user);
index 9a478f9..f0b2227 100644 (file)
@@ -66,7 +66,7 @@ $competency = new \core_competency\competency($competencyid);
 if ($userid > 0) {
     $usercompetencycourses = \core_competency\api::list_user_competencies_in_course($courseid, $userid);
 }
-$subtitle = $competency->get_shortname() . ' <em>' . $competency->get_idnumber() . '</em>';
+$subtitle = $competency->get('shortname') . ' <em>' . $competency->get('idnumber') . '</em>';
 
 list($title, $subtitle) = \tool_lp\page_helper::setup_for_course($url, $course, $subtitle);
 
index 3a48a47..e8c8ac8 100644 (file)
@@ -54,13 +54,13 @@ echo $output->render($nav);
 $page = new \tool_lp\output\user_competency_summary_in_plan($competencyid, $planid);
 echo $output->render($page);
 // Trigger the viewed event.
-$pc = \core_competency\api::get_plan_competency($plan, $competency->get_id());
-if ($plan->get_status() == \core_competency\plan::STATUS_COMPLETE) {
+$pc = \core_competency\api::get_plan_competency($plan, $competency->get('id'));
+if ($plan->get('status') == \core_competency\plan::STATUS_COMPLETE) {
     $usercompetencyplan = $pc->usercompetencyplan;
     \core_competency\api::user_competency_plan_viewed($usercompetencyplan);
 } else {
     $usercompetency = $pc->usercompetency;
-    \core_competency\api::user_competency_viewed_in_plan($usercompetency, $plan->get_id());
+    \core_competency\api::user_competency_viewed_in_plan($usercompetency, $plan->get('id'));
 }
 
 echo $output->footer();
index dfb5dcb..8928ab9 100644 (file)
@@ -34,7 +34,7 @@ $id = required_param('id', PARAM_INT);
 
 $userevidence = \core_competency\api::read_user_evidence($id);
 $url = new moodle_url('/admin/tool/lp/user_evidence.php', array('id' => $id));
-list($title, $subtitle) = \tool_lp\page_helper::setup_for_user_evidence($userevidence->get_userid(), $url, $userevidence);
+list($title, $subtitle) = \tool_lp\page_helper::setup_for_user_evidence($userevidence->get('userid'), $url, $userevidence);
 
 $output = $PAGE->get_renderer('tool_lp');
 echo $output->header();
index e353514..fc3e66a 100644 (file)
@@ -46,7 +46,7 @@ if (empty($id)) {
     $userevidence = \core_competency\api::read_user_evidence($id);
 
     // The userid parameter must be the same as the owner of the evidence.
-    if ($userid != $userevidence->get_userid()) {
+    if ($userid != $userevidence->get('userid')) {
         throw new coding_exception('Inconsistency between the userid parameter and the userid of the plan.');
     }
 
@@ -84,7 +84,7 @@ if ($form->is_cancelled()) {
 // Load existing user evidence.
 $itemid = null;
 if ($userevidence) {
-    $itemid = $userevidence->get_id();
+    $itemid = $userevidence->get('id');
 }
 
 // Massaging the file API.
@@ -100,7 +100,7 @@ if ($data = $form->get_data()) {
 
     if (empty($userevidence)) {
         $userevidence = \core_competency\api::create_user_evidence($data, $draftitemid);
-        $returnurl = new moodle_url('/admin/tool/lp/user_evidence.php', ['id' => $userevidence->get_id()]);
+        $returnurl = new moodle_url('/admin/tool/lp/user_evidence.php', ['id' => $userevidence->get('id')]);
         $returnmsg = get_string('userevidencecreated', 'tool_lp');
     } else {
         \core_competency\api::update_user_evidence($data, $draftitemid);
index 1eac37f..fbcdf2e 100644 (file)
@@ -52,7 +52,7 @@ class export extends moodleform {
         $options = array();
         foreach ($frameworks as $framework) {
 
-            $options[$framework->get_id()] = $framework->get_shortname();
+            $options[$framework->get('id')] = $framework->get('shortname');
         }
         if (empty($options)) {
             $mform->addElement('static', 'frameworkid', '', get_string('noframeworks', 'tool_lpimportcsv'));
index e507dd9..a7c8ad4 100644 (file)
@@ -61,7 +61,7 @@ class framework_exporter {
         require_once($CFG->libdir . '/csvlib.class.php');
 
         $writer = new csv_export_writer();
-        $filename = clean_param($this->framework->get_shortname() . '-' . $this->framework->get_idnumber(), PARAM_FILE);
+        $filename = clean_param($this->framework->get('shortname') . '-' . $this->framework->get('idnumber'), PARAM_FILE);
         $writer->set_filename($filename);
 
         $headers = framework_importer::list_required_headers();
@@ -71,44 +71,44 @@ class framework_exporter {
         // Order and number of columns must match framework_importer::list_required_headers().
         $row = array(
             '',
-            $this->framework->get_idnumber(),
-            $this->framework->get_shortname(),
-            $this->framework->get_description(),
-            $this->framework->get_descriptionformat(),
+            $this->framework->get('idnumber'),
+            $this->framework->get('shortname'),
+            $this->framework->get('description'),
+            $this->framework->get('descriptionformat'),
             $this->framework->get_scale()->compact_items(),
-            $this->framework->get_scaleconfiguration(),
+            $this->framework->get('scaleconfiguration'),
             '',
             '',
             '',
             '',
             '',
             true,
-            implode(',', $this->framework->get_taxonomies())
+            implode(',', $this->framework->get('taxonomies'))
         );
         $writer->add_data($row);
 
-        $filters = array('competencyframeworkid' => $this->framework->get_id());
+        $filters = array('competencyframeworkid' => $this->framework->get('id'));
         $competencies = api::list_competencies($filters);
         // Index by id so we can lookup parents.
         $indexed = array();
         foreach ($competencies as $competency) {
-            $indexed[$competency->get_id()] = $competency;
+            $indexed[$competency->get('id')] = $competency;
         }
         foreach ($competencies as $competency) {
             $parentidnumber = '';
-            if ($competency->get_parentid() > 0) {
-                $parent = $indexed[$competency->get_parentid()];
-                $parentidnumber = $parent->get_idnumber();
+            if ($competency->get('parentid') > 0) {
+                $parent = $indexed[$competency->get('parentid')];
+                $parentidnumber = $parent->get('idnumber');
             }
 
             $scalevalues = '';
             $scaleconfig = '';
-            if ($competency->get_scaleid() !== null) {
+            if ($competency->get('scaleid') !== null) {
                 $scalevalues = $competency->get_scale()->compact_items();
-                $scaleconfig = $competency->get_scaleconfiguration();
+                $scaleconfig = $competency->get('scaleconfiguration');
             }
 
-            $ruleconfig = $competency->get_ruleconfig();
+            $ruleconfig = $competency->get('ruleconfig');
             if ($ruleconfig === null) {
                 $ruleconfig = "null";
             }
@@ -117,24 +117,24 @@ class framework_exporter {
 
             $relatedidnumbers = array();
             foreach ($allrelated as $onerelated) {
-                $relatedidnumbers[] = str_replace(',', '%2C', $onerelated->get_idnumber());
+                $relatedidnumbers[] = str_replace(',', '%2C', $onerelated->get('idnumber'));
             }
             $relatedidnumbers = implode(',', $relatedidnumbers);
 
             // Order and number of columns must match framework_importer::list_required_headers().
             $row = array(
                 $parentidnumber,
-                $competency->get_idnumber(),
-                $competency->get_shortname(),
-                $competency->get_description(),
-                $competency->get_descriptionformat(),
+                $competency->get('idnumber'),
+                $competency->get('shortname'),
+                $competency->get('description'),
+                $competency->get('descriptionformat'),
                 $scalevalues,
                 $scaleconfig,
-                $competency->get_ruletype(),
-                $competency->get_ruleoutcome(),
+                $competency->get('ruletype'),
+                $competency->get('ruleoutcome'),
                 $ruleconfig,
                 $relatedidnumbers,
-                $competency->get_id(),
+                $competency->get('id'),
                 false,
                 ''
             );
index 82b3516..c8f9816 100644 (file)
@@ -320,7 +320,7 @@ class framework_importer {
      */
     public function create_competency($record, $parent, $framework) {
         $competency = new stdClass();
-        $competency->competencyframeworkid = $framework->get_id();
+        $competency->competencyframeworkid = $framework->get('id');
         $competency->shortname = $record->shortname;
         if (!empty($record->description)) {
             $competency->description = $record->description;
@@ -331,7 +331,7 @@ class framework_importer {
             $competency->scaleconfiguration = $this->get_scale_configuration($competency->scaleid, $record->scaleconfiguration);
         }
         if ($parent) {
-            $competency->parentid = $parent->get_id();
+            $competency->parentid = $parent->get('id');
         } else {
             $competency->parentid = 0;
         }
@@ -414,7 +414,7 @@ class framework_importer {
 
                 if (isset($this->flat[$idnumber])) {
                     $relatedcomp = $this->flat[$idnumber]->createdcomp;
-                    api::add_related_competency($comp->get_id(), $relatedcomp->get_id());
+                    api::add_related_competency($comp->get('id'), $relatedcomp->get('id'));
                 }
             }
         }
@@ -437,9 +437,9 @@ class framework_importer {
                     $oldruleconfig = null;
                 }
                 $newruleconfig = $class::migrate_config($oldruleconfig, $this->mappings);
-                $comp->set_ruleconfig($newruleconfig);
-                $comp->set_ruletype($class);
-                $comp->set_ruleoutcome($record->ruleoutcome);
+                $comp->set('ruleconfig', $newruleconfig);
+                $comp->set('ruletype', $class);
+                $comp->set('ruleoutcome', $record->ruleoutcome);
                 $comp->update();
             }
         }
index 63d5a2c..fe14dac 100644 (file)
@@ -62,7 +62,7 @@ if ($form->is_cancelled()) {
             $form->set_import_error($error);
         } else {
             $framework = $importer->import();
-            $urlparams = ['competencyframeworkid' => $framework->get_id(), 'pagecontextid' => $context->id];
+            $urlparams = ['competencyframeworkid' => $framework->get('id'), 'pagecontextid' => $context->id];
             $frameworksurl = new moodle_url('/admin/tool/lp/competencies.php', $urlparams);
             echo $OUTPUT->notification(get_string('competencyframeworkcreated', 'tool_lp'), 'notifysuccess');
             echo $OUTPUT->continue_button($frameworksurl);
index 3063b54..b0d8d09 100644 (file)
@@ -47,10 +47,10 @@ class tool_lpimportcsv_import_testcase extends advanced_testcase {
         $framework = $importer->import();
         $this->assertEmpty('', $importer->get_error());
 
-        $this->assertGreaterThan(0, $framework->get_id());
+        $this->assertGreaterThan(0, $framework->get('id'));
 
         $filters = [
-            'competencyframeworkid' => $framework->get_id()
+            'competencyframeworkid' => $framework->get('id')
         ];
         $count = api::count_competencies($filters);
         $this->assertEquals(64, $count);
index 83090fe..e997f70 100644 (file)
@@ -80,8 +80,8 @@ class framework_mapper {
         // Find mappings.
         foreach ($collectionfrom as $keyfrom => $compfrom) {
             foreach ($collectionto as $keyto => $compto) {
-                if ($compfrom->get_idnumber() == $compto->get_idnumber()) {
-                    $map[$compfrom->get_id()] = $compto->get_id();
+                if ($compfrom->get('idnumber') == $compto->get('idnumber')) {
+                    $map[$compfrom->get('id')] = $compto->get('id');
                     unset($collectionfrom[$keyfrom]);
                     unset($collectionto[$keyto]);
                     break;
index 78eb45b..c8db5c1 100644 (file)
@@ -55,16 +55,16 @@ class tool_lpmigrate_framework_processor_testcase extends advanced_testcase {
         $f2 = $lpg->create_framework(array('idnumber' => 'BIO2016'));
 
         $f1comps = array();
-        $f1comps['A1'] = $lpg->create_competency(array('competencyframeworkid' => $f1->get_id(), 'idnumber' => 'A1'));
-        $f1comps['A2'] = $lpg->create_competency(array('competencyframeworkid' => $f1->get_id(), 'idnumber' => 'A2'));
-        $f1comps['A3'] = $lpg->create_competency(array('competencyframeworkid' => $f1->get_id(), 'idnumber' => 'A3'));
-        $f1comps['X1'] = $lpg->create_competency(array('competencyframeworkid' => $f1->get_id(), 'idnumber' => 'X1'));
+        $f1comps['A1'] = $lpg->create_competency(array('competencyframeworkid' => $f1->get('id'), 'idnumber' => 'A1'));
+        $f1comps['A2'] = $lpg->create_competency(array('competencyframeworkid' => $f1->get('id'), 'idnumber' => 'A2'));
+        $f1comps['A3'] = $lpg->create_competency(array('competencyframeworkid' => $f1->get('id'), 'idnumber' => 'A3'));
+        $f1comps['X1'] = $lpg->create_competency(array('competencyframeworkid' => $f1->get('id'), 'idnumber' => 'X1'));
 
         $f2comps = array();
-        $f2comps['A1'] = $lpg->create_competency(array('competencyframeworkid' => $f2->get_id(), 'idnumber' => 'A1'));
-        $f2comps['A2'] = $lpg->create_competency(array('competencyframeworkid' => $f2->get_id(), 'idnumber' => 'A2'));
-        $f2comps['A3'] = $lpg->create_competency(array('competencyframeworkid' => $f2->get_id(), 'idnumber' => 'A3'));
-        $f2comps['Y1'] = $lpg->create_competency(array('competencyframeworkid' => $f2->get_id(), 'idnumber' => 'Y1'));
+        $f2comps['A1'] = $lpg->create_competency(array('competencyframeworkid' => $f2->get('id'), 'idnumber' => 'A1'));
+        $f2comps['A2'] = $lpg->create_competency(array('competencyframeworkid' => $f2->get('id'), 'idnumber' => 'A2'));
+        $f2comps['A3'] = $lpg->create_competency(array('competencyframeworkid' => $f2->get('id'), 'idnumber' => 'A3'));
+        $f2comps['Y1'] = $lpg->create_competency(array('competencyframeworkid' => $f2->get('id'), 'idnumber' => 'Y1'));
 
         $c1 = $dg->create_course(array('startdate' => time() - 72000));
         $c2 = $dg->create_course(array('startdate' => time() + 72000));
@@ -83,47 +83,47 @@ class tool_lpmigrate_framework_processor_testcase extends advanced_testcase {
         // Course CompetencieS.
         $ccs = array(
             $c1->id => array(
-                $f1comps['A1']->get_id() => $lpg->create_course_competency(array('courseid' => $c1->id,
-                    'competencyid' => $f1comps['A1']->get_id())),
-                $f1comps['A3']->get_id() => $lpg->create_course_competency(array('courseid' => $c1->id,
-                    'competencyid' => $f1comps['A3']->get_id())),
-                $f1comps['X1']->get_id() => $lpg->create_course_competency(array('courseid' => $c1->id,
-                    'competencyid' => $f1comps['X1']->get_id())),
+                $f1comps['A1']->get('id') => $lpg->create_course_competency(array('courseid' => $c1->id,
+                    'competencyid' => $f1comps['A1']->get('id'))),
+                $f1comps['A3']->get('id') => $lpg->create_course_competency(array('courseid' => $c1->id,
+                    'competencyid' => $f1comps['A3']->get('id'))),
+                $f1comps['X1']->get('id') => $lpg->create_course_competency(array('courseid' => $c1->id,
+                    'competencyid' => $f1comps['X1']->get('id'))),
             ),
             $c2->id => array(
-                $f1comps['A2']->get_id() => $lpg->create_course_competency(array('courseid' => $c2->id,
-                    'competencyid' => $f1comps['A2']->get_id())),
-                $f1comps['A3']->get_id() => $lpg->create_course_competency(array('courseid' => $c2->id,
-                    'competencyid' => $f1comps['A3']->get_id())),
+                $f1comps['A2']->get('id') => $lpg->create_course_competency(array('courseid' => $c2->id,
+                    'competencyid' => $f1comps['A2']->get('id'))),
+                $f1comps['A3']->get('id') => $lpg->create_course_competency(array('courseid' => $c2->id,
+                    'competencyid' => $f1comps['A3']->get('id'))),
             )
         );
 
         // Course Module CompetencieS.
         $cmcs = array(
             $cms[$c1->id]['F1']->cmid => array(
-                $f1comps['A1']->get_id() => $lpg->create_course_module_competency(array(
+                $f1comps['A1']->get('id') => $lpg->create_course_module_competency(array(
                     'cmid' => $cms[$c1->id]['F1']->cmid,
-                    'competencyid' => $f1comps['A1']->get_id()
+                    'competencyid' => $f1comps['A1']->get('id')
                 )),
-                $f1comps['X1']->get_id() => $lpg->create_course_module_competency(array(
+                $f1comps['X1']->get('id') => $lpg->create_course_module_competency(array(
                     'cmid' => $cms[$c1->id]['F1']->cmid,
-                    'competencyid' => $f1comps['X1']->get_id()
+                    'competencyid' => $f1comps['X1']->get('id')
                 )),
             ),
             $cms[$c1->id]['P1']->cmid => array(
-                $f1comps['A3']->get_id() => $lpg->create_course_module_competency(array(
+                $f1comps['A3']->get('id') => $lpg->create_course_module_competency(array(
                     'cmid' => $cms[$c1->id]['P1']->cmid,
-                    'competencyid' => $f1comps['A3']->get_id()
+                    'competencyid' => $f1comps['A3']->get('id')
                 )),
             ),
             $cms[$c2->id]['F1']->cmid => array(
-                $f1comps['A2']->get_id() => $lpg->create_course_module_competency(array(
+                $f1comps['A2']->get('id') => $lpg->create_course_module_competency(array(
                     'cmid' => $cms[$c2->id]['F1']->cmid,
-                    'competencyid' => $f1comps['A2']->get_id()
+                    'competencyid' => $f1comps['A2']->get('id')
                 )),
-                $f1comps['A3']->get_id() => $lpg->create_course_module_competency(array(
+                $f1comps['A3']->get('id') => $lpg->create_course_module_competency(array(
                     'cmid' => $cms[$c2->id]['F1']->cmid,
-                    'competencyid' => $f1comps['A3']->get_id()
+                    'competencyid' => $f1comps['A3']->get('id')
                 )),
             ),
         );
@@ -153,7 +153,7 @@ class tool_lpmigrate_framework_processor_testcase extends advanced_testcase {
     public function test_simple_migration() {
         $this->setAdminUser();
 
-        $mapper = new framework_mapper($this->f1->get_id(), $this->f2->get_id());
+        $mapper = new framework_mapper($this->f1->get('id'), $this->f2->get('id'));
         $mapper->automap();
         $processor = new framework_processor($mapper);
         $processor->proceed();
@@ -170,7 +170,7 @@ class tool_lpmigrate_framework_processor_testcase extends advanced_testcase {
 
         $this->assertEquals(array(), $processor->get_warnings());
         $this->assertEquals(array(), $processor->get_errors());
-        $this->assertEquals(array($this->f1comps['X1']->get_id() => true), $processor->get_missing_mappings());
+        $this->assertEquals(array($this->f1comps['X1']->get('id') => true), $processor->get_missing_mappings());
 
         $this->assertCourseCompetencyMigrated($this->c1, $this->f1comps['A1'], $this->f2comps['A1']);
         $this->assertCourseCompetencyMigrated($this->c1, $this->f1comps['A3'], $this->f2comps['A3']);
@@ -189,7 +189,7 @@ class tool_lpmigrate_framework_processor_testcase extends advanced_testcase {
     public function test_remove_when_missing() {
         $this->setAdminUser();
 
-        $mapper = new framework_mapper($this->f1->get_id(), $this->f2->get_id());
+        $mapper = new framework_mapper($this->f1->get('id'), $this->f2->get('id'));
         $mapper->automap();
         $processor = new framework_processor($mapper);
         $processor->set_remove_when_mapping_is_missing(true);
@@ -215,7 +215,7 @@ class tool_lpmigrate_framework_processor_testcase extends advanced_testcase {
     public function test_allowed_courses() {
         $this->setAdminUser();
 
-        $mapper = new framework_mapper($this->f1->get_id(), $this->f2->get_id());
+        $mapper = new framework_mapper($this->f1->get('id'), $this->f2->get('id'));
         $mapper->automap();
         $processor = new framework_processor($mapper);
         $processor->set_allowedcourses(array($this->c1->id));
@@ -248,7 +248,7 @@ class tool_lpmigrate_framework_processor_testcase extends advanced_testcase {
     public function test_disallowed_courses() {
         $this->setAdminUser();
 
-        $mapper = new framework_mapper($this->f1->get_id(), $this->f2->get_id());
+        $mapper = new framework_mapper($this->f1->get('id'), $this->f2->get('id'));
         $mapper->automap();
         $processor = new framework_processor($mapper);
         $processor->set_disallowedcourses(array($this->c2->id));
@@ -281,7 +281,7 @@ class tool_lpmigrate_framework_processor_testcase extends advanced_testcase {
     public function test_course_start_date_from() {
         $this->setAdminUser();
 
-        $mapper = new framework_mapper($this->f1->get_id(), $this->f2->get_id());
+        $mapper = new framework_mapper($this->f1->get('id'), $this->f2->get('id'));
         $mapper->automap();
         $processor = new framework_processor($mapper);
         $processor->set_course_start_date_from(time());
@@ -316,15 +316,15 @@ class tool_lpmigrate_framework_processor_testcase extends advanced_testcase {
         $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');
 
         // Pre-add the new competency to course 1.
-        $lpg->create_course_competency(array('courseid' => $this->c1->id, 'competencyid' => $this->f2comps['A1']->get_id()));
+        $lpg->create_course_competency(array('courseid' => $this->c1->id, 'competencyid' => $this->f2comps['A1']->get('id')));
 
         // Pre-add the new competency to module in course 2.
         $lpg->create_course_module_competency(array(
             'cmid' => $this->cms[$this->c2->id]['F1']->cmid,
-            'competencyid' => $this->f2comps['A2']->get_id()
+            'competencyid' => $this->f2comps['A2']->get('id')
         ));
 
-        $mapper = new framework_mapper($this->f1->get_id(), $this->f2->get_id());
+        $mapper = new framework_mapper($this->f1->get('id'), $this->f2->get('id'));
         $mapper->automap();
         $processor = new framework_processor($mapper);
         $processor->proceed();
@@ -345,13 +345,13 @@ class tool_lpmigrate_framework_processor_testcase extends advanced_testcase {
 
         $warning = array_shift($warnings);
         $this->assertEquals($this->c1->id, $warning['courseid']);
-        $this->assertEquals($this->f1comps['A1']->get_id(), $warning['competencyid']);
+        $this->assertEquals($this->f1comps['A1']->get('id'), $warning['competencyid']);
         $this->assertEquals(null, $warning['cmid']);
         $this->assertRegexp('/competency already exists/', $warning['message']);
 
         $warning = array_shift($warnings);
         $this->assertEquals($this->c2->id, $warning['courseid']);
-        $this->assertEquals($this->f1comps['A2']->get_id(), $warning['competencyid']);
+        $this->assertEquals($this->f1comps['A2']->get('id'), $warning['competencyid']);
         $this->assertEquals($this->cms[$this->c2->id]['F1']->cmid, $warning['cmid']);
         $this->assertRegexp('/competency already exists/', $warning['message']);
 
@@ -364,15 +364,15 @@ class tool_lpmigrate_framework_processor_testcase extends advanced_testcase {
         $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');
 
         // Pre-add the new competency to course 1.
-        $lpg->create_course_competency(array('courseid' => $this->c1->id, 'competencyid' => $this->f2comps['A1']->get_id()));
+        $lpg->create_course_competency(array('courseid' => $this->c1->id, 'competencyid' => $this->f2comps['A1']->get('id')));
 
         // Pre-add the new competency to module in course 2.
         $lpg->create_course_module_competency(array(
             'cmid' => $this->cms[$this->c2->id]['F1']->cmid,
-            'competencyid' => $this->f2comps['A2']->get_id()
+            'competencyid' => $this->f2comps['A2']->get('id')
         ));
 
-        $mapper = new framework_mapper($this->f1->get_id(), $this->f2->get_id());
+        $mapper = new framework_mapper($this->f1->get('id'), $this->f2->get('id'));
         $mapper->automap();
         $processor = new framework_processor($mapper);
         $processor->set_remove_original_when_destination_already_present(true);
@@ -414,7 +414,7 @@ class tool_lpmigrate_framework_processor_testcase extends advanced_testcase {
         $this->setUser($u);
 
         // Do C1 first.
-        $mapper = new framework_mapper($this->f1->get_id(), $this->f2->get_id());
+        $mapper = new framework_mapper($this->f1->get('id'), $this->f2->get('id'));
         $mapper->automap();
         $processor = new framework_processor($mapper);
         $processor->set_allowedcourses(array($this->c1->id));
@@ -434,10 +434,10 @@ class tool_lpmigrate_framework_processor_testcase extends advanced_testcase {
         $errors = $processor->get_errors();
         $this->assertCount(2, $errors);
         $this->assertEquals($this->c1->id, $errors[0]['courseid']);
-        $this->assertEquals($this->f1comps['A1']->get_id(), $errors[0]['competencyid']);
+        $this->assertEquals($this->f1comps['A1']->get('id'), $errors[0]['competencyid']);
         $this->assertEquals(null, $errors[0]['cmid']);
         $this->assertRegexp('/Sorry, but you do not currently have permissions to do that/', $errors[0]['message']);
-        $this->assertEquals($this->f1comps['A3']->get_id(), $errors[1]['competencyid']);
+        $this->assertEquals($this->f1comps['A3']->get('id'), $errors[1]['competencyid']);
 
         $this->assertCourseCompetencyNotMigrated($this->c1, $this->f1comps['A1'], $this->f2comps['A1']);
         $this->assertCourseCompetencyNotMigrated($this->c1, $this->f1comps['A3'], $this->f2comps['A3']);
@@ -463,10 +463,10 @@ class tool_lpmigrate_framework_processor_testcase extends advanced_testcase {
         $errors = $processor->get_errors();
         $this->assertCount(2, $errors);
         $this->assertEquals($this->c2->id, $errors[0]['courseid']);
-        $this->assertEquals($this->f1comps['A2']->get_id(), $errors[0]['competencyid']);
+        $this->assertEquals($this->f1comps['A2']->get('id'), $errors[0]['competencyid']);
         $this->assertEquals($this->cms[$this->c2->id]['F1']->cmid, $errors[0]['cmid']);
         $this->assertRegexp('/Sorry, but you do not currently have permissions to do that/', $errors[0]['message']);
-        $this->assertEquals($this->f1comps['A3']->get_id(), $errors[1]['competencyid']);
+        $this->assertEquals($this->f1comps['A3']->get('id'), $errors[1]['competencyid']);
 
         // The new competencies were added to the course, but the old ones were not removed because they are still in modules.
         $this->assertCourseCompetencyExists($this->c2, $this->f1comps['A2']);
@@ -487,7 +487,7 @@ class tool_lpmigrate_framework_processor_testcase extends advanced_testcase {
      */
     protected function assertCourseCompetencyExists($course, $competency) {
         $this->assertTrue(course_competency::record_exists_select("courseid = :courseid AND competencyid = :competencyid",
-            array('courseid' => $course->id, 'competencyid' => $competency->get_id())));
+            array('courseid' => $course->id, 'competencyid' => $competency->get('id'))));
     }
 
     /**
@@ -498,7 +498,7 @@ class tool_lpmigrate_framework_processor_testcase extends advanced_testcase {
      */
     protected function assertCourseCompetencyNotExists($course, $competency) {
         $this->assertFalse(course_competency::record_exists_select("courseid = :courseid AND competencyid =&