Skip to content
This repository has been archived by the owner on May 15, 2020. It is now read-only.

Commit

Permalink
Fixed assignment javascript for revert to draft button and editor
Browse files Browse the repository at this point in the history
  • Loading branch information
mattgibson committed Apr 16, 2012
1 parent 59d9e99 commit ef70694
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 6 deletions.
3 changes: 3 additions & 0 deletions actions/grading_popup.php
Expand Up @@ -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');
Expand Down
17 changes: 17 additions & 0 deletions module.js
Expand Up @@ -315,6 +315,19 @@ YAHOO.lang.extend(M.block_ajax_marking.tree_node, YAHOO.widget.HTMLNode, {
return nodefilters;
},

/**
* 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.
*
Expand Down Expand Up @@ -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
Expand Down
54 changes: 48 additions & 6 deletions modules/assignment/block_ajax_marking_assignment.class.php
Expand Up @@ -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
Expand All @@ -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));
Expand Down Expand Up @@ -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,
Expand All @@ -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),
Expand All @@ -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;
}
Expand All @@ -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) {

Expand Down Expand Up @@ -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];
}
}

Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit ef70694

Please sign in to comment.