Browse Source

Acertos nas punições por abandono e reprovação

master
Sesostris Vieira 11 years ago
parent
commit
ffb7e9a588
  1. 2
      edit.php
  2. 4
      edit_form.php
  3. 9
      lang/en/enrol_ilbeadtutorado.php
  4. 9
      lang/pt_br/enrol_ilbeadtutorado.php
  5. 68
      lib.php

2
edit.php

@ -102,6 +102,7 @@ if ($mform->is_cancelled()) {
$instance->customint6 = $data->customint6;
$instance->customint7 = $data->customint7;
$instance->customint8 = $data->customint8;
$instance->customdec1 = $data->customdec1;
$instance->customtext1 = $data->customtext1;
$instance->customtext2 = serialize($data->customtext2);
$instance->roleid = $data->roleid;
@ -131,6 +132,7 @@ if ($mform->is_cancelled()) {
'customint6' => $data->customint6,
'customint7' => $data->customint7,
'customint8' => $data->customint8,
'customdec1' => $data->customdec1;
'customtext1' => $data->customtext1,
'customtext2' => serialize($data->customtext2),
'roleid' => $data->roleid,

4
edit_form.php

@ -112,6 +112,10 @@ class enrol_ilbeadtutorado_edit_form extends moodleform {
$mform->addHelpButton('customint8', 'abandonpunishment', 'enrol_ilbeadtutorado');
$mform->setType('customint8', PARAM_INT);
$mform->addElement('text', 'customdec1', get_string('reprovalpunishment', 'enrol_ilbeadtutorado'));
$mform->addHelpButton('customdec1', 'reprovalpunishment', 'enrol_ilbeadtutorado');
$mform->setType('customdec1', PARAM_INT);
$cohorts = array(0 => get_string('no'));
list($sqlparents, $params) = $DB->get_in_or_equal($context->get_parent_context_ids(), SQL_PARAMS_NAMED);
$params['current'] = $instance->customint5;

9
lang/en/enrol_ilbeadtutorado.php

@ -113,9 +113,12 @@ $string['maxongoing_help'] = 'Maximum simultaneos EAD courses that the user can
$string['ongoingcourses'] = 'List of ongoing courses';
$string['abandonedcourses'] = 'Abandoned courses';
$string['enrolledat'] = 'enrolled at';
$string['abandonalert'] = 'You have abandoned courses and cannot enroll in new courses.';
$string['abandonpunishment'] = 'Days of punishment for abandon';
$string['abandonpunishment_help'] = 'Number of days that the user cannot enroll in another ILB EAD course after abandon any ILB EAD course.';
$string['abandonalert'] = 'You have abandoned the {$a} course and cannot enroll in new courses.';
$string['abandonpunishment'] = 'Offers of punishment for abandon';
$string['abandonpunishment_help'] = 'Number of offers that the user cannot enroll in another ILB EAD course after abandon any ILB EAD course.';
$string['reprovalalert'] = 'You have reproved on {$a} course and cannot enroll in new courses.';
$string['reprovalpunishment'] = 'Offers of punishment for reproval';
$string['reprovalpunishment_help'] = 'Number of offers that the user cannot enroll in another ILB EAD course after abandon any ILB EAD course.';
$string['coursename'] = 'Course name';
$string['startdate'] = 'Start date';
$string['timeend'] = 'Expected time end';

9
lang/pt_br/enrol_ilbeadtutorado.php

@ -113,9 +113,12 @@ $string['maxongoing_help'] = 'Máximo de cursos simultâneos de EAD que o usuár
$string['ongoingcourses'] = 'Lista de cursos que você não concluiu';
$string['abandonedcourses'] = 'Cursos abandonados';
$string['enrolledat'] = 'inscrito em';
$string['abandonalert'] = 'Você abandonou curso(s) e não pode se inscrever em novos cursos.';
$string['abandonpunishment'] = 'Dias de suspensão por abandono/reprovação';
$string['abandonpunishment_help'] = 'Número de dias que o aluno não poderá se inscrever em outro curso EAD do ILB depois de ter abandonado um curso.';
$string['abandonalert'] = 'Você abandonou o curso {$a} e não pode se inscrever nesta oferta. Aguarde ofertas futuras.';
$string['abandonpunishment'] = 'Ofertas de suspensão por abandono';
$string['abandonpunishment_help'] = 'Número de ofertas que o aluno não poderá se inscrever em outro curso EAD do ILB depois de ter abandonado um curso.';
$string['reprovalalert'] = 'Você foi reprovado no curso {$a} e não pode repetí-lo nesta oferta. Aguarde ofertas futuras.';
$string['reprovalpunishment'] = 'Ofertas de suspensão por reprovação';
$string['reprovalpunishment_help'] = 'Número de ofertas que o aluno não poderá se inscrever em outro curso EAD do ILB depois de ter sido reprovado em um curso.';
$string['coursename'] = 'Nome do curso';
$string['startdate'] = 'Data de início';
$string['timeend'] = 'Data prevista de término';

68
lib.php

@ -247,16 +247,27 @@ class enrol_ilbeadtutorado_plugin extends enrol_plugin {
$course = $DB->get_record('course', array('id'=>$instance->courseid), '*', MUST_EXIST);
$course_prefix = explode('.', $course->idnumber);
$course_prefix = $course_prefix[0];
foreach ($ongoing as $course) {
$ongoing_prefix = explode('.', $course->idnumber);
$ongoing_prefix = $ongoing_prefix[0];
if ($course_prefix == $ongoing_prefix) {
$error = $OUTPUT->error_text(get_string('samecoursealert', 'enrol_ilbeadtutorado'));
$link = '<a href="'.course_get_url($course).'">'.$course->fullname.'</a>';
$error .= '<br/><br/><p>'.get_string('samecoursemessage', 'enrol_ilbeadtutorado', $link).'</p>';
$error = $OUTPUT->box($error).$OUTPUT->continue_button("$CFG->wwwroot/index.php");
return $error;
$same_courses = $this->get_same_courses($instance, $course_prefix);
// Search for abandon/reproval facts
$count = 0;
foreach ($same_courses as $course) {
$count++;
$link = '<a href="'.course_get_url($course).'">'.$course->fullname.'</a>';
if ($course->user_enroled) {
if (($count <= $instance->customint8) and ($course->finalgrade === NULL)) {
// Punish for abandon
$error = $OUTPUT->error_text(get_string('abandonalert', 'enrol_ilbeadtutorado', $link));
$error = $OUTPUT->box($error).$OUTPUT->continue_button("$CFG->wwwroot/index.php");
return $error;
}
if (($count <= $instance->customdec1) and ($course->finalgrade < $course->gradepass)) {
// Punish for reproval
$error = $OUTPUT->error_text(get_string('reprovalalert', 'enrol_ilbeadtutorado', $link));
$error = $OUTPUT->box($error).$OUTPUT->continue_button("$CFG->wwwroot/index.php");
return $error;
}
}
}
@ -666,4 +677,41 @@ class enrol_ilbeadtutorado_plugin extends enrol_plugin {
return false; // Default max not reached
}
/**
* Get all same courses tried by the user ordered by startdate descending
*
* @param stdClass $instance
* @param str $course_prefix
*/
public function get_same_courses($instance, $course_prefix) {
global $DB;
global $USER;
if ($instance->customint8 >= $instance->customdec1) {
$limitnum = $instance->customint8;
} else {
$limitnum = int($instance->customdec1);
}
if ($limitnum <= 0) {
return array(); // No validations
}
$idnumberlike = $DB->sql_like('c.idnumber', "'$course_prefix%'");
$sql = "select c.*, cc.gradepass, gg.finalgrade, ue.userid as user_enroled
from {course} c
inner join {enrol} e on e.courseid = c.id and e.enrol = 'ilbeadtutorado'
inner join {grade_items} gi on gi.courseid = c.id and gi.itemtype = 'course'
left outer join {user_enrolments} ue on ue.enrolid = e.id and ue.userid = ?
left outer join {course_completion_criteria} cc on cc.course = c.id and cc.module is null and cc.gradepass > 0
left outer join {grade_grades} gg on gg.itemid = gi.id and gg.userid = ue.userid
where $idnumberlike
and e.id <> ?
order by startdate desc";
return $DB->get_records_sql($sql, array($USER->id, $instance->id), 0, $limitnum);
}
}

Loading…
Cancel
Save