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; } }