Skip to content
Snippets Groups Projects
Commit c241ecf4 authored by Astor Bizard's avatar Astor Bizard :dog2:
Browse files

Various fixes: webservice url, groups pictures, etc.

parent f49952d3
No related branches found
No related tags found
1 merge request!1Dev: Submissions list rework, webservices and bugfixes
...@@ -88,12 +88,10 @@ if ($fromform = $mform->get_data()) { ...@@ -88,12 +88,10 @@ if ($fromform = $mform->get_data()) {
$data = iconv( $encode, 'UTF-8', $data ); $data = iconv( $encode, 'UTF-8', $data );
} }
$files [$name] = $data; $files [$name] = $data;
} } else {
else {
if (in_array($name . '.b64', $reqfiles)) { if (in_array($name . '.b64', $reqfiles)) {
$files [$name . '.b64'] = base64_encode($data); $files [$name . '.b64'] = base64_encode($data);
} } else {
else {
$files [$name] = $data; $files [$name] = $data;
} }
} }
......
...@@ -39,7 +39,7 @@ if ($vpl->has_capability( VPL_GRADE_CAPABILITY )) { ...@@ -39,7 +39,7 @@ if ($vpl->has_capability( VPL_GRADE_CAPABILITY )) {
if ($userid) { if ($userid) {
vpl_inmediate_redirect( vpl_mod_href( 'forms/gradesubmission.php', 'id', $id, 'userid', $userid ) ); vpl_inmediate_redirect( vpl_mod_href( 'forms/gradesubmission.php', 'id', $id, 'userid', $userid ) );
} else { } 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 { } else {
vpl_inmediate_redirect( vpl_mod_href( 'view.php', 'id', $id ) ); vpl_inmediate_redirect( vpl_mod_href( 'view.php', 'id', $id ) );
......
...@@ -334,8 +334,7 @@ function vpl_url_add_param($url, $parm, $value) { ...@@ -334,8 +334,7 @@ function vpl_url_add_param($url, $parm, $value) {
*/ */
function vpl_redirect($link, $message, $type = 'info', $errorcode='') { function vpl_redirect($link, $message, $type = 'info', $errorcode='') {
global $OUTPUT; global $OUTPUT;
global $CFG; if (!$OUTPUT->has_started()) {
if (! mod_vpl::header_is_out()) {
echo $OUTPUT->header(); echo $OUTPUT->header();
} }
echo $OUTPUT->notification($message, $type); echo $OUTPUT->notification($message, $type);
...@@ -351,19 +350,7 @@ function vpl_redirect($link, $message, $type = 'info', $errorcode='') { ...@@ -351,19 +350,7 @@ function vpl_redirect($link, $message, $type = 'info', $errorcode='') {
* @return void * @return void
*/ */
function vpl_inmediate_redirect($url) { function vpl_inmediate_redirect($url) {
global $OUTPUT; echo vpl_include_js( 'window.location.replace("' . html_entity_decode(urldecode($url)) . '");' );
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();
die(); die();
} }
/** /**
...@@ -886,11 +873,10 @@ function vpl_get_webservice_token($vpl) { ...@@ -886,11 +873,10 @@ function vpl_get_webservice_token($vpl) {
return ''; return '';
} }
$tokenrecord = $DB->get_record( 'external_tokens', array ( $tokenrecord = $DB->get_record( 'external_tokens', array (
'sid' => session_id(),
'userid' => $USER->id, 'userid' => $USER->id,
'externalserviceid' => $service->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. unset( $tokenrecord ); // Will be delete before creating a new one.
} }
if (empty( $tokenrecord )) { if (empty( $tokenrecord )) {
...@@ -933,7 +919,7 @@ function vpl_get_webservice_urlbase($vpl) { ...@@ -933,7 +919,7 @@ function vpl_get_webservice_urlbase($vpl) {
if ($token == '') { if ($token == '') {
return ''; 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='; . '&wstoken=' . $token . '&id=' . $vpl->get_course_module()->id . '&wsfunction=';
} }
......
...@@ -1068,7 +1068,15 @@ class mod_vpl { ...@@ -1068,7 +1068,15 @@ class mod_vpl {
public function user_picture($user) { public function user_picture($user) {
global $OUTPUT; global $OUTPUT;
if ($this->is_group_activity()) { 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 { } else {
$options = array('courseid' => $this->get_instance()->course, 'link' => ! $this->use_seb()); $options = array('courseid' => $this->get_instance()->course, 'link' => ! $this->use_seb());
return $OUTPUT->user_picture( $user, $options); return $OUTPUT->user_picture( $user, $options);
...@@ -1089,7 +1097,7 @@ class mod_vpl { ...@@ -1089,7 +1097,7 @@ class mod_vpl {
$group = $this->get_usergroup( $user->id ); $group = $this->get_usergroup( $user->id );
if ($group !== false) { if ($group !== false) {
if ($withlink) { 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>'; return '<a href="' . $url . '">' . $group->name . '</a>';
} else { } else {
return $group->name; return $group->name;
...@@ -1778,7 +1786,7 @@ class mod_vpl { ...@@ -1778,7 +1786,7 @@ class mod_vpl {
$this->print_restriction( 'automaticgrading', $noyes [1], false, false ); $this->print_restriction( 'automaticgrading', $noyes [1], false, false );
} }
if ($instance->maxexetime) { 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) { if ($instance->maxexememory) {
$this->print_restriction( 'maxexememory', vpl_conv_size_to_string( $instance->maxexememory ), false, false ); $this->print_restriction( 'maxexememory', vpl_conv_size_to_string( $instance->maxexememory ), false, false );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment