[opw-web] Add a flag for past-selection-deadline editing
- From: Owen Taylor <otaylor src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [opw-web] Add a flag for past-selection-deadline editing
- Date: Wed, 2 Dec 2015 21:32:41 +0000 (UTC)
commit 4bffdd27cb4d00b5ef250aff1c51e2ee444bff6f
Author: Owen W. Taylor <otaylor fishsoup net>
Date: Wed Nov 18 12:53:02 2015 -0500
Add a flag for past-selection-deadline editing
Let the admin check a box on the projecting editing page that will allow
the student to edit their proposal past the selection deadline.
lang/en-gb.php | 1 +
modules/mod_view_projects.php | 17 +++++++++++++----
schema.sql | 3 +++
.../html/tpl_view_projects_editor.html | 7 +++++++
utils.php | 6 ++++--
5 files changed, 28 insertions(+), 6 deletions(-)
---
diff --git a/lang/en-gb.php b/lang/en-gb.php
index 5d2bd3d..701d2f7 100644
--- a/lang/en-gb.php
+++ b/lang/en-gb.php
@@ -198,6 +198,7 @@ $lang_data = array(
'project_updated' => 'Project updated successfully',
'project_home' => 'Program home',
'project_complete' => 'Project complete?',
+ 'late_editing_allowed' => 'Intern can edit proposal past selection deadline?',
'student_result' => 'Participant result',
'passed' => 'Passed',
'failed' => 'Failed',
diff --git a/modules/mod_view_projects.php b/modules/mod_view_projects.php
index 89cf498..1220b07 100644
--- a/modules/mod_view_projects.php
+++ b/modules/mod_view_projects.php
@@ -19,6 +19,7 @@ $new_student = $core->variable('new_student', '', false, true);
$new_mentor = $core->variable('new_mentor', '', false, true);
$return_url = $core->variable('r', '');
$is_passed = $core->variable('passed', 0);
+$late_edit = $core->variable('late_edit', '') == 'on' ? 1 : 0;
$is_complete = $core->variable('complete', '') == 'on' ? 1 : 0;
$page = $core->variable('pg', 1);
$limit_start = ($page - 1) * $config->per_page;
@@ -94,6 +95,7 @@ if ($action == 'editor')
$description = $project_data['description'];
$organization_id = $project_data['organization_id'];
$is_passed = $row['passed'];
+ $late_edit = $project_data['late_edit'];
$is_complete = $project_data['is_complete'];
}
@@ -126,6 +128,9 @@ if ($action == 'editor')
// Only mentor/admins can mark project as complete and pass a student
$can_decide = ($role == 'm' && $is_owner) || $user->is_admin;
+ // Only admins can mark a project as able to be edited late
+ $can_set_late_edit = $user->is_admin;
+
// Project was saved
if ($project_save)
{
@@ -146,7 +151,8 @@ if ($action == 'editor')
'is_complete' => $is_complete,
'is_passed' => $is_passed,
'new_student' => $new_student,
- 'new_mentor' => $new_mentor);
+ 'new_mentor' => $new_mentor,
+ 'late_edit' => $late_edit);
// Are we updating?
if ($project_id > 0)
@@ -156,7 +162,8 @@ if ($action == 'editor')
"SET title = :title, " .
" description = :description, " .
" organization_id = :organization_id, " .
- " is_complete = " . ($can_decide ? ":is_complete " : "is_complete ") .
+ " is_complete = " . ($can_decide ? ":is_complete, " : "is_complete, ") .
+ " late_edit = " . ($can_set_late_edit ? ":late_edit " : "late_edit ") .
"WHERE id = :project_id";
$db->query($sql, $params);
@@ -296,8 +303,8 @@ if ($action == 'editor')
// Insert new project
$sql = "INSERT INTO {$db->prefix}projects " .
- "(title, description, program_id, organization_id, is_accepted, is_complete) " .
- "VALUES (:title, :description, :program_id, :organization_id, :is_accepted, 0)";
+ "(title, description, program_id, organization_id, is_accepted, is_complete,
late_edit) " .
+ "VALUES (:title, :description, :program_id, :organization_id, :is_accepted, 0, 0)";
$db->query($sql, $params);
// Get the new project ID
@@ -354,9 +361,11 @@ if ($action == 'editor')
'error_visibility' => $skin->visibility(empty($error_message), true),
'new_visibility' => $skin->visibility($project_id == 0),
'late_submission_visibility' => $skin->visibility($project_id == 0 &&
$project_permissions->late_submission),
+ 'late_edit_visibility' => $skin->visibility($can_set_late_edit),
'decision_visibility' => $skin->visibility($project_id > 0 && $can_decide),
'subscribe_visibility' => $skin->visibility(isset($show_subscribe)),
'newuser_visibility' => $skin->visibility($project_id > 0 && $user->is_admin),
+ 'late_edit_checked' => $skin->checked($late_edit == 1),
'complete_checked' => $skin->checked($is_complete == 1),
'pass_checked' => $skin->checked($is_passed == 1),
'fail_checked' => $skin->checked($is_passed == 0),
diff --git a/schema.sql b/schema.sql
index 81b1dfe..3c1497c 100644
--- a/schema.sql
+++ b/schema.sql
@@ -41,6 +41,7 @@ CREATE TABLE `opw_organizations` (
FOREIGN KEY (`program_id`) REFERENCES `opw_programs`(`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+/* alter table opw_projects add `late_edit` varchar(1) NOT NULL DEFAULT 0 ; */
CREATE TABLE `opw_projects` (
`id` mediumint(10) unsigned NOT NULL AUTO_INCREMENT,
`title` varchar(255) NOT NULL DEFAULT '',
@@ -50,6 +51,7 @@ CREATE TABLE `opw_projects` (
`is_accepted` tinyint(1) NOT NULL DEFAULT -1,
`is_complete` tinyint(1) NOT NULL DEFAULT 0,
`is_withdrawn` tinyint(1) NOT NULL DEFAULT 0,
+ `late_edit` tinyint(1) NOT NULL DEFAULT 0,
`ranking` float NOT NULL DEFAULT -1,
/* 'n' - No contribution
* 'y' - No contribution, will not accept
@@ -89,6 +91,7 @@ CREATE TABLE `opw_roles` (
`program_id` mediumint(6) unsigned NOT NULL,
`organization_id` mediumint(6) unsigned,
`role` char(1) NOT NULL DEFAULT 's',
+ `late_edit` tinyint(1) NOT NULL DEFAULT 0,
`contract_approved` tinyint(1) NOT NULL DEFAULT 0,
`contract_accepted_time` int(11) unsigned NOT NULL DEFAULT 0,
`contract_accepted_from` varchar(255) NOT NULL DEFAULT '',
diff --git a/skins/easterngreen/html/tpl_view_projects_editor.html
b/skins/easterngreen/html/tpl_view_projects_editor.html
index 8340cc5..d39055e 100644
--- a/skins/easterngreen/html/tpl_view_projects_editor.html
+++ b/skins/easterngreen/html/tpl_view_projects_editor.html
@@ -55,6 +55,13 @@
</div>
</div>
+<div class="control-group [[late_edit_visibility]]">
+ <label class="control-label">{{late_editing_allowed}}</label>
+ <div class="controls">
+ <input type="checkbox" name="late_edit" [[late_edit_checked]] />
+ </div>
+</div>
+
<div class="control-group [[decision_visibility]]">
<label class="control-label">{{project_complete}}</label>
<div class="controls">
diff --git a/utils.php b/utils.php
index a9335de..64a8086 100644
--- a/utils.php
+++ b/utils.php
@@ -203,8 +203,10 @@ class ProjectPermissions {
$can_delete = true;
} else if ($is_owner && $role == 's') {
if ($core->timestamp >= $program_data['dl_mentor']) {
- // Past the selection deadline, students cannot edit anything
- $can_edit = false;
+ // Past the selection deadline, students cannot edit anything,
+ // unless a special flag is checked by the admin for the project.
+ $can_edit = $project_data['late_edit'] != 0;
+
$can_change_organization = false;
$can_withdraw = $project_data['is_withdrawn'] == 0;
$can_resubmit = false;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]