11<?php
2- // This file is part of Moodle - https://moodle.org
2+
3+ // This file is part of Moodle - http://moodle.org/
34//
45// Moodle is free software: you can redistribute it and/or modify
56// it under the terms of the GNU General Public License as published by
1920 * @subpackage backup-moodle2
2021 * @copyright 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
2122 * @copyright 2011 onwards Sun Zhigang (sunner) {@link http://sunner.cn}
23+ * @copyright 2017 onwards Andrew Naguib (ndrwnaguib) {@link http://ndrwnaguib.com}
2224 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
2325 */
2426
@@ -31,7 +33,7 @@ class backup_assignfeedback_onlinejudge_subplugin extends backup_subplugin {
3133 /**
3234 * Returns the subplugin information to attach at assignment element
3335 */
34- protected function define_assignment_subplugin_structure () {
36+ protected function define_grade_subplugin_structure () {
3537
3638 /**
3739 * Any activity sublugins is always rooted by one backup_subplugin_element()
@@ -55,7 +57,7 @@ protected function define_assignment_subplugin_structure() {
5557 * levels (get_recommended_name() and 'config' in the example below). That will make things
5658 * on restore easier, as far as subplugin information will be clearly separated from module information.
5759 */
58- $ subplugin = $ this ->get_subplugin_element (null , ' /assignment/assignmenttype ' , ' onlinejudge ' );
60+ $ subplugin = $ this ->get_subplugin_element ();
5961
6062 /**
6163 * Here we define the real structure the subplugin is going to generate - see note above. Obviously the
@@ -71,7 +73,7 @@ protected function define_assignment_subplugin_structure() {
7173 $ assassoff = new backup_nested_element ($ this ->get_recommended_name ());
7274
7375 $ onlinejudges = new backup_nested_element ('onlinejudges ' );
74- $ onlinejudge = new backup_nested_element ('onlinejudge ' , array ('id ' ), array ('language ' , 'memlimit ' , 'cpulimit ' , 'compileonly ' , 'ratiope ' , 'ideoneuser ' , 'ideonepass ' ));
76+ $ onlinejudge = new backup_nested_element ('onlinejudge ' , array ('id ' ), array ('language ' , 'memlimit ' , 'cpulimit ' , 'compileonly ' , 'ratiope ' , 'clientid ' , 'accesstoken ' , ' compile_lm_option ' , ' compile_warnings_option ' , ' compile_static_option ' ));
7577 $ testcases = new backup_nested_element ('testcases ' );
7678 $ testcase = new backup_nested_element ('testcase ' , array ('id ' ), array ('input ' , 'output ' , 'usefile ' , 'feedback ' , 'subgrade ' , 'sortorder ' ));
7779
@@ -84,39 +86,36 @@ protected function define_assignment_subplugin_structure() {
8486 $ onlinejudge ->set_source_table ('assignment_oj ' , array ('assignment ' => backup::VAR_PARENTID ));
8587 $ testcase ->set_source_table ('assignment_oj_testcases ' , array ('assignment ' => backup::VAR_PARENTID ));
8688
87- $ testcase ->annotate_files ('assign ' , 'onlinejudge_input ' , 'id ' );
88- $ testcase ->annotate_files ('assign ' , 'onlinejudge_output ' , 'id ' );
89-
90- return $ subplugin ; // And we return the root subplugin element
91- }
92-
93- /**
94- * Returns the subplugin information to attach at submission element
95- */
96- protected function define_submission_subplugin_structure () {
89+ $ testcase ->annotate_files ('assignfeedback_onlinejudge ' , 'onlinejudge_input ' , 'id ' );
90+ $ testcase ->annotate_files ('assignfeedback_onlinejudge ' , 'onlinejudge_output ' , 'id ' );
9791
98- // remember this has not XML representation
99- $ subplugin = $ this ->get_subplugin_element (null , '/assignment/assignmenttype ' , 'onlinejudge ' );
92+ // Returns the subplugin information to attach at submission element
10093
101- // type of the subplugin, name of the subplugin and name of the connection point (recommended)
102- $ asssuboff = new backup_nested_element ($ this ->get_recommended_name ());
10394 // onlinejudge assignment type does not copy task details. So must backup from local onlinejudge
104- $ onlinejudgesubmissions = new backup_nested_element ('onlinejudgesubmissions ' );
105- $ onlinejudgesubmission = new backup_nested_element ('onlinejudgesubmission ' , array ('id ' ), array ('submission ' , 'testcase ' , 'task ' , 'latest ' ));
95+ $ onlinejudge_submissions = new backup_nested_element ('onlinejudge_submissions ' );
96+ $ onlinejudge_submission = new backup_nested_element ('onlinejudge_submission ' , array ('id ' ), array ('submission ' , 'testcase ' , 'task ' , 'latest ' ));
10697 $ tasks = new backup_nested_element ('tasks ' );
107- $ task = new backup_nested_element ('task ' , array ('id ' ), array ('cmid ' , 'userid ' , 'language ' , 'memlimit ' , 'cpulimit ' , 'imput ' , 'output ' , 'compileonly ' , 'component ' , 'status ' , 'stdout ' , 'stderr ' , 'compileroutput ' , 'infoteacher ' , 'infostudent ' , 'cpuusage ' , 'memusage ' , 'submittime ' , 'judgetime ' , 'var1 ' , 'var2 ' , 'var3 ' , 'var4 ' , 'deleted ' ));
108-
109- $ subplugin ->add_child ($ asssuboff );
110- $ asssuboff ->add_child ($ onlinejudgesubmissions );
111- $ onlinejudgesubmissions ->add_child ($ onlinejudgesubmission );
112- $ onlinejudgesubmission ->add_child ($ tasks );
98+ $ task = new backup_nested_element (
99+ 'task ' ,
100+ array ('id ' ),
101+ array (
102+ 'cmid ' , 'userid ' , 'language ' , 'memlimit ' , 'cpulimit ' , 'input ' , 'output ' ,
103+ 'compileonly ' , 'compile_lm_option ' , 'compile_warnings_option ' , 'compile_static_option ' ,
104+ 'component ' , 'status ' , 'stdout ' , 'stderr ' , 'compileroutput ' , 'infoteacher ' , 'infostudent ' ,
105+ 'cpuusage ' , 'memusage ' , 'submittime ' , 'judgetime ' , 'var1 ' , 'var2 ' , 'var3 ' , 'var4 ' , 'deleted '
106+ )
107+ );
108+
109+ $ assassoff ->add_child ($ onlinejudge_submissions );
110+ $ onlinejudge_submissions ->add_child ($ onlinejudge_submission );
111+ $ onlinejudge_submission ->add_child ($ tasks );
113112 $ tasks ->add_child ($ task );
114113
115- $ onlinejudgesubmission ->set_source_table ('assignment_oj_submissions ' , array ('submission ' => backup::VAR_PARENTID ));
114+ $ onlinejudge_submission ->set_source_table ('assignment_oj_submissions ' , array ('submission ' => backup::VAR_PARENTID ));
116115 $ task ->set_source_table ('onlinejudge_tasks ' , array ('cmid ' => backup::VAR_MODID , 'id ' => '../../task ' ));
117116
118117 $ task ->annotate_ids ('user ' , 'userid ' );
119118
120119 return $ subplugin ; // And we return the root subplugin element
121120 }
122- }
121+ }
0 commit comments