report_traspasonotasexam/gradelist.php

340 lines
14 KiB
PHP

<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Participation report
*
* @package report
* @subpackage participation
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require('../../config.php');
require_once($CFG->dirroot.'/lib/tablelib.php');
require_once(dirname(__FILE__) . '/lib.php');
define('DEFAULT_PAGE_SIZE', 20);
define('SHOW_ALL_PAGE_SIZE', 5000);
$activ = required_param('activ', PARAM_INT); // course id.
$cali = required_param('cali', PARAM_INT); // course id.
//$porcent = required_param('porcent', PARAM_INT); // Porcentaje de incidencia de la calificaciòn sobre la evaluaciòn
$idcourse = required_param('idcourse', PARAM_INT);
$dific = isset($_POST['porcent']) ? $_POST['porcent'] : 60;
$page = optional_param('page', 0, PARAM_INT); // which page to show
$perpage = optional_param('perpage', DEFAULT_PAGE_SIZE, PARAM_INT); // how many per page
$url = new moodle_url('/report/traspasonotasexam/gradelist.php', array('course'=>$idcourse));
if ($activ !== 0) $url->param('activ');
if ($cali !== 0) $url->param('cali');
if ($idcourse !== 0) $url->param('course');
if ($page !== 0) $url->param('page');
if ($perpage !== DEFAULT_PAGE_SIZE) $url->param('perpage');
$PAGE->set_url($url, array(
'page' => $page,
'perpage' => $perpage,
'id' => $idcourse));
$PAGE->set_pagelayout('report');
if (!$course = $DB->get_record('course', array('id'=>$idcourse))) {
print_error('invalidcourse');
}
require_login($course);
$context = context_course::instance($course->id);
// require_capability('report/traspasonotasexam:view', $context);// ver capabilities para el docente en la página.
?>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="paging.js"></script>
<script type="text/javascript" src="paginacion.js"></script>
<script>
$(document).ready(function()
{
$(".emptyrow").remove();
// $('#porcent').attr('size',10);
$("h2").css({"display": "block", "font-size": "1.5em"});
$('#porcent').keyup(function (){
this.value = (this.value + '').replace(/[^0-9]/g, '');
});
$("#calcular").click(function(){
var porcentaje = $("#porcent").val();
if(porcentaje.length < 1 || porcentaje < 10 || porcentaje !=60){
alert('Valor ingresado no es valido, sólo se acepta 60%.');
return false;
}
/* if(porcentaje > 99){
alert('Valor ingresado debe estar entre el 10% - 99%.');
return false;
} */
if(porcentaje != 60 ){
alert('Valor ingresado debe ser 60%.');
return false;
}
});
$("#guardar").click(function(){
var formulario = $("#studentsgradesform").serializeArray();
var porcentaje = $("#porcent").val();
if(porcentaje.length < 1 || porcentaje < 60){
alert('Solo se permite el valor 60.');
return false;
}
if(porcentaje > 60){
alert('Valor ingresado debe ser 60%.');
return false;
}
if (confirm('¿Usted está seguro de realizar la acción Guardar al '+ porcentaje+' % ?')){
$.ajax({
type: "POST",
dataType: "html",
url: "guardar.php",
data: formulario,
success: function(source){
alert(source);
// var obj = jQuery.parseJSON(source);
window.location = "index.php?cursos="+<?php echo $course->id; ?>;
}
});
}
});
});
</script>
<?php
$PAGE->set_title($course->shortname .': Traspaso de Calificaciones a SIGA ');
$PAGE->set_heading($course->fullname);
echo $OUTPUT->header();
/* $dbe = new auth_plugin_db_inacap;
$authdb = $dbe->db_init(); */
$enrol = enrol_get_plugin('dbinacap');
$authdb = $enrol->db_init_inacap();
$sqlDif = "select asi.tasg_ccod,decode(asi.tasg_ccod,1,(select ponf_jnota_examen *100
from ponderaciones_nota_final where talu_ccod = nvl (1, 1) and peri_ccod_inicio <= sc.peri_ccod
and sc.peri_ccod <= decode (peri_ccod_termino,0, sc.peri_ccod,peri_ccod_termino)), '')
pond_examen from secciones sc, asignaturas asi Where sc.asig_ccod = asi.asig_ccod and sc.secc_ccod=".$course->idnumber;
$result = $authdb->Execute( $sqlDif );
foreach($result as $Ndif){
$ponde = isset($Ndif['POND_EXAMEN']) ? $Ndif['POND_EXAMEN'] : 1;
}
//$dific = isset($_POST['porcent']) ? $_POST['porcent'] : 25;
$baseurl = $CFG->wwwroot.'/report/traspasonotasexam/gradelist.php?idcourse='.$course->id.'&amp;activ='
.$activ.'&amp;cali='.$cali.'&amp;dific='.$dific.'&amp;perpage='.$perpage.'&amp;page='.$page;
// echo $baseurl;
$sqlgrades="select x.userid, x.idnumber, x.firstname,x.item, x.lastname, x.itemname, NVL(x.grademin,0) grademin, NVL(x.grademax,0) grademax,NVL(g.rawgrade,0) rawgrade,
NVL(g.rawgrademin,0) rawgrademin, NVL(g.rawgrademax,0) rawgrademax, (x.GRADEMAX*$dific)/100 as xexig,
to_char( (((7-4)/((NVL(x.GRADEMAX,0) )-(((NVL(x.GRADEMAX,0) )*$dific)/100)))*(NVL(G.RAWGRADE,0)-(((NVL(x.GRADEMAX,0))*$dific)/100)))+4,'990.9') ap ,
to_char( (((4-1)/(((NVL(x.GRADEMAX,0)-NVL(x.GRADEMin,0))*$dific)/100))*NVL(G.RAWGRADE,0))+1,'990.9') rep
from (
select * from(
SELECT u.id userid,u.firstname,u.lastname, u.idnumber
FROM m_user u
JOIN (SELECT DISTINCT eu1_u.id FROM m_user eu1_u JOIN m_user_enrolments eu1_ue ON eu1_ue.userid = eu1_u.id and eu1_ue.status=0 JOIN m_enrol eu1_e ON (eu1_e.id = eu1_ue.enrolid AND eu1_e.courseid = $idcourse)
WHERE eu1_u.deleted = 0 AND eu1_u.id <> 1) je ON je.id = u.id
JOIN (
SELECT DISTINCT ra.userid
FROM m_role_assignments ra, m_context mctx
WHERE ra.roleid IN (5)
and RA.CONTEXTID = MCTX.ID
and MCTX.CONTEXTLEVEL = 50
and MCTX.INSTANCEID = $idcourse
) rainner ON rainner.userid = u.id
AND u.deleted = 0
) usr,
(SELECT id item, itemname, itemtype, grademin, grademax FROM m_grade_items WHERE courseid = $idcourse AND itemtype <> 'course'
AND categoryid in (SELECT id FROM m_grade_categories WHERE courseid = $idcourse ))
) x left join m_grade_grades g on g.itemid = x.item and g.userid = x.userid
where item in ($activ)
order by firstname, lastname ";
// echo $sqlgrades.'<br><br>';
$grades = $DB->get_records_sql($sqlgrades);
// // //Generación de Tabla 1--
$totalcount = count($grades);
$data = array();
$sqlgrades_header = 'select * from {grade_items} WHERE id = '.$activ;
$grades_header = $DB->get_record_sql($sqlgrades_header);
// $dbe = new auth_plugin_db_inacap;
// $authdb = $dbe->db_init();
$sqlCali = "SELECT 0 CALI_NEVALUACION,
s.secc_ccod,
'Examen' || ' - ' || s.SECC_FTERMINO_SEC || ' ' || $dific caliSIGA
FROM secciones s
WHERE s.secc_ccod =$cali";
// echo $sqlCali;
$Ncali = $authdb->Execute( $sqlCali );
foreach($Ncali as $Ncalif){
$vNCali = $Ncalif['CALI_NEVALUACION'];
$vCalisiga = $Ncalif['CALISIGA'];
}
echo '<form action="'.$CFG->wwwroot.'/report/traspasonotasexam/gradelist.php" method="post" id="studentsgradesform">'."\n";
echo '<div style="text-align:center;">'."\n";
echo '<input type="hidden" name="idcourse" value="'.$course->id.'" />'."\n";
echo '<input type="hidden" name="cursos" value="'.$course->id.'" />'."\n";
echo '<input type="hidden" name="activ" value="'.$activ.'" />'."\n";
echo '<input type="hidden" name="cali" value="'.$cali.'" />'."\n";
echo '<input type="hidden" name="ncali" value="'.$vNCali.'" />'."\n";
echo '<input type="hidden" name="calisiga" value="'.$vCalisiga.'" />'."\n";
echo '<input type="hidden" name="dific" value="'.$dific.'" />'."\n";
echo '<input type="hidden" name="returnto" value="'. s($PAGE->url) .'" />'."\n";
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />'."\n";
echo '<input type="hidden" name="secc_ccod" value="'.$course->idnumber.'" />'."\n";
echo '<input type="hidden" name="gradeid" value="'.$grades_header->id.'" />'."\n";
echo '<input type="hidden" name="grademax" value="'.$grades_header->grademax.'" />'."\n";
echo '<input type="hidden" name="itemmodule" value="'.$grades_header->itemname.'" />'."\n";
// Nueva distribución de Tablas *****************************************
echo html_writer::start_tag('table', array('border' => '0', 'style'=>'margin: 0 auto;'));
echo html_writer::start_tag('tr');
echo html_writer::start_tag('td', array('colspan' => '3', 'align' => 'center'));
echo '<h2> Actividad : '.$grades_header->itemname.'</h2>'."<br/>";
echo html_writer::end_tag('td');
echo html_writer::end_tag('tr');
/* echo html_writer::start_tag('tr');
echo html_writer::start_tag('td', array('colspan' => '3', 'align' => 'center'));
echo '<h2> Tabla de Cálculo</h2>'."\n";
echo html_writer::end_tag('td');
echo html_writer::end_tag('tr'); */
echo html_writer::start_tag('tr');
echo html_writer::start_tag('td',array('colspan' => '3', 'align' => 'center'));
echo html_writer::start_tag('table', array("width" => "100%"));
echo html_writer::start_tag('tr');
echo html_writer::start_tag('td', array('align' => 'center'));
//echo '<div>';
echo '<input type="submit" id="calcular" value="Calcular al " />'."\n";
echo '<input type="text" min="60" max="60" name="porcent" id="porcent" value='.$dific.' />&#160;% '."\n";
// echo '<label for="porcent">%</label>'."\n";
//echo '</div>';
echo html_writer::end_tag('td');
echo html_writer::end_tag('tr');
echo html_writer::end_tag('table');
echo html_writer::end_tag('td');
echo html_writer::end_tag('tr');
echo html_writer::start_tag('tr');
echo html_writer::start_tag('td', array('valign'=>'top'));
//VARIABLES Y DATOS DE REGISTROS PARA GENERAR LA TABLA 1
$table = new flexible_table('course-grade-'.$course->id.'-'.$activ);
$table->course = $course;
$table->define_columns(array('fullname','grade','calif'));
$table->define_headers(array('Nombres / Apellidos','Puntaje','Calificación Calculada al '.$dific.' %'));
$table->define_baseurl($baseurl);
$table->set_attribute('cellpadding','1');
$table->set_attribute('class', 'table table-bordered generaltable yy');
$table->set_attribute('id', 'participantes');
$table->sortable(false,'fullname','ASC');
$table->no_sorting('grade');
$table->no_sorting('calif');
$table->set_control_variables(array(
TABLE_VAR_SORT => 'ssort',
TABLE_VAR_HIDE => 'shide',
TABLE_VAR_SHOW => 'sshow',
TABLE_VAR_IFIRST => 'sifirst',
TABLE_VAR_ILAST => 'silast',
TABLE_VAR_PAGE => 'spage'
));
$table->setup();
foreach ($grades as $u) {
echo '<input type="hidden" name="pers_ncorr" value="'.$u->idnumber.'" />'."\n";
if($u->rawgrade < $u->xexig) $calificacion = $u->rep;else $calificacion = $u->ap;
$data = array('<a href="'.$CFG->wwwroot.'/user/view.php?id='.$u->userid.'&amp;course='.$course->id.'">'.$u->firstname.' '.$u->lastname.'</a>'."\n",
$u->rawgrade,
$calificacion
);
$table->add_data($data);
}
$table->print_html(); //IMPRIME TABLA 1
echo html_writer::end_tag('td');
echo html_writer::start_tag('td', array('valign'=>'top'));
$GRADEMAX =$grades_header->grademax;
$GRADEMIN = $grades_header->grademin;
$table2 = new flexible_table('course-grade-'.$course->id.'-'.$activ.'-grid');
$table2->course = $course;
$table2->define_columns(array('points','grade'));
$table2->define_headers(array('Puntaje','Calificación Calculada al '.$dific.' %'));
$table2->define_baseurl($baseurl);
$table2->set_attribute('cellpadding','1');
$table2->set_attribute('class', 'table table-bordered generaltable xx');
$table2->set_attribute('id', 'resultados');
$table2->setup();
$RAWGRADE = $GRADEMIN;
$v_exig = ($GRADEMAX*$dific)/100;
while ($RAWGRADE <= $GRADEMAX) {
if ($RAWGRADE < $v_exig )
$v_nota= number_format((((4-1)/((($GRADEMAX - $GRADEMIN)*$dific)/100))*$RAWGRADE)+1 ,1);
else
// $v_nota= number_format( (((7-4)/(($GRADEMAX - $GRADEMIN)-(((($GRADEMAX - $GRADEMIN)*$dific)/100*100)/100)))*($RAWGRADE-(((($GRADEMAX - $GRADEMIN)*$dific)/100*100)/100)))+4,2);
$v_nota= number_format((((7-4)/(($GRADEMAX )-((($GRADEMAX )*$dific)/100)))*($RAWGRADE-((($GRADEMAX)*$dific)/100)))+4,1);
$data1 = array($RAWGRADE,$v_nota);
$table2->add_data($data1);
$RAWGRADE++;
}
$table2->print_html(); //IMPRIME TABLA 2
echo "<div id='NavPosicion'></div>";
echo html_writer::end_tag('td');
echo html_writer::start_tag('td', array('valign'=>'top'));
/**/
echo html_writer::end_tag('td');
echo html_writer::end_tag('tr');
echo html_writer::end_tag('table');
echo html_writer::start_tag('tr');
echo html_writer::start_tag('td', array('align' => 'center', 'colspan' =>'3'));
echo html_writer::end_tag('table');
echo html_writer::start_tag('tr', array('style'=>'height: 50px'));
echo html_writer::start_tag('td', array('align' => 'center'));
echo '<input type="button" id="guardar" value="Guardar" />'."<br/>";
echo html_writer::end_tag('td');
echo html_writer::end_tag('tr');
echo html_writer::start_tag('tr');
echo html_writer::start_tag('td', array('align' => 'center', 'style' => 'font-size:12px'));
echo '<a href="'.$CFG->wwwroot.'/report/traspasonotasexam/?cursos='.$idcourse.'"> Volver Atrás</a>'."\n";
echo html_writer::end_tag('td');
echo html_writer::end_tag('tr');
echo html_writer::end_tag('table');
echo html_writer::end_tag('td');
echo html_writer::end_tag('tr');
echo '</div>'."\n";
echo '</form>'."\n";
echo html_writer::end_tag('table');
$PAGE->requires->js_init_call('M.report_traspasonotasexam.init');
echo $OUTPUT->footer();