Skip to content

Commit

Permalink
MDL-36990 mod_feedback - correct some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
grabs committed Mar 9, 2013
1 parent 2694b63 commit fa9ea3e
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 49 deletions.
64 changes: 32 additions & 32 deletions mod/feedback/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@

require_capability('mod/feedback:edititems', $context);

//move up/down items
//Move up/down items
if ($moveupitem) {
$item = $DB->get_record('feedback_item', array('id'=>$moveupitem));
feedback_moveup_item($item);
Expand All @@ -73,7 +73,7 @@
feedback_movedown_item($item);
}

//moving of items
//Moving of items
if ($movehere && isset($SESSION->feedback->moving->movingitem)) {
$item = $DB->get_record('feedback_item', array('id'=>$SESSION->feedback->moving->movingitem));
feedback_move_item($item, intval($movehere));
Expand All @@ -94,22 +94,22 @@
exit;
}

//the create_template-form
//The create_template-form
$create_template_form = new feedback_edit_create_template_form();
$create_template_form->set_feedbackdata(array('context'=>$context, 'course'=>$course));
$create_template_form->set_form_elements();
$create_template_form->set_data(array('id'=>$id, 'do_show'=>'templates'));
$create_template_formdata = $create_template_form->get_data();
if (isset($create_template_formdata->savetemplate) && $create_template_formdata->savetemplate == 1) {
//check the capabilities to create templates
//Check the capabilities to create templates.
if (!has_capability('mod/feedback:createprivatetemplate', $context) AND
!has_capability('mod/feedback:createpublictemplate', $context)) {
print_error('cannotsavetempl', 'feedback');
}
if (trim($create_template_formdata->templatename) == '') {
$savereturn = 'notsaved_name';
} else {
//if the feedback is located on the frontpage then templates can be public
//If the feedback is located on the frontpage then templates can be public.
if (has_capability('mod/feedback:createpublictemplate', get_system_context())) {
$create_template_formdata->ispublic = isset($create_template_formdata->ispublic) ? 1 : 0;
} else {
Expand All @@ -125,7 +125,7 @@
}
}

//get the feedbackitems
//Get the feedbackitems
$lastposition = 0;
$feedbackitems = $DB->get_records('feedback_item', array('feedback'=>$feedback->id), 'position');
if (is_array($feedbackitems)) {
Expand All @@ -140,25 +140,25 @@
$lastposition++;


//the add_item-form
//The add_item-form
$add_item_form = new feedback_edit_add_question_form('edit_item.php');
$add_item_form->set_data(array('cmid'=>$id, 'position'=>$lastposition));

//the use_template-form
//The use_template-form
$use_template_form = new feedback_edit_use_template_form('use_templ.php');
$use_template_form->set_feedbackdata(array('course' => $course));
$use_template_form->set_form_elements();
$use_template_form->set_data(array('id'=>$id));

/// Print the page header
//Print the page header.
$strfeedbacks = get_string('modulenameplural', 'feedback');
$strfeedback = get_string('modulename', 'feedback');

$PAGE->set_url('/mod/feedback/edit.php', array('id'=>$cm->id, 'do_show'=>$do_show));
$PAGE->set_heading(format_string($course->fullname));
$PAGE->set_title(format_string($feedback->name));

// Adding the javascript module for the items dragdrop
//Adding the javascript module for the items dragdrop.
if ($do_show == 'edit') {
$jsmodule = array(
'name' => 'mod_feedback',
Expand All @@ -181,14 +181,14 @@
/// print the tabs
require('tabs.php');

/// Print the main part of the page
/// Print the main part of the page.
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////

$savereturn=isset($savereturn)?$savereturn:'';

//print the messages
//Print the messages.
if ($savereturn == 'notsaved_name') {
echo '<p align="center"><b><font color="red">'.
get_string('name_required', 'feedback').
Expand All @@ -208,7 +208,7 @@
}

///////////////////////////////////////////////////////////////////////////
///print the template-section
///Print the template-section.
///////////////////////////////////////////////////////////////////////////
if ($do_show == 'templates') {
echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
Expand Down Expand Up @@ -237,7 +237,7 @@
echo $OUTPUT->box_end();
}
///////////////////////////////////////////////////////////////////////////
///print the Item-Edit-section
///Print the Item-Edit-section.
///////////////////////////////////////////////////////////////////////////
if ($do_show == 'edit') {

Expand All @@ -258,7 +258,7 @@
echo $OUTPUT->heading($anker);
}

//check, if there exists required-elements
//Check, if there exists required-elements.
$params = array('feedback' => $feedback->id, 'required' => 1);
$countreq = $DB->count_records('feedback_item', $params);
if ($countreq > 0) {
Expand All @@ -267,12 +267,12 @@
echo '</span>';
}

//use list instead a table
//Use list instead a table
echo $OUTPUT->box_start('feedback_items');
if (isset($SESSION->feedback->moving) AND $SESSION->feedback->moving->shouldmoving == 1) {
$moveposition = 1;
$movehereurl = new moodle_url($url, array('movehere'=>$moveposition));
//only shown if shouldmoving = 1
//Only shown if shouldmoving = 1
echo $OUTPUT->box_start('feedback_item_box_'.$align.' clipboard');
$buttonlink = $movehereurl->out();
$strbutton = get_string('move_here', 'feedback');
Expand All @@ -282,19 +282,19 @@
</a>';
echo $OUTPUT->box_end();
}
//print the inserted items
//Print the inserted items
$itempos = 0;
echo '<div id="feedback_dragarea">'; //The container for the dragging area
echo '<ul id="feedback_draglist">'; //the list what includes the draggable items
echo '<ul id="feedback_draglist">'; //The list what includes the draggable items
foreach ($feedbackitems as $feedbackitem) {
$itempos++;
//hiding the item to move
//Hiding the item to move
if (isset($SESSION->feedback->moving)) {
if ($SESSION->feedback->moving->movingitem == $feedbackitem->id) {
continue;
}
}
//here come the draggable items, each one in a single li-element
//Here come the draggable items, each one in a single li-element.
echo '<li class="feedback_itemlist generalbox" id="feedback_item_'.$feedbackitem->id.'">';
echo '<span class="spinnertest"> </span>';
if ($feedbackitem->dependitem > 0) {
Expand All @@ -304,7 +304,7 @@
}
echo $OUTPUT->box_start('feedback_item_box_'.$align.$dependstyle,
'feedback_item_box_'.$feedbackitem->id);
//items without value only are labels
//Items without value only are labels
if ($feedbackitem->hasvalue == 1 AND $feedback->autonumbering) {
$itemnr++;
echo $OUTPUT->box_start('feedback_item_number_'.$align);
Expand All @@ -316,7 +316,7 @@
echo '<span class="feedback_item_commands position">';
echo '('.get_string('position', 'feedback').':'.$itempos .')';
echo '</span>';
//print the moveup-button
//Print the moveup-button
if ($feedbackitem->position > 1) {
echo '<span class="feedback_item_command_moveup">';
$moveupurl = new moodle_url($url, array('moveupitem'=>$feedbackitem->id));
Expand All @@ -327,7 +327,7 @@
</a>';
echo '</span>';
}
//print the movedown-button
//Print the movedown-button
if ($feedbackitem->position < $lastposition - 1) {
echo '<span class="feedback_item_command_movedown">';
$urlparams = array('movedownitem'=>$feedbackitem->id);
Expand All @@ -339,7 +339,7 @@
</a>';
echo '</span>';
}
//print the move-button
//Print the move-button
echo '<span class="feedback_item_command_move">';
$moveurl = new moodle_url($url, array('moveitem'=>$feedbackitem->id));
$buttonlink = $moveurl->out();
Expand All @@ -348,7 +348,7 @@
<img alt="'.$strbutton.'" src="'.$OUTPUT->pix_url('t/move') . '" />
</a>';
echo '</span>';
//print the button to edit the item
//Print the button to edit the item
if ($feedbackitem->typ != 'pagebreak') {
echo '<span class="feedback_item_command_edit">';
$editurl = new moodle_url('/mod/feedback/edit_item.php');
Expand All @@ -357,8 +357,8 @@
'id'=>$feedbackitem->id,
'typ'=>$feedbackitem->typ));

// in edit_item.php the param id is used for the itemid
// and the cmid is the id to get the module
// In edit_item.php the param id is used for the itemid
// and the cmid is the id to get the module.
$buttonlink = $editurl->out();
$strbutton = get_string('edit_item', 'feedback');
echo '<a class="editing_update" title="'.$strbutton.'" href="'.$buttonlink.'">
Expand All @@ -367,7 +367,7 @@
echo '</span>';
}

//print the toggle-button to switch required yes/no
//Print the toggle-button to switch required yes/no
if ($feedbackitem->hasvalue == 1) {
echo '<span class="feedback_item_command_toggle">';
if ($feedbackitem->required == 1) {
Expand All @@ -389,7 +389,7 @@
echo '</span>';
}

//print the delete-button
//Print the delete-button
echo '<span class="feedback_item_command_toggle">';
$deleteitemurl = new moodle_url('/mod/feedback/delete_item.php');
$deleteitemurl->params(array('id'=>$id,
Expand All @@ -415,12 +415,12 @@
echo $OUTPUT->box_end();
echo '<div class="clearer">&nbsp;</div>';
echo '</li>';
//print out the target box if we ar moving an item
//Print out the target box if we ar moving an item
if (isset($SESSION->feedback->moving) AND $SESSION->feedback->moving->shouldmoving == 1) {
echo '<li>';
$moveposition++;
$movehereurl->param('movehere', $moveposition);
echo $OUTPUT->box_start('clipboard'); //only shown if shouldmoving = 1
echo $OUTPUT->box_start('clipboard'); //Only shown if shouldmoving = 1
$buttonlink = $movehereurl->out();
$strbutton = get_string('move_here', 'feedback');
$src = $OUTPUT->pix_url('movehere');
Expand Down
34 changes: 17 additions & 17 deletions mod/feedback/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ M.mod_feedback.init = function(Y, id, sesskey) {
var drag = e.drag.get('node'),
drop = e.drop.get('node');

//Are we dropping on a li node?
//Are we dropping on an li node?
if (drop.get('tagName').toLowerCase() === 'li') {
//Are we not going up?
if (!goingUp) {
Expand All @@ -22,7 +22,7 @@ M.mod_feedback.init = function(Y, id, sesskey) {
Y.DD.DDM.on('drag:drag', function(e) {
//Get the last y point
var y = e.target.lastXY[1];
//is it greater than the lastY var?
//Is it greater than the lastY var?
if (y < lastY) {
//We are going up
goingUp = true;
Expand Down Expand Up @@ -61,7 +61,7 @@ M.mod_feedback.init = function(Y, id, sesskey) {
var drop = e.drop.get('node'),
drag = e.drag.get('node');
dragnode = Y.one(drag);
//if we are not on an li, we must have been dropped on a ul
//If we are not on an li, we must have been dropped on a ul.
if (drop.get('tagName').toLowerCase() !== 'li') {
if (!drop.contains(drag)) {
drop.appendChild(drag);
Expand All @@ -83,9 +83,9 @@ M.mod_feedback.init = function(Y, id, sesskey) {
//Static Vars
var goingUp = false, lastY = 0;

//Get the list of li's in the lists and make them draggable
//Get the list of li's in the lists and make them draggable.
var listitems = Y.Node.all('#feedback_dragarea ul li.feedback_itemlist');
listitems.each(function(v, k) { //make each item draggable
listitems.each(function(v, k) { //Make each item draggable.
var dd = new Y.DD.Drag({
node: v,
target: {
Expand All @@ -94,17 +94,17 @@ M.mod_feedback.init = function(Y, id, sesskey) {
}).plug(Y.Plugin.DDProxy, {
moveOnEnd: false
}).plug(Y.Plugin.DDConstrained, {
constrain2node: '#feedback_dragarea' //prevent dragging outside the dragarea
constrain2node: '#feedback_dragarea' //Prevent dragging outside the dragarea.
});

item_id = get_node_id(v.get('id')); //get the id of the feedback item
item_box = Y.Node.one('#feedback_item_box_' + item_id); //get the current item box so we can add the drag handle
item_id = get_node_id(v.get('id')); //Get the id of the feedback item.
item_box = Y.Node.one('#feedback_item_box_' + item_id); //Get the current item box so we can add the drag handle.
handletitle = M.util.get_string('move_item', 'feedback');
mydraghandle = get_drag_handle(handletitle, 'itemhandle');
v.insert(mydraghandle, item_box); //insert the new handle into the item box
dd.addHandle(mydraghandle); //now we add the handle to the drag object, so the box only can be moved with this handle
v.insert(mydraghandle, item_box); //Insert the new handle into the item box.
dd.addHandle(mydraghandle); //Now we add the handle to the drag object, so the box only can be moved with this handle.
});
// remove all legacy move icons
// Remove all legacy move icons.
Y.Node.all('span.feedback_item_command_moveup').each(function(v, k) {
v.remove();
});;
Expand All @@ -121,20 +121,20 @@ M.mod_feedback.init = function(Y, id, sesskey) {
node: droparea
});

// here we save the new itemorder
// Here we save the new itemorder.
function saveposition(Y, objekt, id, itemorder, sesskey, spinner){

Y.io(M.cfg.wwwroot + '/mod/feedback/ajax.php', {
//the needed paramaters
//The needed paramaters
data: {action: 'saveitemorder',
id: id,
itemorder: itemorder,
sesskey: sesskey
},

timeout: 5000, //5 seconds for timeout I think it is enough
timeout: 5000, //5 seconds for timeout I think it is enough.

//define the events
//Define the events.
on: {
start : function(transactionid) {
spinner.show();
Expand All @@ -155,12 +155,12 @@ M.mod_feedback.init = function(Y, id, sesskey) {
});
};

//this returns the numeric id from the dom id
//This returns the numeric id from the dom id.
function get_node_id(id) {
return Number(id.replace(/feedback_item_/i, ''));
};

//this creates a new drag handle and return it as a new node
//This creates a new drag handle and return it as a new node.
function get_drag_handle(title, handleclass) {
var moveicon = {
pix: "i/move_2d",
Expand Down

0 comments on commit fa9ea3e

Please sign in to comment.