Browse Source

Início de adaptação para pré-matricula de cursos presenciais

master
matheus 5 years ago
parent
commit
5b404caa61
  1. 61
      lib.php
  2. 2
      manage.php
  3. 4
      manage_table.php
  4. 9
      renderer.php

61
lib.php

@ -89,6 +89,45 @@ class enrol_apply_plugin extends enrol_plugin {
return new moodle_url('/enrol/apply/edit.php', array('courseid' => $courseid)); return new moodle_url('/enrol/apply/edit.php', array('courseid' => $courseid));
} }
// TODO mover para outro local, usado também em certificado
function obtemCampoCustomizadoCurso($idCurso, $nomeCampo) {
global $DB;
$sql = "
SELECT d.value, f.configdata::json->>'options' as options
FROM mdl_course c
JOIN mdl_context ctx
ON c.id = ?
AND ctx.contextlevel = 50
AND ctx.instanceid = c.id
JOIN mdl_customfield_field f
ON f.shortname = ?
JOIN mdl_customfield_data d
ON d.fieldid = f.id
AND d.contextid = ctx.id
";
$valueArray = $DB->get_record_sql($sql, [$idCurso, $nomeCampo]);
if($valueArray) {
$value = $valueArray->value;
$options = $valueArray->options;
if($options == null) {
return $value;
} else {
$optionsArray = preg_split("/\s*\n\s*/", trim($options));
return $optionsArray[$value-1];
}
} else {
return '';
}
}
public function insere_assinatura_sigad($codProtocolo, $codUsuario) {
// retorna true se inseriu ou se já tinha, ou falso em caso de erro ou timeout
}
public function enrol_page_hook(stdClass $instance) { public function enrol_page_hook(stdClass $instance) {
global $CFG, $OUTPUT, $SESSION, $USER, $DB; global $CFG, $OUTPUT, $SESSION, $USER, $DB;
@ -103,7 +142,19 @@ class enrol_apply_plugin extends enrol_plugin {
} }
if ($DB->record_exists('user_enrolments', array('userid' => $USER->id, 'enrolid' => $instance->id))) { if ($DB->record_exists('user_enrolments', array('userid' => $USER->id, 'enrolid' => $instance->id))) {
return $OUTPUT->notification(get_string('notification', 'enrol_apply'), 'notifysuccess'); // TODO: incluir aqui chamada para WS que atribui assinatura a documento no SIGAD
// analisar resultado: se timeout ou erro, assinatura deve ser inserida manualmente
// DO contrário já mostra link para usuário assinar.
$textoAssinatura = '';
if(insere_assinatura_sigad()) {
$textoAssinatura = 'Inseriu';
} else {
$textoAssinatura = 'Erro';
}
$textoassinatura = '<a target=_moodleSigad href=\'https://intra.senado.leg.br/sigad/novo/protocolo/assinador.asp?area=documento&cod_protocolo=2648004&cod_cabecalho=1\'>Assinar</a>';
return $textoassinatura . ' '. $OUTPUT->notification(get_string('notification', 'enrol_apply'), 'notifysuccess');
} }
if ($instance->customint3 > 0) { if ($instance->customint3 > 0) {
@ -115,6 +166,9 @@ class enrol_apply_plugin extends enrol_plugin {
} }
} }
require_once("$CFG->dirroot/enrol/apply/apply_form.php"); require_once("$CFG->dirroot/enrol/apply/apply_form.php");
$form = new enrol_apply_apply_form(null, $instance); $form = new enrol_apply_apply_form(null, $instance);
@ -145,8 +199,11 @@ class enrol_apply_plugin extends enrol_plugin {
} }
$output = $form->render(); $output = $form->render();
profile_load_custom_fields($USER);
$campo = obtemCampoCustomizadoCurso($instance->courseid, 'sf_restringir_matricula');
return $OUTPUT->box($output); return $OUTPUT->box('<b>Teste</b> ' . $campo . $USER->profile['sf_cargo_chefia']) . $OUTPUT->box($output);
} }
public function get_action_icons(stdClass $instance) { public function get_action_icons(stdClass $instance) {

2
manage.php

@ -36,6 +36,8 @@ require_login();
$manageurlparams = array(); $manageurlparams = array();
if ($id == null) { if ($id == null) {
$context = context_system::instance(); $context = context_system::instance();
// TODO verificar se coordenador tem esse papel
// TODO criar task para verificar assinaturas e confirmar automaticamente
require_capability('enrol/apply:manageapplications', $context); require_capability('enrol/apply:manageapplications', $context);
$pageheading = get_string('confirmusers', 'enrol_apply'); $pageheading = get_string('confirmusers', 'enrol_apply');
$instance = null; $instance = null;

4
manage_table.php

@ -47,10 +47,12 @@ class enrol_apply_manage_table extends table_sql {
$this->set_sql( $this->set_sql(
'ue.id AS userenrolmentid, ue.userid, ue.status AS enrolstatus, ue.timecreated AS applydate, 'ue.id AS userenrolmentid, ue.userid, ue.status AS enrolstatus, ue.timecreated AS applydate,
ai.comment AS applycomment, u.*, c.fullname as course', ai.comment AS applycomment, u.*, c.fullname as course, fcd.data as sf_cargo_chefia ',
"{user_enrolments} AS ue "{user_enrolments} AS ue
LEFT JOIN {enrol_apply_applicationinfo} ai ON ai.userenrolmentid = ue.id LEFT JOIN {enrol_apply_applicationinfo} ai ON ai.userenrolmentid = ue.id
JOIN {user} u ON u.id = ue.userid JOIN {user} u ON u.id = ue.userid
LEFT JOIN {user_info_field} fc ON fc.shortname = 'sf_cargo_chefia'
LEFT JOIN {user_info_data} fcd ON fc.id = fcd.fieldid AND u.id = fcd.userid
JOIN {enrol} e ON e.id = ue.enrolid JOIN {enrol} e ON e.id = ue.enrolid
JOIN {course} c ON c.id = e.courseid", JOIN {course} c ON c.id = e.courseid",
$sqlwhere, $sqlwhere,

9
renderer.php

@ -80,16 +80,17 @@ class enrol_apply_renderer extends plugin_renderer_base {
public function manage_table($table, $instance) { public function manage_table($table, $instance) {
$columns = array( $columns = array(
'checkboxcolumn', 'checkboxcolumn',
'course', 'sf_cargo_chefia',
'fullname', // Magic happens here: The column heading will automatically be set. 'fullname', // Magic happens here: The column heading will automatically be set.
'email', //'email',
'applydate', 'applydate',
'applycomment'); 'applycomment');
$headers = array( $headers = array(
html_writer::checkbox('toggleall', 'toggleall', false, '', array('id' => 'toggleall')), html_writer::checkbox('toggleall', 'toggleall', false, '', array('id' => 'toggleall')),
get_string('course'), 'sf_cargo_chefia',
//get_string('course'),
'fullname', // Magic happens here: The column heading will automatically be set due to column name 'fullname'. 'fullname', // Magic happens here: The column heading will automatically be set due to column name 'fullname'.
get_string('email'), //get_string('email'),
get_string('applydate', 'enrol_apply'), get_string('applydate', 'enrol_apply'),
get_string('applycomment', 'enrol_apply'), get_string('applycomment', 'enrol_apply'),
); );

Loading…
Cancel
Save