本文整理汇总了PHP中student::retrieve_grade_elements方法的典型用法代码示例。如果您正苦于以下问题:PHP student::retrieve_grade_elements方法的具体用法?PHP student::retrieve_grade_elements怎么用?PHP student::retrieve_grade_elements使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类student
的用法示例。
在下文中一共展示了student::retrieve_grade_elements方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_gradeelementssort
/**
* Test grade elements sorting.
*/
public function test_gradeelementssort()
{
global $CFG, $DB;
$this->load_csv_data();
$rec1 = new stdClass();
$rec1->id = 1;
$rec1->studentgradeid = 1;
$rec1->idnumber = 'required';
$rec1->grade = '0.00000';
$rec1->locked = 0;
$rec1->timegraded = 0;
$rec2 = new stdClass();
$rec2->id = 2;
$rec2->studentgradeid = 2;
$rec2->idnumber = 'notrequired';
$rec2->grade = '80.00000';
$rec2->locked = 0;
$rec2->timegraded = 0;
$dataset = array();
$dataset[$rec1->id] = $rec1;
$dataset[$rec2->id] = $rec2;
// Test idnumber descending sorting.
$sort = student::retrieve_grade_elements(100, 100, 103, 'idnumber', 'DESC');
$sortvalues = array();
foreach ($sort as $val) {
$sortvalues[] = $val;
}
unset($sort);
$this->assertEquals(array_values($dataset), $sortvalues);
// Test grade ascending sorting.
$sort = student::retrieve_grade_elements(100, 100, 103, 'grade', 'ASC');
$sortvalues = array();
foreach ($sort as $val) {
$sortvalues[] = $val;
}
unset($sort);
$this->assertEquals(array_values($dataset), $sortvalues);
$dataset = array();
// Swap.
$dataset[$rec2->id] = $rec2;
$dataset[$rec1->id] = $rec1;
// Test idnumber ascending sorting.
$sort = student::retrieve_grade_elements(100, 100, 103, 'idnumber', 'ASC');
$sortvalues = array();
foreach ($sort as $val) {
$sortvalues[] = $val;
}
unset($sort);
$this->assertEquals(array_values($dataset), $sortvalues);
// Test grade descending sorting.
$sort = student::retrieve_grade_elements(100, 100, 103, 'grade', 'DESC');
$sortvalues = array();
foreach ($sort as $val) {
$sortvalues[] = $val;
}
unset($sort);
$this->assertEquals(array_values($dataset), $sortvalues);
// Test empty array on no results.
$sort = student::retrieve_grade_elements(-1, 100, 103, 'grade', 'DESC');
$sortvalues = array();
foreach ($sort as $val) {
$sortvalues[] = $val;
}
unset($sort);
$this->assertEquals(array(), $sortvalues);
}