<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
	<id>http://wiki.mipt.ru/index.php?action=history&amp;feed=atom&amp;title=Development%3AImplementing_Reset_course_functionality_in_a_module</id>
	<title>Development:Implementing Reset course functionality in a module - История изменений</title>
	<link rel="self" type="application/atom+xml" href="http://wiki.mipt.ru/index.php?action=history&amp;feed=atom&amp;title=Development%3AImplementing_Reset_course_functionality_in_a_module"/>
	<link rel="alternate" type="text/html" href="http://wiki.mipt.ru/index.php?title=Development:Implementing_Reset_course_functionality_in_a_module&amp;action=history"/>
	<updated>2026-05-06T18:33:17Z</updated>
	<subtitle>История изменений этой страницы в вики</subtitle>
	<generator>MediaWiki 1.42.1</generator>
	<entry>
		<id>http://wiki.mipt.ru/index.php?title=Development:Implementing_Reset_course_functionality_in_a_module&amp;diff=11244&amp;oldid=prev</id>
		<title>Олег Давидович: 1 версия импортирована</title>
		<link rel="alternate" type="text/html" href="http://wiki.mipt.ru/index.php?title=Development:Implementing_Reset_course_functionality_in_a_module&amp;diff=11244&amp;oldid=prev"/>
		<updated>2024-10-21T08:51:20Z</updated>

		<summary type="html">&lt;p&gt;1 версия импортирована&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Предыдущая версия&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Версия от 08:51, 21 октября 2024&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Олег Давидович</name></author>
	</entry>
	<entry>
		<id>http://wiki.mipt.ru/index.php?title=Development:Implementing_Reset_course_functionality_in_a_module&amp;diff=11243&amp;oldid=prev</id>
		<title>1&gt;Dlnsk в 20:26, 9 ноября 2008</title>
		<link rel="alternate" type="text/html" href="http://wiki.mipt.ru/index.php?title=Development:Implementing_Reset_course_functionality_in_a_module&amp;diff=11243&amp;oldid=prev"/>
		<updated>2008-11-09T20:26:06Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;The course reset code is triggered from /course/reset.php. To have your module included, you need to implement the three fuctions described below. To work out how to do this, a good example is to look at the implementations in /mod/fourm/lib.php&lt;br /&gt;
&lt;br /&gt;
==&amp;#039;&amp;#039;mymodule&amp;#039;&amp;#039;_reset_course_form_definition(&amp;amp;$mform)==&lt;br /&gt;
&lt;br /&gt;
This is called directly by /course/reset.php. It needs to output some form controls to control different options for resetting your module. You should use Form API for create form.&lt;br /&gt;
&lt;br /&gt;
The convention is to call settings relating your your module reset_&amp;#039;&amp;#039;mymodule&amp;#039;&amp;#039;_&amp;#039;&amp;#039;something&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
The forum implementation is a good model:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
/**&lt;br /&gt;
 * Called by course/reset.php&lt;br /&gt;
 */&lt;br /&gt;
function forum_reset_course_form_definition(&amp;amp;$mform) {&lt;br /&gt;
    $mform-&amp;gt;addElement(&amp;#039;header&amp;#039;, &amp;#039;forumheader&amp;#039;, get_string(&amp;#039;modulenameplural&amp;#039;, &amp;#039;forum&amp;#039;));&lt;br /&gt;
&lt;br /&gt;
    $mform-&amp;gt;addElement(&amp;#039;checkbox&amp;#039;, &amp;#039;reset_forum_all&amp;#039;, get_string(&amp;#039;resetforumsall&amp;#039;,&amp;#039;forum&amp;#039;));&lt;br /&gt;
&lt;br /&gt;
    $mform-&amp;gt;addElement(&amp;#039;select&amp;#039;, &amp;#039;reset_forum_types&amp;#039;, get_string(&amp;#039;resetforums&amp;#039;, &amp;#039;forum&amp;#039;), forum_get_forum_types_all(), array(&amp;#039;multiple&amp;#039; =&amp;gt; &amp;#039;multiple&amp;#039;));&lt;br /&gt;
    $mform-&amp;gt;setAdvanced(&amp;#039;reset_forum_types&amp;#039;);&lt;br /&gt;
    $mform-&amp;gt;disabledIf(&amp;#039;reset_forum_types&amp;#039;, &amp;#039;reset_forum_all&amp;#039;, &amp;#039;checked&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
    $mform-&amp;gt;addElement(&amp;#039;checkbox&amp;#039;, &amp;#039;reset_forum_subscriptions&amp;#039;, get_string(&amp;#039;resetsubscriptions&amp;#039;,&amp;#039;forum&amp;#039;));&lt;br /&gt;
    $mform-&amp;gt;setAdvanced(&amp;#039;reset_forum_subscriptions&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
    $mform-&amp;gt;addElement(&amp;#039;checkbox&amp;#039;, &amp;#039;reset_forum_track_prefs&amp;#039;, get_string(&amp;#039;resettrackprefs&amp;#039;,&amp;#039;forum&amp;#039;));&lt;br /&gt;
    $mform-&amp;gt;setAdvanced(&amp;#039;reset_forum_track_prefs&amp;#039;);&lt;br /&gt;
    $mform-&amp;gt;disabledIf(&amp;#039;reset_forum_track_prefs&amp;#039;, &amp;#039;reset_forum_all&amp;#039;, &amp;#039;checked&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
    $mform-&amp;gt;addElement(&amp;#039;checkbox&amp;#039;, &amp;#039;reset_forum_ratings&amp;#039;, get_string(&amp;#039;deleteallratings&amp;#039;));&lt;br /&gt;
    $mform-&amp;gt;disabledIf(&amp;#039;reset_forum_ratings&amp;#039;, &amp;#039;reset_forum_all&amp;#039;, &amp;#039;checked&amp;#039;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==&amp;#039;&amp;#039;mymodule&amp;#039;&amp;#039;_reset_userdata($data)==&lt;br /&gt;
 &lt;br /&gt;
This actually does the resetting. It is called indirectly, /course/reset.php calls reset_course_userdata() in /lib/moodlelib.php, which then calls the functions for each module.&lt;br /&gt;
&lt;br /&gt;
The $data parameter is what came back from the form printed by forum_reset_course. In particular, $data-&amp;gt;courseid is the id of the coures we are cleaning up.&lt;br /&gt;
&lt;br /&gt;
The forum implementation is again a good one to study, here is a very simple example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
function example_reset_userdata($data) {&lt;br /&gt;
    if (!empty($data-&amp;gt;reset_example_frogs)) {&lt;br /&gt;
        if (delete_records(&amp;#039;example_frogs&amp;#039;, &amp;#039;couresid&amp;#039;, $data-&amp;gt;courseid) and $showfeedback) {&lt;br /&gt;
            notify(get_string(&amp;#039;frogsdeleted&amp;#039;, &amp;#039;example&amp;#039;), &amp;#039;notifysuccess&amp;#039;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    if (!empty($data-&amp;gt;reset_example_newts)) {&lt;br /&gt;
        if (delete_records(&amp;#039;example_newts&amp;#039;, &amp;#039;couresid&amp;#039;, $data-&amp;gt;courseid) and $showfeedback) {&lt;br /&gt;
            notify(get_string(&amp;#039;newtsdeleted&amp;#039;, &amp;#039;example&amp;#039;), &amp;#039;notifysuccess&amp;#039;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==&amp;#039;&amp;#039;mymodule&amp;#039;&amp;#039;_reset_course_form_defaults($course)==&lt;br /&gt;
&lt;br /&gt;
Used for set default values to form&amp;#039;s elements displayed by &amp;#039;&amp;#039;mymodule&amp;#039;&amp;#039;_reset_course_form_definition. The forum implementation:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
function forum_reset_course_form_defaults($course) {&lt;br /&gt;
    return array(&amp;#039;reset_forum_all&amp;#039;=&amp;gt;1, &amp;#039;reset_forum_subscriptions&amp;#039;=&amp;gt;0, &amp;#039;reset_forum_track_prefs&amp;#039;=&amp;gt;0, &amp;#039;reset_forum_ratings&amp;#039;=&amp;gt;1);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[ja:開発:コースのリセット機能をモジュールに実装する]]&lt;/div&gt;</summary>
		<author><name>1&gt;Dlnsk</name></author>
	</entry>
</feed>