Ejemplo n.º 1
0
$toollist = array();
if ($tools) {
    foreach ($tools as $tool) {
        if ($tool->type == 'tmp') {
            //llamada para obtener datos y actualizar. Por lo general
            $response = webservice_evalcomix_client::get_ws_list_tool($course->id, $tool->idtool);
            if ($response != false) {
                $tool->type = $response->type;
                $tool->title = $response->title;
                $tool->update();
                array_push($toollist, $tool);
            } else {
                $result = $tool->delete();
            }
        } else {
            array_push($toollist, $tool);
        }
    }
}
if ($sorttool == 'title') {
    usort($toollist, 'cmp_type_tool');
    usort($toollist, 'cmp_title_tool');
} elseif ($sorttool == 'type') {
    usort($toollist, 'cmp_title_tool');
    usort($toollist, 'cmp_type_tool');
}
//$array = sort_object_array($tools, 'title');print_r($array);exit;
$lang = current_language();
$url_create = webservice_evalcomix_client::get_ws_createtool(null, $lms = MOODLE_NAME, $course->id, $lang . '_utf8');
$counttool = count($toollist);
echo '
Ejemplo n.º 2
0
include_once $CFG->dirroot . '/blocks/evalcomix/classes/evalcomix_tasks.php';
include_once $CFG->dirroot . '/blocks/evalcomix/classes/evalcomix_tool.php';
include_once $CFG->dirroot . '/blocks/evalcomix/classes/evalcomix_modes.php';
$courseid = required_param('id', PARAM_INT);
// course id
$toolid = required_param('t', PARAM_ALPHANUM);
//toolid
require_login($courseid);
$context = context_course::instance($course->id);
$url = new moodle_url('/blocks/evalcomix/tool/edit_form.php', array('courseid' => $courseid, 't' => $toolid));
$PAGE->set_url($url);
$PAGE->set_pagelayout('popup');
//echo $OUTPUT->header();
if (!($tool = evalcomix_tool::fetch(array('idtool' => $toolid)))) {
    print_error('EvalCOMIX: No tool enabled');
}
global $USER, $DB;
//require_capability('block/evalcomix:edit', $context, $USER->id);
require_capability('moodle/block:edit', $context, $USER->id);
$lang = current_language();
$lms = MOODLE_NAME;
$url = webservice_evalcomix_client::get_ws_createtool($toolid, $lms, $courseid, $lang . '_utf8', 'open');
$vars = explode('?', $url);
include_once $CFG->dirroot . '/blocks/evalcomix/classes/curl.class.php';
$curl = new Curly();
$response = $curl->post($vars[0], $vars[1]);
if ($response && $curl->getHttpCode() >= 200 && $curl->getHttpCode() < 400) {
    echo $response;
} else {
    print_error('EvalCOMIX cannot get datas');
}
 /**
  * get_ws_createtool
  */
 public function test_get_ws_createtool_ok()
 {
     $id = webservice_evalcomix_client::get_ws_createtool('', '', '4');
     $this->assertNotNull($id);
     $this->assertIsA($id, 'string');
 }