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; }
'; }*/ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////// Comprobamos si existen instrumentos modificados con evaluaciones asociadas ///////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// if ($toollist = evalcomix_tool::fetch_all(array('evxid' => $environment->id))) { $newgrades = webservice_evalcomix_client::get_assessments_modified(array('tools' => $toollist)); if (!empty($newgrades)) { include_once $CFG->dirroot . '/blocks/evalcomix/classes/evalcomix_assessments.php'; include_once $CFG->dirroot . '/blocks/evalcomix/classes/evalcomix_grades.php'; $toolids = array(); foreach ($tasks as $task) { if ($assessments = evalcomix_assessments::fetch_all(array('taskid' => $task->id))) { foreach ($assessments as $assessment) { $activity = $task->instanceid; $module = evalcomix_tasks::get_type_task($activity); $mode = grade_report_evalcomix::get_type_evaluation($assessment->studentid, $courseid, $assessment->assessorid); $str = $courseid . '_' . $module . '_' . $activity . '_' . $assessment->studentid . '_' . $assessment->assessorid . '_' . $mode . '_' . MOODLE_NAME; $assessmentid = md5($str); if (isset($newgrades[$assessmentid])) { $grade = $newgrades[$assessmentid]->grade; $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(); }
foreach ($assessments as $assessment) { //If it is a self assessment if ($assessment->studentid == $assessment->assessorid && $selfweight) { $selfgrade = $assessment->grade; } elseif (has_capability('moodle/grade:viewhidden', $coursecontext, $assessment->assessorid) && $teacherweight) { $teachergrade += $assessment->grade; $numteachers++; } else { //If it is a peer assessment //Only gets grades when the assessment period in the task is finished if ($modeEI = evalcomix_modes::fetch(array('taskid' => $assessment->taskid, 'modality' => 'peer'))) { $modeEItime = evalcomix_modes_time::fetch(array('modeid' => $modeEI->id)); if ($modeEItime && $now > $modeEItime->timedue) { $peergrade += $assessment->grade; $numpeers++; } } } } //Calculates peergrade if ($numpeers > 0) { $peergrade = round($peergrade / $numpeers, 2); } //Calculates teachergrade if ($numteachers > 0) { $teachergrade = round($teachergrade / $numteachers, 2); } //Calcultes the total grade //if($teachergrade != 0 || $selfgrade != 0 || $peergrade != 0){ if ($numteachers > 0 || $numpeers > 0 || $selfgrade != -1) { if ($selfgrade == -1) { $selfgrade = 0; } $totalgrade = $selfgrade * ($selfweight / 100) + $teachergrade * ($teacherweight / 100) + $peergrade * ($peerweight / 100); //Add grade to array final grades //$finalgrades[$task->id][$user->id] = $totalgrade; $finalgrades[$task->instanceid][$user->id] = $totalgrade; } else { //There is peer assessments but assessment period hasn't finished $finalgrades[$task->instanceid][$user->id] = -1; } } } } } return $finalgrades; } /** * Finds and returns all evalcomix_assessments instances. * @static abstract * @param array $params
} if ($configured) { include_once $CFG->dirroot . '/blocks/evalcomix/classes/evalcomix_tasks.php'; include_once $CFG->dirroot . '/blocks/evalcomix/classes/webservice_evalcomix_client.php'; include_once $CFG->dirroot . '/blocks/evalcomix/classes/evalcomix_assessments.php'; include_once $CFG->dirroot . '/blocks/evalcomix/classes/evalcomix_allowedusers.php'; include_once $CFG->dirroot . '/blocks/evalcomix/configeval.php'; include_once $CFG->dirroot . '/blocks/evalcomix/assessment/lib.php'; $mode = grade_report_evalcomix::get_type_evaluation($userid, $courseid); //Obtains required parameters to create details and evaluate links $type_instrument = evalcomix_tasks::get_type_task($cmid); $task = evalcomix_tasks::fetch(array('instanceid' => $cmid)); $tool = get_evalcomix_modality_tool($courseid, $task->id, $mode); //$url_instrument = webservice_evalcomix_client::get_ws_assessment_form($tool->idtool, $courseid, $type_instrument, $cmid, $userid, $assessorid, $mode, MOODLE_NAME); $url_instrument = 'assessment_form.php?id=' . $courseid . '&a=' . $cmid . '&t=' . $tool->idtool . '&s=' . $userid . '&mode=assess'; $task = evalcomix_tasks::fetch(array('instanceid' => $cmid)); //Evaluate, Delete and Details buttons $evaluate = '<input type="image" value="' . get_string('evaluate', 'block_evalcomix') . '" title="' . get_string('evaluate', 'block_evalcomix') . '" style="width:16px;" src="../images/evaluar.png" onclick="javascript:url(\'' . $url_instrument . '\',\'' . $userid . '\',\'' . $cmid . '\',\'' . $page . '\',\'' . $courseid . '\');"/>'; if ($assessmentgrade = evalcomix_assessments::fetch(array('taskid' => $task->id, 'assessorid' => $assessorid, 'studentid' => $userid))) { $evaluate = '<input type="image" value="' . get_string('evaluate', 'block_evalcomix') . '" title="' . get_string('evaluate', 'block_evalcomix') . '" style="width:16px;" src="../images/evaluar2.png" onclick="javascript:url(\'' . $url_instrument . '\',\'' . $userid . '\',\'' . $cmid . '\', \'' . $page . '\',\'' . $courseid . '\');"/>'; } if ($showdetails) { $details = '<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(\'' . $CFG->wwwroot . '/blocks/evalcomix/assessment/details.php?cid=' . $context->id . '&itemid=' . $task->id . '&userid=' . $userid . '&popup=1\');"/>'; } else { $details = ''; } //Show user�s works $title = get_string('studentwork1', 'block_evalcomix') . get_string('studentwork2', 'block_evalcomix') . $cmid; echo ' <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=' . $userid . '&course=' . $courseid . '&mod=' . $cmid . '\');"/>'; //If the $USER isn�t a teacher or admin evaluate if it should show Evaluate and Details buttons
/** * Builds and returns the headers of the table * @return string HTML */ public function get_headers() { global $USER, $DB; if (!($course = $DB->get_record('course', array('id' => $this->courseid)))) { print_error('nocourseid'); } $total = ''; //To print Lastname / Firstname $arrows = $this->get_sort_arrows(); $header = '<tr style="border:1px solid #146C84;"> <th colspan="2">' . $arrows['studentname'] . '</th>'; //print_r($this->gtree->levels[1]); $levels = $this->gtree->get_levels(); foreach ($levels as $row) { foreach ($row as $element) { if ($element['object']->hidden == 1 && !$this->canviewhidden) { continue; } if (isset($element['object']->itemnumber) && $element['object']->itemnumber == 0 && $element['object']->itemtype != 'manual') { // Checks if it is an activity if ($element['type'] == 'item') { if ($cm = get_coursemodule_from_instance($element['object']->itemmodule, $element['object']->iteminstance, $this->courseid)) { $cmid = $cm->id; if (!($task = evalcomix_tasks::fetch(array('instanceid' => $cmid)))) { $task = new evalcomix_tasks('', $cmid, 100, 50, time(), '1'); $task->insert(); } elseif ($task->visible == 0) { continue; } $this->activities_configured[$cmid] = $this->configured_activity($cmid); if (!$this->canviewhidden && !$this->activities_configured[$cmid]) { continue; } if (property_exists($cm, 'availability')) { $grey = false; $hide = false; global $USER; $this->modinfo = new course_modinfo($course, $USER->id); $instances = $this->modinfo->get_instances_of($element['object']->itemmodule); if (!empty($instances[$element['object']->iteminstance])) { $cm_info = $instances[$element['object']->iteminstance]; if (!$cm_info->uservisible) { // If there is 'availableinfo' text then it is only greyed // out and not entirely hidden. if (!$cm_info->availableinfo) { $hide = true; } $grey = true; } } } if (!$this->canviewhidden) { if (!empty($hide) || !empty($grey)) { continue; } $gm = true; if (property_exists($cm, 'groupmembersonly') && !$cm->groupmembersonly) { $gm = false; } if ($gm) { $groupingid = $cm->groupingid; $intersect1 = array(); $groups = $this->get_groupids($USER->id); if (isset($this->coursegroupings[$groupingid]) && is_array($groups)) { $grouping_groups = $this->coursegroupings[$groupingid]; $intersect1 = array_intersect($groups, $grouping_groups); } if ($cm->groupingid && empty($intersect1)) { continue; } /*elseif(!$cm->groupingid && $groups == -1){ continue; }*/ } } if ($cm->visible == 0 && !$this->canviewhidden) { //if($cm->visible == 0){ continue; } } $header .= '<th style="width:10em;border:1px solid #146C84;">' . $this->print_header_element($element, true); $header .= '</th>'; } // Checks if it is the total grade of the course if ($element['type'] == 'courseitem') { $total = '<th style="border:1px solid #146C84;"> ' . $this->print_header_element($element, true) . '</th>'; } } } } $header .= $total . '</tr>'; return $header; }
/** * @param int $courseid * @return mixed array of moodle activities configurated by evalcomix. * Array key is evalcomix_tasks ID and Array value is activity name */ public static function get_moodle_course_tasks($courseid) { global $DB; $evalcomix_tasks = evalcomix_tasks::get_tasks_by_courseid($courseid); //get_course_tasks($courseid); lo he cambiado por el tema de la duplicacion de funciones, probar si va bien $result = array(); foreach ($evalcomix_tasks as $task) { $cm = $DB->get_record('course_modules', array('id' => $task->instanceid)); if ($cm) { $module = evalcomix_tasks::get_type_task($cm->id); $task_moodle = $DB->get_record($module, array('id' => $cm->instance)); $result[] = array('id' => $task->id, 'nombre' => $task_moodle->name); } } return $result; }
echo ' <center> <div>' . get_string('settings_description', 'block_evalcomix') . '</div><br> <table class="gradestable flexible boxaligncenter generaltable"> <tr><th>' . get_string('activities', 'block_evalcomix') . '</th><th>' . get_string('edition', 'block_evalcomix') . '</th></tr> '; $activities = array(); $tasks = array(); foreach ($levels as $row) { foreach ($row as $element) { if (isset($element['object']->itemnumber) && $element['object']->itemnumber == 0 && $element['object']->itemtype != 'manual') { if ($element['type'] == 'item') { if ($cm = get_coursemodule_from_instance($element['object']->itemmodule, $element['object']->iteminstance, $courseid)) { $cmid = $cm->id; if (!($task = evalcomix_tasks::fetch(array('instanceid' => $cmid)))) { $task = new evalcomix_tasks('', $cmid, 100, 50, time(), '1'); $task->insert(); } $taskid = $task->id; $tasks[$taskid] = $task; $name = $element['object']->get_name(); $dots = ''; if (strlen($name) > 50) { $dots = '... '; } $taskname = substr($element['object']->get_name(), 0, 50) . $dots; $activities[$taskid] = $taskname; $icontask[$taskid] = $report_evalcomix->gtree->get_element_icon($element, false); } } }
require_login($course->id); $url = new moodle_url('/blocks/evalcomix/assessment/details.php', array('contextid' => $contextid, 'itemid' => $itemid)); $PAGE->set_url($url); $PAGE->set_context($context); if ($popup) { $PAGE->set_pagelayout('popup'); } $PAGE->set_title(get_string('ratingsforitem', 'block_evalcomix')); echo $OUTPUT->header(); include_once $CFG->dirroot . '/blocks/evalcomix/classes/evalcomix_assessments.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/webservice_evalcomix_client.php'; include_once $CFG->dirroot . '/blocks/evalcomix/classes/evalcomix_grades.php'; include_once $CFG->dirroot . '/blocks/evalcomix/javascript/popup.php'; global $DB, $USER; //GETTING DATAS---------------------------------------------------------------------------------------- require_capability('block/evalcomix:view', $context, $userid); $user = $DB->get_record('user', array('id' => $userid), '*'); if (!($task = evalcomix_tasks::fetch(array('id' => $itemid)))) { 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), '*');
/** * Calculates finalgrade for a student in a activity * @param int $params[cmid] course module id * @param int $params[userid] student id * @return the finalgrade or -1 if there is only peer-assessment but assessment period hasn't finished or -2 if there is not any assessment */ public static function get_finalgrade_user_task($params) { if (!isset($params['cmid']) || !isset($params['userid']) || !isset($params['courseid'])) { return null; } $cmid = $params['cmid']; $userid = $params['userid']; $courseid = $params['courseid']; //$coursecontext = get_context_instance(CONTEXT_COURSE, $courseid); $coursecontext = context_course::instance($courseid); $now = time(); global $CFG, $DB; include_once $CFG->dirroot . '/blocks/evalcomix/classes/evalcomix_tasks.php'; if (!($task = evalcomix_tasks::fetch(array('instanceid' => $cmid)))) { return null; } $result = null; $teacherweight = -1; $selfweight = -1; $peerweight = -1; $params_modes = array('taskid' => $task->id); $modes = evalcomix_modes::fetch_all($params_modes); if ($modes) { //Obtains activity´s weights foreach ($modes as $mode) { switch ($mode->modality) { case 'teacher': $teacherweight = $mode->weighing; break; case 'self': $selfweight = $mode->weighing; break; case 'peer': $peerweight = $mode->weighing; break; default: } } //echo $task->id . ': teacherweight-' . $teacherweight . ' selfweight-' .$selfweight . ' peerweight-' .$peerweight.'<br/>'; $params2 = array('taskid' => $task->id, 'studentid' => $userid); $assessments = evalcomix_assessments::fetch_all($params2); $inperiod = false; if ($assessments) { //$selfgrade = 0; $selfgrade = -1; $teachergrade = 0; $numteachers = 0; $peergrade = 0; $numpeers = 0; $grade = 0; foreach ($assessments as $assessment) { //If it is a self assessment if ($assessment->studentid == $assessment->assessorid && $selfweight != -1) { $selfgrade = $assessment->grade; } elseif (has_capability('moodle/grade:viewhidden', $coursecontext, $assessment->assessorid)) { if ($teacherweight != -1) { $teachergrade += $assessment->grade; $numteachers++; } } elseif ($assessment->studentid != $assessment->assessorid) { //If it is a peer assessment //Only gets grades when the assessment period in the task is finished if ($modeEI = evalcomix_modes::fetch(array('taskid' => $assessment->taskid, 'modality' => 'peer'))) { $modeEItime = evalcomix_modes_time::fetch(array('modeid' => $modeEI->id)); if ($modeEItime && $now > $modeEItime->timedue) { $peergrade += $assessment->grade; $numpeers++; } elseif ($now >= $modeEItime->timeavailable && $now <= $modeEItime->timedue) { $inperiod = true; } } } } //Calculates peergrade if ($numpeers > 0) { $peergrade = round($peergrade / $numpeers, 2); } //Calculates teachergrade if ($numteachers > 0) { $teachergrade = round($teachergrade / $numteachers, 2); } //Calcultes the total grade //if($teachergrade != 0 || $selfgrade != 0 || $peergrade != 0){ if ($numteachers > 0 || $numpeers > 0 || $selfgrade != -1) { if ($selfgrade == -1) { $selfgrade = 0; } $result = $selfgrade * ($selfweight / 100) + $teachergrade * ($teacherweight / 100) + $peergrade * ($peerweight / 100); } elseif ($inperiod == true) { //There is peer assessments but assessment period hasn't finished $result = -1; } else { $result = -2; } return $result; } else { return null; } } else { return -3; } }
/** * @param int $oldversion */ function xmldb_block_evalcomix_upgrade($oldversion = 201111802) { global $DB; $dbman = $DB->get_manager(); $result = true; /// Add a new column newcol to the mdl_question_myqtype if ($oldversion < 2012013005) { // Define table block_evalcomix to be created $table = new xmldb_table('block_evalcomix'); // Adding fields to table block_evalcomix $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); $table->add_field('courseid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0'); $table->add_field('viewmode', XMLDB_TYPE_CHAR, '10', null, XMLDB_NOTNULL, null, 'evx'); $table->add_field('sendgradebook', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, null, null, '0'); // Adding keys to table block_evalcomix $table->add_key('id', XMLDB_KEY_PRIMARY, array('id')); // Conditionally launch create table for block_evalcomix if (!$dbman->table_exists($table)) { $dbman->create_table($table); } // evalcomix savepoint reached upgrade_block_savepoint(true, 2012013005, 'evalcomix'); } if ($oldversion < 2012013004) { // Define table block_evalcomix_tasks to be created $table = new xmldb_table('block_evalcomix_tasks'); // Adding fields to table block_evalcomix_tasks $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); $table->add_field('instanceid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0'); $table->add_field('maxgrade', XMLDB_TYPE_NUMBER, '10, 5', null, null, null, '0'); $table->add_field('weighing', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0'); $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0'); // Adding keys to table block_evalcomix_tasks $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); // Conditionally launch create table for block_evalcomix_tasks if (!$dbman->table_exists($table)) { $dbman->create_table($table); } // evalcomix savepoint reached upgrade_block_savepoint(true, 2012013004, 'evalcomix'); } if ($oldversion < 2012013004) { // Define table block_evalcomix_modes to be created $table = new xmldb_table('block_evalcomix_modes'); // Adding fields to table block_evalcomix_modes $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); $table->add_field('taskid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0'); $table->add_field('toolid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0'); $table->add_field('modality', XMLDB_TYPE_CHAR, '7', null, XMLDB_NOTNULL, null, 'teacher'); $table->add_field('weighing', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0'); // Adding keys to table block_evalcomix_modes $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); // Conditionally launch create table for block_evalcomix_modes if (!$dbman->table_exists($table)) { $dbman->create_table($table); } // evalcomix savepoint reached upgrade_block_savepoint(true, 2012013004, 'evalcomix'); } if ($oldversion < 2012013004) { // Define table block_evalcomix_modes_time to be created $table = new xmldb_table('block_evalcomix_modes_time'); // Adding fields to table block_evalcomix_modes_time $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); $table->add_field('modeid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0'); $table->add_field('timeavailable', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, '0'); $table->add_field('timedue', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, '0'); // Adding keys to table block_evalcomix_modes_time $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); // Conditionally launch create table for block_evalcomix_modes_time if (!$dbman->table_exists($table)) { $dbman->create_table($table); } // evalcomix savepoint reached upgrade_block_savepoint(true, 2012013004, 'evalcomix'); } //if ($oldversion < 2013110600) { if ($oldversion < 2012013004) { // Define table block_evalcomix_modes_extra to be created. $table = new xmldb_table('block_evalcomix_modes_extra'); // Adding fields to table block_evalcomix_modes_extra. $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); $table->add_field('anonymous', XMLDB_TYPE_INTEGER, '1', null, null, null, '0'); $table->add_field('modeid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0'); // Adding keys to table block_evalcomix_modes_extra. $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); // Conditionally launch create table for block_evalcomix_modes_extra. if (!$dbman->table_exists($table)) { $dbman->create_table($table); } // Evalcomix savepoint reached. //upgrade_block_savepoint(true, 2013110600, 'evalcomix'); upgrade_block_savepoint(true, 2012013004, 'evalcomix'); } else { } //if ($oldversion < 2013090502) { if ($oldversion < 2012013004) { // Define table block_evalcomix_tools to be created $table = new xmldb_table('block_evalcomix_tools'); // Adding fields to table block_evalcomix_tools $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); $table->add_field('evxid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0'); $table->add_field('title', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL, null, null); $table->add_field('type', XMLDB_TYPE_CHAR, '12', null, XMLDB_NOTNULL, null, 'scale'); $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, null, null, '0'); $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, null, null, '0'); $table->add_field('idtool', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, '0'); // Adding keys to table block_evalcomix_tools $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); // Conditionally launch create table for block_evalcomix_tools if (!$dbman->table_exists($table)) { $dbman->create_table($table); } // evalcomix savepoint reached //upgrade_block_savepoint(true, 2013090502, 'evalcomix'); upgrade_block_savepoint(true, 2012013004, 'evalcomix'); } if ($oldversion < 2013102505) { // Define table block_evalcomix_grades to be created. $table = new xmldb_table('block_evalcomix_grades'); // Adding fields to table block_evalcomix_grades. $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); $table->add_field('cmid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); $table->add_field('finalgrade', XMLDB_TYPE_NUMBER, '10, 5', null, null, null, null); $table->add_field('courseid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); // Adding keys to table block_evalcomix_grades. $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); // Conditionally launch create table for block_evalcomix_grades. if (!$dbman->table_exists($table)) { $dbman->create_table($table); } // Evalcomix savepoint reached. upgrade_block_savepoint(true, 2013102505, 'evalcomix'); global $CFG; include_once $CFG->dirroot . '/blocks/evalcomix/classes/evalcomix_grades.php'; 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_extra.php'; include_once $CFG->dirroot . '/blocks/evalcomix/classes/evalcomix_modes_time.php'; if ($tasks = evalcomix_tasks::fetch_all(array())) { foreach ($tasks as $task) { echo '<br><br><br>Procesando task: ' . $task->id . '<br>'; echo 'Finalgrades asociados: <br>'; if ($cm = $DB->get_record('course_modules', array('id' => $task->instanceid))) { $courseid = $cm->course; if ($assessments = evalcomix_assessments::fetch_all(array('taskid' => $task->id))) { foreach ($assessments as $assessment) { $params = array(); //cmid -- userid -- courseid $params['cmid'] = $task->instanceid; $params['userid'] = $assessment->studentid; $params['courseid'] = $courseid; $finalgrade = evalcomix_grades::get_finalgrade_user_task($params); echo "finalgrade: {$finalgrade} <br>"; if ($finalgrade !== null) { if ($gradeObject = evalcomix_grades::fetch($params)) { $gradeObject->finalgrade = $finalgrade; $gradeObject->update(); } else { $params['finalgrade'] = $finalgrade; $gradeObject = new evalcomix_grades($params); $gradeObject->insert(); } } else { if ($gradeObject = evalcomix_grades::fetch($params)) { $gradeObject->delete(); } } } } } } } } if ($oldversion < 2013111801) { // Define table block_evalcomix_allowedusers to be created. $table = new xmldb_table('block_evalcomix_allowedusers'); // Adding fields to table block_evalcomix_allowedusers. $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); $table->add_field('cmid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); $table->add_field('assessorid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); $table->add_field('studentid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); // Adding keys to table block_evalcomix_allowedusers. $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); // Conditionally launch create table for block_evalcomix_allowedusers. if (!$dbman->table_exists($table)) { $dbman->create_table($table); } // Evalcomix savepoint reached. upgrade_block_savepoint(true, 2013111801, 'evalcomix'); } if ($oldversion < 2013111801) { // Define field whoassesses to be added to block_evalcomix_modes_extra. $table = new xmldb_table('block_evalcomix_modes_extra'); $field1 = new xmldb_field('visible', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0'); if (!$dbman->field_exists($table, $field1)) { $dbman->add_field($table, $field1); } $field2 = new xmldb_field('whoassesses', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'visible'); // Conditionally launch add field whoassesses. if (!$dbman->field_exists($table, $field2)) { $dbman->add_field($table, $field2); } // Evalcomix savepoint reached. upgrade_block_savepoint(true, 2013111802, 'evalcomix'); } if ($oldversion < 2013121700) { // Define field visible to be added to block_evalcomix_tasks. $table = new xmldb_table('block_evalcomix_tasks'); $field = new xmldb_field('visible', XMLDB_TYPE_INTEGER, '1', null, null, null, '1', 'timemodified'); // Conditionally launch add field visible. if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } // Evalcomix savepoint reached. upgrade_block_savepoint(true, 2013121700, 'evalcomix'); } if ($oldversion < 2014040716) { // Define field idtool to be added to block_evalcomix_tools. $table = new xmldb_table('block_evalcomix_tools'); $field = new xmldb_field('idtool', XMLDB_TYPE_CHAR, '40', null, XMLDB_NOTNULL, null, '0', 'timemodified'); // Conditionally launch add field idtool. if ($dbman->field_exists($table, $field)) { $dbman->change_field_type($table, $field); } // Evalcomix savepoint reached. upgrade_block_savepoint(true, 2014040716, 'evalcomix'); } return $result; }
/** * Fail to get type task from a not existing instanceid */ public function test_gettypetask_fail() { $result = evalcomix_tasks::get_type_task('58'); $this->assertNull($result); unset($result); }
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; } }
function query($type, $id, $idCurso) { include_once '../../../../config.php'; switch ($type) { // 1.- Listado de tareas case 1: global $DB; include_once '../../classes/evalcomix_tasks.php'; $tasks = evalcomix_tasks::get_moodle_course_tasks($idCurso); return $tasks; /* return array( array('id'=> 1, 'nombre'=> 'tarea1'), array('id'=> 2, 'nombre'=>'tarea2'), array('id'=> 3, 'nombre'=>'tarea3'), array('id'=> 4, 'nombre'=>'tarea4') );*/ break; // 2.- Listado de grupos asociados a una tarea, el id correspondería a una tarea y // habría que seleccionar los grupos asociados a dicho id // 2.- Listado de grupos asociados a una tarea, el id correspondería a una tarea y // habría que seleccionar los grupos asociados a dicho id case 2: global $DB; $groups = $DB->get_records('groups', array('courseid' => $idCurso)); $array_groups = array(); foreach ($groups as $group) { $array_groups[] = array('id' => $group->id, 'nombre' => $group->name); } return $array_groups; /*return array( array('id'=> 1, 'nombre'=> 'grupo1'), array('id'=> 2, 'nombre'=>'grupo2'), array('id'=> 3, 'nombre'=>'grupo3'), array('id'=> 4, 'nombre'=>'grupo4') );*/ break; // 3.- Listado de modalidades disponibles // 3.- Listado de modalidades disponibles case 3: return array(array('id' => 1, 'nombre' => 'profesor'), array('id' => 2, 'nombre' => 'autoevaluacion'), array('id' => 3, 'nombre' => 'entre iguales')); break; // 4.- Listado de los alumnos asociados a una tarea // Llamada de ejemplo: Grafica perfil-tarea al seleccionar por alumno y tarea // Llamada de ejemplo: Grafica perfil-tarea al seleccionar por grupo y a elegir un grupo // 4.- Listado de los alumnos asociados a una tarea // Llamada de ejemplo: Grafica perfil-tarea al seleccionar por alumno y tarea // Llamada de ejemplo: Grafica perfil-tarea al seleccionar por grupo y a elegir un grupo case 4: $pos = strpos($id, ';'); if ($pos == false) { //Entra si no estamos en grupo global $DB, $CFG; include_once '../../classes/evalcomix_assessments.php'; $users = evalcomix_assessments::get_students_assessed($id); $array_students = array(); foreach ($users as $user) { $student = $DB->get_record('user', array('id' => $user)); $array_students[] = array('id' => $user, 'nombre' => $student->lastname . ', ' . $student->firstname); } return $array_students; /*return array( array('id'=> 1, 'nombre'=> 'alumnoTarea1'), array('id'=> 2, 'nombre'=>'alumnoTarea2'), array('id'=> 3, 'nombre'=>'alumnoTarea3'), array('id'=> 4, 'nombre'=>'alumnoTarea4'), array('id'=> 4, 'nombre'=>'alumnoTarea4') );*/ } else { //Entra si estamos en un grupo $idtarea = substr($id, 0, $pos); $idgrupo = substr($id, $pos + 1); if ($idgrupo == -2) { //Caso de sin grupo (Todos los alumnos, idCurso) /*return array( array('id'=> 1, 'nombre'=> 'alumnoTareaGrupo1'), array('id'=> 2, 'nombre'=>'alumnoTareaGrupo2'), array('id'=> 3, 'nombre'=>'alumnoTareaGrupo3'), array('id'=> 4, 'nombre'=>'alumnoTareaGrupo4'), array('id'=> 5, 'nombre'=>'alumnoTareaGrupo5'), array('id'=> 6, 'nombre'=>'alumnoTareaGrupo6'), array('id'=> 7, 'nombre'=>'alumnoTareaGrupo4') );*/ global $DB, $CFG; include_once '../../classes/evalcomix_assessments.php'; $users = evalcomix_assessments::get_students_assessed($idtarea); $array_students = array(); foreach ($users as $user) { $student = $DB->get_record('user', array('id' => $user)); $array_students[] = array('id' => $user, 'nombre' => $student->lastname . ', ' . $student->firstname); } return $array_students; } else { //Caso de un grupo (Alumnos de grupo idgrupo) $idtarea = substr($id, 0, $pos); $idgrupo = substr($id, $pos + 1); global $DB, $CFG; include_once '../../classes/evalcomix_assessments.php'; $users = evalcomix_assessments::get_students_assessed($idtarea); $groups_member = $DB->get_records('groups_members', array('groupid' => $idgrupo)); $members_ids = array(); //Vamos comprobando para cada miembro del grupo si ha sido evaluado en la actividad foreach ($groups_member as $member) { //$members_ids[] = $member->userid; if (in_array($member->userid, $users)) { $members_ids[] = $member->userid; } } //$array_intersection = array_intersect_assoc($users, $members_ids); $array_students = array(); //foreach($array_intersection as $student){ foreach ($members_ids as $student) { $user = $DB->get_record('user', array('id' => $student)); $array_students[] = array('id' => $user->id, 'nombre' => $user->lastname . ', ' . $user->firstname); } /*global $DB; $groups_member = $DB->get_records('groups_members', array('groupid' => $idgrupo)); $array_students = array(); foreach($groups_member as $student){ $user = $DB->get_record('user', array('id' => $student->userid)); $array_students[] = array('id' => $user->id, 'nombre' =>($user->lastname.', '.$user->firstname)); }*/ return $array_students; /*return array( array('id'=> 1, 'nombre'=> 'alumnoTareaGrupo1'), array('id'=> 2, 'nombre'=>'alumnoTareaGrupo2'), array('id'=> 3, 'nombre'=>'alumnoTareaGrupo3'), array('id'=> 4, 'nombre'=>'alumnoTareaGrupo4') );*/ } } break; default: return -1; break; } }
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); }