當前位置: 首頁>>代碼示例>>PHP>>正文


PHP rating_manager::check_rating_is_valid方法代碼示例

本文整理匯總了PHP中rating_manager::check_rating_is_valid方法的典型用法代碼示例。如果您正苦於以下問題:PHP rating_manager::check_rating_is_valid方法的具體用法?PHP rating_manager::check_rating_is_valid怎麽用?PHP rating_manager::check_rating_is_valid使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在rating_manager的用法示例。


在下文中一共展示了rating_manager::check_rating_is_valid方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: test_lib_hooks

 /**
  * Tests getting forum object from id and cmid, inc clones.
  */
 public function test_lib_hooks()
 {
     global $USER, $DB;
     $this->resetAfterTest();
     $generator = $this->getDataGenerator()->get_plugin_generator('mod_forumng');
     $course = $this->get_new_course();
     $suser = $this->get_new_user('student', $course->id);
     $forum = $this->get_new_forumng($course->id, array('name' => 'TEST', 'intro' => 'abc123', 'enableratings' => mod_forumng::FORUMNG_STANDARD_RATING, 'ratingscale' => 10));
     $cm = get_coursemodule_from_instance('forumng', $forum->get_id());
     $result = forumng_rating_permissions($forum->get_context()->id, 'mod_forumng', 'post');
     $this->assertTrue(is_array($result));
     foreach ($result as $cap) {
         $this->assertFalse($cap);
     }
     $this->setAdminUser();
     $result = forumng_rating_permissions($forum->get_context()->id, 'mod_forumng', 'post');
     $this->assertTrue(is_array($result));
     foreach ($result as $cap) {
         $this->assertTrue($cap);
     }
     $did1 = $generator->create_discussion(array('course' => $course, 'forum' => $forum->get_id(), 'userid' => $USER->id));
     $post = $generator->create_post(array('discussionid' => $did1[0], 'parentpostid' => $did1[1], 'userid' => $suser->id));
     $rm = new rating_manager();
     $params = array();
     $params['context'] = $forum->get_context();
     $params['component'] = 'mod_forumng';
     $params['ratingarea'] = 'post';
     $params['itemid'] = $did1[1];
     $params['scaleid'] = $forum->get_rating_scale();
     $params['rateduserid'] = $USER->id;
     $params['rating'] = 21;
     // Check rating valid, should fail with same user + rating too high.
     $this->setExpectedException('rating_exception', get_string('nopermissiontorate', 'error'));
     $rm->check_rating_is_valid($params);
     $params['itemid'] = $post->id;
     $params['rateduserid'] = $suser->id;
     $this->setExpectedException('rating_exception', get_string('invalidnum', 'error'));
     $rm->check_rating_is_valid($params);
     $params['rating'] = 10;
     $result = $rm->check_rating_is_valid($params);
     $this->assertTrue($result);
     // Call to update grades (should do nothing as grading not set, no assertions).
     forumng_update_grades($DB->get_record('forumng', array('id' => $forum->get_id())));
     // Check clones.
     $forum1 = $this->get_new_forumng($course->id, array('name' => 'TEST', 'intro' => 'abc123', 'shared' => true, 'cmidnumber' => 'SF1', 'enableratings' => mod_forumng::FORUMNG_STANDARD_RATING, 'ratingscale' => 10));
     $forum2 = $this->get_new_forumng($course->id, array('name' => 'TEST', 'usesharedgroup' => array('useshared' => true, 'originalcmidnumber' => 'SF1')));
     $did1 = $generator->create_discussion(array('course' => $course, 'forum' => $forum1->get_id(), 'userid' => $USER->id));
     $post = $generator->create_post(array('discussionid' => $did1[0], 'parentpostid' => $did1[1], 'userid' => $suser->id));
     $params['itemid'] = $post->id;
     $params['context'] = $forum2->get_context(true);
     $result = $rm->check_rating_is_valid($params);
     $this->assertTrue($result);
 }
開發者ID:ULCC-QMUL,項目名稱:moodle-mod_forumng,代碼行數:56,代碼來源:rating_test.php

示例2: array

    echo $OUTPUT->header();
    echo get_string('ratepermissiondenied', 'rating');
    echo $OUTPUT->footer();
    die;
}
$rm = new rating_manager();
//check the module rating permissions
//doing this check here rather than within rating_manager::get_ratings() so we can return a json error response
$pluginpermissionsarray = $rm->get_plugin_permissions_array($context->id, $component, $ratingarea);
if (!$pluginpermissionsarray['rate']) {
    $result->error = get_string('ratepermissiondenied', 'rating');
    echo json_encode($result);
    die;
} else {
    $params = array('context' => $context, 'component' => $component, 'ratingarea' => $ratingarea, 'itemid' => $itemid, 'scaleid' => $scaleid, 'rating' => $userrating, 'rateduserid' => $rateduserid);
    if (!$rm->check_rating_is_valid($params)) {
        echo $OUTPUT->header();
        echo get_string('ratinginvalid', 'rating');
        echo $OUTPUT->footer();
        die;
    }
}
if ($userrating != RATING_UNSET_RATING) {
    $ratingoptions = new stdClass();
    $ratingoptions->context = $context;
    $ratingoptions->component = $component;
    $ratingoptions->ratingarea = $ratingarea;
    $ratingoptions->itemid = $itemid;
    $ratingoptions->scaleid = $scaleid;
    $ratingoptions->userid = $USER->id;
    $rating = new rating($ratingoptions);
開發者ID:EmmanuelYupit,項目名稱:educursos,代碼行數:31,代碼來源:rate.php

示例3: array

    echo $OUTPUT->header();
    echo get_string('ratepermissiondenied', 'rating');
    echo $OUTPUT->footer();
    die;
}
$rm = new rating_manager();
//check the module rating permissions
//doing this check here rather than within rating_manager::get_ratings() so we can return a json error response
$pluginpermissionsarray = $rm->get_plugin_permissions_array($context->id, $component);
if (!$pluginpermissionsarray['rate']) {
    $result->error = get_string('ratepermissiondenied', 'rating');
    echo json_encode($result);
    die;
} else {
    $params = array('context' => $context, 'itemid' => $itemid, 'scaleid' => $scaleid, 'rating' => $userrating, 'rateduserid' => $rateduserid);
    if (!$rm->check_rating_is_valid($component, $params)) {
        echo $OUTPUT->header();
        echo get_string('ratinginvalid', 'rating');
        echo $OUTPUT->footer();
        die;
    }
}
if ($userrating != RATING_UNSET_RATING) {
    $ratingoptions = new stdClass();
    $ratingoptions->context = $context;
    $ratingoptions->component = $component;
    $ratingoptions->itemid = $itemid;
    $ratingoptions->scaleid = $scaleid;
    $ratingoptions->userid = $USER->id;
    $rating = new rating($ratingoptions);
    $rating->update_rating($userrating);
開發者ID:esyacelga,項目名稱:sisadmaca,代碼行數:31,代碼來源:rate.php


注:本文中的rating_manager::check_rating_is_valid方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。