Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed assignment javascript for revert to draft button and editor

  • Loading branch information...
commit ef7069426ddf6262e404d55b4ecf6214154736f8 1 parent 59d9e99
@mattgibson authored
View
3  actions/grading_popup.php
@@ -45,6 +45,9 @@
/** @var string $modname */
$modname = $DB->get_field('modules', 'name', array('id' => $coursemodule->module));
+// Page may need custom javascript.
+//$PAGE->require();
+
//permissions checks
if (!$coursemodule) {
print_error('Bad coursemoduleid');
View
17 module.js
@@ -316,6 +316,19 @@ YAHOO.lang.extend(M.block_ajax_marking.tree_node, YAHOO.widget.HTMLNode, {
},
/**
+ * Gets the extra stuff that may be necessary for the pop up to be displayed properly.
+ */
+ get_popup_stuff : function () {
+
+ var popupstuff = [];
+
+ for (var thing in this.data.popupstuff) {
+ popupstuff.push(thing+'='+this.data.popupstuff[thing]);
+ }
+ return popupstuff;
+ },
+
+ /**
* Helper function to get the config groups array or return an empty array if it's not there.
*
* @return {Array}
@@ -2101,6 +2114,10 @@ M.block_ajax_marking.treenodeonclick = function (oArgs) {
var nodefilters = node.get_filters(true);
nodefilters.push('node='+node.index);
+ // Add any extra stuff e.g. assignments always need mode=single to make optional_param() stuff
+ // work internally in assignment classes.
+ var popupstuff = node.get_popup_stuff();
+ nodefilters = nodefilters.concat(popupstuff);
popupurl += nodefilters.join('&');
// Pop-up version
View
54 modules/assignment/block_ajax_marking_assignment.class.php
@@ -102,6 +102,15 @@ public function grading_popup($params, $coursemodule) {
global $PAGE, $CFG, $DB, $OUTPUT, $USER;
+ require_once($CFG->dirroot.'/grade/grading/lib.php');
+
+ $PAGE->requires->js('/mod/assignment/assignment.js');
+//
+// $module = array('name' => 'mod_assignment_files',
+// 'fullpath' => '/mod/assignment/assignment.js',
+// 'requires' => array('yui2-treeview'));
+// $PAGE->requires->js_module($module);
+
$output = '';
// Get all DB stuff
@@ -118,7 +127,7 @@ public function grading_popup($params, $coursemodule) {
$course = $DB->get_record('course', array('id' => $assignment->course));
$coursemodule = $DB->get_record('course_modules', array('id' => $coursemodule->id));
- $context = get_context_instance(CONTEXT_MODULE, $coursemodule->id);
+ $context = context_module::instance($coursemodule->id); // get_context_instance(CONTEXT_MODULE, $coursemodule->id);
// TODO more sanity and security checks
$user = $DB->get_record('user', array('id' => $submission->userid));
@@ -173,6 +182,9 @@ public function grading_popup($params, $coursemodule) {
$mformdata->submission_content = $assignmentinstance->print_user_files($user->id,
true);
+ // filter
+ // mailinfo
+
if ($assignment->assignmenttype == 'upload') {
$mformdata->fileui_options = array(
'subdirs' => 1,
@@ -190,6 +202,28 @@ public function grading_popup($params, $coursemodule) {
'return_types' => FILE_INTERNAL);
}
+ $advancedgradingwarning = false;
+ $gradingmanager = get_grading_manager($context, 'mod_assignment', 'submission');
+ if ($gradingmethod = $gradingmanager->get_active_method()) {
+ $controller = $gradingmanager->get_controller($gradingmethod);
+ if ($controller->is_form_available()) {
+ $itemid = null;
+ if (!empty($submission->id)) {
+ $itemid = $submission->id;
+ }
+ if ($gradingdisabled && $itemid) {
+ $mformdata->advancedgradinginstance =
+ $controller->get_current_instance($USER->id, $itemid);
+ } else if (!$gradingdisabled) {
+ $instanceid = optional_param('advancedgradinginstanceid', 0, PARAM_INT);
+ $mformdata->advancedgradinginstance =
+ $controller->get_or_create_instance($instanceid, $USER->id, $itemid);
+ }
+ } else {
+ $advancedgradingwarning = $controller->form_unavailable_notification();
+ }
+ }
+
// Here, we start to make a specific HTML display, rather than just getting data
$submitform = new mod_assignment_grading_form(block_ajax_marking_form_url($params),
@@ -203,13 +237,15 @@ public function grading_popup($params, $coursemodule) {
// display mform here...
ob_start();
+ if ($advancedgradingwarning) {
+ echo $OUTPUT->notification($advancedgradingwarning, 'error');
+ }
$submitform->display();
$output .= ob_get_contents();
ob_end_clean();
// no variation across subclasses
$customfeedback = $assignmentinstance->custom_feedbackform($submission, true);
-
if (!empty($customfeedback)) {
$output .= $customfeedback;
}
@@ -222,7 +258,7 @@ public function grading_popup($params, $coursemodule) {
*
* @param object $data from the feedback form
* @param $params
- * @return string
+ * @return string|void
*/
public function process_data($data, $params) {
@@ -293,9 +329,9 @@ public function process_data($data, $params) {
foreach ($grading_info->outcomes as $n => $old) {
$name = 'outcome_'.$n;
- $newvalue = $old->grades[$userid]->grade != $formdata->{$name}[$userid];
- if (isset($formdata->{$name}[$userid]) and $newvalue) {
- $outcomedata[$n] = $formdata->{$name}[$userid];
+ $newvalue = $old->grades[$userid]->grade != $data->{$name}[$userid];
+ if (isset($data->{$name}[$userid]) and $newvalue) {
+ $outcomedata[$n] = $data->{$name}[$userid];
}
}
@@ -455,6 +491,12 @@ public function apply_userid_filter(block_ajax_marking_query_base $query, $opera
'column' => 'timestamp',
'alias' => 'tooltip')
);
+ // Need this to make the popup show properly because some assignment code shows or
+ // not depending on this flag to tell if it's in a pop-up e.g. the revert to draft
+ // button for advanced upload
+ $query->add_select(array('column' => "'single'",
+ 'alias' => 'mode')
+ );
$selects = array(
array(
Please sign in to comment.
Something went wrong with that request. Please try again.