当前位置: 首页>>代码示例>>PHP>>正文


PHP grade_grade::delete方法代码示例

本文整理汇总了PHP中grade_grade::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP grade_grade::delete方法的具体用法?PHP grade_grade::delete怎么用?PHP grade_grade::delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在grade_grade的用法示例。


在下文中一共展示了grade_grade::delete方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: stdClass

 function test_gradebook()
 {
     global $DB;
     $this->resetAfterTest(true);
     // reset all changes automatically after this test
     $location_str = 'manual';
     // try to get category
     $grade_category = grade_category::fetch(array('courseid' => $this->courseid, 'fullname' => $this->cat_name));
     // NOTE: grade category will not be null but it will be empty
     $this->assertFalse($grade_category);
     // create a category
     $params = new stdClass();
     $params->courseid = $this->courseid;
     $params->fullname = $this->cat_name;
     $grade_category = new grade_category($params, false);
     $this->assertTrue(method_exists($grade_category, 'insert'));
     $grade_category->insert($location_str);
     // now we will really get the category that we just made
     $grade_category_fetched = grade_category::fetch(array('courseid' => $this->courseid, 'fullname' => $this->cat_name));
     $this->assertTrue($grade_category_fetched !== false);
     $this->assertEquals($grade_category->id, $grade_category_fetched->id);
     $this->assertEquals($grade_category->courseid, $grade_category_fetched->courseid);
     $this->assertEquals($grade_category->path, $grade_category_fetched->path);
     $this->assertEquals($grade_category->fullname, $grade_category_fetched->fullname);
     $this->assertEquals($grade_category->parent, $grade_category_fetched->parent);
     // try to get grade item
     $grade_item = grade_item::fetch(array('courseid' => $this->courseid, 'categoryid' => $grade_category->id, 'itemname' => $this->item_name));
     // NOTE: grade category will not be null but it will be empty
     $this->assertFalse($grade_item);
     // create a grade item
     $grade_item = new grade_item();
     $this->assertTrue(method_exists($grade_item, 'insert'));
     $grade_item->courseid = $this->courseid;
     $grade_item->categoryid = $grade_category->id;
     $grade_item->idnumber = $this->item_name;
     // lookup
     $grade_item->itemname = $this->item_name;
     // display
     $grade_item->itemtype = 'blocks';
     $grade_item->itemmodule = 'iclicker';
     $grade_item->iteminfo = 'blocks/iclicker for unit testing';
     // grademax=100, grademin=0
     $grade_item->grademax = 100.0;
     $grade_item->insert($location_str);
     // now we will really get the new item
     $grade_item_fetched = grade_item::fetch(array('courseid' => $this->courseid, 'categoryid' => $grade_category->id, 'itemname' => $this->item_name));
     $this->assertTrue($grade_item_fetched !== false);
     $this->assertEquals($grade_item->id, $grade_item_fetched->id);
     $this->assertEquals($grade_item->courseid, $grade_item_fetched->courseid);
     $this->assertEquals($grade_item->categoryid, $grade_item_fetched->categoryid);
     $this->assertEquals($grade_item->itemname, $grade_item_fetched->itemname);
     // get empty grades list
     $all_grades = grade_grade::fetch_all(array('itemid' => $grade_item->id));
     $this->assertFalse($all_grades);
     // add grade
     $grade_grade = new grade_grade();
     $this->assertTrue(method_exists($grade_grade, 'insert'));
     $grade_grade->itemid = $grade_item->id;
     $grade_grade->userid = $this->studentid1;
     $grade_grade->rawgrade = $this->grade_score;
     $grade_grade->insert($location_str);
     // get new grade
     $grade_grade_fetched = grade_grade::fetch(array('itemid' => $grade_item->id, 'userid' => $this->studentid1));
     $this->assertTrue($grade_grade_fetched !== false);
     $this->assertEquals($grade_grade->id, $grade_grade_fetched->id);
     $this->assertEquals($grade_grade->itemid, $grade_grade_fetched->itemid);
     $this->assertEquals($grade_grade->userid, $grade_grade_fetched->userid);
     $this->assertEquals($grade_grade->rawgrade, $grade_grade_fetched->rawgrade);
     // update the grade
     $grade_grade->rawgrade = 50;
     $result = $grade_grade->update($location_str);
     $this->assertTrue($result);
     $grade_grade_fetched = grade_grade::fetch(array('id' => $grade_grade->id));
     $this->assertTrue($grade_grade_fetched !== false);
     $this->assertEquals($grade_grade->id, $grade_grade_fetched->id);
     $this->assertEquals($grade_grade->rawgrade, $grade_grade_fetched->rawgrade);
     $this->assertEquals(50, $grade_grade_fetched->rawgrade);
     // get grades
     $all_grades = grade_grade::fetch_all(array('itemid' => $grade_item->id));
     $this->assertTrue($all_grades !== false);
     $this->assertEquals(1, sizeof($all_grades));
     // add more grades
     $grade_grade2 = new grade_grade();
     $grade_grade2->itemid = $grade_item->id;
     $grade_grade2->userid = $this->studentid2;
     $grade_grade2->rawgrade = $this->grade_score;
     $grade_grade2->insert($location_str);
     // get grades
     $all_grades = grade_grade::fetch_all(array('itemid' => $grade_item->id));
     $this->assertTrue($all_grades !== false);
     $this->assertEquals(2, sizeof($all_grades));
     // make sure this can run
     $result = $grade_item->regrade_final_grades();
     $this->assertTrue($result);
     // remove grades
     $this->assertTrue(method_exists($grade_grade, 'delete'));
     $result = $grade_grade->delete($location_str);
     $this->assertTrue($result);
     $result = $grade_grade2->delete($location_str);
     $this->assertTrue($result);
//.........这里部分代码省略.........
开发者ID:dirkcgrunwald,项目名称:iclicker-moodle2-integrate,代码行数:101,代码来源:gradebook_test.php


注:本文中的grade_grade::delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。