Skip to content

Commit

Permalink
NOBUG workshop: display the phases deadlines in the planner tool
Browse files Browse the repository at this point in the history
  • Loading branch information
mudrd8mz committed Jun 8, 2010
1 parent 67ae13d commit 5bab64a
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 6 deletions.
11 changes: 10 additions & 1 deletion mod/workshop/lang/en/workshop.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,13 @@
$string['assessmentbyyourself'] = 'Assessment by yourself';
$string['assessmentdeleted'] = 'Assessment deallocated';
$string['assessmentend'] = 'Assessing not allowed after';
$string['assessmentenddatetime'] = 'Assessing ends on {$a->daydatetime} ({$a->distanceday})';
$string['assessmentform'] = 'Assessment form';
$string['assessmentreference'] = 'Reference assessment';
$string['assessmentreferenceneeded'] = 'You have to assess this example submission to provide a reference assessment. Click \'Continue\' button to assess the submission.';
$string['assessmentsettings'] = 'Assessment settings';
$string['assessmentstart'] = 'Assessing not allowed before';
$string['assessmentstartdatetime'] = 'Assessing starts on {$a->daydatetime} ({$a->distanceday})';
$string['assignedassessments'] = 'Assigned submissions to assess';
$string['assignedassessmentsnone'] = 'You have no assigned submission to assess';
$string['backtoeditform'] = 'Back to editing form';
Expand All @@ -66,6 +68,11 @@
$string['configgradinggrade'] = 'Default maximum grade for assessment in workshops';
$string['configmaxbytes'] = 'Default maximum submission file size for all workshops on the site (subject to course limits and other local settings)';
$string['configstrategy'] = 'Default grading strategy for workshops';
$string['daysago'] = '{$a} days ago';
$string['daysleft'] = '{$a} days left';
$string['daystoday'] = 'today';
$string['daystomorrow'] = 'tomorrow';
$string['daysyesterday'] = 'yesterday';
$string['editassessmentform'] = 'Edit assessment form';
$string['editassessmentformstrategy'] = 'Edit assessment form ({$a})';
$string['editingassessmentform'] = 'Editing assessment form';
Expand Down Expand Up @@ -162,18 +169,20 @@
* Accumulative grading - Comments and a grade are given regarding specified aspects
* Comments - Comments are given regarding specified aspects but no grade can be given
* Number of errors - Comments and a yes/no assessment are given regarding specified assertions
* Number of errors - Comments and a yes/no assessment are given regarding specified assertions
* Rubric - A level assessment is given regarding specified criteria';
$string['strategyhaschanged'] = 'The workshop grading strategy has changed since the form was opened for editing.';
$string['submission'] = 'Submission';
$string['submissionattachment'] = 'Attachment';
$string['submissioncontent'] = 'Submission content';
$string['submissionend'] = 'Submitting not allowed after';
$string['submissionenddatetime'] = 'Submitting ends on {$a->daydatetime} ({$a->distanceday})';
$string['submissiongrade'] = 'Grade for submission';
$string['submissiongrade_help'] = 'This setting specifies the maximum grade a student can obtain for their own submission. It is calculated as the weighted mean of all assessments done by peers and/or teachers.';
$string['submissiongradeof'] = 'Grade for submission (of {$a})';
$string['submissionsettings'] = 'Submission settings';
$string['submissionstart'] = 'Submitting not allowed before';
$string['submissionstartdatetime'] = 'Submitting starts on {$a->daydatetime} ({$a->distanceday})';
$string['submissiontitle'] = 'Title';
$string['switchingphase'] = 'Switching phase';
$string['switchphase'] = 'Switch phase';
Expand Down
82 changes: 77 additions & 5 deletions mod/workshop/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,44 @@ public static function lcm($a, $b) {
return ($a / self::gcd($a,$b)) * $b;
}

/**
* Returns an object suitable for strings containing dates/times
*
* The returned object contains properties date, datefullshort, datetime, ... containing the given
* timestamp formatted using strftimedate, strftimedatefullshort, strftimedatetime, ... from the
* current lang's langconfig.php
* This allows translators and administrators customize the date/time format.
*
* @param int $timestamp the timestamp in UTC
* @return stdclass
*/
public static function timestamp_formats($timestamp) {
$formats = array('date', 'datefullshort', 'dateshort', 'datetime',
'datetimeshort', 'daydate', 'daydatetime', 'dayshort', 'daytime',
'monthyear', 'recent', 'recentfull', 'time');
$a = new stdclass();
foreach ($formats as $format) {
$a->{$format} = userdate($timestamp, get_string('strftime'.$format, 'langconfig'));
}
$day = userdate($timestamp, '%Y%m%d', 99, false);
$today = userdate(time(), '%Y%m%d', 99, false);
$tomorrow = userdate(time() + DAYSECS, '%Y%m%d', 99, false);
$yesterday = userdate(time() - DAYSECS, '%Y%m%d', 99, false);
$distance = (int)round(abs(time() - $timestamp) / DAYSECS);
if ($day == $today) {
$a->distanceday = get_string('daystoday', 'workshop');
} elseif ($day == $yesterday) {
$a->distanceday = get_string('daysyesterday', 'workshop');
} elseif ($day < $today) {
$a->distanceday = get_string('daysago', 'workshop', $distance);
} elseif ($day == $tomorrow) {
$a->distanceday = get_string('daystomorrow', 'workshop');
} elseif ($day > $today) {
$a->distanceday = get_string('daysleft', 'workshop', $distance);
}
return $a;
}

////////////////////////////////////////////////////////////////////////////////
// Workshop API //
////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -1687,7 +1725,9 @@ public function __construct(workshop $workshop, $userid) {

$this->workshop = $workshop;

// Prepare tasks for the setup phase
//---------------------------------------------------------
// * SETUP | submission | assessment | evaluation | closed
//---------------------------------------------------------
$phase = new stdclass();
$phase->title = get_string('phasesetup', 'workshop');
$phase->tasks = array();
Expand Down Expand Up @@ -1736,7 +1776,9 @@ public function __construct(workshop $workshop, $userid) {
}
$this->phases[workshop::PHASE_SETUP] = $phase;

// Prepare tasks for the submission phase
//---------------------------------------------------------
// setup | * SUBMISSION | assessment | evaluation | closed
//---------------------------------------------------------
$phase = new stdclass();
$phase->title = get_string('phasesubmission', 'workshop');
$phase->tasks = array();
Expand Down Expand Up @@ -1802,9 +1844,23 @@ public function __construct(workshop $workshop, $userid) {
$phase->tasks['allocateinfo'] = $task;
}
}
if ($this->workshop->submissionstart) {
$task = new stdclass();
$task->title = get_string('submissionstartdatetime', 'workshop', workshop::timestamp_formats($this->workshop->submissionstart));
$task->completed = 'info';
$phase->tasks['submissionstartdatetime'] = $task;
}
if ($this->workshop->submissionend) {
$task = new stdclass();
$task->title = get_string('submissionenddatetime', 'workshop', workshop::timestamp_formats($this->workshop->submissionend));
$task->completed = 'info';
$phase->tasks['submissionenddatetime'] = $task;
}
$this->phases[workshop::PHASE_SUBMISSION] = $phase;

// Prepare tasks for the peer-assessment phase (includes eventual self-assessments)
//---------------------------------------------------------
// setup | submission | * ASSESSMENT | evaluation | closed
//---------------------------------------------------------
$phase = new stdclass();
$phase->title = get_string('phaseassessment', 'workshop');
$phase->tasks = array();
Expand Down Expand Up @@ -1853,9 +1909,23 @@ public function __construct(workshop $workshop, $userid) {
$task->title = get_string('taskassessself', 'workshop');
$phase->tasks['assessself'] = $task;
}
if ($this->workshop->assessmentstart) {
$task = new stdclass();
$task->title = get_string('assessmentstartdatetime', 'workshop', workshop::timestamp_formats($this->workshop->assessmentstart));
$task->completed = 'info';
$phase->tasks['assessmentstartdatetime'] = $task;
}
if ($this->workshop->assessmentend) {
$task = new stdclass();
$task->title = get_string('assessmentenddatetime', 'workshop', workshop::timestamp_formats($this->workshop->assessmentend));
$task->completed = 'info';
$phase->tasks['assessmentenddatetime'] = $task;
}
$this->phases[workshop::PHASE_ASSESSMENT] = $phase;

// Prepare tasks for the grading evaluation phase
//---------------------------------------------------------
// setup | submission | assessment | * EVALUATION | closed
//---------------------------------------------------------
$phase = new stdclass();
$phase->title = get_string('phaseevaluation', 'workshop');
$phase->tasks = array();
Expand Down Expand Up @@ -1900,7 +1970,9 @@ public function __construct(workshop $workshop, $userid) {
}
$this->phases[workshop::PHASE_EVALUATION] = $phase;

// Prepare tasks for the "workshop closed" phase - todo
//---------------------------------------------------------
// setup | submission | assessment | evaluation | * CLOSED
//---------------------------------------------------------
$phase = new stdclass();
$phase->title = get_string('phaseclosed', 'workshop');
$phase->tasks = array();
Expand Down

0 comments on commit 5bab64a

Please sign in to comment.