123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- $use_anonymous = true;
- require_once __DIR__.'/../inc/global.inc.php';
- function save_objectives($lp_id, $user_id, $view_id, $item_id, $objectives = array())
- {
- $debug = 0;
- $return = '';
- if ($debug > 0) {
- error_log('In xajax_save_objectives('.$lp_id.','.$user_id.','.$view_id.','.$item_id.',"'.(count($objectives) > 0 ? count($objectives) : '').'")', 0);
- }
- $mylp = learnpath::getLpFromSession(api_get_course_id(), $lp_id, $user_id);
- $mylpi = & $mylp->items[$item_id];
- if (is_array($objectives) && count($objectives) > 0) {
- foreach ($objectives as $index=>$objective) {
- $mylpi->add_objective($index, $objectives[$index]);
- }
- $mylpi->write_objectives_to_db();
- }
- return $return;
- }
- $objectives = array();
- if (isset($_REQUEST['objectives'])) {
- if (is_array($_REQUEST['objectives'])) {
- foreach ($_REQUEST['objectives'] as $idx => $ob) {
- $objectives[$idx] = explode(',', substr($ob, 1, -1));
- if (!isset($objectives[$idx][4])) {
-
- $objectives[$idx][4] = '';
- }
- }
- }
- }
- echo save_objectives(
- $_REQUEST['lid'],
- $_REQUEST['uid'],
- $_REQUEST['vid'],
- $_REQUEST['iid'],
- $objectives
- );
|