Commit c241ecf4 authored by Astor Bizard's avatar Astor Bizard
Browse files

Various fixes: webservice url, groups pictures, etc.

parent f49952d3
......@@ -88,12 +88,10 @@ if ($fromform = $mform->get_data()) {
$data = iconv( $encode, 'UTF-8', $data );
}
$files [$name] = $data;
}
else {
} else {
if (in_array($name . '.b64', $reqfiles)) {
$files [$name . '.b64'] = base64_encode($data);
}
else {
} else {
$files [$name] = $data;
}
}
......
......@@ -39,7 +39,7 @@ if ($vpl->has_capability( VPL_GRADE_CAPABILITY )) {
if ($userid) {
vpl_inmediate_redirect( vpl_mod_href( 'forms/gradesubmission.php', 'id', $id, 'userid', $userid ) );
} else {
vpl_inmediate_redirect( vpl_mod_href( 'views/submissionslist.php', 'id', $id ) );
vpl_inmediate_redirect( vpl_mod_href( 'views/submissionslist.php', 'id', $id, 'showgrades', 1 ) );
}
} else {
vpl_inmediate_redirect( vpl_mod_href( 'view.php', 'id', $id ) );
......
......@@ -334,8 +334,7 @@ function vpl_url_add_param($url, $parm, $value) {
*/
function vpl_redirect($link, $message, $type = 'info', $errorcode='') {
global $OUTPUT;
global $CFG;
if (! mod_vpl::header_is_out()) {
if (!$OUTPUT->has_started()) {
echo $OUTPUT->header();
}
echo $OUTPUT->notification($message, $type);
......@@ -351,19 +350,7 @@ function vpl_redirect($link, $message, $type = 'info', $errorcode='') {
* @return void
*/
function vpl_inmediate_redirect($url) {
global $OUTPUT;
if (! mod_vpl::header_is_out()) {
echo $OUTPUT->header();
}
static $idcount = 0;
$idcount ++;
$text = '<div class="continuebutton"><a id="vpl_red' . $idcount . '" href="';
$text .= $url. '">' . get_string( 'continue' ) . '</a></div>';
$deco = urldecode( $url);
$deco = html_entity_decode( $deco );
echo vpl_include_js( 'window.location.replace("' . $deco . '");' );
echo $text;
echo $OUTPUT->footer();
echo vpl_include_js( 'window.location.replace("' . html_entity_decode(urldecode($url)) . '");' );
die();
}
/**
......@@ -886,11 +873,10 @@ function vpl_get_webservice_token($vpl) {
return '';
}
$tokenrecord = $DB->get_record( 'external_tokens', array (
'sid' => session_id(),
'userid' => $USER->id,
'externalserviceid' => $service->id
) );
if (! empty( $tokenrecord ) and $tokenrecord->validuntil < $now) {
if (! empty( $tokenrecord ) and $tokenrecord->validuntil > 0 and $tokenrecord->validuntil < $now) {
unset( $tokenrecord ); // Will be delete before creating a new one.
}
if (empty( $tokenrecord )) {
......@@ -933,7 +919,7 @@ function vpl_get_webservice_urlbase($vpl) {
if ($token == '') {
return '';
}
return $CFG->wwwroot . '/mod/vpl/webservice.php?moodlewsrestformat=json'
return $CFG->wwwroot . '/webservice/rest/server.php?moodlewsrestformat=json'
. '&wstoken=' . $token . '&id=' . $vpl->get_course_module()->id . '&wsfunction=';
}
......
......@@ -1068,7 +1068,15 @@ class mod_vpl {
public function user_picture($user) {
global $OUTPUT;
if ($this->is_group_activity()) {
return print_group_picture( $this->get_usergroup( $user->id ), $this->get_course()->id, false, true );
$group = $this->get_usergroup( $user->id );
$picture = print_group_picture( $group, $this->get_course()->id, false, true );
if (!$picture) {
$url = vpl_abs_href( '/group/overview.php', 'id', $this->get_course()->id, 'group', $group->id);
$picture = '<a href="' . $url . '" style="color: initial;">' .
$OUTPUT->render(new pix_icon('group', '', 'mod_vpl')) .
'</a>';
}
return $picture;
} else {
$options = array('courseid' => $this->get_instance()->course, 'link' => ! $this->use_seb());
return $OUTPUT->user_picture( $user, $options);
......@@ -1089,7 +1097,7 @@ class mod_vpl {
$group = $this->get_usergroup( $user->id );
if ($group !== false) {
if ($withlink) {
$url = vpl_abs_href( '/user/index.php', 'id', $this->get_course()->id, 'group', $group->id );
$url = vpl_abs_href( '/group/overview.php', 'id', $this->get_course()->id, 'group', $group->id);
return '<a href="' . $url . '">' . $group->name . '</a>';
} else {
return $group->name;
......@@ -1778,7 +1786,7 @@ class mod_vpl {
$this->print_restriction( 'automaticgrading', $noyes [1], false, false );
}
if ($instance->maxexetime) {
$this->print_restriction( 'maxexetime', $instance->maxexetime . ' s', false, false );
$this->print_restriction( 'maxexetime', format_time($instance->maxexetime), false, false );
}
if ($instance->maxexememory) {
$this->print_restriction( 'maxexememory', vpl_conv_size_to_string( $instance->maxexememory ), false, false );
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment