Skip to content

Commit

Permalink
More work done on the Workshop Plan UI
Browse files Browse the repository at this point in the history
  • Loading branch information
mudrd8mz committed Jan 4, 2010
1 parent b761e6d commit da0b1f7
Show file tree
Hide file tree
Showing 6 changed files with 193 additions and 48 deletions.
13 changes: 10 additions & 3 deletions mod/workshop/lang/en_utf8/workshop.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,23 @@
defined('MOODLE_INTERNAL') || die();

$string[''] = '';
$string[''] = '';
$string[''] = '';
$string['info'] = 'Info';
$string['undersetup'] = 'The workshop is currently under setup. Please wait until it is switched to the next phase.';
$string['taskinstructreviewers'] = 'Provide instructions for grading';
$string['taskinstructauthors'] = 'Provide instructions for submitting';
$string['taskintro'] = 'Set the workshop introduction';
$string['phaseclosed'] = 'Closed';
$string['phaseevaluation'] = 'Grading evaluation phase';
$string['phaseassessment'] = 'Assessment phase';
$string['phasesubmission'] = 'Submission phase';
$string['phasesetup'] = 'Setup';
$string['phasesetup'] = 'Setup phase';
$string['taskassessself'] = 'Assess yourself';
$string['taskassesspeers'] = 'Assess peers';
$string['taskassesspeersinfo'] = 'total: $a->total<br />pending: $a->todo';
$string['allocatedetails'] = 'submissions: $a->total<br />allocated: $a->done';
$string['taskassesspeersdetails'] = 'total: $a->total<br />pending: $a->todo';
$string['tasksubmit'] = 'Submit your work';
$string['taskeditform'] = 'Define the assessment form';
$string['accesscontrol'] = 'Access control';
$string['agreeassessments'] = 'Assessments must be agreed';
$string['agreeassessmentsdesc'] = 'Authors may comment assessments of their work and agree/disagree with it';
Expand Down
162 changes: 133 additions & 29 deletions mod/workshop/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,38 @@ public function __construct(stdClass $dbrecord, stdClass $cm, stdClass $course)
*/
public function __get($key) {
if (!isset($this->dbrecord->{$key})) {
throw new coding_exception('You are trying to get a non-existing property');
// todo remove the comment here // throw new coding_exception('You are trying to get a non-existing property');
return null;
}
return $this->dbrecord->{$key};
}

/**
* Given a list of user ids, returns the filtered one containing just ids of users with own submission
*
* Example submissions are ignored.
*
* @param array $userids
* @return TODO
*/
protected function users_with_submission(array $userids) {
global $DB;

$userswithsubmission = array();
list($usql, $uparams) = $DB->get_in_or_equal($userids, SQL_PARAMS_NAMED);
$sql = "SELECT id,userid
FROM {workshop_submissions}
WHERE example = 0 AND workshopid = :workshopid AND userid $usql";
$params = array('workshopid' => $this->id);
$params = array_merge($params, $uparams);
$submissions = $DB->get_records_sql($sql, $params);
foreach ($submissions as $submission) {
$userswithsubmission[$submission->userid] = null;
}

return $userswithsubmission;
}

/**
* Fetches all users with the capability mod/workshop:submit in the current context
*
Expand All @@ -110,25 +137,15 @@ public function __get($key) {
* @return array array[userid] => stdClass{->id ->lastname ->firstname}
*/
public function get_peer_authors($musthavesubmission=true) {
global $DB;

$users = get_users_by_capability($this->context, 'mod/workshop:submit',
'u.id, u.lastname, u.firstname', 'u.lastname,u.firstname', '', '', '', '', false, false, true);

if ($musthavesubmission) {
$userswithsubmission = array();
$submissions = $DB->get_records_list('workshop_submissions', 'userid', array_keys($users),'', 'id,userid');
foreach ($submissions as $submission) {
$userswithsubmission[$submission->userid] = null;
}
$userswithsubmission = array_intersect_key($users, $userswithsubmission);
$users = array_intersect_key($users, $this->users_with_submission(array_keys($users)));
}

if ($musthavesubmission) {
return $userswithsubmission;
} else {
return $users;
}
return $users;
}

/**
Expand All @@ -147,18 +164,10 @@ public function get_peer_reviewers($musthavesubmission=false) {

if ($musthavesubmission) {
// users without their own submission can not be reviewers
$submissions = $DB->get_records_list('workshop_submissions', 'userid', array_keys($users),'', 'id,userid');
foreach ($submissions as $submission) {
$userswithsubmission[$submission->userid] = null;
}
$userswithsubmission = array_intersect_key($users, $userswithsubmission);
$users = array_intersect_key($users, $this->users_with_submission(array_keys($users)));
}

if ($musthavesubmission) {
return $userswithsubmission;
} else {
return $users;
}
return $users;
}

/**
Expand Down Expand Up @@ -594,6 +603,19 @@ public function submission_url() {
return new moodle_url($CFG->wwwroot . '/mod/workshop/submission.php', array('cmid' => $this->cm->id));
}

/**
* @return stdClass {@link moodle_url} the URL of the mod_edit form
*/
public function updatemod_url() {
global $CFG;
return new moodle_url($CFG->wwwroot . '/course/modedit.php', array('update' => $this->cm->id, 'return' => 1));
}

public function allocation_url() {
global $CFG;
return new moodle_url($CFG->wwwroot . '/mod/workshop/allocation.php', array('cmid' => $this->cm->id));
}

/**
* Returns an object containing all data to display the user's full name and picture
*
Expand Down Expand Up @@ -645,12 +667,43 @@ public function prepare_user_plan($userid) {
$phase = new stdClass();
$phase->title = get_string('phasesetup', 'workshop');
$phase->tasks = array();
if (has_capability('moodle/course:manageactivities', $this->context, $userid)) {
$task = new stdClass();
$task->title = get_string('taskintro', 'workshop');
$task->link = $this->updatemod_url();
$task->completed = !(trim(strip_tags($this->intro)) == '');
$phase->tasks['intro'] = $task;
}
if (has_capability('mod/workshop:editdimensions', $this->context, $userid)) {
$task = new stdClass();
$task->title = get_string('taskeditform', 'workshop');
$task->completed = $this->assessment_form_ready();
$task->title = get_string('editassessmentform', 'workshop');
$task->link = $this->editform_url();
if ($this->assessment_form_ready()) {
$task->completed = true;
} elseif ($this->phase > self::PHASE_SETUP) {
$task->completed = false;
}
$phase->tasks['editform'] = $task;
}
if (has_capability('moodle/course:manageactivities', $this->context, $userid)) {
$task = new stdClass();
$task->title = get_string('taskinstructauthors', 'workshop');
$task->link = $this->updatemod_url();
if (trim(strip_tags($this->instructauthors))) {
$task->completed = true;
} elseif ($this->phase >= self::PHASE_SUBMISSION) {
$task->completed = false;
}
$phase->tasks['instructauthors'] = $task;
}
if (empty($phase->tasks) and $this->phase == self::PHASE_SETUP) {
// if we are in the setup phase and there is no task (typical for students), let us
// display some explanation what is going on
$task = new stdClass();
$task->title = get_string('undersetup', 'workshop');
$task->completed = 'info';
$phase->tasks['setupinfo'] = $task;
}
$phases[self::PHASE_SETUP] = $phase;

// Prepare tasks for the submission phase
Expand All @@ -660,11 +713,61 @@ public function prepare_user_plan($userid) {
if (has_capability('mod/workshop:submit', $this->context, $userid)) {
$task = new stdClass();
$task->title = get_string('tasksubmit', 'workshop');
$task->completed = $DB->record_exists('workshop_submissions',
array('workshopid' => $this->id, 'example' => 0, 'userid' => $userid));
$task->link = $this->submission_url();
if ($DB->record_exists('workshop_submissions', array('workshopid'=>$this->id, 'example'=>0, 'userid'=>$userid))) {
$task->completed = true;
} elseif ($this->phase >= self::PHASE_ASSESSMENT) {
$task->completed = false;
} else {
$task->completed = null; // still has a chance to submit
}
$phase->tasks['submit'] = $task;
}
if (has_capability('moodle/course:manageactivities', $this->context, $userid)) {
$task = new stdClass();
$task->title = get_string('taskinstructreviewers', 'workshop');
$task->link = $this->updatemod_url();
if (trim(strip_tags($this->instructreviewers))) {
$task->completed = true;
} elseif ($this->phase >= self::PHASE_ASSESSMENT) {
$task->completed = false;
}
$phase->tasks['instructreviewers'] = $task;
}
$phases[self::PHASE_SUBMISSION] = $phase;
if (has_capability('mod/workshop:allocate', $this->context, $userid)) {
$task = new stdClass();
$task->title = get_string('allocate', 'workshop');
$task->link = $this->allocation_url();
$rs = $this->get_allocations_recordset();
$allocations = array(); // 'submissionid' => isallocated
foreach ($rs as $allocation) {
if (!isset($allocations[$allocation->submissionid])) {
$allocations[$allocation->submissionid] = false;
}
if (!empty($allocation->reviewerid)) {
$allocations[$allocation->submissionid] = true;
}
}
$numofsubmissions = count($allocations);
$numofallocated = count(array_filter($allocations));
$rs->close();
if ($numofsubmissions == 0) {
$task->completed = null;
} elseif ($numofsubmissions == $numofallocated) {
$task->completed = true;
} elseif ($this->phase > self::PHASE_SUBMISSION) {
$task->completed = false;
} else {
$task->completed = null; // still has a chance to allocate
}
$a = new stdClass();
$a->total = $numofsubmissions;
$a->done = $numofallocated;
$task->details = get_string('allocatedetails', 'workshop', $a);
unset($a);
$phase->tasks['submit'] = $task;
}

// Prepare tasks for the peer-assessment phase (includes eventual self-assessments)
$phase = new stdClass();
Expand Down Expand Up @@ -697,7 +800,7 @@ public function prepare_user_plan($userid) {
$a->total = $numofpeers;
$a->todo = $numofpeerstodo;
$task->title = get_string('taskassesspeers', 'workshop');
$task->info = get_string('taskassesspeersinfo', 'workshop', $a);
$task->details = get_string('taskassesspeersdetails', 'workshop', $a);
unset($a);
$phase->tasks['assesspeers'] = $task;
}
Expand Down Expand Up @@ -733,7 +836,8 @@ public function prepare_user_plan($userid) {

foreach ($phase->tasks as $taskcode => $task) {
$task->title = isset($task->title) ? $task->title : '';
$task->info = isset($task->info) ? $task->info : '';
$task->link = isset($task->link) ? $task->link : null;
$task->details = isset($task->details) ? $task->details : '';
$task->completed = isset($task->completed) ? $task->completed : null;
}
}
Expand Down
23 changes: 14 additions & 9 deletions mod/workshop/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function status_message(stdClass $message) {
if (empty($message->text)) {
return '';
}
$sty = $message->sty ? $message->sty : 'info';
$sty = empty($message->sty) ? 'info' : $message->sty;

$o = $this->output->output_tag('span', array(), $message->text);
$closer = $this->output->output_tag('a', array('href' => $this->page->url->out()),
Expand Down Expand Up @@ -287,18 +287,23 @@ protected function user_plan_tasks(array $tasks) {
$classes = '';
$icon = null;
if ($task->completed === true) {
$icon = new html_image();
$icon->src = $this->old_icon_url('i/tick_green_big.gif');
$icon->alt = '+';
$classes .= ' completed';
} elseif ($task->completed === false) {
$classes .= ' pending';
$classes .= ' fail';
} elseif ($task->completed === 'info') {
$classes .= ' info';
}
if (is_null($task->link)) {
$title = $task->title;
} else {
$classes .= ' statusunknown';
$link = new html_link();
$link->url = $task->link;
$link->text = $task->title;
$title = $this->output->link($link);
}
$title = $this->output->container($task->title, 'title');
$info = $this->output->container($task->info, 'info');
$out .= $this->output->output_tag('li', array('class' => $classes), $title . $info);
$title = $this->output->container($title, 'title');
$details = $this->output->container($task->details, 'details');
$out .= $this->output->output_tag('li', array('class' => $classes), $title . $details);
}
if ($out) {
$out = $this->output->output_tag('ul', array('class' => 'tasks'), $out);
Expand Down
33 changes: 29 additions & 4 deletions mod/workshop/styles.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@
.userplan {
width: 70%;
margin: 1em auto 1em auto;
font-size: 80%;
}

.userplan th {
Expand All @@ -199,7 +200,7 @@
.userplan th.active {
vertical-align: top;
color: black;
font-size: 110%;
font-size: 140%;
border: 1px solid #ddd;
border-bottom: none;
background-color: #e7f1c3;
Expand All @@ -210,15 +211,31 @@
vertical-align: top;
border-right: 1px solid #ddd;
background-color: #f5f5f5;
}

.userplan td,
.userplan td a,
.userplan td a:link,
.userplan td a:hover,
.userplan td a:visited,
.userplan td a:active {
color: #999;
}

.userplan td.active,
.userplan td.active a,
.userplan td.active a:link,
.userplan td.active a:hover,
.userplan td.active a:visited,
.userplan td.active a:active {
color: black;
}

.userplan td.lastcol {
border-right: none;
}

.userplan td.active {
color: black;
border-left: 1px solid #ddd;
border-right: 1px solid #ddd;
background-color: #e7f1c3;
Expand All @@ -230,10 +247,18 @@
background-repeat: no-repeat;
}

.userplan tr.phasetasks .completed {
.userplan tr.phasetasks li.completed {
background-image: url(../../pix/i/completion-auto-y.gif);
}

.userplan tr.phasetasks li.fail {
background-image: url(../../pix/i/completion-auto-fail.gif);
}

.userplan tr.phasetasks li.info {
background-image: url(../../pix/i/info.gif);
}

.userplan tr.phasetasks .tasks {
list-style:none;
margin: 3px;
Expand All @@ -244,7 +269,7 @@
padding: 0px 10px 0px 20px;
}

.userplan tr.phasetasks .info {
.userplan tr.phasetasks .details {
padding: 0px 10px 0px 25px;
font-size: 80%;
}
Loading

0 comments on commit da0b1f7

Please sign in to comment.