Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Fix behaviour when submitting non locking pages twice #19

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions classes/observers.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public static function submission_graded(\mod_assign\event\submission_graded $ev
$maharasubmission = $DB->get_record('assignsubmission_mahara', array('submission'=>$submission->id));

// Process further only if we are dealing with mahara submission that is locked.
if ($maharasubmission && $maharasubmission->viewstatus == assign_submission_mahara::STATUS_SUBMITTED) {
if ($maharasubmission && $maharasubmission->viewstatus == assign_submission_mahara::MAHARA_STATUS_LOCKED) {
// Check if marking workflow is in place, page unlocking will be handled in
// assignsubmission_mahara_observers::workflow_state_updated unless .
if ($assign->get_instance()->markingworkflow) {
Expand Down Expand Up @@ -101,7 +101,7 @@ public static function workflow_state_updated(\mod_assign\event\workflow_state_u
$maharasubmission = $DB->get_record('assignsubmission_mahara', array('submission'=>$submission->id));

// Process further only if we are dealing with mahara submission that is locked.
if ($maharasubmission && $maharasubmission->viewstatus == assign_submission_mahara::STATUS_SUBMITTED) {
if ($maharasubmission && $maharasubmission->viewstatus == assign_submission_mahara::MAHARA_STATUS_LOCKED) {
// Check marking workflow state, only unlock page if marks are released.
if ($eventdata['other']['newstate'] !== ASSIGN_MARKING_WORKFLOW_STATE_RELEASED) {
return;
Expand Down Expand Up @@ -129,7 +129,7 @@ protected static function release_submitted_view($maharasubmissionplugin, $mahar
if ($maharasubmissionplugin->get_error()) {
$this->set_error($maharasubmissionplugin->get_error());
} else {
$maharasubmissionplugin->set_mahara_submission_status($maharasubmission->submission, assign_submission_mahara::STATUS_RELEASED);
$maharasubmissionplugin->set_mahara_submission_status($maharasubmission->submission, assign_submission_mahara::MAHARA_STATUS_RELEASED);
}
}
}
4 changes: 3 additions & 1 deletion db/mnet.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@

$publishes = array(
'assign_submission_mahara' => array(
'apiversion' => 1,
'apiversion' => 2,
'classname' => 'mnetservice_assign_submission_mahara',
'filename' => 'mnetlib.php',
'methods' => array(
'donothing',
// TODO: Uncomment if MDL-52172 gets merged
// 'can_view_view',
),
),
);
Expand Down
8 changes: 4 additions & 4 deletions db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ function xmldb_assignsubmission_mahara_upgrade($oldversion) {
$dbman->add_field($table, $field);
}

$DB->execute("update {assignsubmission_mahara} set viewstatus='".assign_submission_mahara::STATUS_SELECTED."' where viewaccesskey is null");
$DB->execute("update {assignsubmission_mahara} set viewstatus='".assign_submission_mahara::STATUS_SUBMITTED."' where viewaccesskey is not null");
$DB->execute("update {assignsubmission_mahara} set viewstatus='".assign_submission_mahara::MAHARA_STATUS_NORMAL."' where viewaccesskey is null");
$DB->execute("update {assignsubmission_mahara} set viewstatus='".assign_submission_mahara::MAHARA_STATUS_LOCKED."' where viewaccesskey is not null");

// Define field viewaccesskey to be dropped from assignsubmission_mahara.
$table = new xmldb_table('assignsubmission_mahara');
Expand Down Expand Up @@ -140,7 +140,7 @@ function xmldb_assignsubmission_mahara_upgrade($oldversion) {
$todb->viewtitle = $page->title;
$todb->iscollection = 0;
$status = $submissiondata->status;
if ($status == assign_submission_mahara::STATUS_RELEASED || $status == assign_submission_mahara::STATUS_SELECTED || $status == assign_submission_mahara::STATUS_SUBMITTED) {
if ($status == assign_submission_mahara::MAHARA_STATUS_RELEASED || $status == assign_submission_mahara::MAHARA_STATUS_NORMAL || $status == assign_submission_mahara::MAHARA_STATUS_LOCKED) {
$todb->status = $status;
}
else {
Expand Down Expand Up @@ -177,7 +177,7 @@ function xmldb_assignsubmission_mahara_upgrade($oldversion) {
$pluginman = core_plugin_manager::instance();
$uninstallurl = $pluginman->get_uninstall_url('assignfeedback_mahara', 'overview');
$uninstall = html_writer::link($uninstallurl, 'uninstall');
echo html_writer::div("It seems you are using assignfeedback_mahara plugin. "
echo html_writer::div("It seems you are using the assignfeedback_mahara plugin. "
. "This plugin is no longer required for Mahara pages unlocking and conflicting "
. "with this upgrade. Please " . $uninstall . " assignfeedback_mahara "
. "plugin first, remove its installation directory, and then proceed "
Expand Down
2 changes: 1 addition & 1 deletion lang/en/assignsubmission_mahara.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/

$string['assign_submission_mahara_name'] = 'Assign Submission Mahara services';
$string['assign_submission_mahara_description'] = 'Mahara functions used in Mahara portfolio Assign Submission plugin.<br />Publishing this service on a Moodle site has no effect. Subscribe to this service if you want to be able to use assignments with {$a}.<br />';
$string['assign_submission_mahara_description'] = 'Mahara functions used in Mahara portfolio Assign Submission plugin.<br />Subscribe AND publish to this service if you want to be able to use assignments with {$a}.<br />';
$string['collectionsby'] = 'Collections by {$a}';
$string['defaultlockpages'] = 'Default "{$a}"';
$string['defaultlockpages_help'] = 'Default setting to use for the "{$a}" setting in new Mahara assignments.';
Expand Down
43 changes: 43 additions & 0 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,48 @@ function assignsubmission_mahara_sitelist() {
h.name";

return $DB->get_records_sql_menu($sql, array('mnet_localhost_id'=>$CFG->mnet_localhost_id));
}

/**
* Determines whether or not the specified mnethost is publishing the function needed to
* do Mahara page permissions via MNet.
* TODO: Update this function if MDL-52172 gets merged
*
* @param int $mnethostid
* @return boolean
*/
function assignsubmission_mahara_is_mnet_acl_enabled($mnethostid) {
global $DB, $CFG;
$sql = '
SELECT r.xmlrpcpath
FROM
{mnet_host} h
INNER JOIN {mnet_host2service} h2s
ON h.id = h2s.hostid
INNER JOIN {mnet_service} s
ON s.id = h2s.serviceid
AND s.name=\'assign_submission_mahara\'
INNER JOIN {mnet_service2rpc} s2r
ON s.id = s2r.serviceid
INNER JOIN {mnet_rpc} r
on r.id = s2r.rpcid
AND r.functionname = \'can_view_view\'
AND r.pluginname = \'mahara\'
AND r.plugintype = \'local\'
WHERE
h.id = :mnethostid
AND h.deleted = 0
AND h2s.publish = 1
AND r.enabled = 1
';

$ret = $DB->record_exists_sql($sql, array('mnethostid' => $mnethostid));
// Seemed like a good idea, but it fills up the logs too much.
// if (!$ret) {
// debugging('You should install the Mahara local plugin and publish its service, for better'
// .' interoperability with the Mahara assignment submission plugin.',
// DEBUG_DEVELOPER
// );
// }
return $ret;
}
Loading