-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added two new features to facetoface #3
base: master
Are you sure you want to change the base?
Changes from 3 commits
31d18ba
4be1c65
c3684ad
e3cd552
b7b0ae5
8c3f13c
b8733aa
55b1e9b
25f6447
bf679f6
aed3c38
c592465
5fa03ad
af80a85
92e28fd
c3ff5ac
e928fd3
4686dcd
92c9da2
0566794
476ee77
5abf016
7ee079a
8be19c8
cf5b32f
7f6e3d9
9bc6814
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,7 +34,8 @@ | |
<FIELD NAME="shortname" TYPE="char" LENGTH="32" NOTNULL="false" SEQUENCE="false" PREVIOUS="timemodified" NEXT="showoncalendar"/> | ||
<FIELD NAME="showoncalendar" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" PREVIOUS="shortname" NEXT="approvalreqd"/> | ||
<FIELD NAME="approvalreqd" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="showoncalendar" NEXT="usercalentry"/> | ||
<FIELD NAME="usercalentry" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" PREVIOUS="approvalreqd"/> | ||
<FIELD NAME="usercalentry" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" PREVIOUS="approvalreqd" NEXT="disablewithindays"/> | ||
<FIELD NAME="disablewithindays" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="usercalentry"/> | ||
</FIELDS> | ||
<KEYS> | ||
<KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for facetoface"/> | ||
|
@@ -67,8 +68,10 @@ | |
<FIELD NAME="normalcost" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="The normal (non-discounted) cost of the session" PREVIOUS="duration" NEXT="discountcost"/> | ||
<FIELD NAME="discountcost" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Discounted cost of the event" PREVIOUS="normalcost" NEXT="timecreated"/> | ||
<FIELD NAME="timecreated" TYPE="int" LENGTH="20" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="discountcost" NEXT="timemodified"/> | ||
<FIELD NAME="timemodified" TYPE="int" LENGTH="20" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="timecreated"/> | ||
</FIELDS> | ||
<FIELD NAME="timemodified" TYPE="int" LENGTH="20" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="timecreated" NEXT="disablenewenrolldays"/> | ||
<FIELD NAME="disablenewenrolldays" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="timemodified" NEXT="disableoption"/> | ||
<FIELD NAME="disableoption" TYPE="int" LENGTH="1" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" PREVIOUS="disablenewenrolldays"/> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The name of this field does not describe what it does. A better name might be "disablesignup". |
||
</FIELDS> | ||
<KEYS> | ||
<KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="primary key of the table, please edit me" NEXT="facetoface"/> | ||
<KEY NAME="facetoface" TYPE="foreign" FIELDS="facetoface" REFTABLE="facetoface" REFFIELDS="id" PREVIOUS="primary"/> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -697,5 +697,39 @@ function xmldb_facetoface_upgrade($oldversion=0) { | |
upgrade_mod_savepoint(true, 2013010400, 'facetoface'); | ||
} | ||
|
||
if ($oldversion < 2013010401) { | ||
|
||
$table = new xmldb_table('facetoface'); | ||
$field = new xmldb_field('disablewithindays', XMLDB_TYPE_INTEGER, '3', null, XMLDB_NOTNULL, null, '0', 'approvalreqd'); | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove extra new line |
||
if (!$dbman->field_exists($table, $field)) { | ||
$dbman->add_field($table, $field); | ||
} | ||
|
||
// facetoface savepoint reached | ||
upgrade_mod_savepoint(true, 2012051100, 'facetoface'); | ||
|
||
$table = new xmldb_table('facetoface_sessions'); | ||
$field = new xmldb_field('disablenewenrolldays', XMLDB_TYPE_INTEGER, '3', null, XMLDB_NOTNULL, null, '0', 'timemodified'); | ||
|
||
if (!$dbman->field_exists($table, $field)) { | ||
$dbman->add_field($table, $field); | ||
} | ||
|
||
// facetoface savepoint reached | ||
upgrade_mod_savepoint(true, 2012051200, 'facetoface'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove this line and the comment and newline above so there is only only new line between this and the next line of code. This will break the upgrade |
||
|
||
$table = new xmldb_table('facetoface_sessions'); | ||
$field = new xmldb_field('disableoption', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, null, null, null, 'disablenewenrolldays'); | ||
|
||
if (!$dbman->field_exists($table, $field)) { | ||
$dbman->add_field($table, $field); | ||
} | ||
|
||
// facetoface savepoint reached | ||
upgrade_mod_savepoint(true, 2012053002, 'facetoface'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This version number needs to match the version number at the start of the upgrade block |
||
} | ||
|
||
return $result; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -598,6 +598,14 @@ function facetoface_update_attendees($session) { | |
$booked++; | ||
} | ||
} | ||
|
||
$currenttime = new DateTime(date('c', time())); | ||
$start = $DB->get_record('facetoface_sessions_dates', array('sessionid'=>$session->id)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a function in lib.php called "facetoface_get_session_dates" with a parameter of $sessionid. Use this instead of making a database call |
||
$starttime = new DateTime(date('c', $start->timestart)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A session may have many dates, this code will not work correctly if a session has more than one date |
||
$interval = $starttime->diff($currenttime); | ||
$diffdays = $interval->format('%a'); | ||
$disableddaysDB = $DB->get_record('facetoface', array('id'=>$session->id)); | ||
$disableddays = $disableddaysDB->disablewithindays; | ||
|
||
// If booked less than capacity, book some new users | ||
if ($booked < $capacity) { | ||
|
@@ -606,8 +614,7 @@ function facetoface_update_attendees($session) { | |
break; | ||
} | ||
|
||
if ($user->statuscode == MDL_F2F_STATUS_WAITLISTED) { | ||
|
||
if (($user->statuscode == MDL_F2F_STATUS_WAITLISTED)&($diffdays>$disableddays)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in this you should use "&&" instead of "&". The way it is currently done it is performing a bitwise operation rather than a logical comparison. Also put a space on either side of the "&&" after changing |
||
if (!facetoface_user_signup($session, $facetoface, $course, $user->discountcode, $user->notificationtype, MDL_F2F_STATUS_BOOKED, $user->id)) { | ||
// rollback_sql(); | ||
return false; | ||
|
@@ -618,7 +625,6 @@ function facetoface_update_attendees($session) { | |
} | ||
} | ||
} | ||
|
||
return $session->id; | ||
} | ||
|
||
|
@@ -1447,7 +1453,8 @@ function facetoface_write_activity_attendance(&$worksheet, $startingrow, $faceto | |
s.facetoface = ? | ||
AND d.sessionid = s.id | ||
$locationcondition | ||
ORDER BY s.datetimeknown, d.timestart"; | ||
ORDER BY s.datetimeknown, d.timestart"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line has an extra space at the end which needs to be removed |
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove extra new line |
||
|
||
$sessions = $DB->get_records_sql($sql, array_merge(array($facetofaceid), $locationparam)); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,8 @@ class mod_facetoface_renderer extends plugin_renderer_base { | |
* Builds session list table given an array of sessions | ||
*/ | ||
public function print_session_list_table($customfields, $sessions, $viewattendees, $editsessions) { | ||
$output = ''; | ||
global $DB; | ||
$output = ''; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fix indenting |
||
|
||
$tableheader = array(); | ||
foreach ($customfields as $field) { | ||
|
@@ -32,6 +33,7 @@ public function print_session_list_table($customfields, $sessions, $viewattendee | |
$table = new html_table(); | ||
$table->summary = get_string('previoussessionslist', 'facetoface'); | ||
$table->head = $tableheader; | ||
$table->width = '100%'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add styling by adding a class to the table and adding appropriate css to styles.css There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To perform this: But the width of the table is Not 100% on the output page. Can you please check what I did wrong. I looked into moodle api and into moodle forums and I see that is how it is done, but still I did not get the desired output. |
||
$table->data = array(); | ||
|
||
foreach ($sessions as $session) { | ||
|
@@ -138,8 +140,25 @@ public function print_session_list_table($customfields, $sessions, $viewattendee | |
$options .= html_writer::link('cancelsignup.php?s='.$session->id.'&backtoallsessions='.$session->facetoface, get_string('cancelbooking', 'facetoface'), array('title' => get_string('cancelbooking', 'facetoface'))); | ||
} | ||
elseif (!$sessionstarted and !$bookedsession) { | ||
$options .= html_writer::link('signup.php?s='.$session->id.'&backtoallsessions='.$session->facetoface, get_string('signup', 'facetoface')); | ||
} | ||
$currenttime = new DateTime(date('c', time())); | ||
$start = $DB->get_record('facetoface_sessions_dates', array('sessionid'=>$session->id)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Database calls should not be make in the renderer. All data that is needed in the renderer should be fetched then passed into the rendering function There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To fix this, can I write the code below in view.php
and pass $disableoption as an argument in (print_session_list_table) that is being called in line 182 and 192 in view.php There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've had a closer look at the renderer and the date information is already available. If you look at the code around like 68 or renderer.php you will see that the code loops through all the dates for the session. You should be able to use this information to achieve what you need to. Note that the session may contain multiple dates so I'm assuming you will want to compare again the earliest one. |
||
$starttime = new DateTime(date('c', $start->timestart)); | ||
$interval = $starttime->diff($currenttime); | ||
$diffdays = $interval->format('%a'); | ||
$disableddaysDB = $DB->get_record('facetoface_sessions', array('id'=>$session->id)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This DB call is a little harder to remove but you should be able to pass through the information you need from where print_session_list_table is called. In view.php |
||
$disableddays = $disableddaysDB->disablenewenrolldays; | ||
$disableoption = $disableddaysDB->disableoption; | ||
|
||
if($disableoption) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add space after if and before ( |
||
if($diffdays > $disableddays) { | ||
$options .= new moodle_url('signup.php', array('s' => $session->id, 'backtoallsessions' => $session->facetoface), get_string('signup', 'facetoface')); | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. need to move else on the same line as this bracket as shown in Moodle coding style guidelines |
||
else { | ||
$options .= new moodle_url('signup.php', array('s' => $session->id, 'backtoallsessions' => $session-facetoface), get_string('signup', 'facetoface')); | ||
} | ||
} | ||
|
||
if (empty($options)) { | ||
$options = get_string('none', 'facetoface'); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -122,6 +122,15 @@ | |
$fromform->discountcost = 0; | ||
} | ||
|
||
if (empty($fromform->disablenewenrolldays)) { | ||
$fromform->disablenewenrolldays = 0; | ||
} | ||
|
||
if (empty($fromform->disableoption)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. move bracket onto same line as if statement |
||
{ | ||
$fromform->disableoption = 0; | ||
} | ||
|
||
$sessiondates = array(); | ||
for ($i = 0; $i < $fromform->date_repeats; $i++) { | ||
if (!empty($fromform->datedelete[$i])) { | ||
|
@@ -147,6 +156,10 @@ | |
$todb->normalcost = $fromform->normalcost; | ||
$todb->discountcost = $fromform->discountcost; | ||
|
||
$todb->details = $fromform->details; | ||
$todb->disablenewenrolldays = $fromform->disablenewenrolldays; | ||
$todb->disableoption = $fromform->disableoption; | ||
|
||
$sessionid = null; | ||
$transaction = $DB->start_delegated_transaction(); | ||
|
||
|
@@ -228,6 +241,10 @@ | |
$toform->normalcost = $session->normalcost; | ||
$toform->discountcost = $session->discountcost; | ||
|
||
$toform->details = $session->details; | ||
$toform->disableoption = $session->disableoption; | ||
$toform->disablenewenrolldays = $session->disablenewenrolldays; | ||
|
||
if ($session->sessiondates) { | ||
$i = 0; | ||
foreach ($session->sessiondates as $date) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix indenting of this line