Esempio n. 1
0
function get_datas_profile_attribute($idCurso, $id_tarea, $id_modality, $id_students)
{
    global $CFG;
    include_once $CFG->dirroot . '/blocks/evalcomix/configeval.php';
    include_once $CFG->dirroot . '/blocks/evalcomix/classes/webservice_evalcomix_client.php';
    include_once $CFG->dirroot . '/blocks/evalcomix/classes/evalcomix_tasks.php';
    include_once $CFG->dirroot . '/blocks/evalcomix/classes/evalcomix_tool.php';
    $task = evalcomix_tasks::fetch(array('id' => $id_tarea));
    $module = evalcomix_tasks::get_type_task($task->instanceid);
    $modality = null;
    switch ($id_modality) {
        case 1:
            $modality = 'teacher';
            break;
        case 2:
            $modality = 'self';
            break;
        case 3:
            $modality = 'peer';
            break;
    }
    $xml = webservice_evalcomix_client::get_ws_tool_assessed($idCurso, $module, $task->instanceid, $id_students, $modality, MOODLE_NAME);
    $attributes_grade = evalcomix_tool::get_attributes_grade($xml);
    return $attributes_grade;
}
     * Array of optional table fields, must start with 'id'.
     * @var array $required_fields
     */
    public $optional_fields = array();
    /**
	* evalcomix ID associated
	* @var int $evxid
	*/
    public $evxid;
    /**
	* Tool title
	* @var string $title
	*/
    public $title;
    /**
	* Tool type
	* @var string $type
	*/
    public $type;
    /**
	* ID of Web tool
	* @var string $idtool
Esempio n. 3
0
<?php

/**
 * @package    block_evalcomix
 * @copyright  2010 onwards EVALfor Research Group {@link http://evalfor.net/}
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 * @author     Daniel Cabeza Sánchez <*****@*****.**>, Juan Antonio Caballero Hernández <*****@*****.**>
 */
require_once '../../config.php';
require_once $CFG->dirroot . '/blocks/evalcomix/classes/webservice_evalcomix_client.php';
$u = required_param('u', PARAM_URL);
$result = webservice_evalcomix_client::verify($u);
if ($result == 1) {
    echo get_string('valid_conection', 'block_evalcomix');
} else {
    echo get_string('error_conection', 'block_evalcomix');
    if (isset($result)) {
        echo '    ' . get_string('simple_error_conection', 'block_evalcomix');
        print_r($result);
    }
}
Esempio n. 4
0
                        $toolids[] = $newgrades[$assessmentid]->toolid;
                        $assessment->grade = $grade;
                        $assessment->update();
                        if ($evalcomix_grade = evalcomix_grades::fetch(array('courseid' => $courseid, 'cmid' => $task->instanceid, 'userid' => $assessment->studentid))) {
                            $params = array('cmid' => $task->instanceid, 'userid' => $assessment->studentid, 'courseid' => $courseid);
                            $finalgrade = evalcomix_grades::get_finalgrade_user_task($params);
                            if ($finalgrade !== null) {
                                $evalcomix_grade->finalgrade = $finalgrade;
                                $evalcomix_grade->update();
                            }
                        }
                    }
                }
            }
        }
        webservice_evalcomix_client::set_assessments_modified(array('toolids' => $toolids));
    }
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////// Logo y enlace a la gestión de instrumentos /////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
echo '				
		<center>
			<div><img src="' . $CFG->wwwroot . EVXLOGOROOT . '" width="230" alt="EvalCOMIX"/></div><br>';
//If $USER has editing permits
//if(is_siteadmin($USER) || has_capability('block/evalcomix:edit',$context)){
if (is_siteadmin($USER) || has_capability('moodle/grade:viewhidden', $context)) {
    echo '<div><input type="button" style="color:#333333" value="' . get_string('designsection', 'block_evalcomix') . '" onclick="location.href=\'' . $CFG->wwwroot . '/blocks/evalcomix/tool/index.php?id=' . $courseid . '\'"/></div>';
    echo '<div><input type="button" style="color:#333333" value="' . get_string('graphics', 'block_evalcomix') . '" onclick="location.href=\'' . $CFG->wwwroot . '/blocks/evalcomix/graphics/index.php?mode=1&id=' . $courseid . '\'"/></div>';
    if (has_capability('moodle/block:edit', $context)) {
        echo '<div><input type="button" style="color:#333333" value="' . get_string('settings', 'block_evalcomix') . '" onclick="location.href=\'' . $CFG->wwwroot . '/blocks/evalcomix/assessment/configuration.php?id=' . $courseid . '\'"/></div>';
Esempio n. 5
0
            //If (there are not Separated groups) OR
            //   (there are Separated groups AND
            //($user is member of the same group that login $USER OR they are in the same grouping in that activity))
            //if(($groupmode != 1) || ($groupmode == 1 &&
            //				($gid_loginuser == $gid_user || $report_evalcomix->same_grouping($gid_loginuser, $gid_user, $cmid)))){
            if (!$groupmembersonly && ($same_grouping && ($groupmode != 1 || $same_group) || !$groupingid && ($groupmode != 1 || $same_group)) || $groupmembersonly && (!$groupingid && ($groupmode != 1 || $same_group) || $same_grouping && ($groupmode != 1 || $same_group)) || $condition == true) {
                $mode_time = $report_evalcomix->get_modestime($task->id, $mode);
                if ($mode_time != false) {
                    $now = getdate();
                    $now_timestamp = mktime($now["hours"], $now["seconds"], $now["minutes"], $now["mon"], $now["mday"], $now["year"]);
                    $available = $mode_time->timeavailable;
                    $due = $mode_time->timedue;
                    if ($mode == 'self') {
                        //Details always are shown in selfassessment
                        echo $details;
                    } elseif ($now_timestamp >= $due && $mode == 'peer' && $showdetails == true) {
                        $url_peer_instrument = webservice_evalcomix_client::get_ws_view_assessment($courseid, $type_instrument, $cmid, $assessorid, $userid, 'peer', MOODLE_NAME);
                        echo '<input type="image" value="' . get_string('details', 'block_evalcomix') . '" style="width:16px" title=' . get_string('details', 'block_evalcomix') . ' src="../images/lupa.png" onclick="javascript:urlDetalles(\'' . $url_peer_instrument . '\');"/>';
                    }
                    //Show the buttons if they must be availables
                    if ($now_timestamp >= $available && $now_timestamp < $due) {
                        echo $evaluate;
                    }
                }
            }
        } else {
            //if $mode == 'teacher'
            echo $details . $evaluate;
        }
    }
}
 global $CFG;
 $serverurl = GET_TOOLS . '?format=xml';
 if (!isset($params['courseid']) || !isset($params['module']) || !isset($params['activity']) || !isset($params['student']) || !isset($params['assessor']) || !isset($params['mode']) || !isset($params['lms'])) {
     throw new Exception('Missing Params');
 }
 $countModules = count($params['module']);
 $countActivities = count($params['activity']);
 $countStudents = count($params['student']);
 $countAssessors = count($params['mode']);
 if ($countModules != $countActivities || $countStudents != $countAssessors) {
     throw new Exception('Wrong Params');
 }
 $xml = '<assessments>';
 $courseid = $params['courseid'];
 $lms = $params['lms'];
 for ($i = 0; $i < $countModules; ++$i) {
     $xml .= '<assessment>';
     $module = $params['module'][$i];
     $activity = $params['activity'][$i];
     $student = $params['student'][$i];
     $assessor = $params['assessor'][$i];
     $mode = $params['mode'][$i];
     $str = $courseid . '_' . $module . '_' . $activity . '_' . $student . '_' . $assessor . '_' . $mode . '_' . $lms;
     $assessmentid = md5($str);
     $xml .= $assessmentid;
        } else {
            //if (has_capability('block/evalcomix:edit',$context, $assessorid)){
            if (has_capability('moodle/grade:viewhidden', $context, $assessorid)) {
                $mode = 'teacher';
            } elseif (has_capability('block/evalcomix:assessed', $context, $assessorid)) {
                $mode = 'peer';
            } else {
                print_error('EvalCOMIX: Wrong User');
            }
        }
        $url_instrument = webservice_evalcomix_client::get_ws_viewtool($toolid, $lang . '_utf8', $courseid, $module, $cmid, $studentid, $assessorid, $mode, $lms, $title);
    }
} elseif ($viewtemplate == '1') {
    //require_capability('block/evalcomix:edit', $context, $USER->id);
    require_capability('moodle/grade:viewhidden', $context, $USER->id);
    $url_instrument = webservice_evalcomix_client::get_ws_viewtool($toolid, $lang . '_utf8');
}
$vars = explode('?', $url_instrument);
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');
}
if ($viewtemplate == 0) {
    echo "<script>\n\t\n\twindow.opener.onunload=function(){\n\t\tdoWork('evalcomixtablegrade', 'servidor.php?id=" . $courseid . "&eva=" . $USER->id . "', 'courseid=" . $courseid . "&page=&stu=" . $studentid . "&cma=" . $cmid . "');\n\t\tsetTimeout(close, 1000);\n\t\t\n\t};\n\t\n\t/*window.opener.onbeforeunload(){\n\t\tdoWork('evalcomixtablegrade', 'servidor.php?id=" . $courseid . "&eva=" . $USER->id . "', 'courseid=" . $courseid . "&page=&stu=" . $studentid . "&cma=" . $cmid . "');\n\t\tclose();\n\t};*/\n\t\n\t/*function testParent() {\n\t\tif (window.opener != null && !window.opener.closed){\n\t\t\tsetTimeout(\"testParent()\",1);\n\t\t}\n\t\telse {\n\t\t\talert('Parent closed/does not exist.');\n\t\t\tdoWork('evalcomixtablegrade', 'servidor.php?id=" . $courseid . "&eva=" . $USER->id . "', 'courseid=" . $courseid . "&page=&stu=" . $studentid . "&cma=" . $cmid . "');\n\t\t\twindow.close();\n\t\t}\n}  \n\ttestParent()¨*/\n</script>";
}
//$report_evalcomix->process_data($datapost);
/*$o = '<html>
Esempio n. 8
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');
}
Esempio n. 9
0
    /**
     * Builds the grade table and returns it in HTML
     * @return string HTML
     */
    public function create_grade_table()
    {
        global $CFG, $OUTPUT, $USER;
        include_once $CFG->dirroot . '/blocks/evalcomix/classes/evalcomix_tasks.php';
        include_once $CFG->dirroot . '/blocks/evalcomix/classes/evalcomix_assessments.php';
        include_once $CFG->dirroot . '/blocks/evalcomix/classes/evalcomix_modes_time.php';
        include_once $CFG->dirroot . '/blocks/evalcomix/classes/evalcomix_modes_extra.php';
        include_once $CFG->dirroot . '/blocks/evalcomix/classes/evalcomix_modes.php';
        include_once $CFG->dirroot . '/blocks/evalcomix/classes/webservice_evalcomix_client.php';
        include_once $CFG->dirroot . '/blocks/evalcomix/classes/evalcomix_grades.php';
        include_once $CFG->dirroot . '/blocks/evalcomix/classes/evalcomix_allowedusers.php';
        $context = context_course::instance($this->courseid);
        $table = '
			<style type="text/css">
					.wrapper1, .wrapper2{width: 100%; border: none 0px RED;
					overflow-x: scroll; overflow-y:hidden;}
					.wrapper1{height: 20px; }
					.wrapper2{}
					#div1 {width:500px; height: 10px; }
					#div2 {width:500px;
					overflow: auto;}
					#div {width:100%}

				</style>
			<div id="div"></div>
			<div class="wrapper1">
				<div class="div1" id="div1" style="width:100%">
				</div>
			</div>
			<div class="wrapper2">
				<div class="div2" id="div2" style="width:100%;">
				
			<!-- <div id="wrapper2" style="overflow:auto;overflow-y:hidden;"> -->
			<table border=1 style="font-size:0.8em;text-align:right;" id="user-grades" class="gradestable flexible boxaligncenter generaltable">';
        //Obtains course´s users
        $users = $this->load_users();
        //if(!has_capability('block/evalcomix:edit',$context, $USER->id)){
        if (!has_capability('moodle/grade:viewhidden', $context, $USER->id)) {
            $coursegroups = $this->load_groups();
            $coursegroupings = $this->load_groupings();
        }
        $table .= $this->get_headers();
        $table .= "\n\t\t\t\t<script type=\"text/javascript\" src=\"../ajax.js\"></script>\n\t\t\t\t<script type=\"text/javascript\">\n\t\t\t\t\tvar recarga = 0;\n\t\t\t\t\n\t\t\t\t\t function relocate(page,params)\n\t\t\t\t\t {\n\t\t\t\t\t\t  var body = document.body;\n\t\t\t\t\t\t  form=document.createElement('form'); \n\t\t\t\t\t\t  form.method = 'POST'; \n\t\t\t\t\t\t  form.action = page;\n\t\t\t\t\t\t  form.name = 'jsform';\n\t\t\t\t\t\t  for (index in params)\n\t\t\t\t\t\t  {\n\t\t\t\t\t\t\t\tvar input = document.createElement('input');\n\t\t\t\t\t\t\t\tinput.type='hidden';\n\t\t\t\t\t\t\t\tinput.name=index;\n\t\t\t\t\t\t\t\tinput.id=index;\n\t\t\t\t\t\t\t\tinput.value=params[index];\n\t\t\t\t\t\t\t\tform.appendChild(input);\n\t\t\t\t\t\t  }\t  \t\t  \t\t\t  \n\t\t\t\t\t\t  body.appendChild(form);\n\t\t\t\t\t\t  form.submit();\n\t\t\t\t\t }\n\t\t\t\t\t \n\t\t\t\t\tfunction change_recarga(){\n\t\t\t\t\t\trecarga = 1;\n\t\t\t\t\t}\n\t\t\t\t\n\t\t\t\t\tfunction urlDetalles(u){\n\t\t\t\t\t\twin2 = window.open(u, 0, \"menubar=0,location=1,scrollbars,resizable,width=780,height=500\");\n\t\t\t\t\t\tcheckChildDetalles();\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tfunction url(u, alu, cmidassign, page, courseid, nombre){\n\t\t\t\t\t\twin2 = window.open(u, nombre, \"menubar=0,location=0,scrollbars,resizable,width=780,height=500\");\n\t\t\t\t\t\tcheckChild(alu, cmidassign, page, courseid);\t\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tfunction checkChild(alu, cmidassign, page, course) {\n\t\t\t\t\t\tif (win2.closed) {\n\t\t\t\t\t\t\t/*relocate(window.location, {'stu':alu, 'cma':cmidassign});\t*/\t\n\t\t\t\t\t\t\tdoWork('evalcomixtablegrade_'+alu+'_'+cmidassign, 'servidor.php?id=" . $this->courseid . "&eva=" . $USER->id . "', 'courseid='+course+'&page='+page+'&stu='+alu+'&cma='+cmidassign);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse setTimeout(\"checkChild(\"+alu+\",\"+cmidassign+\")\",1);\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\tfunction checkChildDetalles() {\n\t\t\t\t\t\tif (win2.closed) {\n\t\t\t\t\t\t\tif (recarga == 1) {\n\t\t\t\t\t\t\t\twindow.location.reload(true);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\trecarga = 0;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tsetTimeout(\"checkChildDetalles()\",1);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tfunction checkChild_old(alu) {\t\t\t\t\t\t\n\t\t\t\t\t\tif (win2.closed) {\n\t\t\t\t\t\t\tvar url = String(window.location);\n\t\t\t\t\t\t\tvar long = url.length;\n\t\t\t\t\t\t\tif (url.substring(long-6, long-1) != \"&stu=\") {\n\t\t\t\t\t\t\t\tlocation.href = window.location + \"&stu=\"+alu;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse window.location.reload(true);\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse setTimeout(\"checkChild_old(\"+alu+\")\",1);\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t</script>\n\t\t\t\t\n  <script type='text/javascript' src='" . $CFG->wwwroot . "/blocks/evalcomix/javascript/jquery-1.4.2.js'></script>\n\t\t\t\t<script type='text/javascript'>//<![CDATA[ \n\t\t\t\t\tvar table = document.getElementById('user-grades');\n\t\t\t\t\t\n\t\t\t\t\tvar div11 = document.getElementById('div1');\n\t\t\t\t\tvar div22 = document.getElementById('div2');\n\t\t\t\t\tvar div = document.getElementById('div');\n\t\t\t\t\tvar documentwidth = \$(div).width();\n\t\t\t\t\t\n\t\t\t\t\tif((table.offsetWidth+100) < documentwidth){\n\t\t\t\t\t\tdiv11.style.width = (documentwidth - 50) +'px';\n\t\t\t\t\t\tdiv22.style.width = (documentwidth - 50)+'px';\n\t\t\t\t\t\t\$(div22).css('text-align','center');\n\t\t\t\t\t\t\$(table).css('margin','0 auto');\n\t\t\t\t\t}\n\t\t\t\t\telse{\n\t\t\t\t\t\tdiv11.style.width = (table.offsetWidth+100)+'px';\n\t\t\t\t\t\tdiv22.style.width = (table.offsetWidth+100)+'px';\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\t\$(window).load(function(){\n\t\t\t\t\t\$(function(){\n\t\t\t\t\t\t\$(\".wrapper1\").scroll(function(){\n\t\t\t\t\t\t\t\$(\".wrapper2\")\n\t\t\t\t\t\t\t\t.scrollLeft(\$(\".wrapper1\").scrollLeft());\n\t\t\t\t\t\t});\n\t\t\t\t\t\t\$(\".wrapper2\").scroll(function(){\n\t\t\t\t\t\t\t\$(\".wrapper1\")\n\t\t\t\t\t\t\t\t.scrollLeft(\$(\".wrapper2\").scrollLeft());\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t\t});//]]>  \n\n\t\t\t\t\t</script>\n\n\t\t\t\t<noscript>\n\t\t\t\t\t<div style='color: #f00;'>" . get_string('alertjavascript', 'block_evalcomix') . "</div>\n\t\t\t\t</noscript>\n";
        $tools = $this->load_tools();
        $lang = current_language();
        //array $finalgrades with two dimensions [$taskinstance][$userid] that contains the finalgrades.
        $finalgrades = evalcomix_grades::get_grades($this->courseid);
        //$finalgrades = $this->get_grades('moodleevx');
        //print_r($this->activities_ids);
        $index = 0;
        if (isset($this->activities['id'])) {
            $num_activities = count($this->activities['id']);
        } else {
            $num_activities = 0;
        }
        //$configured = array();
        $tasks_array = array();
        $groupmodes = array();
        $type_instrument = array();
        $cm = array();
        $whoassesses = array();
        global $DB;
        for ($i = 0; $i < $num_activities; $i++) {
            $cmid = $this->activities['id'][$i];
            //$cm[$cmid] = $this->get_cm($cmid);
            if (!$this->canviewhidden && $this->cm[$cmid]->visible == 0) {
                continue;
            }
            //$configured[$cmid] = $this->configured_activity($cmid);
            $groupmodes[$cmid] = $this->cm[$cmid]->groupmode;
            //$type_instrument[$cmid] = evalcomix_tasks::get_type_task($cmid);
            $type_instrument[$cmid] = $this->activities['modulename'][$i];
            //$mode_time[$cmid]['teacher'] = $this->get_modes_time($cmid, 'teacher');
            if ($tasks_array[$cmid] = evalcomix_tasks::fetch(array('instanceid' => $cmid))) {
                $taskid = $tasks_array[$cmid]->id;
                $mode_teacher[$cmid] = evalcomix_modes::fetch(array('taskid' => $taskid, 'modality' => 'teacher'));
                $mode_time[$cmid]['self'] = $this->get_modestime($tasks_array[$cmid]->id, 'self');
                $mode_time[$cmid]['peer'] = $this->get_modestime($tasks_array[$cmid]->id, 'peer');
                if ($mode_peer[$cmid] = evalcomix_modes::fetch(array('taskid' => $taskid, 'modality' => 'peer'))) {
                    if ($mode_peer_extra = evalcomix_modes_extra::fetch(array('modeid' => $mode_peer[$cmid]->id))) {
                        $whoassesses[$cmid] = $mode_peer_extra->whoassesses;
                    }
                }
            }
            //$mode_time[$cmid]['self'] = $this->get_modes_time($cmid, 'self');
            //$mode_time[$cmid]['peer'] = $this->get_modes_time($cmid, 'peer');
        }
        //To know if the documents uploaded by the students must be shown
        $assessments = $this->load_assessments($tasks_array);
        $now = getdate();
        $now_timestamp = mktime($now["hours"], $now["minutes"], $now["seconds"], $now["mon"], $now["mday"], $now["year"]);
        foreach ($users as $user) {
            //$mode = $this->get_type_evaluation($user->id);
            $mode = grade_report_evalcomix::get_type_evaluation($user->id, $this->courseid);
            if ($mode == 'self' || $mode == 'peer') {
                $gid_loginuser = $this->get_groupids($USER->id);
                $gid_user = $this->get_groupids($user->id);
            }
            $background = 'background-color:#ffffff';
            if ($index % 2 == 0) {
                $background = 'background-color:#ededed';
            }
            $index++;
            $aux = array();
            $table .= '
					<tr style="border:1px solid #146C84;' . $background . '">
					<td style="width:35px;padding:3px;"><div class="userpic">' . $OUTPUT->user_picture($user) . '</div></td>
					<td style="border:1px solid #146C84;"><a href="' . $CFG->wwwroot . '/user/view.php?id=' . $user->id . '&course=' . $this->courseid . '">' . fullname($user) . '</a></td>';
            for ($i = 0; $i < $num_activities; $i++) {
                $allowedusers = array();
                $evaluate = '';
                $cmid = $this->activities['id'][$i];
                if (!$this->canviewhidden && $this->cm[$cmid]->visible == 0) {
                    continue;
                }
                //$configured = $this->configured_activity($this->activities['id'][$i]);
                //boolean, if there is not a grade it will not show the details link
                $showdetails = true;
                $table .= '<td style="border:1px solid #146C84;" title="' . htmlentities(fullname($user) . "\n" . $this->activities['name'][$i], ENT_QUOTES, "UTF-8") . '">';
                $table .= '<div id="evalcomixtablegrade_' . $user->id . '_' . $cmid . '">';
                //Only show the user´s grade or all grades if the USER is a teacher or admin
                if ($this->cm[$cmid]->visible == 0) {
                    $table .= '<span style="font-style:italic;color:#838383">Actividad Oculta</span>';
                } elseif ((has_capability('moodle/grade:viewhidden', $context, $USER->id) || $user->id == $USER->id) && isset($finalgrades[$this->activities['id'][$i]][$user->id]) && $finalgrades[$this->activities['id'][$i]][$user->id] > -3) {
                    if ($finalgrades[$cmid][$user->id] > -1) {
                        $table .= format_float($finalgrades[$cmid][$user->id], 2);
                        $aux[] = $finalgrades[$cmid][$user->id];
                    } else {
                        $table .= '-';
                    }
                    //if there is not anything to assess
                    if ($finalgrades[$cmid][$user->id] == -2) {
                        $showdetails = false;
                    }
                } else {
                    //there is not grade
                    //configured
                    //if($configured[$cmid]){
                    if ($this->activities_configured[$cmid]) {
                        $table .= '-';
                    } else {
                        $table .= '<span style="font-style:italic;color:#f54927">' . get_string('noconfigured', 'block_evalcomix') . '</span>';
                    }
                    $showdetails = false;
                }
                //Checks if $this->activities['id'] is configured in evalcomix
                //if ($configured[$cmid]){
                if ($this->activities_configured[$cmid]) {
                    if ($this->cm[$cmid]->visible == 0) {
                        $table .= '<div><span style="font-style:italic;color:#838383;font-weight:bold">Configurada</span></div>';
                        continue;
                    }
                    //if($tool = get_evalcomix_modality_tool($this->courseid, $tasks_array[$cmid]->id, $mode)){
                    $taskid = $tasks_array[$cmid]->id;
                    if (isset($tools[$taskid][$mode])) {
                        $tool = $tools[$taskid][$mode];
                        //$url_instrument = webservice_evalcomix_client::get_ws_assessment_form($tool->idtool, $this->courseid, $type_instrument[$cmid], $this->activities['id'][$i], $user->id, $USER->id, $mode, MOODLE_NAME, 'assess', $lang.'_utf8');
                        $url_instrument = 'assessment_form.php?id=' . $this->courseid . '&a=' . $cmid . '&t=' . $tool->idtool . '&s=' . $user->id . '&mode=assess';
                        $evaluate = '<input type="image" value="' . get_string('evaluate', 'block_evalcomix') . '" title="' . get_string('evaluate', 'block_evalcomix') . '" style="background-color:transparent;width:16px;" src="../images/evaluar.png" onclick="javascript:url(\'' . $url_instrument . '\',\'' . $user->id . '\',\'' . $this->activities['id'][$i] . '\',\'' . $this->page . '\',\'' . $this->courseid . '\');"/>';
                        //if($assessmentgrade = evalcomix_assessments::fetch(array('taskid'=>$tasks_array[$cmid]->id, 'assessorid'=>$USER->id, 'studentid'=>$user->id))){
                        $assessorid = $USER->id;
                        $studentid = $user->id;
                        if (isset($assessments[$taskid][$assessorid][$studentid])) {
                            $evaluate = '<input type="image" value="' . get_string('evaluate', 'block_evalcomix') . '" title="' . get_string('evaluate', 'block_evalcomix') . '" style="background-color:transparent;width:16px;" src="../images/evaluar2.png" onclick="javascript:url(\'' . $url_instrument . '\',\'' . $user->id . '\',\'' . $this->activities['id'][$i] . '\', \'' . $this->page . '\',\'' . $this->courseid . '\');"/>';
                        }
                        //}
                    }
                    if ($showdetails) {
                        $details = '<input  type="image" value="' . get_string('details', 'block_evalcomix') . '" style="width:16px;background-color:transparent;" title=' . get_string('details', 'block_evalcomix') . ' src="../images/lupa.png" onclick="javascript:urlDetalles(\'' . $CFG->wwwroot . '/blocks/evalcomix/assessment/details.php?cid=' . $context->id . '&itemid=' . $tasks_array[$cmid]->id . '&userid=' . $user->id . '&popup=1\');"/>';
                    } else {
                        $details = '';
                    }
                    //Show user´s documents
                    //echo $showdocuments;
                    if ($mode == 'teacher') {
                        $title = get_string('studentwork1', 'block_evalcomix') . get_string('studentwork2', 'block_evalcomix') . $this->activities['name'][$i];
                        $table .= ' <input type="image" value="' . $title . '" style="background-color:transparent;width:13px" title="' . $title . '" src="../images/task.png" 
							onclick="javascript:urlDetalles(\'' . $CFG->wwwroot . '/blocks/evalcomix/assessment/user_activity.php?id=' . $user->id . '&course=' . $this->courseid . '&mod=' . $cmid . '\');"/>';
                    }
                    //If the $USER isn´t a teacher or admin evaluate if it should show Evaluate and Details buttons
                    if ($mode == 'self' || $mode == 'peer') {
                        //echo $finalgrades[$this->activities['id'][$i]][$user->id];
                        //Obtains the groupmode of the activity
                        //$groupmode = $this->get_groupmode($this->activities['id'][$i]);
                        $groupmode = $groupmodes[$cmid];
                        $groupmembersonly = 0;
                        if (isset($this->cm[$cmid]->groupmembersonly)) {
                            $groupmembersonly = $this->cm[$cmid]->groupmembersonly;
                        }
                        $groupingid = $this->cm[$cmid]->groupingid;
                        $same_grouping = false;
                        $same_group = $this->same_group($USER->id, $user->id);
                        if ($groupingid != 0) {
                            $same_grouping = $this->same_grouping_by_users($USER->id, $user->id, $this->cm[$cmid]);
                        }
                        /*Groupmode == 1 -> Separated Groups */
                        $condition = true;
                        if (isset($whoassesses[$cmid])) {
                            switch ($whoassesses[$cmid]) {
                                case 0:
                                    $condition = true;
                                    break;
                                case 1:
                                    $condition = !$groupmembersonly && ($same_grouping && ($groupmode != 1 || $same_group) || !$groupingid && ($groupmode != 1 || $same_group)) || $groupmembersonly && (!$groupingid && ($groupmode != 1 && $gid_loginuser != -1 && $gid_user != -1 || $same_group) || $same_grouping && ($groupmode != 1 || $same_group));
                                    break;
                                case 2:
                                    if ($evalcomixallowedusers = evalcomix_allowedusers::fetch_all(array('cmid' => $cmid, 'assessorid' => $USER->id))) {
                                        foreach ($evalcomixallowedusers as $auser) {
                                            $indexuser = $auser->studentid;
                                            $allowedusers[$indexuser] = true;
                                        }
                                    }
                                    $userid = $user->id;
                                    $condition = false;
                                    if (isset($allowedusers[$userid])) {
                                        $condition = $allowedusers[$userid];
                                    } elseif ($USER->id == $user->id) {
                                        $condition = true;
                                    }
                            }
                        }
                        /*if((!$groupmembersonly && (
                        								($same_grouping && (
                        										($groupmode != 1 
                        										|| $same_group))
                        								) 
                        								|| 
                        								(!$groupingid && 
                        									(($groupmode != 1 
                        										|| $same_group)))
                        								)
                        							)
                        							|| ($groupmembersonly  && (
                        //								(!$this->cm[$cmid]->groupingid && $gid_loginuser != -1 && $gid_user != -1)
                        								(!$groupingid && 
                        									((($groupmode != 1 && $gid_loginuser != -1 && $gid_user != -1) 
                        										|| $same_group)))
                        								||
                        								($same_grouping && (
                        									($groupmode != 1 
                        										|| $same_group)))
                        								)
                        							)
                        							)*/
                        if ($condition) {
                            //($this->cm[$cmid]->groupmembersonly && $same_grouping && $groupmode == 1) ||
                            //($groupmode == 1 && ($gid_loginuser == $gid_user || $this->same_grouping($gid_loginuser, $gid_user, $this->activities['id'][$i])))){
                            //$mode_time = $this->get_modes_time($this->activities['id'][$i], $mode);
                            if ($mode == 'self') {
                                //Details always are shown in selfassessment
                                $table .= $details;
                            }
                            if ($mode_time[$cmid][$mode] != false) {
                                $available = $mode_time[$cmid][$mode]->timeavailable;
                                $due = $mode_time[$cmid][$mode]->timedue;
                                //If the availability of the activity started
                                if ($now_timestamp >= $available) {
                                    $title = get_string('studentwork1', 'block_evalcomix') . get_string('studentwork2', 'block_evalcomix') . $this->activities['name'][$i];
                                    $table .= ' <input type="image" value="' . $title . '" style="background-color:transparent;width:13px" title="' . $title . '" src="../images/task.png" 
										onclick="javascript:urlDetalles(\'' . $CFG->wwwroot . '/blocks/evalcomix/assessment/user_activity.php?id=' . $user->id . '&course=' . $this->courseid . '&mod=' . $cmid . '\');"/>';
                                }
                                /*if($mode == 'self') { //Details always are shown in selfassessment
                                			$table .= $details;
                                		}*/
                                if ($now_timestamp >= $due && $mode == 'peer' && $showdetails == true) {
                                    $url_peer_instrument = webservice_evalcomix_client::get_ws_view_assessment($this->courseid, $type_instrument[$cmid], $this->activities['id'][$i], $USER->id, $user->id, 'peer', MOODLE_NAME);
                                    $table .= '<input type="image" value="' . get_string('details', 'block_evalcomix') . '" style="width:16px" title=' . get_string('details', 'block_evalcomix') . ' src="../images/lupa.png" onclick="javascript:urlDetalles(\'' . $url_peer_instrument . '\');"/>';
                                }
                                //Show the buttons if they must be availables
                                if ($now_timestamp >= $available && $now_timestamp < $due) {
                                    $table .= $evaluate;
                                }
                            }
                        }
                    } else {
                        //if $mode == 'teacher'
                        //$table .= $details.$evaluate;
                        $table .= $details;
                        if ($mode_teacher[$cmid] != null && $mode_teacher[$cmid]->modality == 'teacher') {
                            $table .= $evaluate;
                        }
                    }
                }
                $table .= '</div>';
            }
            $table .= '</td>';
            //	}
            //Calculates average
            if (count($aux) == 0) {
                $average = 0;
            } else {
                $average = $this->calculator->calculate_one_array($aux);
                $average = round($average, 2, PHP_ROUND_HALF_UP);
                unset($aux);
            }
            $table .= '<td style="border:1px solid #146C84;">' . $average . '</td></tr>';
        }
        $table .= '</table></div>';
        $table .= '</div>';
        return $table;
    }
 protected function define_structure()
 {
     // Define each element separated
     $evalcomix = new backup_nested_element('evalcomix', array('id'), array('viewmode'));
     $evalcomix_environment = new backup_nested_element('environment', null, array('courseid', 'moodlename'));
     $evalcomix_tools = new backup_nested_element('tools');
     $evalcomix_tool = new backup_nested_element('tool', array('id'), array('title', 'type', 'timecreated', 'timemodified', 'idtool', 'code'));
     $evalcomix_tasks = new backup_nested_element('tasks');
     $evalcomix_task = new backup_nested_element('task', array('id'), array('instanceid', 'maxgrade', 'weighing', 'timemodified', 'visible'));
     //$evalcomix_task = new backup_nested_element('task', array('instanceid'), array('id', 'maxgrade', 'weighing', 'timemodified'));
     $evalcomix_assessments = new backup_nested_element('assessments');
     //$evalcomix_assessment = new backup_nested_element('assessment', array('id'), array('assessorid', 'studentid', 'grade', 'timemodified', 'code'));
     $evalcomix_assessment = new backup_nested_element('assessment', array('id'), array('assessorid', 'studentid', 'grade', 'timemodified'));
     $evalcomix_modes = new backup_nested_element('modes');
     $evalcomix_mode = new backup_nested_element('mode', array('id'), array('toolid', 'modality', 'weighing'));
     $evalcomix_modes_time = new backup_nested_element('mode_time', array('id'), array('timeavailable', 'timedue'));
     $evalcomix_modes_extra = new backup_nested_element('mode_extra', array('id'), array('anonymous', 'visible', 'whoassesses'));
     $evalcomix_grades = new backup_nested_element('grades');
     $evalcomix_grade = new backup_nested_element('grade', array('id'), array('userid', 'cmid', 'finalgrade', 'courseid'));
     $evalcomix_allowedusers = new backup_nested_element('allowedusers');
     $evalcomix_alloweduser = new backup_nested_element('alloweduser', array('id'), array('cmid', 'assessorid', 'studentid'));
     // $invented = new backup_nested_element('invented', null, array('one', 'two', 'three')        );
     // Build the tree
     $evalcomix->add_child($evalcomix_tools);
     $evalcomix->add_child($evalcomix_environment);
     $evalcomix->add_child($evalcomix_tasks);
     $evalcomix->add_child($evalcomix_grades);
     $evalcomix_grades->add_child($evalcomix_grade);
     $evalcomix->add_child($evalcomix_allowedusers);
     $evalcomix_allowedusers->add_child($evalcomix_alloweduser);
     $evalcomix_tools->add_child($evalcomix_tool);
     $evalcomix_tasks->add_child($evalcomix_task);
     $evalcomix_task->add_child($evalcomix_assessments);
     $evalcomix_task->add_child($evalcomix_modes);
     $evalcomix_assessments->add_child($evalcomix_assessment);
     $evalcomix_modes->add_child($evalcomix_mode);
     $evalcomix_mode->add_child($evalcomix_modes_time);
     $evalcomix_mode->add_child($evalcomix_modes_extra);
     //$inventeds->add_child($invented);
     // Define sources
     global $DB, $COURSE, $CFG;
     $courseid = $this->get_courseid();
     $cms = $DB->get_records('course_modules', array('course' => $courseid));
     $items = array();
     foreach ($cms as $cm) {
         $items[] = $cm->id;
     }
     $in_params = array();
     if (!empty($items)) {
         list($in_sql, $in_params) = $DB->get_in_or_equal($items);
         foreach ($in_params as $key => $value) {
             $in_params[$key] = backup_helper::is_sqlparam($value);
         }
     }
     if ($block = $DB->get_record('block_evalcomix', array('courseid' => $courseid))) {
         $evalcomix->set_source_table('block_evalcomix', array('id' => backup_helper::is_sqlparam($block->id)));
     }
     include_once $CFG->dirroot . '/blocks/evalcomix/configeval.php';
     include_once $CFG->dirroot . '/blocks/evalcomix/classes/webservice_evalcomix_client.php';
     include_once $CFG->dirroot . '/blocks/evalcomix/classes/evalcomix_tasks.php';
     $evalcomix_environment->set_source_array(array((object) array('courseid' => $COURSE->id, 'moodlename' => MOODLE_NAME)));
     try {
         $array_xml_tool = array();
         $xml = webservice_evalcomix_client::get_ws_xml_tools2(array('courseid' => $courseid));
         foreach ($xml as $toolxml) {
             $id = (string) $toolxml['id'];
             foreach ($toolxml as $txml) {
                 $array_xml_tool[$id] = $txml->asXML();
             }
         }
         if ($tools = $DB->get_records('block_evalcomix_tools', array('evxid' => $block->id))) {
             $array = array();
             foreach ($tools as $tool) {
                 $time = time();
                 $idtool = $tool->idtool;
                 if (isset($array_xml_tool[$idtool])) {
                     $array[] = (object) array('id' => $tool->id, 'title' => $tool->title, 'type' => $tool->type, 'timecreated' => $time, 'timemodified' => $time, 'idtool' => $idtool, 'code' => $array_xml_tool[$idtool]);
                 }
             }
             $evalcomix_tool->set_source_array($array);
         }
     } catch (Exception $e) {
     }
     /*$invented->set_source_array(array((object)array('one' => 1, 'two' => 2, 'three' => 3),
       (object)array('one' => 11, 'two' => 22, 'three' => 33))); // 2 object array*/
     //$evalcomix_tool->set_source_table('block_evalcomix_tools', array('evxid' => backup::VAR_PARENTID));
     if (!empty($in_params)) {
         $evalcomix_task->set_source_sql("\n                SELECT *\n                  FROM {block_evalcomix_tasks}\n                 WHERE instanceid {$in_sql}", $in_params);
         $evalcomix_grade->set_source_sql("\n                SELECT *\n                  FROM {block_evalcomix_grades}\n                 WHERE cmid {$in_sql}", $in_params);
         $evalcomix_alloweduser->set_source_sql("\n                SELECT *\n                  FROM {block_evalcomix_allowedusers}\n                 WHERE cmid {$in_sql}", $in_params);
     }
     $evalcomix_assessment->set_source_table('block_evalcomix_assessments', array('taskid' => backup::VAR_PARENTID));
     $evalcomix_mode->set_source_table('block_evalcomix_modes', array('taskid' => backup::VAR_PARENTID));
     $evalcomix_modes_time->set_source_table('block_evalcomix_modes_time', array('modeid' => backup::VAR_PARENTID));
     $evalcomix_modes_extra->set_source_table('block_evalcomix_modes_extra', array('modeid' => backup::VAR_PARENTID));
     // Define annotations
     $evalcomix_task->annotate_ids('course_modules', 'instanceid');
     //$evalcomix->set_source_table('block_evalcomix', array('id' => backup::VAR_BLOCKID));
     //$evalcomix->set_source_array(array((object)array('id' => $this->task->get_blockid())));
     //$evalcomix_tool->set_source_table('evalcomix_tools', array('evxid' => '../id'));
     return $this->prepare_block_structure($evalcomix);
     //EvalCOMIX assessment-------------------------------------------------------
     /*	$tasks = evalcomix_tasks::get_tasks_by_courseid($courseid);
     			if(!empty($tasks)){ 
     				$array_xml_assessment = array();
     				$hash_assessment = array();
     				$params['courseid'] = $courseid;
     				$params['lms'] = MOODLE_NAME;
     				$array_course_assessments = array();
     				$coursecontext = context_course::instance($courseid);
     			
     				$k = 0;
     				foreach($tasks as $task){ 
     					$module = evalcomix_tasks::get_type_task($task->instanceid);
     					if($assessments = $DB->get_records('block_evalcomix_assessments', array('taskid' => $task->id))){
     						foreach($assessments as $assessment){
     							$params['module'][$k] = $module;
     							$params['activity'][$k] = $task->instanceid;
     							$params['student'][$k] = $assessment->studentid;
     							$params['assessor'][$k] = $assessment->assessorid;
     							if($assessment->studentid == $assessment->assessorid){
     								$params['mode'][$k] = 'self';
     							}
     							elseif(has_capability('moodle/grade:viewhidden',$coursecontext, $assessment->assessorid)){
     								$params['mode'][$k] = 'teacher';
     							}
     							else{
     								$params['mode'][$k] = 'peer';
     							}
     							$str = $courseid . '_' . $params['module'][$k] . '_' . $params['activity'][$k] . '_' . $params['student'][$k] . '_' . $params['assessor'][$k] . '_' . $params['mode'][$k] . '_' . MOODLE_NAME;
     							$id = $assessment->id;
     							$hash_assessment[$id] = md5($str);
     							$array_course_assessments[] = $assessment;
     							
     							++$k;
     						}
     					}
     				}
     				$xml = webservice_evalcomix_client::get_ws_xml_tools($params);
     				foreach($xml as $assessmentxml){
     					$id = (string)$assessmentxml['id'];
     					foreach($assessmentxml as $txml){
     						$array_xml_assessment[$id] = $txml->asXML();
     					}
     				}
     				
     				$array_result = array();
     				if(!empty($array_course_assessments)){
     					foreach($array_course_assessments as $assessment){
     						$time = time();
     						$id = $assessment->id;
     						$assid = $hash_assessment[$id];
     						$array_xml = '';
     						if(isset($array_xml_assessment[$assid])){
     							$array_xml = $array_xml_assessment[$assid];
     						}
     						echo "task = " . $assessment->taskid . ": " . $assessment->assessorid . '--' . $assessment->studentid . "<br>";
     						$array_result[] = (object)array('id' => $assessment->id, 'taskid' => $assessment->taskid, 'assessorid' => $assessment->assessorid, 'studentid' => $assessment->studentid, 'timemodified' => $time, 'grade' => $assessment->grade, 'code' => $array_xml);	
     					}
     					$evalcomix_assessment->set_source_array($array_result);
     				}				
     			}*/
 }
Esempio n. 11
0
    print_error('Wrong parameters');
}
if ($modeEI = evalcomix_modes::fetch(array('taskid' => $task->id, 'modality' => 'peer'))) {
    $modeEItime = evalcomix_modes_time::fetch(array('modeid' => $modeEI->id));
    $modesExtra = evalcomix_modes_extra::fetch(array('modeid' => $modeEI->id));
} else {
    $modeEItime = '';
}
$cm = $DB->get_record('course_modules', array('id' => $task->instanceid), '*');
$module = $DB->get_record('modules', array('id' => $cm->module), '*');
$maxgrade = $task->maxgrade;
$data_activity = $DB->get_record($module->name, array('id' => $cm->instance));
// If a teacher has done click on Delete button
//if($assid && has_capability('block/evalcomix:edit', $context)){
if ($assid && has_capability('moodle/block:edit', $context)) {
    $assessdelete = evalcomix_assessments::fetch(array('id' => $assid));
    if ($assessdelete) {
        $stringmode = 'peer';
        if ($assessdelete->assessorid == $assessdelete->studentid) {
            $stringmode = 'self';
        }
        $response = webservice_evalcomix_client::delete_ws_assessment($course->id, $module->name, $task->instanceid, $user->id, $assessdelete->assessorid, $stringmode, MOODLE_NAME);
        $assessdelete->delete();
        $params = array('cmid' => $task->instanceid, 'userid' => $user->id, 'courseid' => $course->id);
        $finalgrade = evalcomix_grades::get_finalgrade_user_task($params);
        if ($finalgrade !== null) {
            if ($gradeObject = evalcomix_grades::fetch($params)) {
                $gradeObject->finalgrade = $finalgrade;
                $gradeObject->update();
            }
        } else {
Esempio n. 12
0
 protected function process_data($data)
 {
     global $CFG;
     include_once $CFG->dirroot . '/blocks/evalcomix/classes/webservice_evalcomix_client.php';
     include_once $CFG->dirroot . '/blocks/evalcomix/classes/evalcomix_tasks.php';
     if (isset($data['student_ids'])) {
         $user_aux = explode(',', $data['student_ids']);
         $data_num_users = count($user_aux);
     }
     if (isset($data['student_names'])) {
         $username_aux = explode('-', $data['student_names']);
     }
     $assessorid = 0;
     if (isset($data['assessor_id'])) {
         $assessorid = $data['assessor_id'];
     }
     switch ($this->mode) {
         case 'selftask':
             $modality = 'self';
             break;
         case 'teachertask':
             $modality = 'teacher';
             break;
     }
     $params['courseid'] = $this->courseid;
     $params['lms'] = MOODLE_NAME;
     $k = 0;
     $hash_user = array();
     $hash_username = array();
     $attributes[0] = '';
     //$students = array();
     $studentsid = '';
     $values = array();
     if (isset($data['task']) && is_numeric($data_num_users)) {
         foreach ($user_aux as $key => $user) {
             $params['module'][$k] = evalcomix_tasks::get_type_task($data['task']);
             $params['activity'][$k] = $data['task'];
             $params['student'][$k] = $user;
             if ($assessorid != 0) {
                 $params['assessor'][$k] = $assessorid;
             } else {
                 $params['assessor'][$k] = $user;
             }
             $params['mode'][$k] = $modality;
             $str = $this->courseid . '_' . $params['module'][$k] . '_' . $params['activity'][$k] . '_' . $params['student'][$k] . '_' . $params['assessor'][$k] . '_' . $params['mode'][$k] . '_' . $params['lms'];
             $assessmentid = md5($str);
             $hash_user[$assessmentid] = $user;
             $hash_username[$assessmentid] = $username_aux[$key];
             ++$k;
         }
         $this->task = substr($data['task'], 0, -1);
         //TODO:adaptar para rúbricas, argumentarios y mixtas
         if ($xml = webservice_evalcomix_client::get_ws_xml_tools($params)) {
             $row = 0;
             foreach ($xml as $assessment) {
                 $id = (string) $assessment['id'];
                 $userid = $hash_user[$id];
                 $name = explode(',', $hash_username[$id]);
                 $this->names[$row] = $name[0];
                 $this->surnames[$row] = $name[1];
                 foreach ($assessment as $value) {
                     //echo (string)$value->GlobalAssessment->Attribute;
                     $this->header[0] = 'Nombre';
                     $this->header[1] = 'Apellido(s)';
                     $l = 2;
                     if (isset($value->Dimension)) {
                         foreach ($value->Dimension as $dimension) {
                             foreach ($dimension->Subdimension as $subdimension) {
                                 foreach ($subdimension->Attribute as $attribute) {
                                     //echo (string)$attribute['name'];
                                     $this->header[$l] = (string) $attribute['name'];
                                     if (isset($attribute->selection->instance)) {
                                         print_r($attribute->selection->instance);
                                         $this->right_rows[$row][$l] = (string) $attribute->selection->instance;
                                     } elseif (isset($attribute->selection)) {
                                         $this->right_rows[$row][$l] = (string) $attribute->selection;
                                     } else {
                                         $this->right_rows[$row][$l] = (string) $attribute;
                                     }
                                     if ((string) $attribute['comment'] != '') {
                                         ++$l;
                                         $this->header[$l] = 'O';
                                         if ((string) $attribute['comment'] != '1') {
                                             $this->right_rows[$row][$l] = (string) $attribute['comment'];
                                         } else {
                                             $this->right_rows[$row][$l] = '';
                                         }
                                     }
                                     ++$l;
                                 }
                             }
                         }
                     } elseif (isset($value->Attribute)) {
                         foreach ($value->Attribute as $attribute) {
                             $this->header[$l] = (string) $attribute['nameN'] . '/' . (string) $attribute['nameP'];
                             $this->right_rows[$row][$l] = (string) $attribute;
                             ++$l;
                         }
                     }
                 }
                 ++$row;
             }
         }
         exit;
     }
 }
 /**
  * check_url 
  */
 public function test_check_url()
 {
     $id = webservice_evalcomix_client::check_url('http://dipeval.uca.es');
     $this->assertNotNull($id);
 }
 public function after_restore()
 {
     global $DB, $COURSE, $CFG;
     include_once $CFG->dirroot . '/blocks/evalcomix/configeval.php';
     include_once $CFG->dirroot . '/blocks/evalcomix/classes/evalcomix_tasks.php';
     include_once $CFG->dirroot . '/blocks/evalcomix/classes/evalcomix_modes.php';
     include_once $CFG->dirroot . '/blocks/evalcomix/classes/evalcomix_modes_time.php';
     include_once $CFG->dirroot . '/blocks/evalcomix/classes/evalcomix_modes_extra.php';
     include_once $CFG->dirroot . '/blocks/evalcomix/classes/evalcomix_assessments.php';
     include_once $CFG->dirroot . '/blocks/evalcomix/classes/webservice_evalcomix_client.php';
     include_once $CFG->dirroot . '/blocks/evalcomix/classes/evalcomix_grades.php';
     include_once $CFG->dirroot . '/blocks/evalcomix/classes/evalcomix_allowedusers.php';
     $settings = $this->task->get_info()->root_settings;
     //$this->oldcontextid; busco en tabla mdl_context->instanceid es el courseid; con el courseid obtengo todos los cms antiguos y nuevos y voy copiando uno a uno
     //$this->basepath   = $CFG->dataroot . '/temp/backup/' . $controller->get_tempdir();
     //$blockid = $this->get_old_blockid();
     //$xml = simplexml_load_file($this->get_basepath() . '/course/blocks/evalcomix_'. $blockid .'/evalcomix.xml');
     $fullpath = $this->task->get_taskbasepath();
     // We MUST have one fullpath here, else, error
     if (empty($fullpath)) {
         throw new restore_step_exception('restore_structure_step_undefined_fullpath');
     }
     // Append the filename to the fullpath
     $fullpath = rtrim($fullpath, '/') . '/' . $this->filename;
     // And it MUST exist
     if (!file_exists($fullpath)) {
         // Shouldn't happen ever, but...
         throw new restore_step_exception('missing_moodle_backup_xml_file', $fullpath);
     }
     $xml = simplexml_load_file($fullpath);
     //echo $this->task->get_taskbasepath() . '/course/blocks/evalcomix_'. $blockid .'/evalcomix.xml';
     $evxid_old = (int) $xml->evalcomix['id'];
     $viewmode_old = (string) $xml->evalcomix->viewmode;
     if (isset($xml->evalcomix->environment->courseid)) {
         $courseid_old = $xml->evalcomix->environment->courseid;
     }
     if (isset($xml->evalcomix->environment->moodlename)) {
         $moodlename_old = $xml->evalcomix->environment->moodlename;
     }
     include_once $CFG->dirroot . '/blocks/evalcomix/configeval.php';
     //include_once($CFG->dirroot . '/backup/lib.php');
     //$courseid_new = $this->plan->get_courseid();
     $courseid_new = $this->get_courseid();
     $moodlename_new = MOODLE_NAME;
     $block_evalcomix = $DB->get_record('block_evalcomix', array('courseid' => $courseid_new));
     //$coursecontext = get_context_instance(CONTEXT_COURSE, $courseid_new);
     $coursecontext = context_course::instance($courseid_new);
     $tasksid = '';
     if (isset($xml->evalcomix->tasks[0])) {
         $assessmentids = array();
         foreach ($xml->evalcomix->tasks[0] as $task) {
             $task_id_old = (int) $task['id'];
             $task_instanceid_old = (int) $task->instanceid;
             $task_maxgrade_old = (string) $task->maxgrade;
             $task_weighing_old = (string) $task->weighing;
             $cm = $DB->get_record('block_evalcomix', array('courseid' => $courseid_new));
             $cm_mapping = $this->get_mapping('course_module', $task_instanceid_old);
             $newcmid = $cm_mapping->newitemid;
             $visibletask = '1';
             if (isset($task->visible)) {
                 $visibletask = (string) $task->visible;
             }
             if (!($task_fetch = evalcomix_tasks::fetch(array('instanceid' => $newcmid)))) {
                 $task_object = new evalcomix_tasks('', $newcmid, $task_maxgrade_old, $task_weighing_old, '', $visibletask);
                 $newtaskid = $task_object->insert();
                 $tasksid .= $task_instanceid_old . '-' . $newcmid . ',';
                 foreach ($task->modes[0] as $mode) {
                     $mode_id_old = (int) $mode['id'];
                     $mode_toolid_old = (string) $mode->toolid;
                     $mode_modality_old = (string) $mode->modality;
                     $mode_weighing_old = (string) $mode->weighing;
                     $tool_mapping = $this->get_mapping('evalcomix_tool', $mode_toolid_old);
                     if (!empty($tool_mapping) && ($newtoolid = $tool_mapping->newitemid)) {
                         if (!($mode_object = evalcomix_modes::fetch(array('taskid' => $newtaskid, 'toolid' => $newtoolid, 'modality' => $mode_modality_old)))) {
                             $mode_object = new evalcomix_modes('', $newtaskid, $newtoolid, $mode_modality_old, $mode_weighing_old);
                             $newmodeid = $mode_object->insert();
                             if (isset($mode->mode_time['id'])) {
                                 $mode_time_id_old = (string) $mode->mode_time['id'];
                                 $mode_time_timeavailable_old = (string) $mode->mode_time->timeavailable;
                                 $mode_time_timedue_old = (string) $mode->mode_time->timedue;
                                 if (!evalcomix_modes_time::fetch(array('modeid' => $newmodeid))) {
                                     $mode_time_object = new evalcomix_modes_time('', $newmodeid, $mode_time_timeavailable_old, $mode_time_timedue_old);
                                     $mode_time_object->insert();
                                 }
                             }
                             if (isset($mode->mode_extra)) {
                                 $mode_extra_id_old = (string) $mode->mode_extra['id'];
                                 $mode_extra_timeavailable_old = (string) $mode->mode_extra->anonymous;
                                 $mode_extra_visible = $mode->mode_extra->visible;
                                 $mode_extra_whoassesses = $mode->mode_extra->whoassesses;
                                 if (!($mode_extra_object = evalcomix_modes_extra::fetch(array('modeid' => $newmodeid)))) {
                                     $mode_extra_object = new evalcomix_modes_extra('', $newmodeid, $mode_extra_timeavailable_old, $mode_extra_visible, $mode_extra_whoassesses);
                                     $mode_extra_object->insert();
                                 }
                             }
                         }
                     }
                 }
             }
             if ($settings['users'] == 1) {
                 foreach ($task->assessments[0] as $assessment) {
                     $assessment_id_old = (string) $assessment['id'];
                     $assessment_assessorid_old = (string) $assessment->assessorid;
                     $assessment_studentid_old = (string) $assessment->studentid;
                     $assessment_grade_old = (string) $assessment->grade;
                     $assessor_user = $this->get_mapping('user', $assessment_assessorid_old);
                     $student_user = $this->get_mapping('user', $assessment_studentid_old);
                     if (!isset($assessor_user->newitemid) || !isset($student_user->newitemid)) {
                         continue;
                     }
                     if (!($assessment_object = evalcomix_assessments::fetch(array('taskid' => $newtaskid, 'assessorid' => $assessor_user->newitemid, 'studentid' => $student_user->newitemid)))) {
                         $assessment_object = new evalcomix_assessments('', $newtaskid, $assessor_user->newitemid, $student_user->newitemid, $assessment_grade_old);
                         $assessment_object->insert();
                     }
                     //$modulename = get_module_type ($courseid_new, $newcmid);
                     $modulename = evalcomix_tasks::get_type_task($newcmid);
                     $mode = '';
                     if ($student_user->newitemid == $assessor_user->newitemid) {
                         $mode = 'self';
                     } elseif (has_capability('moodle/grade:viewhidden', $coursecontext, $assessor_user->newitemid)) {
                         $mode = 'teacher';
                     } else {
                         $mode = 'peer';
                     }
                     //$courseid_old, $modulename, $task_instanceid_old, $assessment_studentid_old, $assessment_assessorid_old, $mode, $moodlename_old
                     $str = $courseid_old . '_' . $modulename . '_' . $task_instanceid_old . '_' . $assessment_studentid_old . '_' . $assessment_assessorid_old . '_' . $mode . '_' . $moodlename_old;
                     $assessmentid_old = md5($str);
                     $str = $courseid_new . '_' . $modulename . '_' . $newcmid . '_' . $student_user->newitemid . '_' . $assessor_user->newitemid . '_' . $mode . '_' . $moodlename_new;
                     //echo $str . ' -- ';
                     $assessmentid_new = md5($str);
                     $object = new stdClass();
                     $object->oldid = $assessmentid_old;
                     $object->newid = $assessmentid_new;
                     $assessmentids[] = $object;
                 }
             }
         }
     }
     if ($tasksid != '') {
         $tasksid = substr($tasksid, 0, -1);
     }
     if ($settings['users'] == 1) {
         if (isset($xml->evalcomix->grades[0])) {
             foreach ($xml->evalcomix->grades[0] as $grade) {
                 $cm_mapping = $this->get_mapping('course_module', $grade->cmid);
                 $newcmid = $cm_mapping->newitemid;
                 $student = $this->get_mapping('user', (int) $grade->userid);
                 if (!isset($student->newitemid)) {
                     continue;
                 }
                 $params = array('finalgrade' => (double) $grade->finalgrade, 'courseid' => $courseid_new, 'cmid' => $newcmid, 'userid' => $student->newitemid);
                 if (!($grade_object = evalcomix_grades::fetch(array('courseid' => $courseid_new, 'cmid' => $newcmid, 'userid' => $student->newitemid)))) {
                     $grade_object = new evalcomix_grades($params);
                     $newgradeid = $grade_object->insert();
                 }
             }
         }
         if (isset($xml->evalcomix->allowedusers[0])) {
             foreach ($xml->evalcomix->allowedusers[0] as $users) {
                 $cm_mapping = $this->get_mapping('course_module', $users->cmid);
                 $newcmid = $cm_mapping->newitemid;
                 $assessor = $this->get_mapping('user', (int) $users->assessorid);
                 $student = $this->get_mapping('user', (int) $users->studentid);
                 if (!isset($student->newitemid) || !isset($assessor->newitemid)) {
                     continue;
                 }
                 $params = array('assessorid' => (int) $assessor->newitemid, 'studentid' => $student->newitemid, 'cmid' => $newcmid);
                 if (!($allowedusers_object = evalcomix_allowedusers::fetch($params))) {
                     $allowedusers_object = new evalcomix_allowedusers($params);
                     $newid = $allowedusers_object->insert();
                 }
             }
         }
     }
     if (isset($xml->evalcomix->tools[0])) {
         $hashtools = array();
         foreach ($xml->evalcomix->tools[0] as $tool) {
             if ((string) $tool->type == 'tmp') {
                 continue;
             }
             $idtoolold = (string) $tool->idtool;
             $tool_mapping = $this->get_mapping('evalcomix_tool', (string) $tool['id']);
             $toolnew = evalcomix_tool::fetch(array('id' => $tool_mapping->newitemid));
             $idtoolnew = $toolnew->idtool;
             $object = new stdClass();
             $object->oldid = $idtoolold;
             $object->newid = $idtoolnew;
             $hashtools[] = $object;
         }
     }
     if (isset($hashtools) && isset($assessmentids)) {
         $result = webservice_evalcomix_client::duplicate_course($assessmentids, $hashtools);
     }
     //$newtools = webservice_evalcomix_client::get_ws_list_tool($courseid_new, $moodlename_new);
 }