Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
moodle
moodle
Commits
398a160d
Commit
398a160d
authored
Apr 22, 2009
by
skodak
Browse files
MDL-18934 removed legacy grading support
parent
38a9fc55
Changes
3
Hide whitespace changes
Inline
Side-by-side
grade/edit/tree/index.php
View file @
398a160d
...
...
@@ -157,10 +157,6 @@ switch ($action) {
//TODO: implement autosorting based on order of mods on course page, categories first, manual items last
break
;
case
'synclegacy'
:
grade_grab_legacy_grades
(
$course
->
id
);
redirect
(
$returnurl
);
case
'move'
:
if
(
$eid
and
confirm_sesskey
())
{
$moveafter
=
required_param
(
'moveafter'
,
PARAM_ALPHANUM
);
...
...
@@ -361,9 +357,6 @@ if ($moving) {
}
//print_single_button('index.php', array('id'=>$course->id, 'action'=>'autosort'), get_string('autosort', 'grades'), 'get');
echo
"<br /><br />"
;
print_single_button
(
'index.php'
,
array
(
'id'
=>
$course
->
id
,
'action'
=>
'synclegacy'
),
get_string
(
'synclegacygrades'
,
'grades'
),
'get'
);
helpbutton
(
'synclegacygrades'
,
get_string
(
'synclegacygrades'
,
'grades'
),
'grade'
);
}
echo
'</div>'
;
...
...
lib/gradelib.php
View file @
398a160d
...
...
@@ -997,38 +997,6 @@ function grade_regrade_final_grades($courseid, $userid=null, $updated_item=null)
}
}
/**
* For backwards compatibility with old third-party modules, this function can
* be used to import all grades from activities with legacy grading.
* @param int $courseid
*/
function
grade_grab_legacy_grades
(
$courseid
)
{
global
$CFG
;
if
(
!
$mods
=
get_list_of_plugins
(
'mod'
)
)
{
print_error
(
'nomodules'
,
'debug'
);
}
foreach
(
$mods
as
$mod
)
{
if
(
$mod
==
'NEWMODULE'
)
{
// Someone has unzipped the template, ignore it
continue
;
}
$fullmod
=
$CFG
->
dirroot
.
'/mod/'
.
$mod
;
// include the module lib once
if
(
file_exists
(
$fullmod
.
'/lib.php'
))
{
include_once
(
$fullmod
.
'/lib.php'
);
// look for modname_grades() function - old gradebook pulling function
// if present sync the grades with new grading system
$gradefunc
=
$mod
.
'_grades'
;
if
(
function_exists
(
$gradefunc
))
{
grade_grab_course_grades
(
$courseid
,
$mod
);
}
}
}
}
/**
* Refetches data from all course activities
* @param int $courseid
...
...
@@ -1081,7 +1049,7 @@ function grade_grab_course_grades($courseid, $modname=null) {
}
/**
* Force full update of module grades in central gradebook
- works for both legacy and converted activities.
* Force full update of module grades in central gradebook
* @param object $modinstance object with extra cmidnumber and modname property
* @return boolean success
*/
...
...
@@ -1095,64 +1063,10 @@ function grade_update_mod_grades($modinstance, $userid=0) {
}
include_once
(
$fullmod
.
'/lib.php'
);
// does it use legacy grading?
$gradefunc
=
$modinstance
->
modname
.
'_grades'
;
$updategradesfunc
=
$modinstance
->
modname
.
'_update_grades'
;
$updateitemfunc
=
$modinstance
->
modname
.
'_grade_item_update'
;
if
(
function_exists
(
$gradefunc
))
{
// legacy module - not yet converted
if
(
$oldgrades
=
$gradefunc
(
$modinstance
->
id
))
{
$grademax
=
$oldgrades
->
maxgrade
;
$scaleid
=
NULL
;
if
(
!
is_numeric
(
$grademax
))
{
// scale name is provided as a string, try to find it
if
(
!
$scale
=
$DB
->
get_record
(
'scale'
,
array
(
'name'
=>
$grademax
)))
{
debugging
(
'Incorrect scale name! name:'
.
$grademax
);
return
false
;
}
$scaleid
=
$scale
->
id
;
}
if
(
!
$grade_item
=
grade_get_legacy_grade_item
(
$modinstance
,
$grademax
,
$scaleid
))
{
debugging
(
'Can not get/create legacy grade item!'
);
return
false
;
}
if
(
!
empty
(
$oldgrades
->
grades
))
{
$grades
=
array
();
foreach
(
$oldgrades
->
grades
as
$uid
=>
$usergrade
)
{
if
(
$userid
and
$uid
!=
$userid
)
{
continue
;
}
$grade
=
new
object
();
$grade
->
userid
=
$uid
;
if
(
$usergrade
==
'-'
)
{
// no grade
$grade
->
rawgrade
=
null
;
}
else
if
(
$scaleid
)
{
// scale in use, words used
$gradescale
=
explode
(
","
,
$scale
->
scale
);
$grade
->
rawgrade
=
array_search
(
$usergrade
,
$gradescale
)
+
1
;
}
else
{
// good old numeric value
$grade
->
rawgrade
=
$usergrade
;
}
$grades
[]
=
$grade
;
}
grade_update
(
'legacygrab'
,
$grade_item
->
courseid
,
$grade_item
->
itemtype
,
$grade_item
->
itemmodule
,
$grade_item
->
iteminstance
,
$grade_item
->
itemnumber
,
$grades
);
}
}
}
else
if
(
function_exists
(
$updategradesfunc
)
and
function_exists
(
$updateitemfunc
))
{
if
(
function_exists
(
$updategradesfunc
)
and
function_exists
(
$updateitemfunc
))
{
//new grading supported, force updating of grades
$updateitemfunc
(
$modinstance
);
$updategradesfunc
(
$modinstance
,
$userid
);
...
...
@@ -1164,70 +1078,6 @@ function grade_update_mod_grades($modinstance, $userid=0) {
return
true
;
}
/**
* Get and update/create grade item for legacy modules.
*/
function
grade_get_legacy_grade_item
(
$modinstance
,
$grademax
,
$scaleid
)
{
// does it already exist?
if
(
$grade_items
=
grade_item
::
fetch_all
(
array
(
'courseid'
=>
$modinstance
->
course
,
'itemtype'
=>
'mod'
,
'itemmodule'
=>
$modinstance
->
modname
,
'iteminstance'
=>
$modinstance
->
id
,
'itemnumber'
=>
0
)))
{
if
(
count
(
$grade_items
)
>
1
)
{
debugging
(
'Multiple legacy grade_items found.'
);
return
false
;
}
$grade_item
=
reset
(
$grade_items
);
if
(
is_null
(
$grademax
)
and
is_null
(
$scaleid
))
{
$grade_item
->
gradetype
=
GRADE_TYPE_NONE
;
}
else
if
(
$scaleid
)
{
$grade_item
->
gradetype
=
GRADE_TYPE_SCALE
;
$grade_item
->
scaleid
=
$scaleid
;
$grade_item
->
grademin
=
1
;
}
else
{
$grade_item
->
gradetype
=
GRADE_TYPE_VALUE
;
$grade_item
->
grademax
=
$grademax
;
$grade_item
->
grademin
=
0
;
}
$grade_item
->
itemname
=
$modinstance
->
name
;
$grade_item
->
idnumber
=
$modinstance
->
cmidnumber
;
$grade_item
->
update
();
return
$grade_item
;
}
// create new one
$params
=
array
(
'courseid'
=>
$modinstance
->
course
,
'itemtype'
=>
'mod'
,
'itemmodule'
=>
$modinstance
->
modname
,
'iteminstance'
=>
$modinstance
->
id
,
'itemnumber'
=>
0
,
'itemname'
=>
$modinstance
->
name
,
'idnumber'
=>
$modinstance
->
cmidnumber
);
if
(
is_null
(
$grademax
)
and
is_null
(
$scaleid
))
{
$params
[
'gradetype'
]
=
GRADE_TYPE_NONE
;
}
else
if
(
$scaleid
)
{
$params
[
'gradetype'
]
=
GRADE_TYPE_SCALE
;
$params
[
'scaleid'
]
=
$scaleid
;
$grade_item
->
grademin
=
1
;
}
else
{
$params
[
'gradetype'
]
=
GRADE_TYPE_VALUE
;
$params
[
'grademax'
]
=
$grademax
;
$params
[
'grademin'
]
=
0
;
}
$grade_item
=
new
grade_item
(
$params
);
$grade_item
->
insert
();
return
$grade_item
;
}
/**
* Remove grade letters for given context
* @param object $context
...
...
mod/upgrade.txt
View file @
398a160d
...
...
@@ -13,6 +13,7 @@ required changes in code:
* rewrite backup/restore
* rewrite trusstext support - new db table columns needed
* migrade all module features from mod_edit.php form to lib.php/modulename_supports() function
* implement new gradebook support (legacy 1.8.x grading not supported anymore)
optional - no changes needed in older code:
* portfolio support
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment