本文整理汇总了PHP中feedback_create_template函数的典型用法代码示例。如果您正苦于以下问题:PHP feedback_create_template函数的具体用法?PHP feedback_create_template怎么用?PHP feedback_create_template使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了feedback_create_template函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: feedback_save_as_template
/**
* creates new template items.
* all items will be copied and the attribute feedback will be set to 0
* and the attribute template will be set to the new templateid
* @param object $feedback
* @param string $name the name of template shown in the templatelist
* @param int $ispublic 0:privat 1:public
* @return boolean
*/
function feedback_save_as_template($feedback, $name, $ispublic = 0)
{
$feedbackitems = get_records('feedback_item', 'feedback', $feedback->id);
if (!is_array($feedbackitems)) {
return false;
}
if (!($newtempl = feedback_create_template($feedback->course, $name, $ispublic))) {
return false;
}
//create items of this new template
foreach ($feedbackitems as $item) {
$item->id = '';
$item->feedback = 0;
$item->template = $newtempl;
$item->name = addslashes($item->name);
$item->presentation = addslashes($item->presentation);
insert_record('feedback_item', $item);
}
return true;
}
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:29,代码来源:lib.php
示例2: feedback_save_as_template
/**
* creates new template items.
* all items will be copied and the attribute feedback will be set to 0
* and the attribute template will be set to the new templateid
*
* @global object
* @uses CONTEXT_MODULE
* @uses CONTEXT_COURSE
* @param object $feedback
* @param string $name the name of template shown in the templatelist
* @param int $ispublic 0:privat 1:public
* @return boolean
*/
function feedback_save_as_template($feedback, $name, $ispublic = 0) {
global $DB;
$fs = get_file_storage();
if (!$feedbackitems = $DB->get_records('feedback_item', array('feedback'=>$feedback->id))) {
return false;
}
if (!$newtempl = feedback_create_template($feedback->course, $name, $ispublic)) {
return false;
}
//files in the template_item are in the context of the current course or
//if the template is public the files are in the system context
//files in the feedback_item are in the feedback_context of the feedback
if ($ispublic) {
$s_context = get_system_context();
} else {
$s_context = get_context_instance(CONTEXT_COURSE, $newtempl->course);
}
$cm = get_coursemodule_from_instance('feedback', $feedback->id);
$f_context = get_context_instance(CONTEXT_MODULE, $cm->id);
//create items of this new template
//depend items we are storing temporary in an mapping list array(new id => dependitem)
//we also store a mapping of all items array(oldid => newid)
$dependitemsmap = array();
$itembackup = array();
foreach ($feedbackitems as $item) {
$t_item = clone($item);
unset($t_item->id);
$t_item->feedback = 0;
$t_item->template = $newtempl->id;
$t_item->id = $DB->insert_record('feedback_item', $t_item);
//copy all included files to the feedback_template filearea
$itemfiles = $fs->get_area_files($f_context->id,
'mod_feedback',
'item',
$item->id,
"id",
false);
if ($itemfiles) {
foreach ($itemfiles as $ifile) {
$file_record = new stdClass();
$file_record->contextid = $s_context->id;
$file_record->component = 'mod_feedback';
$file_record->filearea = 'template';
$file_record->itemid = $t_item->id;
$fs->create_file_from_storedfile($file_record, $ifile);
}
}
$itembackup[$item->id] = $t_item->id;
if ($t_item->dependitem) {
$dependitemsmap[$t_item->id] = $t_item->dependitem;
}
}
//remapping the dependency
foreach ($dependitemsmap as $key => $dependitem) {
$newitem = $DB->get_record('feedback_item', array('id'=>$key));
$newitem->dependitem = $itembackup[$newitem->dependitem];
$DB->update_record('feedback_item', $newitem);
}
return true;
}
开发者ID:numbas,项目名称:moodle,代码行数:83,代码来源:lib.php
示例3: feedback_save_as_template
/**
* creates new template items.
* all items will be copied and the attribute feedback will be set to 0
* and the attribute template will be set to the new templateid
*
* @global object
* @param object $feedback
* @param string $name the name of template shown in the templatelist
* @param int $ispublic 0:privat 1:public
* @return boolean
*/
function feedback_save_as_template($feedback, $name, $ispublic = 0)
{
global $DB;
if (!($feedbackitems = $DB->get_records('feedback_item', array('feedback' => $feedback->id)))) {
return false;
}
if (!($newtempl = feedback_create_template($feedback->course, $name, $ispublic))) {
return false;
}
//create items of this new template
foreach ($feedbackitems as $item) {
unset($item->id);
$item->feedback = 0;
$item->template = $newtempl;
$DB->insert_record('feedback_item', $nitem);
}
return true;
}
开发者ID:ajv,项目名称:Offline-Caching,代码行数:29,代码来源:lib.php
注:本文中的feedback_create_template函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论