Moodle
  1. Moodle
  2. MDL-27960

create backup converters for sub-plugin types of activities.

    Details

    • Rank:
      17601

      Description

      towards the end of MDL-22414 it was realized that we needed to implement moodle1 backup converters for various activities being restored into 2.1

      The following may need a moodle1 converter (as they are sub-plugins), if not for functional purpose, then at least as template of reference for 3rd party sub-plugins.

      • mod/assignment : offline type moodle1 converter
      • mod/data : datapresets, datafields
      • mod/quiz : reports

        Issue Links

          Activity

          Hide
          Tim Hunt added a comment -

          None of the quiz reports have any data that needs to be backed up. It would, however, by useful if that option existed. Someone might want it in the future.

          Show
          Tim Hunt added a comment - None of the quiz reports have any data that needs to be backed up. It would, however, by useful if that option existed. Someone might want it in the future.
          Hide
          Aparup Banerjee added a comment -

          Thanks Tim.

          What sort of structure would a sub-plugin converter have ? would it be similar to the one described in http://docs.moodle.org/en/Development:Backup_1.9_conversion_for_developers ?

          Show
          Aparup Banerjee added a comment - Thanks Tim. What sort of structure would a sub-plugin converter have ? would it be similar to the one described in http://docs.moodle.org/en/Development:Backup_1.9_conversion_for_developers ?
          Hide
          Tim Hunt added a comment -

          No idea. You need to ask Eloy.

          Show
          Tim Hunt added a comment - No idea. You need to ask Eloy.
          Hide
          Michael de Raadt added a comment -

          Attaching a backup file that includes an assignment type.

          Show
          Michael de Raadt added a comment - Attaching a backup file that includes an assignment type.
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Well, I would say that, ideally, we need support for subplugins... but I'm not sure if that is 100% real, as far as moodle 1.9 backup didn't implemented them as subplugins at all, but straight handled all them.

          For example, I'm 99% sure that data->fields didn't have any special handling. And data->presets aren't included in backup at all. Also, I think we have not any 1.9 backup/restore support for quiz->reports.

          So, the only point were we could we needing proper subplugins support in 1.9 converted is in assignment more, I think it has some minor bits handling those "subtypes", although I think we are not using them in core subtypes (but other can be, for sure).

          Perhaps it could be, simply, a matter of allowing the call to some custom sublpugin_xxxx() function(s) or so at some strategic points in the assignment convert process. And we don't need complete subplugin support at all, just a bunch of clever hooks (more knowing that the 1.9 backup format isn't going to evolve at all).

          Surely David can comment about how he sees this issue. And also surely the data/quiz/assignment restorelib.php files nees to be reviewed to see where and how we were using those "subplugins".

          But my initial +1 goes to simple hooks/callbacks at strategic points in the conversion and done.

          Ciao

          Show
          Eloy Lafuente (stronk7) added a comment - Well, I would say that, ideally, we need support for subplugins... but I'm not sure if that is 100% real, as far as moodle 1.9 backup didn't implemented them as subplugins at all, but straight handled all them. For example, I'm 99% sure that data->fields didn't have any special handling. And data->presets aren't included in backup at all. Also, I think we have not any 1.9 backup/restore support for quiz->reports. So, the only point were we could we needing proper subplugins support in 1.9 converted is in assignment more, I think it has some minor bits handling those "subtypes", although I think we are not using them in core subtypes (but other can be, for sure). Perhaps it could be, simply, a matter of allowing the call to some custom sublpugin_xxxx() function(s) or so at some strategic points in the assignment convert process. And we don't need complete subplugin support at all, just a bunch of clever hooks (more knowing that the 1.9 backup format isn't going to evolve at all). Surely David can comment about how he sees this issue. And also surely the data/quiz/assignment restorelib.php files nees to be reviewed to see where and how we were using those "subplugins". But my initial +1 goes to simple hooks/callbacks at strategic points in the conversion and done. Ciao
          Hide
          Aparup Banerjee added a comment -

          Thanks Eloy,
          I had initially done some work based on workshop , just for assignment @ https://github.com/nebgor/moodle/compare/mistress...wip-MDL-27960
          i guess its still along the lines of what you've said

          Show
          Aparup Banerjee added a comment - Thanks Eloy, I had initially done some work based on workshop , just for assignment @ https://github.com/nebgor/moodle/compare/mistress...wip-MDL-27960 i guess its still along the lines of what you've said
          Hide
          Aparup Banerjee added a comment -

          David, nice to have you back after your moot

          can you take a look to see if i'm heading down the right track?

          Show
          Aparup Banerjee added a comment - David, nice to have you back after your moot can you take a look to see if i'm heading down the right track?
          Hide
          Michael de Raadt added a comment -

          Thanks for working on this. It looks OK to me.

          Show
          Michael de Raadt added a comment - Thanks for working on this. It looks OK to me.
          Hide
          Aparup Banerjee added a comment -

          Thanks.

          i have one issue left.
          somehow the on_assignment_subplugin_start() and on_assignment_subplugin_end() is called but not the process_assignment_subplugin()

          Show
          Aparup Banerjee added a comment - Thanks. i have one issue left. somehow the on_assignment_subplugin_start() and on_assignment_subplugin_end() is called but not the process_assignment_subplugin()
          Hide
          David Mudrak added a comment -

          Apu, of course process_assignment_subplugin() is not executed. The whole

          new convert_path('assignment_subplugin', '/MOODLE_BACKUP/COURSE/MODULES/MOD/ASSIGNMENT/ASSIGNMENTTYPE')
          

          is wrong actually. You can only register a path to a node containing other subelements. But <ASSIGNMENTTYPE> is a final container (leaf) holding the name of the assignment type (like "upload"). So the parser returns it as a property of the /MOD/ASSIGNMENT path and there is nothing to process here.

          As I read the code it seems to be similar to what we do for QUESTION elements. There also is a part of the node common for all qtypes and then every question type can append its specific data. So in theory, what must be passed to the subplugins is the whole $data parsed from /MOD/ASSIGNMENT

          If the subplugins add just other final elements to the list (so the /MOD/ASSIGNMENT is a plain list of properties), your job is easy. But I am afraid that subplugins might want to append treeish structures like

               <MOD>
                  <ID>77</ID>
                  <MODTYPE>assignment</MODTYPE>
                  <NAME>Online Text Example</NAME>
                  ...
                  <ASSIGNMENTTYPE>custom</ASSIGNMENTTYPE>
                  ...
                  <CUSTOMDATA>
                      <SOMETHING>
                          <FOO>bar</FOO>
                      </SOMETHING>
                  </CUSTOMDATA>
          
          

          in this case you will have to give the subplugins a chance to declare the paths they are interested in, too. Tricky tricky ...

          Show
          David Mudrak added a comment - Apu, of course process_assignment_subplugin() is not executed. The whole new convert_path('assignment_subplugin', '/MOODLE_BACKUP/COURSE/MODULES/MOD/ASSIGNMENT/ASSIGNMENTTYPE') is wrong actually. You can only register a path to a node containing other subelements. But <ASSIGNMENTTYPE> is a final container (leaf) holding the name of the assignment type (like "upload"). So the parser returns it as a property of the /MOD/ASSIGNMENT path and there is nothing to process here. As I read the code it seems to be similar to what we do for QUESTION elements. There also is a part of the node common for all qtypes and then every question type can append its specific data. So in theory, what must be passed to the subplugins is the whole $data parsed from /MOD/ASSIGNMENT If the subplugins add just other final elements to the list (so the /MOD/ASSIGNMENT is a plain list of properties), your job is easy. But I am afraid that subplugins might want to append treeish structures like <MOD> <ID>77</ID> <MODTYPE>assignment</MODTYPE> <NAME>Online Text Example</NAME> ... <ASSIGNMENTTYPE>custom</ASSIGNMENTTYPE> ... <CUSTOMDATA> <SOMETHING> <FOO>bar</FOO> </SOMETHING> </CUSTOMDATA> in this case you will have to give the subplugins a chance to declare the paths they are interested in, too. Tricky tricky ...
          Hide
          Aparup Banerjee added a comment -

          Thanks for the review David,

          I've created a new branch with a simpler call back structure. https://github.com/nebgor/moodle/compare/mistress..MDL-27960

          so as discussed: 1.9 subplugin tree structures aren't supported yet. whats works is 1.9 listed elements structures converted to 2.x list/tree.

          Show
          Aparup Banerjee added a comment - Thanks for the review David, I've created a new branch with a simpler call back structure. https://github.com/nebgor/moodle/compare/mistress..MDL-27960 so as discussed: 1.9 subplugin tree structures aren't supported yet. whats works is 1.9 listed elements structures converted to 2.x list/tree.
          Hide
          David Mudrak added a comment -

          Just an addition to what was discussed in the chat: I would probably go the way of adding nothing-doing subtype converters to all assignment types.

          Show
          David Mudrak added a comment - Just an addition to what was discussed in the chat: I would probably go the way of adding nothing-doing subtype converters to all assignment types.
          Hide
          Aparup Banerjee added a comment -

          Many thanks David.

          all subplugins now have no-op handlers.

          also exceptions are thrown all the way up when there isn't a conversion handler for the subplugin.

          I'm putting this out there for integration reviews.

          Show
          Aparup Banerjee added a comment - Many thanks David. all subplugins now have no-op handlers. also exceptions are thrown all the way up when there isn't a conversion handler for the subplugin. I'm putting this out there for integration reviews.
          Hide
          David Mudrak added a comment -

          Fixing the diff URL

          Show
          David Mudrak added a comment - Fixing the diff URL
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Integrated, many thanks!

          Show
          Eloy Lafuente (stronk7) added a comment - Integrated, many thanks!
          Hide
          David Mudrak added a comment -

          Tested - works as expected:

          1. all standard assignment are converted correctly
          2. if there is a non-standard assignment type detected without moodle1 converter support, an exception is thrown before the restore even starts. This is all we can do unfortunately. There is no way to skip such assignment because of the progressive way we process moodle.xml - the information about the assignment type is detected too late when the info about the instance is already present in other parts of MBZ

          Show
          David Mudrak added a comment - Tested - works as expected: 1. all standard assignment are converted correctly 2. if there is a non-standard assignment type detected without moodle1 converter support, an exception is thrown before the restore even starts. This is all we can do unfortunately. There is no way to skip such assignment because of the progressive way we process moodle.xml - the information about the assignment type is detected too late when the info about the instance is already present in other parts of MBZ
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Yay, this is now part of the just released Moodle 2.1 ! Thanks for all the hard work!

          Show
          Eloy Lafuente (stronk7) added a comment - Yay, this is now part of the just released Moodle 2.1 ! Thanks for all the hard work!
          Hide
          Nadav Kavalerchik added a comment -

          A workaround...

          I have duplicated assignment type offline into "team", which allowed me to pass the exception and display the list of assignments to the teacher which is restoring the Moodle 19 course into Moodle 2.

          Now, the teacher can discard (un select) the problematic assignment type.
          Even when the teacher is not discarding the assignment, the restore process completes successfully. And then the teacher can delete the assignment from the course.

          I am attaching a "dummy team assignment" (Duplicated from latest Moodle 2.4 stable assignment/type/offline code)
          It is practically an offline assignment + minor cosmetic changes the make Moodle think it is a Team assignment.

          Looking forward to see this solved properly, as suggested by David Mudrak.

          Show
          Nadav Kavalerchik added a comment - A workaround... I have duplicated assignment type offline into "team", which allowed me to pass the exception and display the list of assignments to the teacher which is restoring the Moodle 19 course into Moodle 2. Now, the teacher can discard (un select) the problematic assignment type. Even when the teacher is not discarding the assignment, the restore process completes successfully. And then the teacher can delete the assignment from the course. I am attaching a "dummy team assignment" (Duplicated from latest Moodle 2.4 stable assignment/type/offline code) It is practically an offline assignment + minor cosmetic changes the make Moodle think it is a Team assignment. Looking forward to see this solved properly, as suggested by David Mudrak .

            People

            • Votes:
              1 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: