Commit 7cd51c5a authored by Astor Bizard's avatar Astor Bizard
Browse files

Minor refactor of menu links.

parent cd2abdb2
......@@ -973,4 +973,16 @@ function vpl_get_name_fields_display() {
}
$strname = trim(fullname($nameformat));
return substr($strname, 0, strlen($strname) - 2);
}
/**
* Return action_menu_link for menu in list
* @param string $str
* @param moodle_url $link
* @param string $comp value for get_string
* @return action_menu_link_secondary
*/
function vpl_get_menu_action_link($str, $link, $comp = 'mod_vpl') {
$stri18n = get_string($str, $comp);
return new action_menu_link_secondary($link, new pix_icon($str, '', 'mod_vpl'), $stri18n);
}
\ No newline at end of file
......@@ -37,13 +37,9 @@ function vpl_actions_menu($id, $userid, $subid) {
$menu = new action_menu();
$linkparms = array('id' => $id, 'userid' => $userid, 'submissionid' => $subid);
$link = new moodle_url('/mod/vpl/forms/submissionview.php', $linkparms);
$stri18n = get_string('submissionview', 'mod_vpl');
$action = new action_menu_link_secondary($link, new pix_icon('submissionview', '', 'mod_vpl'), $stri18n);
$menu->add($action);
$stri18n = get_string('copy', 'mod_vpl');
$menu->add( vpl_get_menu_action_link('submissionview', $link) );
$link = new moodle_url('/mod/vpl/forms/edit.php', array_merge($linkparms, array('privatecopy' => 1)));
$action = new action_menu_link_secondary($link, new pix_icon('copy', '', 'mod_vpl'), $stri18n);
$menu->add($action);
$menu->add( vpl_get_menu_action_link('copy', $link) );
return $menu;
}
......
......@@ -50,37 +50,25 @@ function vpl_get_listmenu($id, $showgrades, $group) {
$menu = new action_menu();
$url = new moodle_url( '/mod/vpl/views/activityworkinggraph.php', array (
'id' => $id) );
$menu->add(vpl_get_action_link('submissionscharts', $url));
$menu->add(vpl_get_menu_action_link('submissionscharts', $url));
if ($showgrades) {
$url = get_this_page_url($id, 0, $group);
$menu->add(vpl_get_action_link('submissionslist', $url));
$menu->add(vpl_get_menu_action_link('submissionslist', $url));
} else {
$url = get_this_page_url($id, 1, $group);
$menu->add(vpl_get_action_link('gradercomments', $url));
$menu->add(vpl_get_menu_action_link('gradercomments', $url));
}
$url = new moodle_url( '/mod/vpl/views/downloadallsubmissions.php', array (
'id' => $id) );
$menu->add(vpl_get_action_link('downloadsubmissions', $url));
$menu->add(vpl_get_menu_action_link('downloadsubmissions', $url));
$url = new moodle_url( '/mod/vpl/views/downloadallsubmissions.php', array (
'id' => $id,
'all' => 1) );
$menu->add(vpl_get_action_link('downloadallsubmissions', $url));
$menu->add(vpl_get_menu_action_link('downloadallsubmissions', $url));
return $menu;
}
/**
* Return action_menu_link for menu in list
* @param string $str
* @param moodle_url $link
* @param string $comp value for get_string
* @return action_menu_link_secondary
*/
function vpl_get_action_link($str, $link, $comp = 'mod_vpl') {
$stri18n = get_string($str, $comp);
return new action_menu_link_secondary($link, new pix_icon($str, '', 'mod_vpl'), $stri18n);
}
require_login();
$id = required_param( 'id', PARAM_INT );
......@@ -249,7 +237,7 @@ foreach ($list as $uginfo) {
$gradecomments = '';
$linkparms = array('id' => $id, 'userid' => $user->id);
$viewlink = new moodle_url('/mod/vpl/forms/submissionview.php', $linkparms);
$actions->add(vpl_get_action_link('submissionview', $viewlink));
$actions->add(vpl_get_menu_action_link('submissionview', $viewlink));
if ($submission == null) {
$subtime = $OUTPUT->action_link( $viewlink, get_string( 'nosubmission', VPL ) );
$prev = '';
......@@ -270,7 +258,7 @@ foreach ($list as $uginfo) {
array(
'title' => get_string('previoussubmissionslist', VPL)
) );
$actions->add(vpl_get_action_link('previoussubmissionslist', $prevlink));
$actions->add(vpl_get_menu_action_link('previoussubmissionslist', $prevlink));
} else {
$prev = '';
}
......@@ -336,7 +324,7 @@ foreach ($list as $uginfo) {
}
$link = new moodle_url('/mod/vpl/forms/gradesubmission.php', $linkparms);
$actions->add(vpl_get_action_link('grade', $link, 'moodle'));
$actions->add(vpl_get_menu_action_link('grade', $link, 'moodle'));
// Add div id to submission info.
$grader = '<div id="m' . $subid . '" class="gd' . $subid . '">' . $grader . '</div>';
$gradedon = '<div id="o' . $subid . '" class="gd' . $subid . '">'.
......@@ -350,7 +338,7 @@ foreach ($list as $uginfo) {
array(
'title' => get_string('copy', VPL)
) );
$actions->add(vpl_get_action_link('copy', $copylink));
$actions->add(vpl_get_menu_action_link('copy', $copylink));
$submissiondata = array (
$usernumberlink,
......
Markdown is supported
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