mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 12:40:01 +01:00
MDL-36990 mod_feedback - move ajax function into lib.php
This commit is contained in:
parent
575c88c12f
commit
3b4afad07c
@ -5,6 +5,7 @@ if (!defined('AJAX_SCRIPT')) {
|
||||
}
|
||||
|
||||
require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
|
||||
require_once("lib.php");
|
||||
|
||||
$id = required_param('id', PARAM_INT);
|
||||
$action = optional_param('action', '', PARAM_ALPHA);
|
||||
@ -34,20 +35,3 @@ switch ($action) {
|
||||
|
||||
echo json_encode($return);
|
||||
die;
|
||||
|
||||
////////////////////////////////////////
|
||||
|
||||
function feedback_ajax_saveitemorder($itemlist, $feedback) {
|
||||
global $DB;
|
||||
|
||||
$result = true;
|
||||
$position = 0;
|
||||
foreach ($itemlist as $itemid) {
|
||||
$position++;
|
||||
$result = $result && $DB->set_field('feedback_item',
|
||||
'position',
|
||||
$position,
|
||||
array('id'=>$itemid, 'feedback'=>$feedback->id));
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
@ -3122,3 +3122,24 @@ function feedback_page_type_list($pagetype, $parentcontext, $currentcontext) {
|
||||
$module_pagetype = array('mod-feedback-*'=>get_string('page-mod-feedback-x', 'feedback'));
|
||||
return $module_pagetype;
|
||||
}
|
||||
|
||||
/**
|
||||
* Move save the items of the given $feedback in the order of $itemlist.
|
||||
* @param string $itemlist a comma separated list with item ids
|
||||
* @param stdClass $feedback
|
||||
* @return bool true if success
|
||||
*/
|
||||
function feedback_ajax_saveitemorder($itemlist, $feedback) {
|
||||
global $DB;
|
||||
|
||||
$result = true;
|
||||
$position = 0;
|
||||
foreach ($itemlist as $itemid) {
|
||||
$position++;
|
||||
$result = $result && $DB->set_field('feedback_item',
|
||||
'position',
|
||||
$position,
|
||||
array('id'=>$itemid, 'feedback'=>$feedback->id));
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user