@@ -321,7 +321,6 @@ public function add_settings_form_to_activity_page($mform, $context, $modulename
321
321
if ($ PAGE ->pagetype != 'course-editbulkcompletion ' &&
322
322
$ PAGE ->pagetype != 'course-editdefaultcompletion ' &&
323
323
$ PAGE ->pagetype != 'course-defaultcompletion ' ) {
324
-
325
324
// Check for existing settings and add the form
326
325
$ course = turnitin_assignment::get_course_data ($ COURSE ->id , "site " );
327
326
$ turnitinview ->add_elements_to_settings_form ($ mform , $ course , "activity " , $ modulename , $ cmid , $ plagiarismvalues ["plagiarism_rubric " ]);
@@ -1531,8 +1530,9 @@ private function update_submission($cm, $submissionid, $tiisubmission) {
1531
1530
* @param object $cm The course module.
1532
1531
* @param object $submission The submission object.
1533
1532
* @param int $userid The user id.
1533
+ * @param bool $cron Whether this is a cron job.
1534
1534
*/
1535
- private function update_grade ($ cm , $ submission , $ userid , $ cron = FALSE ) {
1535
+ private function update_grade ($ cm , $ submission , $ userid , $ cron = false ) {
1536
1536
global $ DB , $ USER , $ CFG ;
1537
1537
$ return = true ;
1538
1538
@@ -1632,7 +1632,7 @@ private function update_grade($cm, $submission, $userid, $cron = FALSE) {
1632
1632
$ context = context_course::instance ($ cm ->course );
1633
1633
if (has_capability ('mod/assign:grade ' , $ context , $ USER ->id )) {
1634
1634
// If the grade has changed and the change is not from a cron task then update the grader.
1635
- if ($ currentgrade ->grade != $ grade ->grade && $ cron == FALSE ) {
1635
+ if ($ currentgrade ->grade != $ grade ->grade && $ cron == false ) {
1636
1636
$ grade ->grader = $ USER ->id ;
1637
1637
}
1638
1638
}
@@ -1840,53 +1840,6 @@ public function refresh_peermark_assignments($cm, $tiiassignmentid) {
1840
1840
}
1841
1841
}
1842
1842
1843
- /**
1844
- * Check for rubric and save to assignment.
1845
- *
1846
- * @param object $cm The course module.
1847
- */
1848
- public function update_rubric_from_tii ($ cm ) {
1849
- global $ DB ;
1850
-
1851
- $ turnitincomms = new turnitin_comms ();
1852
- $ turnitincall = $ turnitincomms ->initialise_api ();
1853
- $ assignment = new TiiAssignment ();
1854
-
1855
- if ($ tiimoduledata = $ DB ->get_record ('plagiarism_turnitin_config ' ,
1856
- ['cm ' => $ cm ->id , 'name ' => 'turnitin_assignid ' ], 'value ' )) {
1857
-
1858
- $ assignment ->setAssignmentId ($ tiimoduledata ->value );
1859
-
1860
- try {
1861
- // Retrieve assignment from Turnitin.
1862
- $ response = $ turnitincall ->readAssignment ($ assignment );
1863
- $ tiiassignment = $ response ->getAssignment ();
1864
-
1865
- // Create rubric config field with rubric value from Turnitin.
1866
- $ rubricfield = new stdClass ();
1867
- $ rubricfield ->cm = $ cm ->id ;
1868
- $ rubricfield ->name = 'plagiarism_rubric ' ;
1869
- $ rubricfield ->value = $ tiiassignment ->getRubricId ();
1870
-
1871
- // Check if rubric already exists for this module.
1872
- if ($ configfield = $ DB ->get_field ('plagiarism_turnitin_config ' , 'id ' ,
1873
- (['cm ' => $ cm ->id , 'name ' => 'plagiarism_rubric ' ]))) {
1874
-
1875
- // Use current configfield to update rubric value.
1876
- $ rubricfield ->id = $ configfield ;
1877
-
1878
- $ DB ->update_record ('plagiarism_turnitin_config ' , $ rubricfield );
1879
- } else {
1880
- // Otherwise create rubric entry for this module.
1881
- $ rubricfield ->config_hash = $ rubricfield ->cm ."_ " .$ rubricfield ->name ;
1882
- $ DB ->create_record ('plagiarism_turnitin_config ' , $ rubricfield );
1883
- }
1884
- } catch (Exception $ e ) {
1885
- $ turnitincomms ->handle_exceptions ($ e , 'tiiassignmentgeterror ' , false );
1886
- }
1887
- }
1888
- }
1889
-
1890
1843
/**
1891
1844
* Create the module as an assignment within Turnitin if it does not exist,
1892
1845
* if we have a Turnitin id for the module then edit it
@@ -1984,12 +1937,12 @@ public function sync_tii_assignment($cm, $coursetiiid, $workflowcontext = "site"
1984
1937
$ dtpost = 0 ;
1985
1938
if ($ cm ->modname != "forum " ) {
1986
1939
if ($ gradeitem = $ DB ->get_record (
1987
- 'grade_items ' ,
1988
- [
1989
- 'iteminstance ' => $ cm ->instance ,
1990
- 'itemmodule ' => $ cm ->modname ,
1991
- 'courseid ' => $ cm ->course ,
1992
- 'itemnumber ' => 0 , ]
1940
+ 'grade_items ' ,
1941
+ [
1942
+ 'iteminstance ' => $ cm ->instance ,
1943
+ 'itemmodule ' => $ cm ->modname ,
1944
+ 'courseid ' => $ cm ->course ,
1945
+ 'itemnumber ' => 0 , ]
1993
1946
)) {
1994
1947
1995
1948
switch ($ gradeitem ->hidden ) {
@@ -2058,24 +2011,6 @@ public function sync_tii_assignment($cm, $coursetiiid, $workflowcontext = "site"
2058
2011
2059
2012
$ assignment ->setFeedbackReleaseDate (gmdate ("Y-m-d\TH:i:s\Z " , $ dtpost ));
2060
2013
2061
- // Erater settings.
2062
- $ assignment ->setErater ((isset ($ modulepluginsettings ["plagiarism_erater " ])) ?
2063
- $ modulepluginsettings ["plagiarism_erater " ] : 0 );
2064
- $ assignment ->setEraterSpelling ((isset ($ modulepluginsettings ["plagiarism_erater_spelling " ])) ?
2065
- $ modulepluginsettings ["plagiarism_erater_spelling " ] : 0 );
2066
- $ assignment ->setEraterGrammar ((isset ($ modulepluginsettings ["plagiarism_erater_grammar " ])) ?
2067
- $ modulepluginsettings ["plagiarism_erater_grammar " ] : 0 );
2068
- $ assignment ->setEraterUsage ((isset ($ modulepluginsettings ["plagiarism_erater_usage " ])) ?
2069
- $ modulepluginsettings ["plagiarism_erater_usage " ] : 0 );
2070
- $ assignment ->setEraterMechanics ((isset ($ modulepluginsettings ["plagiarism_erater_mechanics " ])) ?
2071
- $ modulepluginsettings ["plagiarism_erater_mechanics " ] : 0 );
2072
- $ assignment ->setEraterStyle ((isset ($ modulepluginsettings ["plagiarism_erater_style " ])) ?
2073
- $ modulepluginsettings ["plagiarism_erater_style " ] : 0 );
2074
- $ assignment ->setEraterSpellingDictionary ((isset ($ modulepluginsettings ["plagiarism_erater_dictionary " ])) ?
2075
- $ modulepluginsettings ["plagiarism_erater_dictionary " ] : 'en_US ' );
2076
- $ assignment ->setEraterHandbook ((isset ($ modulepluginsettings ["plagiarism_erater_handbook " ])) ?
2077
- $ modulepluginsettings ["plagiarism_erater_handbook " ] : 0 );
2078
-
2079
2014
// If we have a turnitin id then edit the assignment otherwise create it.
2080
2015
if ($ tiiassignment = $ DB ->get_record ('plagiarism_turnitin_config ' ,
2081
2016
['cm ' => $ cm ->id , 'name ' => 'turnitin_assignid ' ], 'value ' )) {
@@ -2107,6 +2042,52 @@ public function sync_tii_assignment($cm, $coursetiiid, $workflowcontext = "site"
2107
2042
}
2108
2043
}
2109
2044
2045
+ /**
2046
+ * Check for rubric and save to assignment.
2047
+ */
2048
+ public function update_rubric_from_tii ($ cm ) {
2049
+ global $ DB ;
2050
+
2051
+ $ turnitincomms = new turnitin_comms ();
2052
+ $ turnitincall = $ turnitincomms ->initialise_api ();
2053
+ $ assignment = new TiiAssignment ();
2054
+
2055
+ if ($ tiimoduledata = $ DB ->get_record ('plagiarism_turnitin_config ' ,
2056
+ array ('cm ' => $ cm ->id , 'name ' => 'turnitin_assignid ' ), 'value ' )) {
2057
+
2058
+ $ assignment ->setAssignmentId ($ tiimoduledata ->value );
2059
+
2060
+ try {
2061
+ // Retrieve assignment from Turnitin.
2062
+ $ response = $ turnitincall ->readAssignment ($ assignment );
2063
+ $ tiiassignment = $ response ->getAssignment ();
2064
+
2065
+ // Create rubric config field with rubric value from Turnitin.
2066
+ $ rubricfield = new stdClass ();
2067
+ $ rubricfield ->cm = $ cm ->id ;
2068
+ $ rubricfield ->name = 'plagiarism_rubric ' ;
2069
+ $ rubricfield ->value = $ tiiassignment ->getRubricId ();
2070
+
2071
+ // Check if rubric already exists for this module.
2072
+ if ($ configfield = $ DB ->get_field ('plagiarism_turnitin_config ' , 'id ' ,
2073
+ (array ('cm ' => $ cm ->id , 'name ' => 'plagiarism_rubric ' )))) {
2074
+
2075
+ // Use current configfield to update rubric value.
2076
+ $ rubricfield ->id = $ configfield ;
2077
+
2078
+ $ DB ->update_record ('plagiarism_turnitin_config ' , $ rubricfield );
2079
+ } else {
2080
+ // Otherwise create rubric entry for this module.
2081
+ $ rubricfield ->config_hash = $ rubricfield ->cm ."_ " .$ rubricfield ->name ;
2082
+ $ DB ->create_record ('plagiarism_turnitin_config ' , $ rubricfield );
2083
+ }
2084
+ }
2085
+ catch (Exception $ e ) {
2086
+ $ turnitincomms ->handle_exceptions ($ e , 'tiiassignmentgeterror ' , false );
2087
+ }
2088
+ }
2089
+ }
2090
+
2110
2091
/**
2111
2092
* Updates the database field duedate_report_refresh for any given submission ID.
2112
2093
* @param int $id - the ID of the submission to update.
@@ -2129,10 +2110,9 @@ public function set_duedate_report_refresh($id, $newvalue) {
2129
2110
public function cron_update_scores () {
2130
2111
global $ DB ;
2131
2112
2132
- <<<<<<< HEAD
2133
- $ submissionids = array ();
2134
- $ reportsexpected = array ();
2135
- $ assignmentids = array ();
2113
+ $ submissionids = [];
2114
+ $ reportsexpected = [];
2115
+ $ assignmentids = [];
2136
2116
2137
2117
// Grab all plagiarism files where all the following conditions are met:
2138
2118
// 1. The file has been successfully sent to TII
@@ -2150,19 +2130,6 @@ public function cron_update_scores() {
2150
2130
AND ( orcapable = ? OR orcapable IS NULL )
2151
2131
ORDER BY externalid DESC ' ,
2152
2132
['success ' , 1 ]
2153
- =======
2154
- $ submissionids = [];
2155
- $ reportsexpected = [];
2156
- $ assignmentids = [];
2157
-
2158
- $ submissions = $ DB ->get_records_select (
2159
- 'plagiarism_turnitin_files ' ,
2160
- 'statuscode = ?
2161
- AND ( similarityscore IS NULL OR duedate_report_refresh = 1 )
2162
- AND ( orcapable = ? OR orcapable IS NULL ) ' ,
2163
- ['success ' , 1 ],
2164
- 'externalid DESC '
2165
- >>>>>>> 796 b5bd (Fix 'Short array syntax must be used to define arrays ' warnings.)
2166
2133
);
2167
2134
2168
2135
// Cache module settings
@@ -2192,19 +2159,10 @@ public function cron_update_scores() {
2192
2159
2193
2160
if (!isset ($ reportsexpected [$ tiisubmission ->cm ])) {
2194
2161
2195
- <<<<<<< HEAD
2196
2162
$ reportsexpected [$ tiisubmission ->cm ] = 1 ;
2197
2163
2198
2164
if (!isset ($ modulesettings [$ tiisubmission ->cm ]['plagiarism_compare_institution ' ])) {
2199
2165
$ modulesettings [$ tiisubmission ->cm ]['plagiarism_compare_institution ' ] = 0 ;
2200
- =======
2201
- // Updates the db field 'duedate_report_refresh' if the due date has passed within the last twenty four hours.
2202
- $ moduledata = $ DB ->get_record ($ cm ->modname , ['id ' => $ cm ->instance ]);
2203
- $ now = strtotime ('now ' );
2204
- $ dtdue = (!empty ($ moduledata ->duedate )) ? $ moduledata ->duedate : 0 ;
2205
- if ($ now >= $ dtdue && $ now < strtotime ('+1 day ' , $ dtdue )) {
2206
- $ this ->set_duedate_report_refresh ($ tiisubmission ->id , 1 );
2207
- >>>>>>> 796 b5bd (Fix 'Short array syntax must be used to define arrays ' warnings.)
2208
2166
}
2209
2167
2210
2168
// Don't add the submission to the request if module settings mean we will not get a report back.
@@ -2221,26 +2179,12 @@ public function cron_update_scores() {
2221
2179
if ($ reportsexpected [$ tiisubmission ->cm ] == 1 ) {
2222
2180
$ submissionids [] = $ tiisubmission ->externalid ;
2223
2181
2224
- <<<<<<< HEAD
2225
2182
// If submission is added to the request, add the corresponding assign id in the assignids array.
2226
2183
$ moduleturnitinconfig = $ DB ->get_record ('plagiarism_turnitin_config ' ,
2227
2184
[ 'cm ' => $ tiisubmission ->cm , 'name ' => 'turnitin_assignid ' ]);
2228
2185
2229
2186
if (!isset (array_flip ($ assignmentids )[$ moduleturnitinconfig ->value ])) {
2230
2187
$ assignmentids [] = $ moduleturnitinconfig ->value ;
2231
- =======
2232
- // If submission is added to the request, add the corresponding assign id in the assignids array.
2233
- $ moduleturnitinconfig = $ DB ->get_record ('plagiarism_turnitin_config ' ,
2234
- [
2235
- 'cm ' => $ cm ->id ,
2236
- 'name ' => 'turnitin_assignid ' ,
2237
- ]
2238
- );
2239
-
2240
- if (!isset (array_flip ($ assignmentids )[$ moduleturnitinconfig ->value ])) {
2241
- $ assignmentids [] = $ moduleturnitinconfig ->value ;
2242
- }
2243
- >>>>>>> 796 b5bd (Fix 'Short array syntax must be used to define arrays ' warnings.)
2244
2188
}
2245
2189
}
2246
2190
}
@@ -2313,7 +2257,7 @@ public function cron_update_scores() {
2313
2257
// At the moment TII doesn't support double marking so we won't synchronise grades from Grade Mark
2314
2258
// as it would destroy the workflow.
2315
2259
if (!is_null ($ plagiarismfile ->grade ) && $ cm ->modname != "coursework " ) {
2316
- $ this ->update_grade ($ cm , $ readsubmission , $ currentsubmission ->userid , TRUE );
2260
+ $ this ->update_grade ($ cm , $ readsubmission , $ currentsubmission ->userid , true );
2317
2261
}
2318
2262
}
2319
2263
} catch (Exception $ e ) {
@@ -2840,14 +2784,9 @@ public function event_handler($eventdata) {
2840
2784
2841
2785
$ submissiontype = ($ cm ->modname == 'forum ' ) ? 'forum_post ' : 'text_content ' ;
2842
2786
2843
- <<<<<<< HEAD
2844
2787
// The content inside the event data will not always correspond to the content we will look up later, e.g.
2845
2788
// because URLs have been converted to use @@PLUGINFILE@@ etc. Therefore to calculate the same hash, we need to
2846
2789
// do a lookup to get the file content
2847
- =======
2848
- // phpcs:disable PSR2.Methods.MethodDeclaration.Underscore,moodle.Commenting.TodoComment
2849
- // TODO: Check eventdata to see if content is included correctly. If so, this can be removed.
2850
- >>>>>>> f6223b8 (Fixes for remaining errors/warnings.)
2851
2790
if ($ cm ->modname == 'workshop ' ) {
2852
2791
$ moodlesubmission = $ DB ->get_record ('workshop_submissions ' , ['id ' => $ eventdata ['objectid ' ]]);
2853
2792
$ eventdata ['other ' ]['content ' ] = $ moodlesubmission ->content ;
0 commit comments