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


PHP feedback_compare_item_value函数代码示例

本文整理汇总了PHP中feedback_compare_item_value函数的典型用法代码示例。如果您正苦于以下问题:PHP feedback_compare_item_value函数的具体用法?PHP feedback_compare_item_value怎么用?PHP feedback_compare_item_value使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: feedback_save_tmp_values

/**
 * this saves the temporary saved values permanently
 *
 * @global object
 * @param object $feedbackcompletedtmp the temporary completed
 * @param object $feedbackcompleted the target completed
 * @param int $userid
 * @return int the id of the completed
 */
function feedback_save_tmp_values($feedbackcompletedtmp, $feedbackcompleted, $userid) {
    global $DB;

    $tmpcplid = $feedbackcompletedtmp->id;
    if ($feedbackcompleted) {
        //first drop all existing values
        $DB->delete_records('feedback_value', array('completed'=>$feedbackcompleted->id));
        //update the current completed
        $feedbackcompleted->timemodified = time();
        $DB->update_record('feedback_completed', $feedbackcompleted);
    } else {
        $feedbackcompleted = clone($feedbackcompletedtmp);
        $feedbackcompleted->id = '';
        $feedbackcompleted->userid = $userid;
        $feedbackcompleted->timemodified = time();
        $feedbackcompleted->id = $DB->insert_record('feedback_completed', $feedbackcompleted);
    }

    //save all the new values from feedback_valuetmp
    //get all values of tmp-completed
    $params = array('completed'=>$feedbackcompletedtmp->id);
    if (!$values = $DB->get_records('feedback_valuetmp', $params)) {
        return false;
    }
    foreach ($values as $value) {
        //check if there are depend items
        $item = $DB->get_record('feedback_item', array('id'=>$value->item));
        if ($item->dependitem > 0) {
            $check = feedback_compare_item_value($tmpcplid,
                                        $item->dependitem,
                                        $item->dependvalue,
                                        true);
        } else {
            $check = true;
        }
        if ($check) {
            unset($value->id);
            $value->completed = $feedbackcompleted->id;
            $DB->insert_record('feedback_value', $value);
        }
    }
    //drop all the tmpvalues
    $DB->delete_records('feedback_valuetmp', array('completed'=>$tmpcplid));
    $DB->delete_records('feedback_completedtmp', array('id'=>$tmpcplid));
    return $feedbackcompleted->id;

}
开发者ID:numbas,项目名称:moodle,代码行数:56,代码来源:lib.php

示例2: right_to_left

            $lastbreakposition = 0;
            $align = right_to_left() ? 'right' : 'left';

            foreach ($feedbackitems as $feedbackitem) {
                if (!isset($startitem)) {
                    //avoid showing double pagebreaks
                    if ($feedbackitem->typ == 'pagebreak') {
                        continue;
                    }
                    $startitem = $feedbackitem;
                }

                if ($feedbackitem->dependitem > 0) {
                    //chech if the conditions are ok
                    $fb_compare_value = feedback_compare_item_value($feedbackcompletedtmp->id,
                                                                    $feedbackitem->dependitem,
                                                                    $feedbackitem->dependvalue,
                                                                    true);
                    if (!isset($feedbackcompletedtmp->id) OR !$fb_compare_value) {
                        $lastitem = $feedbackitem;
                        $lastbreakposition = $feedbackitem->position;
                        continue;
                    }
                }

                if ($feedbackitem->dependitem > 0) {
                    $dependstyle = ' feedback_complete_depend';
                } else {
                    $dependstyle = '';
                }

                echo $OUTPUT->box_start('feedback_item_box_'.$align.$dependstyle);
开发者ID:JP-Git,项目名称:moodle,代码行数:32,代码来源:complete.php

示例3: array

 echo $OUTPUT->box_start('feedback_items');
 $startitem = null;
 $itemnr = $DB->count_records_select('feedback_item', 'feedback = ? AND hasvalue = 1 AND position < ?', array($feedback->id, $startposition));
 $lastbreakposition = 0;
 $align = right_to_left() ? 'right' : 'left';
 foreach ($feedbackitems as $feedbackitem) {
     if (!isset($startitem)) {
         //avoid showing double pagebreaks
         if ($feedbackitem->typ == 'pagebreak') {
             continue;
         }
         $startitem = $feedbackitem;
     }
     if ($feedbackitem->dependitem > 0) {
         //chech if the conditions are ok
         if (!isset($feedbackcompletedtmp->id) or !feedback_compare_item_value($feedbackcompletedtmp->id, $feedbackitem->dependitem, $feedbackitem->dependvalue, true)) {
             $lastitem = $feedbackitem;
             $lastbreakposition = $feedbackitem->position;
             continue;
         }
     }
     if ($feedbackitem->dependitem > 0) {
         $dependstyle = ' feedback_complete_depend';
     } else {
         $dependstyle = '';
     }
     echo $OUTPUT->box_start('feedback_item_box_' . $align . $dependstyle);
     $value = '';
     //get the value
     $frmvaluename = $feedbackitem->typ . '_' . $feedbackitem->id;
     if (isset($savereturn)) {
开发者ID:vuchannguyen,项目名称:web,代码行数:31,代码来源:complete_guest.php

示例4: feedback_check_values

/**
 * this function checks the correctness of values.
 * the rules for this are implemented in the class of each item.
 * it can be the required attribute or the value self e.g. numeric.
 * the params first/lastitem are given to determine the visible range between pagebreaks.
 *
 * @global object
 * @param int $firstitem the position of firstitem for checking
 * @param int $lastitem the position of lastitem for checking
 * @return boolean
 */
function feedback_check_values($firstitem, $lastitem)
{
    global $DB, $CFG;
    $feedbackid = optional_param('feedbackid', 0, PARAM_INT);
    //get all items between the first- and lastitem
    $select = "feedback = ?\n                    AND position >= ?\n                    AND position <= ?\n                    AND hasvalue = 1";
    $params = array($feedbackid, $firstitem, $lastitem);
    if (!($feedbackitems = $DB->get_records_select('feedback_item', $select, $params))) {
        //if no values are given so no values can be wrong ;-)
        return true;
    }
    foreach ($feedbackitems as $item) {
        //get the instance of the item-class
        $itemobj = feedback_get_item_class($item->typ);
        //the name of the input field of the completeform is given in a special form:
        //<item-typ>_<item-id> eg. numeric_234
        //this is the key to get the value for the correct item
        $formvalname = $item->typ . '_' . $item->id;
        if ($itemobj->value_is_array()) {
            //get the raw value here. It is cleaned after that by the object itself
            $value = optional_param_array($formvalname, null, PARAM_RAW);
        } else {
            //get the raw value here. It is cleaned after that by the object itself
            $value = optional_param($formvalname, null, PARAM_RAW);
        }
        $value = $itemobj->clean_input_value($value);
        // If the item is not visible due to its dependency so it shouldn't be required.
        // Many thanks to Pau Ferrer Ocaña.
        if ($item->dependitem > 0 and $item->required == 1) {
            $comparevalue = false;
            if ($feedbackcompletedtmp = feedback_get_current_completed($item->feedback, true)) {
                $comparevalue = feedback_compare_item_value($feedbackcompletedtmp->id, $item->dependitem, $item->dependvalue, true);
            }
            if (!$comparevalue) {
                $item->required = 0;
                // Override the required property.
            }
        }
        //check if the value is set
        if (is_null($value) and $item->required == 1) {
            return false;
        }
        //now we let check the value by the item-class
        if (!$itemobj->check_value($value, $item)) {
            return false;
        }
    }
    //if no wrong values so we can return true
    return true;
}
开发者ID:Gavinthisisit,项目名称:Moodle,代码行数:61,代码来源:lib.php

示例5: feedback_save_tmp_values

/**
 * this saves the temporary saved values permanently
 *
 * @global object
 * @param object $feedbackcompletedtmp the temporary completed
 * @param object $feedbackcompleted the target completed
 * @param int $userid
 * @return int the id of the completed
 */
function feedback_save_tmp_values($feedbackcompletedtmp, $feedbackcompleted, $userid)
{
    global $DB;
    $tmpcplid = $feedbackcompletedtmp->id;
    if ($feedbackcompleted) {
        //first drop all existing values
        $DB->delete_records('feedback_value', array('completed' => $feedbackcompleted->id));
        //update the current completed
        $feedbackcompleted->timemodified = time();
        $DB->update_record('feedback_completed', $feedbackcompleted);
    } else {
        $feedbackcompleted = clone $feedbackcompletedtmp;
        $feedbackcompleted->id = '';
        $feedbackcompleted->userid = $userid;
        $feedbackcompleted->timemodified = time();
        $feedbackcompleted->id = $DB->insert_record('feedback_completed', $feedbackcompleted);
    }
    //save all the new values from feedback_valuetmp
    //get all values of tmp-completed
    $params = array('completed' => $feedbackcompletedtmp->id);
    if (!($values = $DB->get_records('feedback_valuetmp', $params))) {
        return false;
    }
    foreach ($values as $value) {
        //check if there are depend items
        $item = $DB->get_record('feedback_item', array('id' => $value->item));
        if ($item->dependitem > 0) {
            $check = feedback_compare_item_value($tmpcplid, $item->dependitem, $item->dependvalue, true);
        } else {
            $check = true;
        }
        if ($check) {
            unset($value->id);
            $value->completed = $feedbackcompleted->id;
            $DB->insert_record('feedback_value', $value);
        }
    }
    //drop all the tmpvalues
    $DB->delete_records('feedback_valuetmp', array('completed' => $tmpcplid));
    $DB->delete_records('feedback_completedtmp', array('id' => $tmpcplid));
    // Trigger event for the delete action we performed.
    $cm = get_coursemodule_from_instance('feedback', $feedbackcompleted->feedback);
    $event = \mod_feedback\event\response_submitted::create(array('relateduserid' => $userid, 'objectid' => $feedbackcompleted->id, 'context' => context_module::instance($cm->id), 'other' => array('cmid' => $cm->id, 'instanceid' => $feedbackcompleted->feedback, 'anonymous' => $feedbackcompleted->anonymous_response)));
    $event->add_record_snapshot('feedback_completed', $feedbackcompleted);
    $event->trigger();
    return $feedbackcompleted->id;
}
开发者ID:tyleung,项目名称:CMPUT401MoodleExams,代码行数:56,代码来源:lib.php

示例6: feedback_save_tmp_values

/**
 * this saves the temporary saved values permanently
 *
 * @global object
 * @param object $feedbackcompletedtmp the temporary completed
 * @param object $feedbackcompleted the target completed
 * @return int the id of the completed
 */
function feedback_save_tmp_values($feedbackcompletedtmp, $feedbackcompleted)
{
    global $DB;
    $tmpcplid = $feedbackcompletedtmp->id;
    if ($feedbackcompleted) {
        //first drop all existing values
        $DB->delete_records('feedback_value', array('completed' => $feedbackcompleted->id));
        //update the current completed
        $feedbackcompleted->timemodified = time();
        $DB->update_record('feedback_completed', $feedbackcompleted);
    } else {
        $feedbackcompleted = clone $feedbackcompletedtmp;
        $feedbackcompleted->id = '';
        $feedbackcompleted->timemodified = time();
        $feedbackcompleted->id = $DB->insert_record('feedback_completed', $feedbackcompleted);
    }
    $allitems = $DB->get_records('feedback_item', array('feedback' => $feedbackcompleted->feedback));
    //save all the new values from feedback_valuetmp
    //get all values of tmp-completed
    $params = array('completed' => $feedbackcompletedtmp->id);
    $values = $DB->get_records('feedback_valuetmp', $params);
    foreach ($values as $value) {
        //check if there are depend items
        $item = $DB->get_record('feedback_item', array('id' => $value->item));
        if ($item->dependitem > 0 && isset($allitems[$item->dependitem])) {
            $check = feedback_compare_item_value($tmpcplid, $allitems[$item->dependitem], $item->dependvalue, true);
        } else {
            $check = true;
        }
        if ($check) {
            unset($value->id);
            $value->completed = $feedbackcompleted->id;
            $DB->insert_record('feedback_value', $value);
        }
    }
    //drop all the tmpvalues
    $DB->delete_records('feedback_valuetmp', array('completed' => $tmpcplid));
    $DB->delete_records('feedback_completedtmp', array('id' => $tmpcplid));
    // Trigger event for the delete action we performed.
    $cm = get_coursemodule_from_instance('feedback', $feedbackcompleted->feedback);
    $event = \mod_feedback\event\response_submitted::create_from_record($feedbackcompleted, $cm);
    $event->trigger();
    return $feedbackcompleted->id;
}
开发者ID:evltuma,项目名称:moodle,代码行数:52,代码来源:lib.php


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