//	}
        //$this->assertTrue($var);
        //unset($objectnew2);
    }
    /**
	* Object construction without the required param 'type'. It should print error:'The type assessment tool is wrong'
	*/
    public function testParamMissingOne()
    {
    }
    /**
	* Update a recently insert object in the DB. Param 'timemodified' change
	*/
    public function test_update_ok()
    {
        $objectnew = new evalcomix_assessments('', 5, 4, 5, 60);
        $objectnew->insert();
        $id = $objectnew->update();
        $this->assertTrue($id);
        $objectnew->delete();
        unset($objectnew, $id);
Exemplo n.º 3
0
/**
 * Update database tools with Web Services tools
 * @param int $evxid primary key of evalcomix table
 * @param mixed $webtools tools of Web Service
 */
function update_tool_list($evxid, $webtools)
{
    global $CFG;
    include_once $CFG->dirroot . '/blocks/evalcomix/classes/evalcomix_tool.php';
    foreach ($webtools as $tool) {
        if (!($toolupdate = evalcomix_tool::fetch(array('evxid' => $evxid, 'idtool' => $tool->idtool)))) {
            $newtool = new evalcomix_tool('', $evxid, $tool->title, $tool->type, (string) $tool->idtool);
            $newtool->insert();
        } else {
            evalcomix_tool::set_properties($toolupdate, array('title' => $tool->title));
            $toolupdate->update();
        }
    }
    //Si hay instrumentos duplicados de una restauración de eliminan y se configuran las actividades correctamente
    if ($oldtools_restored = evalcomix_tool::fetch_all(array('evxid' => $evxid, 'timemodified' => '-1'))) {
        global $COURSE, $DB;
        include_once $CFG->dirroot . '/blocks/evalcomix/classes/evalcomix_tasks.php';
        include_once $CFG->dirroot . '/blocks/evalcomix/classes/evalcomix_modes.php';
        $activities = $DB->get_records('course_modules', array('course' => $COURSE->id));
        //Bucle recorriendo las actividades del curso y llamando a webservice_evalcomix_client::get_instrument($courseid, $module, $activity, $lms)
        //De ahí sacar el idtool de evalcomix y actualizar la tabla modes en moodle
        foreach ($activities as $activity) {
            if ($task = evalcomix_tasks::fetch(array('instanceid' => $activity->id))) {
                $module = evalcomix_tasks::get_type_task($task->instanceid);
                $xml = webservice_evalcomix_client::get_instrument($COURSE->id, $module, $task->instanceid, MOODLE_NAME);
                //echo $COURSE->id . ' - ' .$module . ' - ' . $task->instanceid . ' - ' . MOODLE_NAME . '<br>';//
                //print_r($xml->evaluacion);
                //echo '<br>';
                if (isset($xml->evaluacion->teacher) && $xml->evaluacion->teacher != null) {
                    $tool = evalcomix_tool::fetch(array('evxid' => $evxid, 'idtool' => $xml->evaluacion->teacher));
                    $modes = evalcomix_modes::fetch(array('taskid' => $task->id, 'modality' => 'teacher'));
                    //Actualizamos el toolid de modes al toolid correcto
                    evalcomix_modes::set_properties($modes, array('toolid' => $tool->id));
                    $modes->update();
                }
                if (isset($xml->evaluacion->self) && $xml->evaluacion->self != null) {
                    $tool = evalcomix_tool::fetch(array('evxid' => $evxid, 'idtool' => $xml->evaluacion->self));
                    $modes = evalcomix_modes::fetch(array('taskid' => $task->id, 'modality' => 'self'));
                    //Actualizamos el toolid de modes al toolid correcto
                    evalcomix_modes::set_properties($modes, array('toolid' => $tool->id));
                    $modes->update();
                }
                if (isset($xml->evaluacion->peer) && $xml->evaluacion->peer != null) {
                    $tool = evalcomix_tool::fetch(array('evxid' => $evxid, 'idtool' => $xml->evaluacion->peer));
                    $modes = evalcomix_modes::fetch(array('taskid' => $task->id, 'modality' => 'peer'));
                    //Actualizamos el toolid de modes al toolid correcto
                    evalcomix_modes::set_properties($modes, array('toolid' => $tool->id));
                    $modes->update();
                }
            }
        }
        //Delete old restored tools
        foreach ($oldtools_restored as $tool) {
            $tool->delete();
        }
        //$DB->get_record('block_evalcomix_tasks', array('instanceid' => $activity->id))
        /*print_r($old_new_instruments);
        		print_r($oldtools_restored);*/
        //$xml_olds = array();
        /*foreach($oldtools_restored as $tool){				
        			//Almacenamos los instrumentos antiguos antes de eliminarlos
        			//$xml_olds[] = webservice_evalcomix_client::get_ws_tool_assessed('', '', '', '', '', '', '', (string)$tool->idtool);
        			//$tool->delete(); DESCOMENTAR
        		}*/
        /*$newtools =  evalcomix_tool::fetch_all(array('evxid' => $evxid));
        		evalcomix_modes::fetch_all(array('toolid' => ));
        		foreach($xml_olds as $xml_old_tool){
        			foreach($newtools as $newtool){
        				$new_xml = webservice_evalcomix_client::get_ws_tool_assessed('', '', '', '', '', '', '', $newtool->idtool);
        				if ($xml_old_tool === $new_xml){
        					
        					//$mode = evalcomix_modes::fetch(array('taskid' => $xml_old_tool->taskid, 'toolid' => $xml_old_tool->idtool));
        					
        				}
        			}			
        		}*/
    }
}
        $objectnew->insert();
        unset($objectnew);
    }
    /**
	* Update a recently insert object in the DB
	*/
    public function sub_test_evalcomix_tool_update_ok()
    {
        global $DB;
        $objectnew = new evalcomix_tool($this->evalcomix_tool[0]->id, $this->evalcomix_tool[0]->evxid, $this->evalcomix_tool[0]->title, $this->evalcomix_tool[0]->type, $this->evalcomix_tool[0]->idtool);