Skip to content

Instantly share code, notes, and snippets.

@ienliven
Last active December 11, 2015 05:18
Show Gist options
  • Save ienliven/4550870 to your computer and use it in GitHub Desktop.
Save ienliven/4550870 to your computer and use it in GitHub Desktop.
diff --git a/public/sapling/variants/canada/includes/div_login_form.php b/public/sapling/variants/canada/includes/div_login_form.php
index 0306157..6a0f811 100644
--- a/public/sapling/variants/canada/includes/div_login_form.php
+++ b/public/sapling/variants/canada/includes/div_login_form.php
@@ -15,20 +15,20 @@
var dataSend = {};
dataSend.fb_userid = FB_userid;
dataSend.email = false;
-
+
jQuery.ajax({
url: fb_server_path+"/ibiscms/auth/facebook/dao_facebook.php",
data: dataSend,
type: 'post',
success: function(data) {
if(data == 'true'){
- jQuery.getJSON("https://graph.facebook.com/"+FB_userid+"/&callback=?", function(json){
+ jQuery.getJSON("https://graph.facebook.com/"+FB_userid+"?callback=?", function(json){
replaceLoginFacebook(FB_userid, json);
});
}
else {
if(linked == 1){
- jQuery.getJSON("https://graph.facebook.com/"+FB_userid+"/&callback=?", function(json){
+ jQuery.getJSON("https://graph.facebook.com/"+FB_userid+"?callback=?", function(json){
location.replace(fb_server_path+'/ibiscms/auth/facebook/link_account.php');
});
}
@@ -74,9 +74,9 @@
startFacebook(false);
var htmlShow = '<form id="login" name="login" method="post" action="'+fb_server_path+'/ibiscms/login/index.php">';
htmlShow += '<ul>';
- htmlShow += '<li class="facebook_bt"><fb:login-button scope="email,user_location,user_hometown" onlogin="replaceLoginFacebook(\'\', \'\')"></fb:login-button></li>';
- htmlShow += '<li><div><label>username</label><input name="username" id="loginUser" type="text" onKeypress="doSubmitLoginReturn()" tabindex=1 /></div></li>';
- htmlShow += '<li class="borderright"><div><label>password</label> <input id="loginPass" name="password" class="password" type="password" onKeypress="doSubmitLoginReturn()" tabindex=2 /> <a class="go" href="javascript:document.login.submit()" tabindex=3></a><a href="'+fb_server_path+'/ibiscms/login/forgot_password.php" title="forgot it?" tabindex=5>forgot password?</a></div></li>';
+ htmlShow += '<li class="facebook_bt"><div id="facebook-bt-content"><fb:login-button scope="email,user_location,user_hometown" onlogin="replaceLoginFacebook(\'\', \'\')"></fb:login-button></div></li>';
+ htmlShow += '<li><div class="login-item"><label>username</label><input name="username" id="loginUser" type="text" onKeypress="doSubmitLoginReturn()" tabindex=1 /></div></li>';
+ htmlShow += '<li class="borderright"><div class="login-item"><label>password</label> <input id="loginPass" name="password" class="password" type="password" onKeypress="doSubmitLoginReturn()" tabindex=2 /> <a class="go" href="javascript:document.login.submit()" tabindex=3></a><a href="'+fb_server_path+'/ibiscms/login/forgot_password.php" title="forgot it?" tabindex=5>forgot password?</a></div></li>';
htmlShow += '<li><a class="help" href="/help"title="help">help</a></li>';
htmlShow += '</ul>';
htmlShow += '</form>';
@@ -93,9 +93,9 @@
});
}
}
-
+
function doSubmitLogin(){
-
+
if(jQuery('#loginPass').val() == ''){
jQuery('#loginPass').focus();
return false;
@@ -123,9 +123,9 @@
<div id="password">
<form id="login" name="login" method="post" action="<?= $SERVER_SETTINGS['TARGET_SSL_WWW'] ?>/ibiscms/login/index.php">
<ul>
- <li class="facebook_bt"><fb:login-button scope="email,user_location,user_hometown" onlogin="replaceLoginFacebook('', '')" width="100"></fb:login-button></li>
- <li><div><label>username</label><input id="loginUser" name="username" type="text" tabindex=1 /></div></li>
- <li class="borderright"><div><label>password</label> <input id="loginPass" name="password" class="password" type="password" tabindex=2 /> <a class="go" href="javascript:doSubmitLogin()" tabindex=3></a><a href="<?= $SERVER_SETTINGS['TARGET_SSL_WWW'] ?>/ibiscms/login/forgot_password.php" title="forgot it?" tabindex=5>forgot password?</a></div></li>
+ <li class="facebook_bt"><div id="facebook-bt-content"><fb:login-button scope="email,user_location,user_hometown" onlogin="replaceLoginFacebook('', '')" width="100"></fb:login-button></div></li>
+ <li><div class="login-item"><label>username</label><input id="loginUser" name="username" type="text" tabindex=1 /></div></li>
+ <li class="borderright"><div class="login-item"><label>password</label> <input id="loginPass" name="password" class="password" type="password" tabindex=2 /> <a class="go" href="javascript:doSubmitLogin()" tabindex=3></a><a href="<?= $SERVER_SETTINGS['TARGET_SSL_WWW'] ?>/ibiscms/login/forgot_password.php" title="forgot it?" tabindex=5>forgot password?</a></div></li>
<li><a class="help" href="/help"title="help">help</a></li>
</ul>
<input type="hidden" name="flashversion" id="flashversion"/>
@@ -138,13 +138,13 @@
</div>
<script>
$("#loginUser, #loginPass").keypress(function(evt) {
- if (evt.keyCode == 13){
+ if (evt.keyCode == 13){
doSubmitLogin();
}
});
-
+
function showBox(id, url){
- jQuery(".tab_content-login").hide();
+ jQuery(".tab_content-login").hide();
jQuery("ul.tabs-login li:eq("+id+")").addClass("active").show();
jQuery(".tab_content-login:eq("+id+")").show();
window.location.href = url;
@@ -154,13 +154,13 @@
jQuery("ul.tabs-login li").removeClass("active");
jQuery(this).addClass("active");
jQuery(".tab_content-login").hide();
-
+
var activeTab = jQuery(this).find("a").attr("href");
jQuery(activeTab).fadeIn();
});
jQuery(document).ready(function() {
- jQuery(".tab_content-login").hide();
+ jQuery(".tab_content-login").hide();
jQuery("ul.tabs-login li:eq(1)").addClass("active").show();
jQuery(".tab_content-login:eq(1)").show();
diff --git a/src/cds/classware/PeriodicTable.fla b/src/cds/classware/PeriodicTable.fla
index 866e1d7..53bd15d 100755
Binary files a/src/cds/classware/PeriodicTable.fla and b/src/cds/classware/PeriodicTable.fla differ
diff --git a/src/cds/classware/PeriodicTable.swf b/src/cds/classware/PeriodicTable.swf
index 1445c36..6905585 100644
Binary files a/src/cds/classware/PeriodicTable.swf and b/src/cds/classware/PeriodicTable.swf differ
diff --git a/src/cds/itemcredits/Credits.as b/src/cds/itemcredits/Credits.as
index 088319f..85a5d51 100644
--- a/src/cds/itemcredits/Credits.as
+++ b/src/cds/itemcredits/Credits.as
@@ -1 +1 @@
-class Credits
{
private var _firstname:String = "";
private var _lastname:String = "";
private var _institution:String = "";
private var _visibility:String = "";
private var _itemcopiedid:String = "";
private var _templatecopiedid:String = "";
private var _error:String = "";
public var callback:Function; // client can override to get a callback once the data is loaded
public function Credits() {} // constructor
public function load(creditsUrl:String):Void
{
var my_xml:XML = new XML();
my_xml.ignoreWhite=true;
my_xml.load(creditsUrl);
var thisObj:Credits = this; // need this so we can access credits instance from within callback function
my_xml.onLoad = function(success) {
if ( !success )
{
thisObj._error = "network failure";
}
else if ( my_xml.firstChild.nodeName == "error" )
{
thisObj._error = my_xml.firstChild.childNodes[0].nodeValue;
}
else
{
thisObj._firstname = my_xml.firstChild.childNodes[0].childNodes[0].nodeValue;
thisObj._lastname = my_xml.firstChild.childNodes[1].childNodes[0].nodeValue;
thisObj._institution = my_xml.firstChild.childNodes[2].childNodes[0].nodeValue;
thisObj._visibility = my_xml.firstChild.childNodes[3].childNodes[0].nodeValue;
thisObj._itemcopiedid = my_xml.firstChild.childNodes[4].childNodes[0].nodeValue;
thisObj._templatecopiedid = my_xml.firstChild.childNodes[5].childNodes[0].nodeValue;
}
thisObj.callback();
}
}
public function hasError():Boolean
{
return ( this._error.length > 0 );
}
public function getError()
{
return this._error;
}
public function get firstname():String
{
return this._firstname;
}
public function get lastname():String
{
return this._lastname;
}
public function get institution():String
{
return this._institution;
}
public function get visibility():String
{
return this._visibility;
}
public function get itemcopiedid():String
{
return this._itemcopiedid;
}
public function get templatecopiedid():String
{
return this._templatecopiedid;
}
}
\ No newline at end of file
+class Credits
{
private var _firstname:String = "";
private var _lastname:String = "";
private var _institution:String = "";
private var _visibility:String = "";
private var _itemcopiedid:String = "";
private var _templatecopiedid:String = "";
private var _error:String = "";
public var callback:Function; // client can override to get a callback once the data is loaded
public function Credits() {} // constructor
public function load(creditsUrl:String):Void
{
var my_xml:XML = new XML();
my_xml.ignoreWhite=true;
my_xml.load(creditsUrl);
var thisObj:Credits = this; // need this so we can access credits instance from within callback function
my_xml.onLoad = function(success) {
if ( !success )
{
thisObj._error = "network failure";
}
else if ( my_xml.firstChild.nodeName == "error" )
{
thisObj._error = my_xml.firstChild.childNodes[0].nodeValue;
}
else
{
thisObj._firstname = my_xml.firstChild.childNodes[0].childNodes[0].nodeValue;
thisObj._lastname = my_xml.firstChild.childNodes[1].childNodes[0].nodeValue;
thisObj._institution = my_xml.firstChild.childNodes[2].childNodes[0].nodeValue;
thisObj._visibility = my_xml.firstChild.childNodes[3].childNodes[0].nodeValue;
thisObj._itemcopiedid = my_xml.firstChild.childNodes[4].childNodes[0].nodeValue;
thisObj._templatecopiedid = my_xml.firstChild.childNodes[5].childNodes[0].nodeValue;
}
thisObj.callback();
}
}
public function hasError():Boolean
{
return ( this._error.length > 0 );
}
public function getError()
{
return this._error;
}
public function get firstname():String
{
return this._firstname;
}
public function get lastname():String
{
return this._lastname;
}
public function get institution():String
{
return this._institution;
}
public function get visibility():String
{
return this._visibility;
}
public function get itemcopiedid():String
{
return this._itemcopiedid;
}
public function get templatecopiedid():String
{
return this._templatecopiedid;
}
}
\ No newline at end of file
diff --git a/src/cds/itemcredits/SaplingLearning_header.fla b/src/cds/itemcredits/SaplingLearning_header.fla
index 286d296..94dc92a 100644
Binary files a/src/cds/itemcredits/SaplingLearning_header.fla and b/src/cds/itemcredits/SaplingLearning_header.fla differ
diff --git a/src/cds/itemcredits/SaplingLearning_header.swf b/src/cds/itemcredits/SaplingLearning_header.swf
index 09c88b2..b57d71c 100644
Binary files a/src/cds/itemcredits/SaplingLearning_header.swf and b/src/cds/itemcredits/SaplingLearning_header.swf differ
diff --git a/src/cds/modules/Text/mTextArea.as b/src/cds/modules/Text/mTextArea.as
index 5bab2c7..181b51e 100644
--- a/src/cds/modules/Text/mTextArea.as
+++ b/src/cds/modules/Text/mTextArea.as
@@ -1 +1 @@
-import components.ui.ssTextEntry
import modules.Text.mTextField
import components.ui.ssSpeechButton
/**
Single line text field module with various properties
@author Nathan Wheeler
@version June 19, 2007
*/
class modules.Text.mTextArea extends mTextField{
//constructor
function mTextArea(){
}
// PRIVATE MEMBERS
private var format_options:Array;
// END PRIVATE MEMBERS
// PUBLIC MEMBERS
/**
Returns format options
@return Array - format_options
*/
public function getFormatOptions(){
return format_options;
}
/**
Initializes textarea module
@return Void
*/
private var speechButton : MovieClip;
private function init():Void{
super.init(true);
var o = {startText:"Enter text here: ", multiline:true, wordWrap:true, width:(width == -1) ? 300 : width, border:false, autoBorder:true};
o.autoSize = (initProps.autoSize == undefined) ? "left" : initProps.autoSize;
if(o.autoSize == "none"){
if(initProps.numLines != undefined){
o.numLines = initProps.numLines;
}else if(height != -1){
o.height = height;
}
}
this.createIbisClip(ssTextEntry,"tf__", o, 2);
if(this.isMarkup) this.tf__.defaultColor = 0xCB1616;
this._nohighlight_ = true;
tf__.addEventListener("tab", this);
tf__.addEventListener("resize", this);
tf__.field.formattable = true;
format_options = new Array("boldtext", "italictext", "subtext", "suptext", "urltext", {head:true, font:"Arial Reduced", label:"δ", children:"greek", toolTipText:"lowercase greek alphabet"},{head:true, font:"Arial Reduced", label:"Δ", children:"Greek", toolTipText:"uppercase greek alphabet"},{head:true, headInit:{icon:components.eqEntry.ssEqEntry, iconParams:{laTex:"\\lte\\inf", displayMode:"chemistry", _xscale:65, _yscale:65, enabled:false}}, toolTipText:"special characters", children:"relationals,operators,symbols"}, {head:true, font:'Arial Reduced', label:"C=C", children:'bonds', toolTipText:'bonds'});
this.resizemode__ = "both";
this.owner = "Text/mTextArea";
this.currentVersion = 20100222;
this.editorSet = {question:"Text/qTextAreaEditor.swf", student:"Text/ssTextAreaEditor.swf"};
this.usageChangeable = false;
this.usage = "static";
}
private function draw () {
super.draw();
if(core.Globals.appMode == "student") {
var owner = this;
speechButton = createIbisClip(ssSpeechButton, "speechButton", {toolTipText: "launch text for screen reader", transparentBackground:true, icon:"SpeechIcon", iconType:"attached", toolTipText:"click to hear audio", autoSize:true, _width: 18, _height:18, _visible:false}, 12345);
speechButton.onRelease = function () {
var tempText : String = (String(owner.tf__.text) == "") ? owner.tf__.field.text : owner.tf__.text;
this.textToSpeech(tempText);
}
this.onMouseMove = function () {
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
owner.speechButton._visible = true;
} else {
owner.speechButton._visible = false;
}
}
}
}
}
\ No newline at end of file
+import components.ui.ssTextEntry
import modules.Text.mTextField
import components.ui.ssSpeechButton
/**
Single line text field module with various properties
@author Nathan Wheeler
@version June 19, 2007
*/
class modules.Text.mTextArea extends mTextField{
//constructor
function mTextArea(){
}
// PRIVATE MEMBERS
private var format_options:Array;
// END PRIVATE MEMBERS
// PUBLIC MEMBERS
/**
Returns format options
@return Array - format_options
*/
public function getFormatOptions(){
return format_options;
}
/**
Initializes textarea module
@return Void
*/
private var speechButton : MovieClip;
private function init():Void{
super.init(true);
var o = {startText:"Enter text here: ", multiline:true, wordWrap:true, width:(width == -1) ? 300 : width, border:false, autoBorder:true};
o.autoSize = (initProps.autoSize == undefined) ? "left" : initProps.autoSize;
if(o.autoSize == "none"){
if(initProps.numLines != undefined){
o.numLines = initProps.numLines;
}else if(height != -1){
o.height = height;
}
}
this.createIbisClip(ssTextEntry,"tf__", o, 2);
if(this.isMarkup) this.tf__.defaultColor = 0xCB1616;
this._nohighlight_ = true;
tf__.addEventListener("tab", this);
tf__.addEventListener("resize", this);
tf__.field.formattable = true;
format_options = new Array("boldtext", "italictext", "subtext", "suptext", "urltext", {head:true, font:"Arial Reduced", label:"δ", children:"greek", toolTipText:"lowercase greek alphabet"},{head:true, font:"Arial Reduced", label:"Δ", children:"Greek", toolTipText:"uppercase greek alphabet"},{head:true, headInit:{icon:components.eqEntry.ssEqEntry, iconParams:{laTex:"\\lte\\inf", displayMode:"chemistry", _xscale:65, _yscale:65, enabled:false}}, toolTipText:"special characters", children:"relationals,operators,symbols"}, {head:true, font:'Arial Reduced', label:"C=C", children:'bonds', toolTipText:'bonds'});
this.resizemode__ = "both";
this.owner = "Text/mTextArea";
this.currentVersion = 20100222;
this.editorSet = {question:"Text/qTextAreaEditor.swf", student:"Text/ssTextAreaEditor.swf"};
this.usageChangeable = false;
this.usage = "static";
}
private function draw () {
super.draw();
if(core.Globals.appMode == "student") {
var owner = this;
speechButton = createIbisClip(ssSpeechButton, "speechButton", {toolTipText: "launch text for screen reader", transparentBackground:true, icon:"SpeechIcon", iconType:"attached", toolTipText:"click to hear audio", autoSize:true, _width: 18, _height:18, _visible:false}, 12345);
//this mouse click func is now inside of the hittest below as a onMouseDown for redmine#2452 to allow clicking bubble on disabled modules on response tabs
/*speechButton.onRelease = function () {
var tempText : String = (String(owner.tf__.text) == "") ? owner.tf__.field.text : owner.tf__.text;
this.textToSpeech(tempText);
}*/
this.onMouseMove = function () {
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
//this mouse click func for redmine#2452 to allow clicking bubble on disabled modules on response tabs
this.onMouseDown = function(){
if(speechButton.hitTest(_root._xmouse, _root._ymouse, true)){
var tempText : String = (String(owner.tf__.text) == "") ? owner.tf__.field.text : owner.tf__.text;
speechButton.textToSpeech(tempText);
}
}
owner.speechButton._visible = true;
} else {
if(core.Globals.tabType != "question"){
}
owner.speechButton._visible = false;
delete this.onMouseDown;
}
}
}
}
}
\ No newline at end of file
diff --git a/src/cms/moodle/admin/course/lib.php b/src/cms/moodle/admin/course/lib.php
index e3c4428..df00d6c 100755
--- a/src/cms/moodle/admin/course/lib.php
+++ b/src/cms/moodle/admin/course/lib.php
@@ -73,11 +73,12 @@ function filterCourses($page, $perpage, $placeReturn="course")
}
// End: Feature #1105 Moodle: Create New-and-Improved "Add/edit courses" to Use New Settings for Sorting
+ // Bug #2661 - Move extra configuration from course to sl_course_settings
if($subject > 0)
- $sqlFilter[] = "c.Subject_ID = $subject";
+ $sqlFilter[] = "sc.Subject_ID = $subject";
if($institution > 0)
- $sqlFilter[] = "c.institution = $institution";
+ $sqlFilter[] = "sc.institution = $institution";
if(!empty($startDate))
{
@@ -90,7 +91,8 @@ function filterCourses($page, $perpage, $placeReturn="course")
{
$tmpParts = explode('/', $endDate);
$timestamp = strtotime("{$tmpParts[2]}/{$tmpParts[0]}/{$tmpParts[1]}");
- $sqlFilter[] = "c.sl_enddate <= $timestamp";
+ // Bug #2661 - Move extra configuration from course to sl_course_settings
+ $sqlFilter[] = "sc.sl_enddate <= $timestamp";
}
if(!empty($sqlFilter))
@@ -102,6 +104,7 @@ function filterCourses($page, $perpage, $placeReturn="course")
$limit->pageSize = $perpage;
$limit->start = $page * $limit->pageSize;
$limit->end = $limit->start + $limit->pageSize - 1;
+ // Bug #2661 - Move extra configuration from course to sl_course_settings
$sql = "SELECT
c.id,
c.sortorder,
@@ -113,10 +116,12 @@ function filterCourses($page, $perpage, $placeReturn="course")
s.name subject
FROM
$moodleDB.course c
+ LEFT JOIN $moodleDB.sl_course_settings sc
+ ON c.id= sc.course_id
LEFT JOIN $moodleDB.institution i
- ON c.institution = i.id
+ ON sc.institution = i.id
LEFT JOIN $contentDB.subject s
- ON c.Subject_ID = s.Key
+ ON sc.Subject_ID = s.Key
$categoryFilter
$sqlFilter
ORDER BY
@@ -328,7 +333,7 @@ function filterCourses($page, $perpage, $placeReturn="course")
array(
!empty($course->actions) ? implode('&nbsp;&nbsp;', $course->actions) : '',
"<a href='{$CFG->wwwroot}/course/view.php?id={$course->id}' title='{$course->fullname}'>{$course->shortname}</a>",
- $course->instructors,
+ isset($course->instructors) ? $course->instructors : '',
isset($course->institutionName) ? $course->institutionName : '',
isset($course->subject) ? $course->subject : ''
)
diff --git a/src/cms/moodle/admin/courserequest/dao_create_users_courses.php b/src/cms/moodle/admin/courserequest/dao_create_users_courses.php
index d8ece87..c92c233 100644
--- a/src/cms/moodle/admin/courserequest/dao_create_users_courses.php
+++ b/src/cms/moodle/admin/courserequest/dao_create_users_courses.php
@@ -141,8 +141,10 @@
//Feature #1474 - High School: Set Initial course.userlimit Values (Teacher Tools)
$contextusersGet = get_role_users(5, $context, false, 'u.id, u.firstname, u.lastname');
- $course->userlimit = ceil(1.05 * count($contextusersGet));
- update_record('course', $course);
+ // Bug #2661 - Move extra configuration from course to sl_course_settings
+ $sl_course_settings = get_record('sl_course_settings', 'course_id', $course->id);
+ $sl_course_settings->userlimit = ceil(1.05 * count($contextusersGet));
+ update_record('sl_course_settings', $sl_course_settings);
}
$fileName = substr($requestRQ->district, 0, 3).substr($requestRQ->school, 0, 3).substr($subjectRQ->name, 0, 3).mktime();
diff --git a/src/cms/moodle/auth/facebook/link_account_confirm.html b/src/cms/moodle/auth/facebook/link_account_confirm.html
index 9952ffd..1dd79af 100644
--- a/src/cms/moodle/auth/facebook/link_account_confirm.html
+++ b/src/cms/moodle/auth/facebook/link_account_confirm.html
@@ -1,63 +1,63 @@
<div class="loginbox clearfix onecolumn">
- <div class="loginpanel">
- <p><?php print_string("accountreviewconfirm", "auth_facebook") ?></p>
- <div id="facebook-user-login" style="padding-left: 30%;"><!-- --></div>
-
- <div class="subcontent loginsub">
- <form action="<?php print $CFG->wwwsslroot .'/login/index.php' ?>" method="post" id="login">
- <input type="hidden" name="username" id="username" size="15" value="<?=$username ?>" />
- <input type="hidden" name="password" id="password" size="15" value="<?=$password ?>" />
- <input type="hidden" name="fb_userid" id="fb_userid" size="15" value="" />
- <input type="hidden" name="testcookies" value="1" />
- <input type="hidden" name="fb_login" value="2" />
- <div class="loginform">
- <div style="float:left;">
- <h2>Facebook account:</h2>
- <div id="div-facebook-data"></div>
- </div>
- <div style="float:right;">
- <h2>Sapling Learning account:</h2>
- <center></center>
- <p><b>Name:</b> <?=$user->firstname ?> <?=$user->lastname ?></p>
- <p><b>E-Mail:</b> <?=$user->email ?></p>
- </div>
+ <div class="loginpanel">
+ <p><?php print_string("accountreviewconfirm", "auth_facebook") ?></p>
+ <div id="facebook-user-login" style="padding-left: 30%;"><!-- --></div>
- <div class="clearer"><!-- --></div>
- </div>
- <div class="form-input">
- <input id="submit_confirm" type="submit" value="Confirm account link" disabled />
- </div>
- </form>
-
- </div>
- </div>
+ <div class="subcontent loginsub">
+ <form action="<?php print $CFG->wwwsslroot .'/login/index.php' ?>" method="post" id="login">
+ <input type="hidden" name="username" id="username" size="15" value="<?=$username ?>" />
+ <input type="hidden" name="password" id="password" size="15" value="<?=$password ?>" />
+ <input type="hidden" name="fb_userid" id="fb_userid" size="15" value="" />
+ <input type="hidden" name="testcookies" value="1" />
+ <input type="hidden" name="fb_login" value="2" />
+ <div class="loginform">
+ <div style="float:left;">
+ <h2>Facebook account:</h2>
+ <div id="div-facebook-data"></div>
+ </div>
+ <div style="float:right;">
+ <h2>Sapling Learning account:</h2>
+ <center></center>
+ <p><b>Name:</b> <?=$user->firstname ?> <?=$user->lastname ?></p>
+ <p><b>E-Mail:</b> <?=$user->email ?></p>
+ </div>
+
+ <div class="clearer"><!-- --></div>
+ </div>
+ <div class="form-input">
+ <input id="submit_confirm" type="submit" value="Confirm account link" disabled />
+ </div>
+ </form>
+
+ </div>
+ </div>
</div>
<div id="fb-root"></div>
<script src="https://connect.facebook.net/en_US/all.js"></script>
<?php
- require_js(array("$CFG->wwwsslroot/lib/jQuery/jquery-1.5.1.min.js"));
+require_js(array("$CFG->wwwsslroot/lib/jQuery/jquery-1.5.1.min.js"));
?>
<script>
-$(document).ready(function() {
- FB.getLoginStatus(function(response) {
- if (response.authResponse) {
- $.getJSON("https://graph.facebook.com/"+response.authResponse.userID+"/&callback=?", function(json){
-
- var FB_userid = response.authResponse.userID;
- var FB_name = json.name;
- var FB_link = json.link;
-
- if(FB_userid){
- document.getElementById('fb_userid').value = FB_userid;
- document.getElementById('div-facebook-data').innerHTML = '<div style="padding:10px;"><center><a href="'+FB_link+'" target="_blank">'
- +'<img src="https://graph.facebook.com/'+FB_userid+'/picture" border="0" title="'+FB_name+'" /></a></center><br />'
- +'Name: <a href="'+FB_link+'" target="_blank">'+FB_name+'</a><br />'
- +'<a href="'+fb_server_path+'/auth/facebook/logoff.php?url='+escape(window.location)+'">(Logout)</a>'
- +'</div>';
- document.getElementById('submit_confirm').disabled = false;
- }
- });
- }
- });
-});
+ $(document).ready(function() {
+ FB.getLoginStatus(function(response) {
+ if (response.authResponse) {
+ $.getJSON("https://graph.facebook.com/"+response.authResponse.userID+"?callback=?", function(json){
+
+ var FB_userid = response.authResponse.userID;
+ var FB_name = json.name;
+ var FB_link = json.link;
+
+ if(FB_userid){
+ document.getElementById('fb_userid').value = FB_userid;
+ document.getElementById('div-facebook-data').innerHTML = '<div style="padding:10px;"><center><a href="'+FB_link+'" target="_blank">'
+ +'<img src="https://graph.facebook.com/'+FB_userid+'/picture" border="0" title="'+FB_name+'" /></a></center><br />'
+ +'Name: <a href="'+FB_link+'" target="_blank">'+FB_name+'</a><br />'
+ +'<a href="'+fb_server_path+'/auth/facebook/logoff.php?url='+escape(window.location)+'">(Logout)</a>'
+ +'</div>';
+ document.getElementById('submit_confirm').disabled = false;
+ }
+ });
+ }
+ });
+ });
</script>
\ No newline at end of file
diff --git a/src/cms/moodle/backup/backuplib.php b/src/cms/moodle/backup/backuplib.php
index 0734543..1830d6e 100644
--- a/src/cms/moodle/backup/backuplib.php
+++ b/src/cms/moodle/backup/backuplib.php
@@ -710,6 +710,7 @@
//Get info from course
$course = get_record("course","id",$preferences->backup_course);
+ $sl_course_settings = get_record('sl_course_settings', 'course_id', $course->id);
$context = get_context_instance(CONTEXT_COURSE, $course->id);
if ($course) {
//Prints course info
@@ -836,7 +837,8 @@
// Feature #1372 Moodle: Remember sl_enddate on Course Backup and Restore
// Feature #1436 Moodle: Even Better Course Duplication
- fwrite ($bf,full_tag("SLENDDATE",3,false, isset($preferences->newEndDate) ? $preferences->newEndDate : $course->sl_enddate));
+ // Bug #2661 - Move extra configuration from course to sl_course_settings
+ fwrite ($bf,full_tag("SLENDDATE",3,false, isset($preferences->newEndDate) ? $preferences->newEndDate : $sl_course_settings->sl_enddate));
$numSections = $course->numsections;
diff --git a/src/cms/moodle/backup/duplicate.php b/src/cms/moodle/backup/duplicate.php
index e497c48..7fcc579 100644
--- a/src/cms/moodle/backup/duplicate.php
+++ b/src/cms/moodle/backup/duplicate.php
@@ -103,6 +103,8 @@
if (!$course = get_record("course", "id", $id)) {
error("Course ID was incorrect (can't find it)");
}
+ // Bug #2661 - Move extra configuration from course to sl_course_settings
+ $sl_course_settings = get_record('sl_course_settings', 'course_id', $course->id);
//Print header
if (has_capability('moodle/site:backup', get_context_instance(CONTEXT_SYSTEM))) {
@@ -347,11 +349,12 @@
//Feature #1436 Moodle: Even Better Course Duplication
echo '<script type="text/javascript">var pathServer = "' . $CFG->wwwroot . '";</script>';
- if ($course->institution)
- $institution = get_record('institution', 'id', $course->institution);
+ // Bug #2661 - Move extra configuration from course to sl_course_settings
+ if ($sl_course_settings->institution)
+ $institution = get_record('institution', 'id', $sl_course_settings->institution);
?>
<input type="text" name="institution_name" id="id_institution_name" value="<?php echo $institution->name; ?>" disabled="disabled" onBlur="getTimeBlur()" />
- <input type="hidden" name="institution" id="institution" value="<?php echo $course->institution; ?>" />
+ <input type="hidden" name="institution" id="institution" value="<?php echo $sl_course_settings->institution; ?>" />
<script type="text/javascript">getInstitutions();</script>
</p>
<div id="institution-form" title="Add New Institution">
@@ -482,7 +485,8 @@
$cfgenddate = date('U', mktime(0, 0, 0, $cfgenddate[1], $cfgenddate[0], $cfgenddate[2]));
print_date_selector('sl_enddate[day]', 'sl_enddate[month]', 'sl_enddate[year]', $cfgenddate);
- print_checkbox('sl_enddatedisabled', null, $course->sl_enddate == 0, get_string('disable'));
+ // Bug #2661 - Move extra configuration from course to sl_course_settings
+ print_checkbox('sl_enddatedisabled', null, $sl_course_settings->sl_enddate == 0, get_string('disable'));
?>
</p>
</fieldset>
@@ -609,7 +613,8 @@
<label>
User Limit
</label>
- <input type="text" name="userlimit" value="<?php echo $course->userlimit; ?>" maxlength="4" size="4" onblur="extractNumber(this,0,true);" onkeyup="extractNumber(this,0,true);" style="width:auto;" />
+ <?php // Bug #2661 - Move extra configuration from course to sl_course_settings ?>
+ <input type="text" name="userlimit" value="<?php echo $sl_course_settings->userlimit; ?>" maxlength="4" size="4" onblur="extractNumber(this,0,true);" onkeyup="extractNumber(this,0,true);" style="width:auto;" />
</p>
</fieldset>
<fieldset>
@@ -721,8 +726,9 @@
<b>Course Price</b>
</legend>
<?php
- if ($course->institution)
- $institution = get_record('institution', 'id', $course->institution);
+ // Bug #2661 - Move extra configuration from course to sl_course_settings
+ if ($sl_course_settings->institution)
+ $institution = get_record('institution', 'id', $sl_course_settings->institution);
$multidiscount = $institution->multicoursediscount ? $institution->multicoursediscount : 0;
$course->cost = ($course->cost == "") ? 0 : $course->cost;
@@ -730,7 +736,8 @@
<script type='text/javascript'>var courseConfigCost = <?php echo $course->cost; ?>;</script>
<script type='text/javascript'>var institutionMultiDiscount = <?php echo $multidiscount; ?>;</script>
<script type='text/javascript'>doStartGets('/ibiscms/course/')</script>
- <input type="hidden" id="id_Subject_ID" value="<?php echo $course->Subject_ID; ?>" />
+ <?php // Bug #2661 - Move extra configuration from course to sl_course_settings ?>
+ <input type="hidden" id="id_Subject_ID" value="<?php echo $sl_course_settings->Subject_ID; ?>" />
<p>
<label for="bigcoursediscount">
<?php echo get_string('suggestbigdiscount'); ?>
diff --git a/src/cms/moodle/backup/refresh.php b/src/cms/moodle/backup/refresh.php
index b07546f..381a4fe 100644
--- a/src/cms/moodle/backup/refresh.php
+++ b/src/cms/moodle/backup/refresh.php
@@ -166,8 +166,9 @@ if(empty($refresh)):
else:
execute_sql("UPDATE sl_course_settings SET allow_refresh='no' WHERE course_id='$id'", false);
- execute_sql("UPDATE course SET sl_enddate = UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 DAY))
- WHERE id='$id' AND (sl_enddate IS NULL OR sl_enddate = 0 OR sl_enddate > UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 DAY)))", false);
+ // Bug #2661 - Move extra configuration from course to sl_course_settings
+ execute_sql("UPDATE sl_course_settings SET sl_enddate = UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 DAY))
+ WHERE course_id='$id' AND (sl_enddate IS NULL OR sl_enddate = 0 OR sl_enddate > UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 DAY)))", false);
$course->visible = 0;
$newCourseName = preg_replace('/^(\d{4}) - /', '', $course->fullname);
diff --git a/src/cms/moodle/backup/restorelib.php b/src/cms/moodle/backup/restorelib.php
index db327b7..413427a 100644
--- a/src/cms/moodle/backup/restorelib.php
+++ b/src/cms/moodle/backup/restorelib.php
@@ -924,6 +924,11 @@ define('RESTORE_GROUPS_GROUPINGS', 3);
$fields = '';
$values = '';
foreach ($course_header->sl_course_settings as $key => $value) {
+ // Bug #2661 - Move extra configuration from course to sl_course_settings - Course end date fix
+ if($key == 'sl_enddate') {
+ if (isset($restore->course_sl_enddate))
+ $value = $restore->course_sl_enddate;
+ }
$fields .= $key.',';
// Bug #2512 - Taxonomy is lost during creatinator
// HOTFIX - No Home Taxonomy When Duplicating or Restoring
diff --git a/src/cms/moodle/course/dao_get_course_by_institution.php b/src/cms/moodle/course/dao_get_course_by_institution.php
index 495add6..4fac7de 100644
--- a/src/cms/moodle/course/dao_get_course_by_institution.php
+++ b/src/cms/moodle/course/dao_get_course_by_institution.php
@@ -16,12 +16,16 @@
$institution = get_record('institution', 'id', $id);
- $sqlGetCourses = "SELECT * FROM course WHERE course.visible = 1
+ // Bug #2661 - Move extra configuration from course to sl_course_settings
+ $sqlGetCourses = "SELECT course.*, sc.* FROM course, sl_course_settings sc
+ WHERE sc.institution = $institution->id
+ AND course.id = sc.course_id
+ AND course.visible = 1
AND (course.enrollable = 1 OR (course.enrollable = 2 AND course.enrolstartdate <= $now AND (course.enrolenddate = 0 OR course.enrolenddate >= $now)))
AND course.enrolstartdate <= $now
AND (course.enrolenddate = 0 OR course.enrolenddate >= $now)
- AND (course.sl_enddate IS NULL OR course.sl_enddate = 0 OR course.sl_enddate >= $now)
- AND course.institution = " . $institution->id . " order by term";
+ AND (sc.sl_enddate IS NULL OR sc.sl_enddate = 0 OR sc.sl_enddate >= $now)
+ AND order by sc.term";
$courses = get_records_sql($sqlGetCourses);
echo ($courses) ? '<a name="showCourse_' . $institution->id . '"></a>' . print_center_courses_no_enrol('inst_' . $institution->id, $courses, $institution, false) : 'false';
diff --git a/src/cms/moodle/course/edit.php b/src/cms/moodle/course/edit.php
index 685ad0e..433e29f 100644
--- a/src/cms/moodle/course/edit.php
+++ b/src/cms/moodle/course/edit.php
@@ -92,6 +92,9 @@
$taxonomy = get_record($GLOBALS['SERVER_SETTINGS']['TARGET_CONTENT_DATABASE'].'.taxonomy', '`Key`', $sl_course_settings->home_taxonomy);
$taxonomyReading = get_record($GLOBALS['SERVER_SETTINGS']['TARGET_CONTENT_DATABASE'].'.taxonomy_reading', '`taxonomy__Key`', $taxonomy->Key);
+ $course->isbn10 = ($taxonomy->isbn10) ? $taxonomy->isbn10 : null;
+ $course->isbn13 = ($taxonomy->isbn13) ? $taxonomy->isbn13 : null;
+
$course->taxonomy_taxid = $taxonomy->Key;
$course->taxonomy_reading = ($taxonomyReading) ? $taxonomyReading->taxonomy__Key : false;
@@ -192,8 +195,22 @@
mark_context_dirty($context->path);
}
+ $real_textbok = (!$data->real_textbook) ? 'no' : 'yes';
+
+ // Bug #2661 - Move extra configuration from course to sl_course_settings
//Task #2036 - Update Settings and Associated Pages to Use Better Taxonomy Finding
- execute_sql("INSERT INTO sl_course_settings (course_id, home_taxonomy) VALUES ($data->id, $data->home_taxonomy) ON DUPLICATE KEY UPDATE home_taxonomy = $data->home_taxonomy", false);
+ execute_sql("INSERT INTO sl_course_settings (course_id, home_taxonomy, real_textbook,
+ Subject_ID, institution, userlimit, sl_enddate)
+ VALUES ($data->id, $data->home_taxonomy, '$real_textbok', '$data->Subject_ID',
+ '$data->institution', '$data->userlimit', '$data->sl_enddate')
+ ON DUPLICATE KEY UPDATE
+ real_textbook = '$real_textbok',
+ home_taxonomy = $data->home_taxonomy,
+ Subject_ID = '$data->Subject_ID',
+ institution = '$data->institution',
+ userlimit = '$data->userlimit',
+ sl_enddate = '$data->sl_enddate'
+ ", false);
//Temporary to course.idnumber crap (:
$taxTemp = get_record($GLOBALS['SERVER_SETTINGS']['TARGET_CONTENT_DATABASE'].'.taxonomy', '`Key`', $data->home_taxonomy);
@@ -219,7 +236,8 @@
//For Required (calculate to include or not)
if($data->reading_integrate == 'required'){
$nowPlusDays = strtotime("+".$reading_price['days']." days", $dateNow);
- if($nowPlusDays >= $course->sl_enddate){
+ // Bug #2661 - Move extra configuration from course to sl_course_settings
+ if($nowPlusDays >= $sl_course_settings->sl_enddate){
$sql = "INSERT INTO reading_course_pricing (taxonomy__Key, course__id, days, publisher_price, sapling_price) VALUES ($data->reading_integrate_taxid, $data->id, ".$reading_price['days'].", ".$reading_price['publisher_price'].", ".$reading_price['sapling_price'].") ON DUPLICATE KEY UPDATE publisher_price = ".$reading_price['publisher_price'].", sapling_price = ".$reading_price['sapling_price'];
$stmts[] = new SDB_STATEMENT($sql, array(), true);
}
diff --git a/src/cms/moodle/course/edit_form.php b/src/cms/moodle/course/edit_form.php
index 1123536..158e57e 100644
--- a/src/cms/moodle/course/edit_form.php
+++ b/src/cms/moodle/course/edit_form.php
@@ -135,17 +135,18 @@
$mform->addElement('html', '<script type="text/javascript" src="' . $CFG->wwwroot . '/lib/jQuery/jquery.jsonSuggest-2.js"></script>');
$mform->addElement('html', '<script type="text/javascript" src="' . $CFG->wwwroot . '/lib/jQuery/course_edit_suggest_call.js"></script>');
- if ($course->institution) {
- $institution = get_record('institution', 'id', $course->institution);
+ // Bug #2661 - Move extra configuration from course to sl_course_settings
+ if ($sl_course_settings->institution) {
+ $institution = get_record('institution', 'id', $sl_course_settings->institution);
}
- $mform->addElement('text', 'institution_name', 'Institution', 'size="100" value="' . $institution->name . '" disabled="disabled" onBlur="getTimeBlur()"');
+ $mform->addElement('text', 'institution_name', 'Institution', 'size="100" value="' . (isset($institution->name) ? $institution->name : '') . '" disabled="disabled" onBlur="getTimeBlur()"');
$mform->setHelpButton('institution_name', array('institution_name', 'Institution'), true);
$mform->addElement('hidden', 'institution', 0, 'id="institution"');
$mform->setType('institution', PARAM_INT);
- $mform->setDefault('institution', $course->institution);
+ $mform->setDefault('institution', $sl_course_settings->institution);
$mform->addElement('html', '<script>getInstitutions()</script>');
@@ -225,7 +226,8 @@
}
}
$mform->addElement('select', 'Subject_ID', get_string('coursesubject'), $subjec, array('onchange' => 'doStartGets(); mountTaxonomySelect(this.value)'));
- $mform->setDefault('Subject_ID', '0');
+ // Bug #2661 - changes to subject not saving correctly
+ $mform->setDefault('Subject_ID', $sl_course_settings->Subject_ID ? $sl_course_settings->Subject_ID : '0');
$mform->setType('Subject_ID', PARAM_RAW);
//Taxonomies Reading
@@ -244,6 +246,9 @@
$courseTaxonomy = get_record($GLOBALS['SERVER_SETTINGS']['TARGET_CONTENT_DATABASE'].".taxonomy t", "t.Key", $sl_course_settings->home_taxonomy);
$subjectData = ($courseTaxonomy->subject__Key) ? $courseTaxonomy->subject__Key : 0;
+ $isbn10 = ($courseTaxonomy->isbn10) ? $courseTaxonomy->isbn10 : 0;
+ $isbn13 = ($courseTaxonomy->isbn13) ? $courseTaxonomy->isbn13 : 0;
+
if($courseTaxonomy->short_title){
$titleDisplay = utf8_encode($courseTaxonomy->short_title);
}
@@ -258,7 +263,7 @@
$authors = get_records_sql($sqlAuthors);
$titleDisplay .= authorsName($authors);
}
- $jsTaxonomyArray .= 'var tempData = {}; tempData.Key = '.$courseTaxonomy->Key.'; tempData.title = "'.$titleDisplay.'"; tempData.subject__Key = '.$subjectData.'; arrayTaxonomies.push(tempData);';
+ $jsTaxonomyArray .= 'var tempData = {}; tempData.Key = '.$courseTaxonomy->Key.'; tempData.title = "'.$titleDisplay.'"; tempData.subject__Key = '.$subjectData.'; tempData.isbn10 = '.$isbn10.'; tempData.isbn13 = '.$isbn13.'; arrayTaxonomies.push(tempData);';
$taxData[$courseTaxonomy->Key] = $titleDisplay;
foreach ($taxonomies as $key => $val) {
@@ -280,7 +285,10 @@
$titleDisplay .= authorsName($authors);
}
- $jsTaxonomyArray .= 'var tempData = {}; tempData.Key = '.$val->Key.'; tempData.title = "'.$titleDisplay.'"; tempData.subject__Key = '.$subjectData.'; arrayTaxonomies.push(tempData);';
+ $isbn10 = ($val->isbn10) ? $val->isbn10 : 0;
+ $isbn13 = ($val->isbn13) ? $val->isbn13 : 0;
+
+ $jsTaxonomyArray .= 'var tempData = {}; tempData.Key = '.$val->Key.'; tempData.title = "'.$titleDisplay.'"; tempData.subject__Key = '.$subjectData.'; tempData.isbn10 = '.$isbn10.'; tempData.isbn13 = '.$isbn13.'; arrayTaxonomies.push(tempData);';
$taxData[$val->Key] = $titleDisplay;
}
}
@@ -290,10 +298,21 @@
$mform->addRule('home_taxonomy', get_string('missinghome_taxonomy'), 'required', null, 'client');
//Javascript Arrays
- $jsTaxonomyArray .= 'setCurrentHomeTaxonomy('.$sl_course_settings->home_taxonomy.'); mountTaxonomySelect('.$course->Subject_ID.');</script>';
+ // Bug #2661 - Move extra configuration from course to sl_course_settings
+ $jsTaxonomyArray .= 'setCurrentHomeTaxonomy('.$sl_course_settings->home_taxonomy.'); mountTaxonomySelect('.$sl_course_settings->Subject_ID.');</script>';
$mform->addElement('html', $jsTaxonomyArray);
}
+ //Feature #2743 - Add Course Setting for Chegg
+ if ($iscreator) {
+ $mform->addElement('checkbox', 'real_textbook', get_string('real_textbook'), null, array('id' => 'real_textbook'));
+ $real_textbook = ($sl_course_settings->real_textbook == 'yes') ? 1 : 0;
+ $mform->setDefault('real_textbook', $real_textbook);
+
+ $mform->addElement('hidden', 'course_isbn10', $course->isbn10, 'id="course_isbn10"');
+ $mform->addElement('hidden', 'course_isbn13', $course->isbn13, 'id="course_isbn13"');
+ }
+
// Feature #1084 - Moodle: Admin Add Term to Courses
if ($iscreator) {
@@ -374,17 +393,23 @@
$coursedatestartgrp[] = &MoodleQuickForm::createElement('date_selector', 'sl_enddate');
$coursedatestartgrp[] = &MoodleQuickForm::createElement('checkbox', 'sl_enddatedisabled', null, get_string('disable'));
$mform->addGroup($coursedatestartgrp, 'sl_enddategrp', get_string('sl_enddate'), ' ', false);
- if ($course->sl_enddate == 0) {
+ // Bug #2661 - Move extra configuration from course to sl_course_settings
+ if ($sl_course_settings->sl_enddate == 0) {
$mform->setDefault('sl_enddatedisabled', 1);
+ $cfgendatate = explode('-', $CFG->defaultcourseenddate);
+ $defaultEndDate = mktime(0, 0, 0, $cfgendatate[1], $cfgendatate[0]+1, $cfgendatate[2]);
+ }
+ else {
+ $defaultEndDate = $sl_course_settings->sl_enddate;
}
+ // Feature #2361 - Add Category and End Date to Default Course Settings
+ $mform->setDefault('sl_enddate', date('U', $defaultEndDate));
+
$mform->disabledIf('sl_enddategrp', 'sl_enddatedisabled', 'checked');
//End Feature #1073
- // Feature #2361 - Add Category and End Date to Default Course Settings
- $cfgendatate = explode('-', $CFG->defaultcourseenddate);
- $mform->setDefault('sl_enddate', date('U', mktime(0, 0, 0, $cfgendatate[1], $cfgendatate[0]+1, $cfgendatate[2])));
$choices = array();
$choices['0'] = get_string('hiddensectionscollapsed');
@@ -564,7 +589,7 @@
//End Feature #1091
//Feature #1472 - High School: Course User Limits (Teacher Tools)
$mform->addElement('text', 'userlimit', 'User Limit: ', 'maxlength="4" size="4" onblur="extractNumber(this,0,true);" onkeyup="extractNumber(this,0,true);"');
- $mform->setDefault('userlimit', $course->userlimit);
+ $mform->setDefault('userlimit', $sl_course_settings->userlimit);
}
@@ -854,7 +879,8 @@
$nowPlusDays = strtotime("+".$reading_price['days']." days", $dateNow);
$classSpan = '';
- if($nowPlusDays >= $course->sl_enddate){
+ // Bug #2661 - Move extra configuration from course to sl_course_settings
+ if($nowPlusDays >= $sl_course_settings->sl_enddate){
$classSpan = 'required-only';
}
@@ -868,7 +894,8 @@
$priceShowLabel = '<div id="content_reading_pricing"><div class="fitem"><div class="fitemtitle"><label for="id_reading_price">Price: </label></div><div class="felement ftext"><span style="font-size:12px;" id="id_reading_price">'.$tableData.'</span></div></div></div>';
$mform->addElement('html', $priceShowLabel);
- $mform->addElement('hidden', 'reading_pricing_enddate', $course->sl_enddate, 'id="reading_pricing_enddate"');
+ // Bug #2661 - Move extra configuration from course to sl_course_settings
+ $mform->addElement('hidden', 'reading_pricing_enddate', $sl_course_settings->sl_enddate, 'id="reading_pricing_enddate"');
$taxIDSend = ($course->taxonomy_taxid) ? $course->taxonomy_taxid : 0;
$taxReadingSend = ($course->taxonomy_reading) ? $course->taxonomy_reading : 'null';
diff --git a/src/cms/moodle/course/js/courseLib.js b/src/cms/moodle/course/js/courseLib.js
index 564d9ba..5c522a8 100644
--- a/src/cms/moodle/course/js/courseLib.js
+++ b/src/cms/moodle/course/js/courseLib.js
@@ -28,6 +28,24 @@ var arraySubjects = [];
var initialTaxonomy = 0;
+function checkISBNCheggOption(){
+ $('#id_real_textbook').parent().parent().parent().attr('id', 'formitem_id_real_textbook');
+ if($('#course_isbn10').val() == '' && $('#course_isbn13').val() == ''){
+ $('#id_real_textbook').prop('checked', false);
+ $('#formitem_id_real_textbook').hide();
+ }
+}
+
+function checkTaxonomyISBNCheggBook(taxonomySelected){
+ if( (taxonomySelected.isbn10 == 0 && taxonomySelected.isbn13 == 0) || (!taxonomySelected.isbn10 && !taxonomySelected.isbn13) ){
+ $('#id_real_textbook').prop('checked', false);
+ $('#formitem_id_real_textbook').hide();
+ }
+ else{
+ $('#formitem_id_real_textbook').show();
+ }
+}
+
function checkReadingPricing(value){
if(value == 'not available'){
$("#content_reading_pricing").hide();
@@ -100,6 +118,7 @@ function setSubject(taxid){
});
setTextbookBySubject(taxonomySelected.Key, taxonomyReading);
+ checkTaxonomyISBNCheggBook(taxonomySelected);
//Start Calling Cascate
getDefaultCoursePrices();
@@ -319,6 +338,8 @@ function updateMulticourseValue(){
}
$().ready(function () {
+ checkISBNCheggOption();
+
$("#dialog-zerovalue").dialog({
autoOpen: false,
height: 300,
diff --git a/src/cms/moodle/course/lib.php b/src/cms/moodle/course/lib.php
index 288f809..b734f72 100644
--- a/src/cms/moodle/course/lib.php
+++ b/src/cms/moodle/course/lib.php
@@ -3839,6 +3839,8 @@ function print_center_courses_logically($category_type, $accordion_name, $accord
foreach($courses as $course){
if($course->visible == 1 || ($course->visible == 0 && has_capability('moodle/course:viewhiddencourses', get_context_instance(CONTEXT_COURSE, $course->id)))){
+ // Bug #2661 - Move extra configuration from course to sl_course_settings
+ $sl_course_settings = get_record('sl_course_settings', 'course_id', $course->id);
$course_category = get_record('course_categories', 'id', $course->category);
if($course_category->type == 'inherit' && $course_category->parent != 0){
@@ -3861,21 +3863,23 @@ function print_center_courses_logically($category_type, $accordion_name, $accord
$course_category->type = $category_type;
}
- $institution = get_record('institution', 'id', $course->institution);
+ // Bug #2661 - Move extra configuration from course to sl_course_settings
+ $institution = get_record('institution', 'id', $sl_course_settings->institution);
if(!$institution){
$institution = new Object();
$institution->id = 0;
$institution->name = "Institution not set";
}
- $course->Subject_ID = ($course->Subject_ID) ? $course->Subject_ID : 0;
+ // Bug #2661 - Move extra configuration from course to sl_course_settings
+ $sl_course_settings->Subject_ID = ($sl_course_settings->Subject_ID) ? $sl_course_settings->Subject_ID : 0;
- $sqlSubject = "SELECT s.Key as Subject_ID, s.name as Description from ".$SERVER_SETTINGS['TARGET_CONTENT_DATABASE'].".subject s WHERE s.Key = $course->Subject_ID";
+ $sqlSubject = "SELECT s.Key as Subject_ID, s.name as Description from ".$SERVER_SETTINGS['TARGET_CONTENT_DATABASE'].".subject s WHERE s.Key = $sl_course_settings->Subject_ID";
$subject = get_record_sql($sqlSubject);
if($course_category->type == $category_type || ($course_category->type == 'inherit' && $category_type == 'other')){
$hasCourses = true;
- if(($course->startdate <= $now && $course->sl_enddate > $now) || ($course->startdate <= $now && $course->sl_enddate == 0)){
+ if(($course->startdate <= $now && $sl_course_settings->sl_enddate > $now) || ($course->startdate <= $now && $sl_course_settings->sl_enddate == 0)){
if(!in_array($institution, $arrayInstitutionsC)){
array_push($arrayInstitutionsC, $institution);
}
@@ -3935,7 +3939,8 @@ function print_center_courses_logically($category_type, $accordion_name, $accord
$countSubjectsC = 0;
$hasCourse = false;
foreach($arrayCoursesC as $course){
- if($course->institution == $institution->id && $course->Subject_ID == $subject->Subject_ID){
+ // Bug #2661 - Move extra configuration from course to sl_course_settings
+ if($sl_course_settings->institution == $institution->id && $sl_course_settings->Subject_ID == $sl_course_settings->Subject_ID){
$hasCourse = true;
$countSubjectsC++;
}
@@ -3950,7 +3955,7 @@ function print_center_courses_logically($category_type, $accordion_name, $accord
}
foreach($arrayCoursesC as $course){
- if($course->institution == $institution->id && $course->Subject_ID == $subject->Subject_ID){
+ if($sl_course_settings->institution == $institution->id && $sl_course_settings->Subject_ID == $subject->Subject_ID){
$testC = true;
$treeShow .= '<li>';
$treeShow .= print_course_return_string($course);
@@ -3992,7 +3997,8 @@ function print_center_courses_logically($category_type, $accordion_name, $accord
$countSubjectsF = 0;
$hasCourse = false;
foreach($arrayCoursesF as $course){
- if($course->institution == $institution->id && $course->Subject_ID == $subject->Subject_ID){
+ // Bug #2661 - Move extra configuration from course to sl_course_settings
+ if($sl_course_settings->institution == $institution->id && $sl_course_settings->Subject_ID == $subject->Subject_ID){
$hasCourse = true;
$countSubjectsF++;
}
@@ -4007,7 +4013,8 @@ function print_center_courses_logically($category_type, $accordion_name, $accord
}
foreach($arrayCoursesF as $course){
- if($course->institution == $institution->id && $course->Subject_ID == $subject->Subject_ID){
+ // Bug #2661 - Move extra configuration from course to sl_course_settings
+ if($sl_course_settings->institution == $institution->id && $sl_course_settings->Subject_ID == $subject->Subject_ID){
$testF = true;
$treeShow .= '<li>';
$treeShow .= print_course_return_string($course);
@@ -4049,7 +4056,8 @@ function print_center_courses_logically($category_type, $accordion_name, $accord
$countSubjectsP = 0;
$hasCourse = false;
foreach($arrayCoursesP as $course){
- if($course->institution == $institution->id && $course->Subject_ID == $subject->Subject_ID){
+ // Bug #2661 - Move extra configuration from course to sl_course_settings
+ if($sl_course_settings->institution == $institution->id && $sl_course_settings->Subject_ID == $subject->Subject_ID){
$hasCourse = true;
$countSubjectsP++;
}
@@ -4063,7 +4071,8 @@ function print_center_courses_logically($category_type, $accordion_name, $accord
$treeShow .= '<ul>';
}
foreach($arrayCoursesP as $course){
- if($course->institution == $institution->id && $course->Subject_ID == $subject->Subject_ID){
+ // Bug #2661 - Move extra configuration from course to sl_course_settings
+ if($sl_course_settings->institution == $institution->id && $sl_course_settings->Subject_ID == $subject->Subject_ID){
$testP = true;
$treeShow .= '<li>';
$treeShow .= print_course_return_string($course);
@@ -4122,9 +4131,13 @@ function print_center_courses_no_enrol($treeID, $courses, $institution, $homewor
$arraySubjects = array();
$arrayTerms = array();
+ // Bug #2661 - Move extra configuration from course to sl_course_settings
+ $sl_course_settings = array();
$hasDefault = false;
foreach($courses as $course){
+ // Bug #2661 - Move extra configuration from course to sl_course_settings
+ $sl_course_settings[$course->id] = QDB::row("cms", "SELECT * FROM sl_course_settings WHERE course_id = ".$course->id);
$course_category = get_record('course_categories', 'id', $course->category);
if($course_category){
@@ -4147,7 +4160,8 @@ function print_center_courses_no_enrol($treeID, $courses, $institution, $homewor
}
if($categoryVisible){
- $course->Subject_ID = ($course->Subject_ID) ? $course->Subject_ID : 0;
+ // Bug #2661 - Move extra configuration from course to sl_course_settings
+ $course->Subject_ID = ($sl_course_settings[$course->id]['Subject_ID']) ? $sl_course_settings[$course->id]['Subject_ID'] : 0;
$sqlSubject = "SELECT s.Key as Subject_ID, s.name as Description from ".$SERVER_SETTINGS['TARGET_CONTENT_DATABASE'].".subject s WHERE s.Key = $course->Subject_ID";
$subject = get_record_sql($sqlSubject);
@@ -4160,6 +4174,7 @@ function print_center_courses_no_enrol($treeID, $courses, $institution, $homewor
$hasDefault = $subject;
}
+ // Bug #2661 - Move extra configuration from course to sl_course_settings
$termFormat = new Object();
$termFormat->termtype = $course->termtype;
$termFormat->term = $course->term;
@@ -4293,18 +4308,26 @@ function call_enroll_accordion($asAccordion = true){
}
else{
+ // Bug #2661 - Move extra configuration from course to sl_course_settings
//Getting Institution Courses
- $sqlGetCourses = "SELECT * FROM course WHERE course.visible = 1
+ $sqlGetCourses = "SELECT course.*, sc.* FROM course, sl_course_settings sc
+ WHERE sc.institution = $institution->id
+ AND course.id = sc.course_id
+ AND course.visible = 1
AND (course.enrollable = 1 OR (course.enrollable = 2 AND course.enrolstartdate <= $now AND (course.enrolenddate = 0 OR course.enrolenddate >= $now)))
- AND (course.sl_enddate IS NULL OR course.sl_enddate = 0 OR course.sl_enddate >= $now)
+ AND (sc.sl_enddate IS NULL OR sc.sl_enddate = 0 OR sc.sl_enddate >= $now)
AND course.institution = $institution->id;";
$courses = get_records_sql($sqlGetCourses);
+ // Bug #2661 - Move extra configuration from course to sl_course_settings
//Getting Homework Help Courses
- $sqlGetCoursesHH = "SELECT * FROM course WHERE course.visible = 1 AND course.enrollable = 1 AND course.category = 6
+ $sqlGetCoursesHH = "SELECT course.*, sc.* FROM course, sl_course_settings sc
+ WHERE sc.institution = $institution->id
+ AND course.id = sc.course_id
+ AND course.visible = 1 AND course.enrollable = 1 AND course.category = 6
AND course.enrolstartdate <= $now
AND (course.enrolenddate = 0 OR course.enrolenddate >= $now)
- AND (course.sl_enddate IS NULL OR course.sl_enddate = 0 OR course.sl_enddate >= $now);";
+ AND (sc.sl_enddate IS NULL OR sc.sl_enddate = 0 OR sc.sl_enddate >= $now);";
$coursesHH = get_records_sql($sqlGetCoursesHH);
if($courses){
diff --git a/src/cms/moodle/enrol/saplinglearning/check_payment_info.php b/src/cms/moodle/enrol/saplinglearning/check_payment_info.php
index e112507..d8a2dba 100644
--- a/src/cms/moodle/enrol/saplinglearning/check_payment_info.php
+++ b/src/cms/moodle/enrol/saplinglearning/check_payment_info.php
@@ -19,6 +19,8 @@
$hasCoursePayment = optional_param("hasCoursePayment", NULL, PARAM_INT);
$makePayment = optional_param("makePayment", NULL, PARAM_INT);
+ $cheggData = optional_param("chegg_data");
+
$expected_paid = (float)($expected_paid);
$expected_value = (float)($expected_value);
@@ -111,6 +113,24 @@
exit();
}
+ //Feature #2744 - Allow Students to Purchase Chegg Books for Their Courses
+ $cheggKey = null;
+ if($cheggData){
+
+ $arraysl_user_chegg_log = array();
+ $arraysl_user_chegg_log['user__id'] = $USER->id;
+ $arraysl_user_chegg_log['course__id'] = $course->id;
+ $arraysl_user_chegg_log['content__taxonomy__Key'] = $taxonomy['Key'];
+ $arraysl_user_chegg_log['purchase_type'] = ($cheggData[0] == 'sell') ? $cheggData[1] : $cheggData[0];
+ if($cheggData[0] == 'rent'){
+ $arraysl_user_chegg_log['rental_days'] = $cheggData[1];
+ }
+ $arraysl_user_chegg_log['price'] = $cheggData[2];
+ $arraysl_user_chegg_log['chegg_pid_cache'] = $cheggData[3];
+
+ $cheggKey = QDB::insert("cms", "sl_user_chegg_log", $arraysl_user_chegg_log);
+ }
+
$arraypayment_gateway_log = array();
$arraypayment_gateway_log['user__id'] = $USER->id;
$arraypayment_gateway_log['expected_paid'] = $total_expected_paid;
@@ -123,6 +143,10 @@
$arraypayment_gateway_log['reading_days'] = $reading_days;
$arraypayment_gateway_log['Payment_source_ID'] = $Payment_source_ID;
+ if($cheggData && $cheggKey){
+ $arraypayment_gateway_log['sl_user_chegg_log__Key'] = $cheggKey;
+ }
+
}
else{
diff --git a/src/cms/moodle/enrol/saplinglearning/dao_verifycardcolor.php b/src/cms/moodle/enrol/saplinglearning/dao_verifycardcolor.php
index 00bf3f0..d0603ca 100644
--- a/src/cms/moodle/enrol/saplinglearning/dao_verifycardcolor.php
+++ b/src/cms/moodle/enrol/saplinglearning/dao_verifycardcolor.php
@@ -10,7 +10,7 @@
*/
require("../../config.php");
- global $USER, $CFG;
+ global $CFG;
require_once("$CFG->dirroot/enrol/saplinglearning/enrol.php");
require_once("$CFG->libdir/paypalcardslib.php");
@@ -23,8 +23,9 @@
$courseid = required_param('courseid', PARAM_INT);
$groupid = required_param('groupid', PARAM_INT);
- $card = get_record('cards', 'code', $code);
+ $cheggData = optional_param("chegg_data");
+ require_once("quickDB.php");
if (!$card) {
$codeInt = intval($code);
$sqlInt = "SELECT * FROM cards WHERE CAST(code AS UNSIGNED) = ".$codeInt;
@@ -62,7 +63,7 @@
die;
}
- $mktimeTransaction = mktime();
+ $mktimeTransaction = date("Y-m-d H:i:s");
$card->user_id = $userid;
$card->course_id = $courseid;
@@ -77,27 +78,46 @@
email_saplinglearning_error("Error while trying to enrol " . fullname($user) . " in '$course->fullname'", print_r($card));
echo "Error on enrol. Please try again!";
die;
- } else {
+ }
+ else {
+
+ //Feature #2744 - Allow Students to Purchase Chegg Books for Their Courses
+ if($cheggData){
+ $sl_course_settings = QDB::row("cms", "SELECT * FROM sl_course_settings WHERE course_id = ".$courseid);
+
+ $arraysl_user_chegg_log = array();
+ $arraysl_user_chegg_log['user__id'] = $userid;
+ $arraysl_user_chegg_log['course__id'] = $courseid;
+ $arraysl_user_chegg_log['content__taxonomy__Key'] = $sl_course_settings['home_taxonomy'];
+ $arraysl_user_chegg_log['purchase_type'] = ($cheggData[0] == 'sell') ? $cheggData[1] : $cheggData[0];
+ if($cheggData[0] == 'rent'){
+ $arraysl_user_chegg_log['rental_days'] = $cheggData[1];
+ }
+ $arraysl_user_chegg_log['price'] = $cheggData[2];
+ $arraysl_user_chegg_log['chegg_pid_cache'] = $cheggData[3];
+
+ $cheggKey = QDB::insert("cms", "sl_user_chegg_log", $arraysl_user_chegg_log);
+ }
//Getting Card Label Information
$sqlMulticourse = "select cl.multicourse, cl.min_value, cl.max_value, c.code from cards c, card_labels cl where cl.id = c.label_id and c.code = '$card->code'";
$card_labels_info = get_record_sql($sqlMulticourse);
$valueToUse = $course->cost;
- if($card_labels_info){
- if(is_numeric($card_labels_info->min_value)){
- if($valueToUse < $card_labels_info->min_value){
+ if ($card_labels_info) {
+ if (is_numeric($card_labels_info->min_value)) {
+ if ($valueToUse < $card_labels_info->min_value) {
$valueToUse = $card_labels_info->min_value;
}
}
-
- if(is_numeric($card_labels_info->max_value)){
- if($valueToUse > $card_labels_info->max_value){
+
+ if (is_numeric($card_labels_info->max_value)) {
+ if ($valueToUse > $card_labels_info->max_value) {
$valueToUse = $card_labels_info->max_value;
}
}
}
-
+
//PAYMENT_USER
$dataClone = new stdClass();
$dataClone->user = $user->id;
@@ -111,8 +131,8 @@
$payment_user = new PaymentUser($dataClone);
$payment_user->save();
-
-
+
+
//PAYMENT_USER_USE
$dataClone = new stdClass();
$dataClone->user = $user->id;
@@ -124,30 +144,30 @@
$payment_user_use = new PaymentUserUse($dataClone);
$payment_user_use->save();
-
+
if ($card_labels_info) {
if ($card_labels_info->multicourse == 1) {
$payment_user->multicourse = 1;
-
- if($course->multivalue > 0){
+
+ if ($course->multivalue > 0) {
$payment_user->value = $course->multivalue;
}
- else if($course->multivalue == 0 || !$course->multivalue){
- $payment_user->value = $course->cost*($course->termcount);
+ else if ($course->multivalue == 0 || !$course->multivalue) {
+ $payment_user->value = $course->cost * ($course->termcount);
}
-
- if(is_numeric($card_labels_info->min_value)){
- if($payment_user->value < $card_labels_info->min_value){
+
+ if (is_numeric($card_labels_info->min_value)) {
+ if ($payment_user->value < $card_labels_info->min_value) {
$payment_user->value = $card_labels_info->min_value;
}
}
-
- if(is_numeric($card_labels_info->max_value)){
- if($payment_user->value > $card_labels_info->max_value){
+
+ if (is_numeric($card_labels_info->max_value)) {
+ if ($payment_user->value > $card_labels_info->max_value) {
$payment_user->value = $card_labels_info->max_value;
}
}
-
+
$payment_user->update();
}
}
diff --git a/src/cms/moodle/enrol/saplinglearning/enrol_form.php b/src/cms/moodle/enrol/saplinglearning/enrol_form.php
index e58d552..62c3636 100644
--- a/src/cms/moodle/enrol/saplinglearning/enrol_form.php
+++ b/src/cms/moodle/enrol/saplinglearning/enrol_form.php
@@ -7,6 +7,8 @@
$dateTimeNow = mktime();
+ $taxonomy = QDB::row("content", "SELECT * FROM taxonomy t WHERE t.Key = ".$sl_course_settings['home_taxonomy']);
+
$reading_course = QDB::row("cms", "SELECT * FROM reading_course WHERE course__id = ".$course->id);
if ($reading_course && $reading_course['requirement'] != 'not available') {
$reading_availability = QDB::row("content", "SELECT * FROM reading_availability WHERE taxonomy__Key = ".$sl_course_settings['home_taxonomy']." AND server = '".$SERVER_SETTINGS['TARGET_PLATFORM']."'");
@@ -15,7 +17,6 @@
$reading_course_pricing = QDB::query("cms", "SELECT * FROM reading_course_pricing WHERE course__id = $course->id AND taxonomy__Key = ".$sl_course_settings['home_taxonomy']);
if ($reading_course_pricing) {
- $taxonomy = QDB::row("content", "SELECT * FROM taxonomy t WHERE t.Key = ".$sl_course_settings['home_taxonomy']);
$sqlAuthors = "SELECT a.* FROM author AS a JOIN taxonomy_author ta ON ta.author__Key = a.Key WHERE ta.taxonomy__Key = ".$taxonomy['Key'];
$authors = QDB::query("content", $sqlAuthors);
$totalAuthors = count($authors);
@@ -50,6 +51,7 @@
echo '<h2 id="courseType">Single Course</h2>';
echo '<div id="messageContent">';
echo '<p id="courseTypeText">'.$messageSingle.'</p>';
+ echo '<p id="cheggBookText"></p>';
}
else {
echo '<div id="messageContent">';
@@ -134,21 +136,15 @@
if ($daysLeft > 0 && !$isEnrolled) {
?>
- <script>
- function doEnterFreePeriod(){
- jQ('#groupid').val(groupKey);
- jQ('#frmConfirm').submit();
- }
- </script>
<center>
- <form name="frmConfirm" id="frmConfirm" action="<?= $CFG->wwwroot.'/enrol/saplinglearning/enrol_free_period.php' ?>" method="post">
+ <form name="frmFreePeriod" id="frmFreePeriod" action="<?= $CFG->wwwroot.'/enrol/saplinglearning/enrol_free_period.php' ?>" method="post">
<input type="hidden" name="description" value="<?php p('Enrol at course '.$coursefullname) ?>" />
<input type="hidden" name="userid" value="<?= $USER->id ?>" />
<input type="hidden" name="courseid" value="<?= $course->id ?>" />
<input id="groupid" name="groupid" type="hidden" value=""/>
<input type="hidden" name="value" value="<?php p($cost) ?>" />
- <input type="button" value="Enter this course for <?php echo $daysLeft ?> days free" onclick="doEnterFreePeriod();" />
+ <input type="button" value="Enter this course for <?php echo $daysLeft ?> days free" onclick="fillGroupAndSubmit('#frmFreePeriod');" />
</form>
<p>or pay now</p>
</center>
@@ -174,18 +170,15 @@
echo "<div style='width:100%; margin-top:15px; text-align: center;'>";
echo "<form id='frmPaymentMount' name='frmPaymentMount'>";
- if ($userCreditTotal >= $cost) {
- echo "<input type='radio' name='rdPaymentSelect' value='".format_float($cost, 2)."' checked='true' onclick='doCallPaySelect(this.value, 2);' />&nbsp;&nbsp;<b>Use my credit: $".$userCreditTotal." (".$CFG->enrol_currency.")</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
- $selectFirst = "";
- }
- else if ($userCreditTotal < $cost) {
- $selectFirst = "checked='true'";
- }
-
- if(!$getUserPaymentInfo){
+ if (!$getUserPaymentInfo) {
echo "<div style='float: left; width: 100px; text-align: left;'><b>Course:&nbsp;&nbsp;</b></div>";
echo "<div style='float: left;'>";
- echo "<input type='radio' name='rdPaymentSelect' value='".format_float($cost, 2)."' $selectFirst onclick='doCallPaySelect(this.value, 0);' />&nbsp;&nbsp;<b>This ".ucwords($course->termtype).": $".format_float($cost, 2)." (".$CFG->enrol_currency.")</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
+
+ if ($userCreditTotal >= $cost) {
+ echo "<input id='use-my-credit-payment' type='radio' name='rdPaymentSelect' value='0.00' checked='true' onclick='doCallPaySelect(this.value, 2);' />&nbsp;&nbsp;<b>Use my credit: $".$userCreditTotal." (".$CFG->enrol_currency.")</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
+ }
+
+ echo "<input type='radio' name='rdPaymentSelect' value='".format_float($cost, 2)."' onclick='doCallPaySelect(this.value, 0);' />&nbsp;&nbsp;<b>This ".ucwords($course->termtype).": $".format_float($cost, 2)." (".$CFG->enrol_currency.")</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
if ($course->multicourse) {
echo "<input type='radio' name='rdPaymentSelect' value='".format_float($course->multicost, 2)."' onclick='doCallPaySelect(this.value, 1);' />&nbsp;&nbsp;<b>All ".ucwords($course->termtype)."s: $".format_float($course->multicost, 2)." (".$CFG->enrol_currency.")</b>";
}
@@ -211,22 +204,22 @@
}
}
- if($reading_course['requirement'] == 'optional'){
+ if ($reading_course['requirement'] == 'optional') {
echo "<li><input id='no-thanks' type='radio' name='rdReadingPricing' value='0' onclick='doCallReadingSelect(this.value);' checked />&nbsp;&nbsp;<b>No thanks</b></li>";
}
foreach ($reading_course_pricing as $reading_price) {
$daysDisplay = "";
- if($reading_price['days'] == CONST_6MONTHS){
+ if ($reading_price['days'] == CONST_6MONTHS) {
$daysDisplay = "6 Months";
}
- else if($reading_price['days'] == CONST_1YEAR){
+ else if ($reading_price['days'] == CONST_1YEAR) {
$daysDisplay = "1 Year";
}
- else if($reading_price['days'] == CONST_2YEARS){
+ else if ($reading_price['days'] == CONST_2YEARS) {
$daysDisplay = "2 Years";
}
- else{
+ else {
$daysDisplay = $reading_price['days']." days";
}
@@ -246,18 +239,70 @@
echo "<script>var hasReading = false;</script>";
}
+ //Feature #2744 - Allow Students to Purchase Chegg Books for Their Courses
+ if($sl_course_settings['real_textbook'] && $sl_course_settings['real_textbook'] == 'yes'){
+ $isbnToUse = ($taxonomy['isbn13']) ? $taxonomy['isbn13'] : $taxonomy['isbn10'];
+
+ $ch = curl_init();
+ curl_setopt($ch, CURLOPT_URL, "http://services.chegg.com/search/pricing/aggregate/isbn/$isbnToUse?client_id=7FDE1F2F5CDAE383789486D7795001DB1281650609.32&format=json");
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+ $chReturn = curl_exec($ch);
+ curl_close($ch);
+
+ $cheggReturn = json_decode($chReturn);
+
+ if(isset($cheggReturn->Items->Item[0])){
+
+ //Need to check if we can have more than one book. I believe not (Leandro)
+ $cheggBook = $cheggReturn->Items->Item[0];
+
+ if($cheggBook->IsRenting){
+ echo "<div style='float: left; width: 300px; text-align: left; margin-top: 20px; margin-bottom: 20px;'><b>Textbooks from Chegg.com:</b></div>";
+ echo "<div style='clear: both;'></div>";
+ echo '<div>';
+ echo '<div style="float: left; width: 150px;">';
+ echo '<img src="'.$cheggBook->ImageSmall.'" border="0" width="150px" /><br />';
+ echo '<b>'.$cheggBook->Title.' by '.$cheggBook->PrimaryAuthor.'</b>';
+ echo '</div>';
+ echo "<div style='float: left;'>";
+ echo '<ul class="reading-pricing-ul">';
+ echo "<li><input type='radio' name='rdCheggBook' onchange='checkCheggBook(this.value)' value='0' checked />&nbsp;&nbsp;<b>No thanks</b></li>";
+
+ if($cheggBook->IsRenting){
+ foreach ($cheggBook->RentalPrices->RentalPrice as $rentalPrices) {
+ echo "<li><input type='radio' name='rdCheggBook' onchange='checkCheggBook(this.value)' value='rent:$rentalPrices->TermDays:".format_float($rentalPrices->RentalPrice, 2).":$rentalPrices->PidCache' />&nbsp;&nbsp;<b>Rent ".ucfirst(strtolower($rentalPrices->Term))." - $".format_float($rentalPrices->RentalPrice, 2)." (".$CFG->enrol_currency.")</b></li>";
+ }
+ }
+
+ /*
+ if($cheggBook->IsSell){
+ foreach ($cheggBook->SellPrices->SellPrice as $sellPrices) {
+ $termSave = (strpos($sellPrices->TermDesc, 'New') === false) ? 'used' : 'new';
+ echo "<li><input type='radio' name='rdCheggBook' onchange='checkCheggBook(this.value)' value='sell:$termSave:".format_float($sellPrices->Price, 2).":$sellPrices->PID' />&nbsp;&nbsp;<b>".ucfirst(strtolower($sellPrices->TermDesc))." - $".format_float($sellPrices->Price, 2)." (".$CFG->enrol_currency.")</b></li>";
+ }
+ }
+ */
+ echo '</ul>';
+ echo "</div>";
+ echo "</div>";
+
+ echo "<div style='clear: both;'></div>";
+ }
+ }
+ }
+
echo "</form>";
echo "</div>";
echo '<br style="clear:both;" />';
if ($userCreditTotal >= $cost) {
echo '<div id="formUseCredit" style="display:none; text-align:center;">';
- echo '<form name="frmConfirm" id="frmConfirm" action="'.$CFG->wwwroot.'/enrol/saplinglearning/confirm_enrol.php" method="post">';
+ echo '<form name="frmUseCredit" id="frmUseCredit" action="'.$CFG->wwwroot.'/enrol/saplinglearning/confirm_enrol.php" method="post">';
echo '<input type="hidden" name="user" value="'.$USER->id.'" />';
echo '<input type="hidden" name="course" value="'.$course->id.'" />';
echo '<input id="groupid" name="groupid" type="hidden" value=""/>';
echo '<input type="hidden" name="value" value="'.format_float($cost, 2).'" />';
- echo '<input type="submit" value="Use my Sapling Learning credit to enter the course" />';
+ echo '<input type="button" value="Use my Sapling Learning credit to enter the course" onclick="fillGroupAndSubmit(\'#frmUseCredit\')" />';
echo '</form>';
echo '</div>';
echo "<script>jQ(document).ready(function() { doCallPaySelect(".format_float($cost, 2).", 2);});</script>";
@@ -273,7 +318,7 @@
echo "<div id='return-to-course'><input type='button' value='Return to Course' onclick='returnToCourse($course->id)' /></div>";
echo "</center></div>";
- if(!$getUserPaymentInfo){
+ if (!$getUserPaymentInfo) {
include($CFG->dirroot.'/enrol/saplinglearning/enrol_cards.php');
}
}
diff --git a/src/cms/moodle/enrol/saplinglearning/js/CardColorLib.js b/src/cms/moodle/enrol/saplinglearning/js/CardColorLib.js
index 813cf33..4835eea 100644
--- a/src/cms/moodle/enrol/saplinglearning/js/CardColorLib.js
+++ b/src/cms/moodle/enrol/saplinglearning/js/CardColorLib.js
@@ -17,6 +17,12 @@ function doVerifyCardCode(){
dataSend.userid = userid;
dataSend.courseid = courseid;
dataSend.groupid = groupKey;
+
+ if(jQ('input[name=rdCheggBook]').length && jQ('input[name=rdCheggBook]:checked').val() != 0){
+ var cheggValues = jQ('input[name=rdCheggBook]:checked').val();
+ dataSend.chegg_data = cheggValues.split(":");
+ }
+
jQ.ajax({
url: pathURL+"/enrol/saplinglearning/dao_verifycardcolor.php",
data: dataSend,
@@ -24,7 +30,12 @@ function doVerifyCardCode(){
success: function(data) {
if(data == 'true'){
jQ('#cardResults').html('<img src="'+pathURL+'/mod/ibis/ico_check.png" />&nbsp;Code accepted.');
- location.href = pathURL+"/course/view.php?id="+dataSend.courseid;
+ if(dataSend.chegg_data){
+ location.href = pathURL+"/enrol/saplinglearning/returnCard.php?id="+dataSend.courseid;
+ }
+ else{
+ location.href = pathURL+"/course/view.php?id="+dataSend.courseid;
+ }
}
else{
jQ('#cardCode').focus();
diff --git a/src/cms/moodle/enrol/saplinglearning/libJS.js b/src/cms/moodle/enrol/saplinglearning/libJS.js
index 2a461de..cd4fe0f 100644
--- a/src/cms/moodle/enrol/saplinglearning/libJS.js
+++ b/src/cms/moodle/enrol/saplinglearning/libJS.js
@@ -1,6 +1,11 @@
var mcsenddatakey = 0;
var addingReading = 0;
+function fillGroupAndSubmit(form){
+ jQ(form+' #groupid').val(groupKey);
+ jQ(form).submit();
+}
+
function callPayment(sourceid){
var html = "<br /><center><img src='"+pathURL+"/admin/ajaxLoading.gif' /><br />Connecting to payment gateway. Please wait...</center><br />";
jQ('#centerPayment').html(html);
@@ -14,6 +19,11 @@ function callPayment(sourceid){
window.location.href = locationString;
}
else{
+ if(jQ('input[name=rdCheggBook]').length && jQ('input[name=rdCheggBook]:checked').val() != 0){
+ var cheggValues = jQ('input[name=rdCheggBook]:checked').val();
+ paymentInfo.chegg_data = cheggValues.split(":");
+ }
+
jQ.ajax({
url: pathURL+'/enrol/saplinglearning/check_payment_info.php',
data: paymentInfo,
@@ -114,6 +124,15 @@ function doCallPaySelect(value, sdt){
doUpdatePricesLabels();
}
+function checkCheggBook(value){
+ if(value == 0){
+ jQ('#cheggBookText').html('');
+ }
+ else{
+ jQ('#cheggBookText').html('After you complete your payment for Sapling Learning, you will be sent to Chegg.com to order your book.');
+ }
+}
+
function checkUseCredit(){
doUpdatePricesLabels();
}
@@ -232,9 +251,9 @@ function returnToCourse(courseid){
function mktime () {
var d = new Date(),
- r = arguments,
- i = 0,
- e = ['Hours', 'Minutes', 'Seconds', 'Month', 'Date', 'FullYear'];
+ r = arguments,
+ i = 0,
+ e = ['Hours', 'Minutes', 'Seconds', 'Month', 'Date', 'FullYear'];
for (i = 0; i < e.length; i++) {
if (typeof r[i] === 'undefined') {
@@ -260,7 +279,8 @@ function mktime () {
function strtotime (str, now) {
var i, l, match, s, parse = '';
- str = (str + '').replace(/\s{2,}|^\s|\s$/g, ' ').replace(/[\t\r\n]/g, '');; // unecessary spaces and chars
+ str = (str + '').replace(/\s{2,}|^\s|\s$/g, ' ').replace(/[\t\r\n]/g, '');
+ ; // unecessary spaces and chars
if (str === 'now') {
return now === null || isNaN(now) ? new Date().getTime() / 1000 | 0 : now | 0;
@@ -285,18 +305,18 @@ function strtotime (str, now) {
'sat': 6
},
mon: [
- 'jan',
- 'feb',
- 'mar',
- 'apr',
- 'may',
- 'jun',
- 'jul',
- 'aug',
- 'sep',
- 'oct',
- 'nov',
- 'dec'
+ 'jan',
+ 'feb',
+ 'mar',
+ 'apr',
+ 'may',
+ 'jun',
+ 'jul',
+ 'aug',
+ 'sep',
+ 'oct',
+ 'nov',
+ 'dec'
]
};
@@ -305,85 +325,85 @@ function strtotime (str, now) {
var num = (num = m[0] === 'last' ? -1 : 1) * (ago ? -1 : 1);
switch (m[0]) {
- case 'last':
- case 'next':
- switch (m[1].substring(0, 3)) {
- case 'yea':
- now.setFullYear(now.getFullYear() + num);
- break;
- case 'wee':
- now.setDate(now.getDate() + (num * 7));
- break;
- case 'day':
- now.setDate(now.getDate() + num);
- break;
- case 'hou':
- now.setHours(now.getHours() + num);
- break;
- case 'min':
- now.setMinutes(now.getMinutes() + num);
- break;
- case 'sec':
- now.setSeconds(now.getSeconds() + num);
- break;
- case 'mon':
- if (m[1] === "month") {
- now.setMonth(now.getMonth() + num);
- break;
- }
- // fall through
- default:
- var day = __is.day[m[1].substring(0, 3)];
- if (typeof day !== 'undefined') {
- var diff = day - now.getDay();
- if (diff === 0) {
- diff = 7 * num;
- } else if (diff > 0) {
- if (m[0] === 'last') {
- diff -= 7;
+ case 'last':
+ case 'next':
+ switch (m[1].substring(0, 3)) {
+ case 'yea':
+ now.setFullYear(now.getFullYear() + num);
+ break;
+ case 'wee':
+ now.setDate(now.getDate() + (num * 7));
+ break;
+ case 'day':
+ now.setDate(now.getDate() + num);
+ break;
+ case 'hou':
+ now.setHours(now.getHours() + num);
+ break;
+ case 'min':
+ now.setMinutes(now.getMinutes() + num);
+ break;
+ case 'sec':
+ now.setSeconds(now.getSeconds() + num);
+ break;
+ case 'mon':
+ if (m[1] === "month") {
+ now.setMonth(now.getMonth() + num);
+ break;
}
- } else {
- if (m[0] === 'next') {
- diff += 7;
+ // fall through
+ default:
+ var day = __is.day[m[1].substring(0, 3)];
+ if (typeof day !== 'undefined') {
+ var diff = day - now.getDay();
+ if (diff === 0) {
+ diff = 7 * num;
+ } else if (diff > 0) {
+ if (m[0] === 'last') {
+ diff -= 7;
+ }
+ } else {
+ if (m[0] === 'next') {
+ diff += 7;
+ }
+ }
+ now.setDate(now.getDate() + diff);
+ now.setHours(0, 0, 0, 0); // when jumping to a specific last/previous day of week, PHP sets the time to 00:00:00
}
- }
- now.setDate(now.getDate() + diff);
- now.setHours(0, 0, 0, 0); // when jumping to a specific last/previous day of week, PHP sets the time to 00:00:00
}
- }
- break;
-
- default:
- if (/\d+/.test(m[0])) {
- num *= parseInt(m[0], 10);
+ break;
- switch (m[1].substring(0, 3)) {
- case 'yea':
- now.setFullYear(now.getFullYear() + num);
- break;
- case 'mon':
- now.setMonth(now.getMonth() + num);
- break;
- case 'wee':
- now.setDate(now.getDate() + (num * 7));
- break;
- case 'day':
- now.setDate(now.getDate() + num);
- break;
- case 'hou':
- now.setHours(now.getHours() + num);
- break;
- case 'min':
- now.setMinutes(now.getMinutes() + num);
- break;
- case 'sec':
- now.setSeconds(now.getSeconds() + num);
- break;
+ default:
+ if (/\d+/.test(m[0])) {
+ num *= parseInt(m[0], 10);
+
+ switch (m[1].substring(0, 3)) {
+ case 'yea':
+ now.setFullYear(now.getFullYear() + num);
+ break;
+ case 'mon':
+ now.setMonth(now.getMonth() + num);
+ break;
+ case 'wee':
+ now.setDate(now.getDate() + (num * 7));
+ break;
+ case 'day':
+ now.setDate(now.getDate() + num);
+ break;
+ case 'hou':
+ now.setHours(now.getHours() + num);
+ break;
+ case 'min':
+ now.setMinutes(now.getMinutes() + num);
+ break;
+ case 'sec':
+ now.setSeconds(now.getSeconds() + num);
+ break;
+ }
+ } else {
+ return false;
}
- } else {
- return false;
- }
- break;
+ break;
}
return true;
};
@@ -423,18 +443,18 @@ function strtotime (str, now) {
function date (format, timestamp) {
var that = this,
- jsdate, f, formatChr = /\\?([a-z])/gi,
- formatChrCb,
- // Keep this here (works, but for code commented-out
- // below for file size reasons)
- //, tal= [],
- _pad = function (n, c) {
- if ((n = n + '').length < c) {
- return new Array((++c) - n.length).join('0') + n;
- }
- return n;
- },
- txt_words = ["Sun", "Mon", "Tues", "Wednes", "Thurs", "Fri", "Satur", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
+ jsdate, f, formatChr = /\\?([a-z])/gi,
+ formatChrCb,
+ // Keep this here (works, but for code commented-out
+ // below for file size reasons)
+ //, tal= [],
+ _pad = function (n, c) {
+ if ((n = n + '').length < c) {
+ return new Array((++c) - n.length).join('0') + n;
+ }
+ return n;
+ },
+ txt_words = ["Sun", "Mon", "Tues", "Wednes", "Thurs", "Fri", "Satur", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
formatChrCb = function (t, s) {
return f[t] ? f[t]() : s;
};
@@ -464,14 +484,14 @@ function date (format, timestamp) {
},
z: function () { // Day of year; 0..365
var a = new Date(f.Y(), f.n() - 1, f.j()),
- b = new Date(f.Y(), 0, 1);
+ b = new Date(f.Y(), 0, 1);
return Math.round((a - b) / 864e5) + 1;
},
// Week
W: function () { // ISO-8601 week number
var a = new Date(f.Y(), f.n() - 1, f.j() - f.N() + 3),
- b = new Date(a.getFullYear(), 0, 4);
+ b = new Date(a.getFullYear(), 0, 4);
return _pad(1 + Math.round((a - b) / 864e5 / 7), 2);
},
@@ -499,8 +519,8 @@ function date (format, timestamp) {
},
o: function () { // ISO-8601 year
var n = f.n(),
- W = f.W(),
- Y = f.Y();
+ W = f.W(),
+ Y = f.Y();
return Y + (n === 12 && W < 9 ? 1 : n === 1 && W > 9 ? -1 : 0);
},
Y: function () { // Full year; e.g. 1980...2010
@@ -519,10 +539,10 @@ function date (format, timestamp) {
},
B: function () { // Swatch Internet time; 000..999
var H = jsdate.getUTCHours() * 36e2,
- // Hours
- i = jsdate.getUTCMinutes() * 60,
- // Minutes
- s = jsdate.getUTCSeconds(); // Seconds
+ // Hours
+ i = jsdate.getUTCMinutes() * 60,
+ // Minutes
+ s = jsdate.getUTCSeconds(); // Seconds
return _pad(Math.floor((H + i + s + 36e2) / 86.4) % 1e3, 3);
},
g: function () { // 12-Hours; 1..12
@@ -555,17 +575,17 @@ function date (format, timestamp) {
// Compares Jan 1 minus Jan 1 UTC to Jul 1 minus Jul 1 UTC.
// If they are not equal, then DST is observed.
var a = new Date(f.Y(), 0),
- // Jan 1
- c = Date.UTC(f.Y(), 0),
- // Jan 1 UTC
- b = new Date(f.Y(), 6),
- // Jul 1
- d = Date.UTC(f.Y(), 6); // Jul 1 UTC
+ // Jan 1
+ c = Date.UTC(f.Y(), 0),
+ // Jan 1 UTC
+ b = new Date(f.Y(), 6),
+ // Jul 1
+ d = Date.UTC(f.Y(), 6); // Jul 1 UTC
return 0 + ((a - c) !== (b - d));
},
O: function () { // Difference to GMT in hour format; e.g. +0200
var tzo = jsdate.getTimezoneOffset(),
- a = Math.abs(tzo);
+ a = Math.abs(tzo);
return (tzo > 0 ? "-" : "+") + _pad(Math.floor(a / 60) * 100 + a % 60, 4);
},
P: function () { // Difference to GMT w/colon; e.g. +02:00
@@ -595,7 +615,7 @@ function date (format, timestamp) {
jsdate = (timestamp == null ? new Date() : // Not provided
(timestamp instanceof Date) ? new Date(timestamp) : // JS Date()
new Date(timestamp * 1000) // UNIX timestamp (auto-convert to int)
- );
+ );
return format.replace(formatChr, formatChrCb);
};
return this.date(format, timestamp);
diff --git a/src/cms/moodle/enrol/saplinglearning/return.php b/src/cms/moodle/enrol/saplinglearning/return.php
index 45385ac..26300f3 100644
--- a/src/cms/moodle/enrol/saplinglearning/return.php
+++ b/src/cms/moodle/enrol/saplinglearning/return.php
@@ -1,30 +1,29 @@
<?php
- /**
- * Feature #1055 - Payment: New Payment Plugin
- * Capture the return from Paypal
- *
- * @author Leandro Prudente
- * @copyright Sapling Learning 2011
- *
- */
-
+ /**
+ * Feature #1055 - Payment: New Payment Plugin
+ * Capture the return from Paypal
+ *
+ * @author Leandro Prudente
+ * @copyright Sapling Learning 2011
+ *
+ */
require("../../config.php");
require_once("$CFG->dirroot/enrol/saplinglearning/enrol.php");
global $USER, $CFG;
-
+
$id = required_param('id', PARAM_INT);
if (!$user = get_record("user", "id", $USER->id)) {
redirect($CFG->wwwroot);
}
-
+
if (!$course = get_record("course", "id", $id)) {
redirect($CFG->wwwroot);
}
- if (! $context = get_context_instance(CONTEXT_COURSE, $course->id)) {
+ if (!$context = get_context_instance(CONTEXT_COURSE, $course->id)) {
redirect($CFG->wwwroot);
}
@@ -33,56 +32,61 @@
$strloginto = "Pay for ".$course->shortname;
$strcourses = get_string("courses");
$teacher = get_teacher($course->id);
-
+
$navlinks = array();
$navlinks[] = array('name' => $strcourses, 'link' => "$CFG->wwwroot/course", 'type' => 'misc');
$navlinks[] = array('name' => $strloginto, 'link' => null, 'type' => 'misc');
$navigation = build_navigation($navlinks);
print_header($strloginto, $course->fullname, $navigation);
-
+
load_all_capabilities();
if ($SESSION->wantsurl) {
$destination = $SESSION->wantsurl;
unset($SESSION->wantsurl);
- } else {
+ }
+ else {
$destination = "$CFG->wwwroot/course/view.php?id=$course->id";
}
-
+
require_js(array("$CFG->wwwroot/lib/jQuery/jquery.js", "$CFG->wwwroot/enrol/saplinglearning/js/PaymentLib.js"));
-
- $snippet = '<!-- Google Code for Sapling Product Purchase Conversion Page -->
- <script language="JavaScript" type="text/javascript">
- <!--
- var google_conversion_id = 1035099881;
- var google_conversion_language = "en_US";
- var google_conversion_format = "1";
- var google_conversion_color = "ffffff";
- var google_conversion_label = "0tj2CNXEhwEQ6b3J7QM";
- //-->
- </script>
- <script language="JavaScript" src="http://www.googleadservices.com/pagead/conversion.js">
- </script>
- <noscript>
- <img height="1" width="1" border="0" src="http://www.googleadservices.com/pagead/conversion/1035099881/?label=0tj2CNXEhwEQ6b3J7QM&amp;guid=ON&amp;script=0"/>
- </noscript>';
-
- echo "<script>";
- echo "var pathContinue = '".$destination."';";
- echo "var strPaymentOK = '<center><p>&nbsp;</p>".get_string('paymentthanks', 'enrol_saplinglearning', $course->fullname)."</center>';";
- echo "var strPaymentERROR = '<center><p>&nbsp;</p>".get_string('paymentsorry', 'enrol_saplinglearning', $course->fullname)."</center>';";
- echo "</script>";
-
+
+ $snippet = '<!-- Google Code for Sapling Product Purchase Conversion Page -->
+ <script language="JavaScript" type="text/javascript">
+ <!--
+ var google_conversion_id = 1035099881;
+ var google_conversion_language = "en_US";
+ var google_conversion_format = "1";
+ var google_conversion_color = "ffffff";
+ var google_conversion_label = "0tj2CNXEhwEQ6b3J7QM";
+ //-->
+ </script>
+ <script language="JavaScript" src="http://www.googleadservices.com/pagead/conversion.js">
+ </script>
+ <noscript>
+ <img height="1" width="1" border="0" src="http://www.googleadservices.com/pagead/conversion/1035099881/?label=0tj2CNXEhwEQ6b3J7QM&amp;guid=ON&amp;script=0"/>
+ </noscript>';
+
+ echo "<script>";
+ echo "var pathContinue = '".$destination."';";
+ echo "var strPaymentOK = '<center><p>&nbsp;</p>".get_string('paymentthanks', 'enrol_saplinglearning', $course->fullname)."</center>';";
+ echo "var strPaymentERROR = '<center><p>&nbsp;</p>".get_string('paymentsorry', 'enrol_saplinglearning', $course->fullname)."</center>';";
+ echo "</script>";
+
print_box("", 'generalbox', 'notice');
- echo "<br />";
- $output = print_footer($course, NULL, true);
- $position = strpos($output, '</body>');
- $new_output = substr($output, 0, $position).$snippet.substr($output, $position);
-
- echo "<script>checkPaymentStatus(".$course->id.")</script>";
-
- echo $new_output;
+ $sl_user_chegg_log = get_record_sql('SELECT slucl.chegg_pid_cache FROM sl_user_chegg_log slucl WHERE slucl.user__id = '.$user->id.' AND slucl.course__id = '.$course->id.' ORDER BY slucl.Key DESC');
+ if($sl_user_chegg_log){
+ echo "<center><small><a href='http://www.chegg.com/?pids=$sl_user_chegg_log->chegg_pid_cache&referrer=5Z4CF91JCM' target='_blank'>Click here to purchase your textbook from Chegg.com. Clicking this link will open a new window.</a></small></center><br />";
+ echo "<script>window.open('http://www.chegg.com/?pids=$sl_user_chegg_log->chegg_pid_cache&referrer=5Z4CF91JCM', '_blank')</script>";
+ }
+
+ $output = print_footer($course, NULL, true);
+ $position = strpos($output, '</body>');
+ $new_output = substr($output, 0, $position).$snippet.substr($output, $position);
+
+ echo "<script>checkPaymentStatus(".$course->id.")</script>";
+ echo $new_output;
?>
\ No newline at end of file
diff --git a/src/cms/moodle/enrol/saplinglearning/returnCard.php b/src/cms/moodle/enrol/saplinglearning/returnCard.php
new file mode 100644
index 0000000..2c07b2f
--- /dev/null
+++ b/src/cms/moodle/enrol/saplinglearning/returnCard.php
@@ -0,0 +1,50 @@
+<?php
+
+ require("../../config.php");
+ require_once("$CFG->dirroot/enrol/saplinglearning/enrol.php");
+
+ global $USER, $CFG;
+
+ $id = required_param('id', PARAM_INT);
+
+ if (!$user = get_record("user", "id", $USER->id)) {
+ redirect($CFG->wwwroot);
+ }
+
+ if (!$course = get_record("course", "id", $id)) {
+ redirect($CFG->wwwroot);
+ }
+
+ if (!$context = get_context_instance(CONTEXT_COURSE, $course->id)) {
+ redirect($CFG->wwwroot);
+ }
+
+ require_login();
+
+ $strloginto = "Confirmation for ".$course->shortname;
+ $strcourses = get_string("courses");
+
+ $navlinks = array();
+ $navlinks[] = array('name' => $strcourses, 'link' => "$CFG->wwwroot/course", 'type' => 'misc');
+ $navlinks[] = array('name' => $strloginto, 'link' => null, 'type' => 'misc');
+ $navigation = build_navigation($navlinks);
+
+ print_header($strloginto, $course->fullname, $navigation);
+
+ load_all_capabilities();
+
+ print_box_start();
+
+ echo "<br /><center>Thank you. Your credit has been applied successfully</center><br />";
+ $sl_user_chegg_log = get_record_sql('SELECT slucl.chegg_pid_cache FROM sl_user_chegg_log slucl WHERE slucl.user__id = '.$user->id.' AND slucl.course__id = '.$course->id.' ORDER BY slucl.Key DESC');
+ if($sl_user_chegg_log){
+ echo "<center><small><a href='http://www.chegg.com/?pids=$sl_user_chegg_log->chegg_pid_cache&referrer=5Z4CF91JCM' target='_blank'>Click here to purchase your textbook from Chegg.com. Clicking this link will open a new window.</a></small></center><br />";
+ echo "<script>window.open('http://www.chegg.com/?pids=$sl_user_chegg_log->chegg_pid_cache&referrer=5Z4CF91JCM', '_blank')</script>";
+ }
+
+ print_continue("$CFG->wwwroot/course/view.php?id=$course->id");
+ echo "<br />";
+ print_box_end();
+
+ print_footer();
+?>
\ No newline at end of file
diff --git a/src/cms/moodle/lang/en_utf8/moodle.php b/src/cms/moodle/lang/en_utf8/moodle.php
index 699ea04..e1c38b6 100644
--- a/src/cms/moodle/lang/en_utf8/moodle.php
+++ b/src/cms/moodle/lang/en_utf8/moodle.php
@@ -1,6 +1,9 @@
<?PHP // $Id: moodle.php,v 1.141.2.64 2009/05/27 03:00:06 jerome Exp $
// moodle.php - created with Moodle 1.7 beta + (2006101003)
+//Feature #2743 - Add Course Setting for Chegg
+$string['real_textbook'] = 'Students should purchase this book';
+
//Feature #1089 - Payment: Multi-Course Discount
$string['suggestmulticourseprice'] = 'Suggested Multi-Course Price';
$string['multicoursecheckbox'] = 'Multi-course pricing?';
diff --git a/src/cms/moodle/lib/accesslib.php b/src/cms/moodle/lib/accesslib.php
index 05be9d2..138ff6e 100644
--- a/src/cms/moodle/lib/accesslib.php
+++ b/src/cms/moodle/lib/accesslib.php
@@ -2920,7 +2920,8 @@ function role_assign($roleid, $userid, $groupid, $contextid, $timestart=0, $time
//Feature #1472 - High School: Course User Limits (Teacher Tools)
if(!has_capability('moodle/role:override', $context)){
- $course = get_record('course', 'id', $context->instanceid);
+ // Bug #2661 - Move extra configuration from course to sl_course_settings
+ $course = get_record_sql("SELECT c.*, cs.* FROM course c LEFT JOIN sl_course_settings cs ON c.id=cs.course_id WHERE c.id=$context->instanceid");
if($course->userlimit){
$contextusers = get_role_users($roleid, $context, false, 'u.id, u.firstname, u.lastname');
if(count($contextusers) >= $course->userlimit){
diff --git a/src/cms/moodle/lib/datalib.php b/src/cms/moodle/lib/datalib.php
index 683e0bf..c175e73 100644
--- a/src/cms/moodle/lib/datalib.php
+++ b/src/cms/moodle/lib/datalib.php
@@ -1253,10 +1253,13 @@ function get_courses_search($searchterms, $sort='fullname ASC', $page=0, $record
}
- $sql = "SELECT c.*,
+ // Bug #2661 - Move extra configuration from course to sl_course_settings
+ $sql = "SELECT c.*, cs.*,
ctx.id AS ctxid, ctx.path AS ctxpath,
ctx.depth AS ctxdepth, ctx.contextlevel AS ctxlevel
FROM {$CFG->prefix}course c
+ JOIN {$CFG->prefix}sl_course_settings cs
+ ON (cs.course_id=c.id)
JOIN {$CFG->prefix}context ctx
ON (c.id = ctx.instanceid AND ctx.contextlevel=".CONTEXT_COURSE.")
WHERE (( $fullnamesearch ) OR ( $summarysearch ) OR ( $idnumbersearch ) OR ( $shortnamesearch ))
diff --git a/src/cms/moodle/lib/payment_saplinglearning.php b/src/cms/moodle/lib/payment_saplinglearning.php
index 58ef297..349c544 100644
--- a/src/cms/moodle/lib/payment_saplinglearning.php
+++ b/src/cms/moodle/lib/payment_saplinglearning.php
@@ -99,7 +99,6 @@
}
function getPaymentUserCreditByUser($userid) {
- global $USER;
$userCredit = get_record_sql("select sum(pu.value) as total_value from payment_user pu where user = $userid");
$userDebit = get_record_sql("select sum(pu.value) as total_value from payment_user_use pu where user = $userid");
@@ -111,19 +110,19 @@
function getPaypalPayment($userid, $courseid) {
$sqlGet = "SELECT pp.id, pp.paid, pp.value, pp.txn_id, pp.payment_status, pp.paid+IFNULL(pp2.paid, 0) as remainPaid, pp.value+IFNULL(pp2.value, 0) as remainValue
- FROM payment_paypal AS pp
- INNER JOIN payment_user AS pu
- ON pp.id = pu.sourceid
- AND pu.Payment_gateway_ID = 1
+ FROM payment_paypal AS pp
+ INNER JOIN payment_user AS pu
+ ON pp.id = pu.sourceid
+ AND pu.Payment_gateway_ID = 1
AND pu.value > 0
- INNER JOIN payment_user_use AS puu
- ON pu.id = puu.payment_user_id
- AND puu.course = $courseid
- AND puu.user = $userid
- LEFT JOIN payment_paypal AS pp2
- ON pp.txn_id = pp2.parent_txn_id
- AND pp2.payment_status = 'Refunded'
- WHERE pp.payment_status = 'Completed'
+ INNER JOIN payment_user_use AS puu
+ ON pu.id = puu.payment_user_id
+ AND puu.course = $courseid
+ AND puu.user = $userid
+ LEFT JOIN payment_paypal AS pp2
+ ON pp.txn_id = pp2.parent_txn_id
+ AND pp2.payment_status = 'Refunded'
+ WHERE pp.payment_status = 'Completed'
AND pp.paid+IFNULL(pp2.paid, 0) > 0
ORDER BY puu.id
DESC LIMIT 1";
@@ -132,6 +131,27 @@
return $dataReturn;
}
+ function getPaypalPaymentReading($userid, $taxid) {
+ $sqlGet = "SELECT pp.id, pp.paid, pp.value, pp.txn_id, pp.payment_status, (pp.value + SUM(pp2.value)) as value_remaining
+ FROM payment_paypal AS pp
+ INNER JOIN payment_user AS pu
+ ON pp.id = pu.sourceid
+ AND pu.Payment_gateway_ID = 1
+ INNER JOIN payment_user_use AS puu
+ ON pu.id = puu.payment_user_id
+ AND puu.content__taxonomy__Key = $taxid
+ AND puu.user = $userid
+ LEFT JOIN payment_paypal AS pp2
+ ON pp.txn_id = pp2.parent_txn_id
+ AND pp2.payment_status = 'Refunded'
+ WHERE pp.payment_status = 'Completed'
+ GROUP BY pp.id
+ ORDER BY puu.id DESC";
+ $dataReturn = get_record_sql($sqlGet);
+
+ return $dataReturn;
+ }
+
function email_saplinglearning_error_to_admin($subject, $data, $refund = false, $updatetransaction = false) {
$admin = get_admin();
$site = get_site();
@@ -456,7 +476,7 @@
- SUM(IFNULL( PUU.value , 0 ))
- IFNULL( refundTable.UsedValue , 0 )
) AS value_remaining
- FROM payment_user AS PU
+ FROM payment_user AS PU
LEFT JOIN payment_paypal AS PP
ON PU.Payment_gateway_ID = 1
AND PU.sourceid = PP.id
@@ -475,8 +495,8 @@
ON PU.id = PUU.payment_user_id
WHERE PU.user = $userid
AND PU.value > 0
- GROUP BY PU.id
- HAVING value_remaining > 0";
+ GROUP BY PU.id
+ HAVING value_remaining > 0";
return get_records_sql($sqlGet);
}
@@ -543,6 +563,102 @@
error_log($message);
}
+ function createPaymentFree($userid, $course, $payment_data){
+ $timeOfTransaction = mktime();
+
+ //Creating the payment_free Object
+ $payment_free = new object();
+ $payment_free->value = $course->cost;
+ $payment_free->user = $userid;
+ $payment_free->adminid = $USER->id;
+ $payment_free->timeupdated = $timeOfTransaction;
+
+ //Inserting the [payment_free] record
+ $idPaymentFree = insert_record("payment_free", $payment_free);
+ $payment_free_get = get_record('payment_free', 'id', $idPaymentFree);
+
+ //Creating the payment_user Object
+ $payment_user = new object();
+ $payment_user->user = $userid;
+ $payment_user->Payment_gateway_ID = 4;
+ $payment_user->Payment_source_ID = 0;
+ $payment_user->sourceid = $payment_free_get->id;
+ $payment_user->date = $timeOfTransaction;
+ $payment_user->value = $payment_free->value;
+ $payment_user->multicourse = 0;
+ $payment_user->payment_url = $course->id;
+
+ //Inserting the [payment_user] record
+ $idPaymentUser = insert_record("payment_user", $payment_user);
+
+ //Creating the payment_user_use Object
+ $payment_user_use = new object();
+ $payment_user_use->user = $userid;
+ $payment_user_use->payment_user_id = $idPaymentUser;
+ $payment_user_use->date = $timeOfTransaction;
+ $payment_user_use->value = $payment_free->value;
+ $payment_user_use->course = $course->id;
+
+ //Inserting the [payment_user_use] record
+ insert_record("payment_user_use", $payment_user_use);
+ }
+
+ function logEnrolSaplingLearning($course, $user){
+
+ $enrolGet = get_record('enrol', 'shortname', $course->enrol);
+ $sqlEnrol = "SELECT * FROM enrol_sapling_learning where user = $user->id and course = $course->id order by id desc";
+ $enrolSapling = get_record_sql($sqlEnrol);
+
+ if (($enrolSapling && $enrolSapling->type == 'unenrol') || !$enrolSapling) {
+ $enrolSapling = new Object();
+ $enrolSapling->user = $user->id;
+ $enrolSapling->course = $course->id;
+ $enrolSapling->date = mktime();
+ $enrolSapling->type = 1;
+ $enrolSapling->enrol = $enrolGet->id;
+ $enrolSapling->modifierid = $user->id;
+
+ //Creating the enrol_sapling_learning log
+ insert_record("enrol_sapling_learning", $enrolSapling);
+ }
+ }
+
+ function logUnenrolSaplingLearning($course, $user, $roleid){
+
+ global $USER;
+
+ $enrolGet = get_record('enrol', 'shortname', $course->enrol);
+
+ if ($roleid == 5 || $roleid == 15) {
+
+ $sqlEnrol = "SELECT * FROM enrol_sapling_learning where user = $user->id and course = $course->id order by id desc";
+ $enrolSapling = get_record_sql($sqlEnrol);
+
+ if (($enrolSapling && $enrolSapling->type == 'enrol') || !$enrolSapling) {
+
+ $enrolSapling = new Object();
+ $enrolSapling->user = $user->id;
+ $enrolSapling->course = $course->id;
+ $enrolSapling->date = mktime();
+ $enrolSapling->type = 2;
+ $enrolSapling->enrol = $enrolGet->id;
+ $enrolSapling->modifierid = $USER->id;
+
+ insert_record("enrol_sapling_learning", $enrolSapling);
+ }
+ else {
+ if ($enrolSapling->modifierid != $USER->id) {
+ $enrolSapling->enrol = $enrolGet->id;
+ $enrolSapling->date = mktime();
+ $enrolSapling->modifierid = $USER->id;
+ $enrolSapling->user = $user->id;
+
+ update_record("enrol_sapling_learning", $enrolSapling);
+ }
+ }
+ }
+ }
+
function getReadingPriceTotal($courseid, $taxonomyid, $days){
$reading_course_pricing = QDB::row("cms", "SELECT * FROM reading_course_pricing WHERE course__id = ".$courseid." AND taxonomy__Key = ".$taxonomyid." AND days = ".$days);
@@ -560,6 +676,247 @@
return $reading_user;
}
+ /*
+ * IPN PAYPAL CENTRAL FUNCTIONS
+ */
+
+ function updateExistingPayment($data, $existing){
+
+ $existing->parent_txn_id = $data->parent_txn_id;
+ $existing->mc_fee = $data->mc_fee;
+ $existing->payment_type = $data->payment_type;
+ $existing->payment_status = $data->payment_status;
+ $existing->pending_reason = $data->pending_reason;
+ $existing->reason_code = $data->reason_code;
+ $existing->timeupdated = date("Y-m-d H:i:s");
+
+ update_record('payment_paypal', $existing);
+
+ $payment_user_refund_pending = get_record("payment_user_refund_pending", "txn_id", $existing->parent_txn_id);
+ if($payment_user_refund_pending){
+ delete_records("payment_user_refund_pending", "txn_id", $existing->parent_txn_id);
+ }
+
+ exit();
+ }
+
+ function processRefundFromPaypal($data){
+
+ $paymentPaypalUsedGet = get_record('payment_paypal', 'txn_id', $data->parent_txn_id);
+ if ($paymentPaypalUsedGet) {
+
+ $dataClone = $data;
+ $dataClone->paid = ($paymentPaypalUsedGet->paid * (-1));
+ $dataClone->value = ($paymentPaypalUsedGet->value * (-1));
+
+ //Creating PAYMENT_PAYPAL Record
+ $payment_paypal = new PaymentPaypal($dataClone);
+ $payment_paypal->save();
+
+ $dataClone = $data;
+ $dataClone->Payment_gateway_ID = 1;
+ $dataClone->Payment_source_ID = 0;
+ $dataClone->sourceid = $payment_paypal->id;
+ $dataClone->value = $payment_paypal->value;
+ $dataClone->multicourse = 0;
+
+ //Creating PAYMENT_USER Record
+ $payment_user = new PaymentUser($dataClone);
+ $payment_user->save();
+
+ $payment_user_refund_pending = get_record("payment_user_refund_pending", "txn_id", $data->parent_txn_id);
+ if($payment_user_refund_pending){
+ delete_records("payment_user_refund_pending", "txn_id", $data->parent_txn_id);
+ }
+ }
+ }
+
+ //Feature #1558 - Payment: Handle Changes to Course Price Better
+ //Feature #1559 - Payment: Partial Refunds
+ function processRefundCourseChangePrice($course, $valToRefund){
+ $sqlGet = "SELECT puu.user, pu.id as payment_user_id FROM payment_user_use puu
+ LEFT JOIN payment_user pu ON puu.payment_user_id = pu.id
+ LEFT JOIN payment_paypal pp ON pu.sourceid = pp.id
+ WHERE puu.course = $course->id AND puu.reading_days IS NULL AND puu.content__taxonomy__Key IS NULL
+ GROUP BY puu.user
+ HAVING SUM(puu.value) > 0";
+
+ $course_payment_users = get_records_sql($sqlGet);
+ if($course_payment_users){
+ $stmts = array();
+ foreach($course_payment_users as $course_payment_user){
+ $paymentPaypalUsed = getPaypalPayment($course_payment_user->user, $course->id);
+ if($paymentPaypalUsed){
+ $stmts[] = new SDB_STATEMENT("INSERT INTO payment_user_use (user, payment_user_id, date, value, course) VALUES ($course_payment_user->user, $course_payment_user->payment_user_id, '".date("Y-m-d H:i:s")."', ".($valToRefund * (-1)).", $course->id)", array(), true);
+ $stmts[] = new SDB_STATEMENT("INSERT INTO payment_user_refund_pending (txn_id, value, date_sent) VALUES ('$paymentPaypalUsed->txn_id', $valToRefund, '".date("Y-m-d H:i:s")."') ON DUPLICATE KEY UPDATE value = value+$valToRefund, date_sent = '".date("Y-m-d H:i:s")."'", array(), true);
+ }
+ }
+
+ $series = new SDB_SERIES($stmts,"cms");
+ $handler = new SDB_HANDLER(array($series));
+
+ $handler->execute();
+ }
+ }
+
+ /*
+ * Function Info: processRefundFromSaplingSite()
+ *
+ * Possible Values on $payment_data
+ *
+ * Field ($payment_data->refund):
+ * 0 => No Refund
+ * 1 => Give Sapling Credit
+ * 2 => Paypal Refund
+ *
+ * Field ($payment_data->refund_reading):
+ * 1 => Remove Rading payment and subscription
+ * 2 => Do not remove reading
+ *
+ */
+
+ function processRefundFromSaplingSite($user, $course, $payment_data) {
+
+ $reading_user = null;
+ if($payment_data->refund_reading){
+ $sl_course_settings = get_record("sl_course_settings", "course_id", $course->id);
+ $taxonomy = get_record("content.taxonomy t", "t.Key", $sl_course_settings->home_taxonomy);
+
+ $reading_user = QDB::row("cms", "SELECT * FROM reading_user WHERE content__taxonomy__Key = $taxonomy->Key AND user__id = $user->id");
+ }
+
+ if (getPaymentUserCourse($user, $course) || $reading_user) {
+ if ($payment_data->refund == 2) {
+
+ //Getting Paypal Informations (course and reading)
+ $paymentPaypalUsed = getPaypalPayment($user->id, $course->id);
+ if($reading_user){
+ $readingPayment = getPaypalPaymentReading($user->id, $reading_user['content__taxonomy__Key']);
+ }
+
+ if ($paymentPaypalUsed) {
+ $payment_user_used = get_record("payment_user", "sourceid", $paymentPaypalUsed->id);
+
+ //Make a Partial Refund (Only for course) and leave the reading payment untouched.
+ if($reading_user && $payment_data->refund_reading == 2 && $payment_user_used->multicourse != 1){
+ $sql = "SELECT * FROM payment_user_use WHERE payment_user_id = $payment_user_used->id AND course IS NULL AND user = $user->id AND value > 0 AND content__taxonomy__Key = ".$reading_user['content__taxonomy__Key']." AND reading_days IS NOT NULL";
+ $payment_user_use_reading = get_record_sql($sql);
+
+ $paymentPaypalUsed->paid = $paymentPaypalUsed->paid - $payment_user_use_reading->value;
+ $paymentPaypalUsed->value = $paymentPaypalUsed->value - $payment_user_use_reading->value;
+
+ $paypalReturn = PaypalDoRefund($paymentPaypalUsed->txn_id, 'Partial', $paymentPaypalUsed->paid, "Refund only for Sapling Course payment");
+ }
+ //Make Full Refund
+ else{
+ //Fixing multicourse full refund
+ if($payment_user_used->multicourse == 1){
+ $payment_data->refund_reading == 1;
+ }
+
+ $paypalReturn = PaypalDoRefund($paymentPaypalUsed->txn_id);
+
+ //In case of double paypal payment for course and reading
+ if($readingPayment && $payment_data->refund_reading == 1){
+ $paypalReturn = PaypalDoRefund($readingPayment->txn_id);
+ }
+ }
+ }
+ else if(!$paymentPaypalUsed && $reading_user){
+
+ if($readingPayment){
+ $payment_user_used = get_record("payment_user", "sourceid", $readingPayment->id);
+
+ //Make a Partial Refund (Only for course) and leave the reading payment untouched.
+ if($payment_data->refund_reading == 2 && $payment_user_used->multicourse != 1){
+ $sql = "SELECT * FROM payment_user_use WHERE payment_user_id = $payment_user_used->id AND course IS NULL AND user = $user->id AND value > 0 AND content__taxonomy__Key = ".$reading_user['content__taxonomy__Key']." AND reading_days IS NOT NULL";
+ $payment_user_use_reading = get_record_sql($sql);
+
+ $readingPayment->paid = $readingPayment->paid - $payment_user_use_reading->value;
+ $readingPayment->value = $readingPayment->value - $payment_user_use_reading->value;
+
+ $paypalReturn = PaypalDoRefund($readingPayment->txn_id, 'Partial', $readingPayment->paid, "Refund only for Sapling Course payment");
+ }
+ //Make Full Refund
+ else{
+ //Fixing multicourse full refund
+ if($payment_user_used->multicourse == 1){
+ $payment_data->refund_reading == 1;
+ }
+
+ $paypalReturn = PaypalDoRefund($readingPayment->txn_id);
+ }
+ }
+ }
+ else {
+ //Only to jump the paypal request
+ $paypalReturn = array();
+ $paypalReturn["ACK"] = "GIVESAPLINGCREDIT";
+ }
+
+ if (strtoupper($paypalReturn["ACK"]) == "SUCCESS" || strtoupper($paypalReturn["ACK"]) == "SUCCESSWITHWARNING") {
+
+ $paymentUserUseUsed = get_record_sql("SELECT * FROM payment_user_use WHERE course = $course->id AND user = $user->id AND value > 0 AND reading_days IS NULL ORDER BY id DESC");
+ if($paymentUserUseUsed){
+ $paymentUserUseUsed->id = null;
+ $paymentUserUseUsed->date = mktime();
+ $paymentUserUseUsed->value = ($paymentUserUseUsed->value * (-1));
+
+ insert_record("payment_user_use", $paymentUserUseUsed);
+ }
+
+ //For a Full Refund, update the PUU and expire the reading_user
+ if($reading_user && $payment_data->refund_reading == 1){
+ $sql = "SELECT * FROM payment_user_use WHERE course IS NULL AND user = $user->id AND value > 0 AND content__taxonomy__Key = ".$reading_user['content__taxonomy__Key']." AND reading_days IS NOT NULL ORDER BY id DESC";
+ $payment_user_use_reading = get_record_sql($sql);
+
+ //Inserting the Negative for Reading PUU
+ $payment_user_use_reading->id = null;
+ $payment_user_use_reading->date = mktime();
+ $payment_user_use_reading->value = ($payment_user_use_reading->value * (-1));
+
+ insert_record("payment_user_use", $payment_user_use_reading);
+
+ //Expiring the reading_user
+ $timeExpired = strtotime("-".$payment_user_use_reading->reading_days." days", strtotime($reading_user['expiration']));
+ $reading_user['expiration'] = date("Y-m-d H:i:s", $timeExpired);
+
+ QDB::insertOnDuplicate("cms", "reading_user", $reading_user);
+ }
+ }
+ else {
+ giveSaplingCredit($user, $course, $payment_data);
+ }
+ }
+ else {
+ giveSaplingCredit($user, $course, $payment_data);
+ }
+ }
+ }
+
+ function giveSaplingCredit($user, $course, $payment_data){
+ $sql = "SELECT * FROM payment_user_use WHERE user = $user->id AND course = $course->id AND value > 0 ORDER BY id DESC";
+ $payment_user_use = get_record_sql($sql);
+
+ $payment = new Object();
+ $payment->user = $user->id;
+ $payment->payment_user_id = $payment_user_use->payment_user_id;
+ $payment->date = mktime();
+ $payment->course = $course->id;
+
+ if($payment_data->refund == 1){
+ $payment->value = ($payment_data->refund_value * (-1));
+ }
+ else if($payment_data->refund == 2){
+ $payment->value = ($payment_user_use->value * (-1));
+ }
+ else {
+ $payment->value = 0;
+ }
+
+ insert_record("payment_user_use", $payment);
+ }
+
/**
* Sapling Learning Payment Classes
*
@@ -645,10 +1002,7 @@
public function save(){
if($this->paymentGatewayLogID){
$payment_gateway_log = QDB::row("cms", "SELECT * FROM payment_gateway_log WHERE `Key` = ".$this->paymentGatewayLogID);
- if($payment_gateway_log['reading_days'] > 0){
- $readingPriceTotal = getReadingPriceTotal($payment_gateway_log['course__id'], $payment_gateway_log['content__taxonomy__Key'], $payment_gateway_log['reading_days']);
- $this->value += $readingPriceTotal;
- }
+ $this->value = $payment_gateway_log['expected_value'];
}
if (!$idInserted = insert_record("payment_user", $this)) {
diff --git a/src/cms/moodle/mod/ibis/js/ibisOffsetLib.js b/src/cms/moodle/mod/ibis/js/ibisOffsetLib.js
index f27af09..83f2c3c 100644
--- a/src/cms/moodle/mod/ibis/js/ibisOffsetLib.js
+++ b/src/cms/moodle/mod/ibis/js/ibisOffsetLib.js
@@ -11,419 +11,419 @@ var arrayGroupSelecteds = [];
var arrayCreate = [];
function showComboTime(id, time, repeat){
- comboTime = document.getElementById(id);
-
- optTime = document.createElement("OPTION");
- textHour = document.createTextNode("");
- optTime.appendChild(textHour);
- optTime.setAttribute("value","");
- if(time == ""){
- optTime.setAttribute("selected","selected");
- }
- if(comboTime){
- comboTime.appendChild(optTime);
- }
-
- var i=0;
-
- // Getting and setting minutes
- if(repeat == 59){
- for (i=0; i<=repeat; i++){
- if(i%5 == 0){
- optTime = document.createElement("OPTION");
- if(i < 10){
- textHour = document.createTextNode("0"+i);
- }
- else{
- textHour = document.createTextNode(i);
- }
-
- while(time%5 != 0){
- time--;
- }
-
- optTime.appendChild(textHour);
- optTime.setAttribute("value",i);
- if(i == time && time != ""){
- optTime.setAttribute("selected","selected");
- }
-
- if(comboTime){
- comboTime.appendChild(optTime);
- }
-
- }
- }
- }
- // Getting and setting hours
- else{
- for (i=0; i<=repeat; i++){
- optTime = document.createElement("OPTION");
- if(i < 10){
- textHour = document.createTextNode("0"+i);
- }
- else{
- textHour = document.createTextNode(i);
- }
-
- optTime.appendChild(textHour);
- optTime.setAttribute("value",i);
- if(i == time && time != ""){
- optTime.setAttribute("selected","selected");
- }
- if(comboTime){
- comboTime.appendChild(optTime);
- }
- }
- }
+ comboTime = document.getElementById(id);
+
+ optTime = document.createElement("OPTION");
+ textHour = document.createTextNode("");
+ optTime.appendChild(textHour);
+ optTime.setAttribute("value","");
+ if(time == ""){
+ optTime.setAttribute("selected","selected");
+ }
+ if(comboTime){
+ comboTime.appendChild(optTime);
+ }
+
+ var i=0;
+
+ // Getting and setting minutes
+ if(repeat == 59){
+ for (i=0; i<=repeat; i++){
+ if(i%5 == 0){
+ optTime = document.createElement("OPTION");
+ if(i < 10){
+ textHour = document.createTextNode("0"+i);
+ }
+ else{
+ textHour = document.createTextNode(i);
+ }
+
+ while(time%5 != 0){
+ time--;
+ }
+
+ optTime.appendChild(textHour);
+ optTime.setAttribute("value",i);
+ if(i == time && time != ""){
+ optTime.setAttribute("selected","selected");
+ }
+
+ if(comboTime){
+ comboTime.appendChild(optTime);
+ }
+
+ }
+ }
+ }
+ // Getting and setting hours
+ else{
+ for (i=0; i<=repeat; i++){
+ optTime = document.createElement("OPTION");
+ if(i < 10){
+ textHour = document.createTextNode("0"+i);
+ }
+ else{
+ textHour = document.createTextNode(i);
+ }
+
+ optTime.appendChild(textHour);
+ optTime.setAttribute("value",i);
+ if(i == time && time != ""){
+ optTime.setAttribute("selected","selected");
+ }
+ if(comboTime){
+ comboTime.appendChild(optTime);
+ }
+ }
+ }
}
function editIbisDates(type){
- var datePickerContainer = "";
- var datePickerContainerAc = "";
- var termGet = "";
- var valueDate = "";
- var valueHour = "";
- var valueMinute = "";
-
- if(type == 1){
- datePickerContainer = "#ibisAvailableFrom";
- datePickerContainerAc = "#ibisAvailableFromAction";
- termGet = "AVA";
- valueDate = availableDt;
- valueHour = availableHr;
- valueMinute = availableMn;
- }
- else{
- datePickerContainer = "#ibisDueDate";
- datePickerContainerAc = "#ibisDueDateAction";
- termGet = "DUE";
- valueDate = dueDt;
- valueHour = dueHr;
- valueMinute = dueMn;
- }
-
- var htmlSend = '<input type="text" readonly="readonly" id="datePick'+termGet+'" value="'+valueDate+'" size="10" /> ';
- htmlSend += '<select id="HR'+termGet+'"></select> : <select id="MI'+termGet+'"></select>';
- $(datePickerContainer).html(htmlSend);
-
- $("#datePick"+termGet).datepicker();
- showComboTime("HR"+termGet, '', 23);
- showComboTime("MI"+termGet, '', 59);
-
- $("#HR"+termGet).val(valueHour);
- $("#MI"+termGet).val(valueMinute);
-
- var htmlSend = '<a href="#" style="padding-top:10px;" onclick="editIbisDatesSave('+type+');"><img src="'+pathURL+'/mod/ibis/ico_save.png" width="15" /></a>';
- $(datePickerContainerAc).html(htmlSend);
+ var datePickerContainer = "";
+ var datePickerContainerAc = "";
+ var termGet = "";
+ var valueDate = "";
+ var valueHour = "";
+ var valueMinute = "";
+
+ if(type == 1){
+ datePickerContainer = "#ibisAvailableFrom";
+ datePickerContainerAc = "#ibisAvailableFromAction";
+ termGet = "AVA";
+ valueDate = availableDt;
+ valueHour = availableHr;
+ valueMinute = availableMn;
+ }
+ else{
+ datePickerContainer = "#ibisDueDate";
+ datePickerContainerAc = "#ibisDueDateAction";
+ termGet = "DUE";
+ valueDate = dueDt;
+ valueHour = dueHr;
+ valueMinute = dueMn;
+ }
+
+ var htmlSend = '<input type="text" readonly="readonly" id="datePick'+termGet+'" value="'+valueDate+'" size="10" /> ';
+ htmlSend += '<select id="HR'+termGet+'"></select> : <select id="MI'+termGet+'"></select>';
+ $(datePickerContainer).html(htmlSend);
+
+ $("#datePick"+termGet).datepicker();
+ showComboTime("HR"+termGet, '', 23);
+ showComboTime("MI"+termGet, '', 59);
+
+ $("#HR"+termGet).val(valueHour);
+ $("#MI"+termGet).val(valueMinute);
+
+ var htmlSend = '<a href="#" style="padding-top:10px;" onclick="editIbisDatesSave('+type+');"><img src="'+pathURL+'/mod/ibis/ico_save.png" width="15" /></a>';
+ $(datePickerContainerAc).html(htmlSend);
}
function editIbisDatesSave(type){
- var dataSend = {};
- var termGet = "";
-
- if(type == 1){
- dataSend.tp = "A";
- termGet = "AVA";
- }
- else{
- dataSend.tp = "D";
- termGet = "DUE";
- }
-
- dataSend.id = ibisid;
- dataSend.dt = $("#datePick"+termGet).val();
- dataSend.hr = $("#HR"+termGet).val();
- dataSend.mn = $("#MI"+termGet).val();
-
- $.ajax({
- url: pathURL+"/mod/ibis/grade/ajaxSaveActivitiesDue.php",
- data: dataSend,
- type: 'post',
- success: function(data) {
- if(data == 'true'){
- location.href = pathURL+"/mod/ibis/offset/index.php?id="+cmid;
- }
- }
- });
+ var dataSend = {};
+ var termGet = "";
+
+ if(type == 1){
+ dataSend.tp = "A";
+ termGet = "AVA";
+ }
+ else{
+ dataSend.tp = "D";
+ termGet = "DUE";
+ }
+
+ dataSend.id = ibisid;
+ dataSend.dt = $("#datePick"+termGet).val();
+ dataSend.hr = $("#HR"+termGet).val();
+ dataSend.mn = $("#MI"+termGet).val();
+
+ $.ajax({
+ url: pathURL+"/mod/ibis/grade/ajaxSaveActivitiesDue.php",
+ data: dataSend,
+ type: 'post',
+ success: function(data) {
+ if(data == 'true'){
+ location.href = pathURL+"/mod/ibis/offset/index.php?id="+cmid;
+ }
+ }
+ });
}
function deleteExtension(id, type, user, cmid){
- var dataSend = {};
- dataSend.id = id;
- dataSend.type = type;
- if(confirm('You really want to remove this record?')){
- $.ajax({
- url: "dao_delete_offset.php",
- data: dataSend,
- type: 'post',
- success: function(data) {
- if(data == 'true'){
- var jsClickFunction = 'enableEdit('+id+', '+type+', '+user+', '+cmid+');';
- var newOnClick = new Function(jsClickFunction);
- var termDiv = "";
- if(type == 1){
- termDiv = "OAF";
- }
- else{
- termDiv = "EDD";
- }
-
- $("#datePick"+termDiv+id+user+cmid).attr('disabled', 'disabled').val(availableDt);
- $("#HR"+termDiv+"_"+id+user+cmid).val(availableHr).attr('disabled', 'disabled');
- $("#MI"+termDiv+"_"+id+user+cmid).val(availableMn).attr('disabled', 'disabled');
-
- $("#linkGrid"+termDiv+id+user+cmid).attr('onclick', '').click(newOnClick);
- $("#imgGrid"+termDiv+id+user+cmid).attr('src', pathIcon+'/edit.gif');
-
- }
- else{
- alert('Error');
- }
- }
- });
- }
+ var dataSend = {};
+ dataSend.id = id;
+ dataSend.type = type;
+ if(confirm('You really want to remove this record?')){
+ $.ajax({
+ url: "dao_delete_offset.php",
+ data: dataSend,
+ type: 'post',
+ success: function(data) {
+ if(data == 'true'){
+ var jsClickFunction = 'enableEdit('+id+', '+type+', '+user+', '+cmid+');';
+ var newOnClick = new Function(jsClickFunction);
+ var termDiv = "";
+ if(type == 1){
+ termDiv = "OAF";
+ }
+ else{
+ termDiv = "EDD";
+ }
+
+ $("#datePick"+termDiv+id+user+cmid).attr('disabled', 'disabled').val(availableDt);
+ $("#HR"+termDiv+"_"+id+user+cmid).val(availableHr).attr('disabled', 'disabled');
+ $("#MI"+termDiv+"_"+id+user+cmid).val(availableMn).attr('disabled', 'disabled');
+
+ $("#linkGrid"+termDiv+id+user+cmid).attr('onclick', '').click(newOnClick);
+ $("#imgGrid"+termDiv+id+user+cmid).attr('src', pathIcon+'/edit.gif');
+
+ }
+ else{
+ alert('Error');
+ }
+ }
+ });
+ }
}
function enableSave(id, type, user, cmid){
- var termDiv = "";
- if(type == 1){
- termDiv = "OAF";
- }
- else{
- termDiv = "EDD";
- }
-
- if($("#datePick"+termDiv+id+user+cmid).val() != "" && $("#HR"+termDiv+"_"+id+user+cmid) != "" && $("#MI"+termDiv+"_"+id+user+cmid).val() != ""){
- $("#Save"+termDiv+id+user+cmid).show();
- }
+ var termDiv = "";
+ if(type == 1){
+ termDiv = "OAF";
+ }
+ else{
+ termDiv = "EDD";
+ }
+
+ if($("#datePick"+termDiv+id+user+cmid).val() != "" && $("#HR"+termDiv+"_"+id+user+cmid) != "" && $("#MI"+termDiv+"_"+id+user+cmid).val() != ""){
+ $("#Save"+termDiv+id+user+cmid).show();
+ }
}
function enableEdit(id, type, user, cmid){
- var jsClickFunction = 'deleteExtension('+id+', '+type+', '+user+', '+cmid+');';
+ var jsClickFunction = 'deleteExtension('+id+', '+type+', '+user+', '+cmid+');';
var newOnClick = new Function(jsClickFunction);
var termDiv = "";
- if(type == 1){
- termDiv = "OAF";
- }
- else{
- termDiv = "EDD";
- }
+ if(type == 1){
+ termDiv = "OAF";
+ }
+ else{
+ termDiv = "EDD";
+ }
- $("#datePick"+termDiv+id+user+cmid).removeAttr('disabled').focus();
- $("#HR"+termDiv+"_"+id+user+cmid).removeAttr('disabled');
- $("#MI"+termDiv+"_"+id+user+cmid).removeAttr('disabled');
+ $("#datePick"+termDiv+id+user+cmid).removeAttr('disabled').focus();
+ $("#HR"+termDiv+"_"+id+user+cmid).removeAttr('disabled');
+ $("#MI"+termDiv+"_"+id+user+cmid).removeAttr('disabled');
- $("#linkGrid"+termDiv+id+user+cmid).attr('onclick', '').click(newOnClick);
- $("#imgGrid"+termDiv+id+user+cmid).hide();
- $("#Save"+termDiv+id+user+cmid).show();
+ $("#linkGrid"+termDiv+id+user+cmid).attr('onclick', '').click(newOnClick);
+ $("#imgGrid"+termDiv+id+user+cmid).hide();
+ $("#Save"+termDiv+id+user+cmid).show();
}
function createOffset(id, type, user, cmid){
- var termDiv = "";
- if(type == 1){
- termDiv = "OAF";
- }
- else{
- termDiv = "EDD";
- }
-
- var dataSend = {};
- dataSend.id = id;
- dataSend.type = type;
- dataSend.user = user;
- dataSend.cmid = cmid;
- dataSend.date = $("#datePick"+termDiv+id+user+cmid).val();
- dataSend.hr = $("#HR"+termDiv+"_"+id+user+cmid).val();
- dataSend.mn = $("#MI"+termDiv+"_"+id+user+cmid).val();
-
- if(dataSend.date == "" || dataSend.hr == "" || dataSend.mn == ""){
- alert('Please, insert a complete date. [Date, Hour and Minute]');
- return false;
- }
-
- $.ajax({
- url: "dao_create_offset.php",
- data: dataSend,
- type: 'post',
- success: function(data) {
- if(data == 'true'){
- var jsClickFunction = 'deleteExtension('+id+', '+type+', '+user+', '+cmid+');';
- var newOnClick = new Function(jsClickFunction);
- var termDiv = "";
- if(type == 1){
- termDiv = "OAF";
- }
- else{
- termDiv = "EDD";
- }
-
- $("#linkGrid"+termDiv+id+user+cmid).attr('onclick', '').click(newOnClick);
- $("#imgGrid"+termDiv+id+user+cmid).attr('src', pathIcon+'/delete.png').show();
- $("#Save"+termDiv+id+user+cmid).hide();
- }
- else{
- alert('Error');
- }
- }
- });
+ var termDiv = "";
+ if(type == 1){
+ termDiv = "OAF";
+ }
+ else{
+ termDiv = "EDD";
+ }
+
+ var dataSend = {};
+ dataSend.id = id;
+ dataSend.type = type;
+ dataSend.user = user;
+ dataSend.cmid = cmid;
+ dataSend.date = $("#datePick"+termDiv+id+user+cmid).val();
+ dataSend.hr = $("#HR"+termDiv+"_"+id+user+cmid).val();
+ dataSend.mn = $("#MI"+termDiv+"_"+id+user+cmid).val();
+
+ if(dataSend.date == "" || dataSend.hr == "" || dataSend.mn == ""){
+ alert('Please, insert a complete date. [Date, Hour and Minute]');
+ return false;
+ }
+
+ $.ajax({
+ url: "dao_create_offset.php",
+ data: dataSend,
+ type: 'post',
+ success: function(data) {
+ if(data == 'true'){
+ var jsClickFunction = 'deleteExtension('+id+', '+type+', '+user+', '+cmid+');';
+ var newOnClick = new Function(jsClickFunction);
+ var termDiv = "";
+ if(type == 1){
+ termDiv = "OAF";
+ }
+ else{
+ termDiv = "EDD";
+ }
+
+ $("#linkGrid"+termDiv+id+user+cmid).attr('onclick', '').click(newOnClick);
+ $("#imgGrid"+termDiv+id+user+cmid).attr('src', pathIcon+'/delete.png').show();
+ $("#Save"+termDiv+id+user+cmid).hide();
+ }
+ else{
+ alert('Error');
+ }
+ }
+ });
}
function createOffsetSelecteds(){
- var dataSend = {};
- dataSend.availableDT = $("#datePickOAFSelected").val();
- dataSend.availableHR = $("#HROAFSelected").val();
- dataSend.availableMN = $("#MIOAFSelected").val();
-
- dataSend.dueDT = $("#datePickEDDSelected").val();
- dataSend.dueHR = $("#HREDDSelected").val();
- dataSend.dueMN = $("#MIEDDSelected").val();
-
- if((dataSend.availableDT == "" || dataSend.availableHR == "" || dataSend.availableMN == "") && (dataSend.dueDT == "" || dataSend.dueHR == "" || dataSend.dueMN == "")){
- alert('Please, insert a full date.');
- return false;
- }
- else{
- var countUsers = arraySelecteds.length;
- var countLoop = 1;
- for(var i in arraySelecteds){
-
- dataSend.user = arraySelecteds[i]["user"];
- dataSend.cmid = arraySelecteds[i]["cmid"];
-
- $.ajax({
- url: "dao_create_offset_selecteds.php",
- data: dataSend,
- type: 'post',
- success: function(data) {
- if(data == 'true'){
- if(countLoop == countUsers){
- location.href = pathURL+"/mod/ibis/offset/index.php?id="+cmid;
- }
- countLoop++;
- }
- else{
- alert('Error User: '+dataSend.user);
- }
- }
- });
- }
- }
+ var dataSend = {};
+ dataSend.availableDT = $("#datePickOAFSelected").val();
+ dataSend.availableHR = $("#HROAFSelected").val();
+ dataSend.availableMN = $("#MIOAFSelected").val();
+
+ dataSend.dueDT = $("#datePickEDDSelected").val();
+ dataSend.dueHR = $("#HREDDSelected").val();
+ dataSend.dueMN = $("#MIEDDSelected").val();
+
+ if((dataSend.availableDT == "" || dataSend.availableHR == "" || dataSend.availableMN == "") && (dataSend.dueDT == "" || dataSend.dueHR == "" || dataSend.dueMN == "")){
+ alert('Please, insert a full date.');
+ return false;
+ }
+ else{
+ var countUsers = arraySelecteds.length;
+ var countLoop = 1;
+ for(var i in arraySelecteds){
+
+ dataSend.user = arraySelecteds[i]["user"];
+ dataSend.cmid = arraySelecteds[i]["cmid"];
+
+ $.ajax({
+ url: "dao_create_offset_selecteds.php",
+ data: dataSend,
+ type: 'post',
+ success: function(data) {
+ if(data == 'true'){
+ if(countLoop == countUsers){
+ location.href = pathURL+"/mod/ibis/offset/index.php?id="+cmid;
+ }
+ countLoop++;
+ }
+ else{
+ alert('Error User: '+dataSend.user);
+ }
+ }
+ });
+ }
+ }
}
function checkUser(user, cmid, ck){
- var obj = {};
- obj.user = user;
- obj.cmid = cmid;
-
- if(ck == true){
- arraySelecteds.push(obj);
- }
- else{
- for(var i in arraySelecteds){
- if(arraySelecteds[i]["user"] == user){
- arraySelecteds.splice(i,1);
- }
- }
- }
-
- if(arraySelecteds.length > 0){
- $("#updateLabel").show("fast");
- $("#updateOAF").show("fast");
- $("#updateEDD").show("fast");
- }
- else{
- $("#updateLabel").hide("fast");
- $("#updateOAF").hide("fast");
- $("#updateEDD").hide("fast");
- }
+ var obj = {};
+ obj.user = user;
+ obj.cmid = cmid;
+
+ if(ck == true){
+ arraySelecteds.push(obj);
+ }
+ else{
+ for(var i in arraySelecteds){
+ if(arraySelecteds[i]["user"] == user){
+ arraySelecteds.splice(i,1);
+ }
+ }
+ }
+
+ if(arraySelecteds.length > 0){
+ $("#updateLabel").show("fast");
+ $("#updateOAF").show("fast");
+ $("#updateEDD").show("fast");
+ }
+ else{
+ $("#updateLabel").hide("fast");
+ $("#updateOAF").hide("fast");
+ $("#updateEDD").hide("fast");
+ }
}
function showArray(){
- var showBack = "";
- for(var i in arraySelecteds){
- showBack += "User: "+arraySelecteds[i]["user"]+" - CMID: "+arraySelecteds[i]["cmid"]+"\n";
- }
- alert(showBack);
+ var showBack = "";
+ for(var i in arraySelecteds){
+ showBack += "User: "+arraySelecteds[i]["user"]+" - CMID: "+arraySelecteds[i]["cmid"]+"\n";
+ }
+ alert(showBack);
}
function enableAddBox(div){
- $("#"+div).show("fast");
+ $("#"+div).show("fast");
}
function disableAddBox(div){
- $("#"+div).hide("fast");
+ $("#"+div).hide("fast");
}
function countMultipleSelecteds(select, div){
- var count = 0;
- $("#"+select+" option:selected").each(function () {
- count++;
- });
- $("#"+div).html(count);
+ var count = 0;
+ $("#"+select+" option:selected").each(function () {
+ count++;
+ });
+ $("#"+div).html(count);
}
function createOffsetAdd(){
- var dataSend = {};
- dataSend.availableDT = $("#datePickOAFAdd").val();
- dataSend.availableHR = $("#HROAFAdd").val();
- dataSend.availableMN = $("#MIOAFAdd").val();
-
- var availableCheck = false;
- if(dataSend.availableDT == availableDt && dataSend.availableHR == availableHr && dataSend.availableMN == availableMn){
- availableCheck = true;
- }
-
- dataSend.dueDT = $("#datePickEDDAdd").val();
- dataSend.dueHR = $("#HREDDAdd").val();
- dataSend.dueMN = $("#MIEDDAdd").val();
-
- var countUsers = 0;
- $("#addOffsetSelect option:selected").each(function () {
- countUsers++;
- });
-
- if(countUsers == 0){
- alert('Please, select student(s).');
- return false;
- }
-
- var dueCheck = false;
- if(dataSend.dueDT == dueDt && dataSend.dueHR == dueHr && dataSend.dueMN == dueMn){
- dueCheck = true;
- }
-
- if(availableCheck == true && dueCheck == true){
- alert("Available From and Due Dates will not be created. Same as Ibis Dates");
- return false;
- }
-
- if((dataSend.availableDT == "" || dataSend.availableHR == "" || dataSend.availableMN == "") && (dataSend.dueDT == "" || dataSend.dueHR == "" || dataSend.dueMN == "")){
- alert('Please, insert a full date.');
- return false;
- }
- else{
- var countLoop = 1;
- $("#addOffsetSelect option:selected").each(function () {
- dataSend.user = $(this).val();
- dataSend.cmid = cmid;
- $.ajax({
- url: "dao_create_offset_selecteds.php",
- data: dataSend,
- type: 'post',
- success: function(data) {
- if(data == 'true'){
- if(countLoop == countUsers){
- location.href = pathURL+"/mod/ibis/offset/index.php?id="+cmid;
- }
- countLoop++;
- }
- }
- });
- });
- }
+ var dataSend = {};
+ dataSend.availableDT = $("#datePickOAFAdd").val();
+ dataSend.availableHR = $("#HROAFAdd").val();
+ dataSend.availableMN = $("#MIOAFAdd").val();
+
+ var availableCheck = false;
+ if(dataSend.availableDT == availableDt && dataSend.availableHR == availableHr && dataSend.availableMN == availableMn){
+ availableCheck = true;
+ }
+
+ dataSend.dueDT = $("#datePickEDDAdd").val();
+ dataSend.dueHR = $("#HREDDAdd").val();
+ dataSend.dueMN = $("#MIEDDAdd").val();
+
+ var countUsers = 0;
+ $("#addOffsetSelect option:selected").each(function () {
+ countUsers++;
+ });
+
+ if(countUsers == 0){
+ alert('Please, select student(s).');
+ return false;
+ }
+
+ var dueCheck = false;
+ if(dataSend.dueDT == dueDt && dataSend.dueHR == dueHr && dataSend.dueMN == dueMn){
+ dueCheck = true;
+ }
+
+ if(availableCheck == true && dueCheck == true){
+ alert("Available From and Due Dates will not be created. Same as Ibis Dates");
+ return false;
+ }
+
+ if((dataSend.availableDT == "" || dataSend.availableHR == "" || dataSend.availableMN == "") && (dataSend.dueDT == "" || dataSend.dueHR == "" || dataSend.dueMN == "")){
+ alert('Please, insert a full date.');
+ return false;
+ }
+ else{
+ var countLoop = 1;
+ $("#addOffsetSelect option:selected").each(function () {
+ dataSend.user = $(this).val();
+ dataSend.cmid = cmid;
+ $.ajax({
+ url: "dao_create_offset_selecteds.php",
+ data: dataSend,
+ type: 'post',
+ success: function(data) {
+ if(data == 'true'){
+ if(countLoop == countUsers){
+ location.href = pathURL+"/mod/ibis/offset/index.php?id="+cmid;
+ }
+ countLoop++;
+ }
+ }
+ });
+ });
+ }
}
/**
@@ -431,228 +431,228 @@ function createOffsetAdd(){
*/
function createOffsetAddGroup(){
- var dataSend = {};
- dataSend.availableDT = $("#datePickOAFAddG").val();
- dataSend.availableHR = $("#HROAFAddG").val();
- dataSend.availableMN = $("#MIOAFAddG").val();
-
- var availableCheck = false;
- if(dataSend.availableDT == availableDt && dataSend.availableHR == availableHr && dataSend.availableMN == availableMn){
- availableCheck = true;
- }
-
- dataSend.dueDT = $("#datePickEDDAddG").val();
- dataSend.dueHR = $("#HREDDAddG").val();
- dataSend.dueMN = $("#MIEDDAddG").val();
-
- var countGroups = 0;
- $("#addOffsetSelectG option:selected").each(function () {
- countGroups++;
- });
-
- if(countGroups == 0){
- alert('Please, select group(s).');
- return false;
- }
-
- var dueCheck = false;
- if(dataSend.dueDT == dueDt && dataSend.dueHR == dueHr && dataSend.dueMN == dueMn){
- dueCheck = true;
- }
-
- if(availableCheck == true && dueCheck == true){
- alert("Available From and Due Dates will not be created. Same as Ibis Dates");
- return false;
- }
-
- if((dataSend.availableDT == "" || dataSend.availableHR == "" || dataSend.availableMN == "") && (dataSend.dueDT == "" || dataSend.dueHR == "" || dataSend.dueMN == "")){
- alert('Please, insert a full date.');
- return false;
- }
- else{
- var countLoop = 1;
- $("#addOffsetSelectG option:selected").each(function () {
- dataSend.group = $(this).val();
- dataSend.cmid = cmid;
- $.ajax({
- url: "dao_create_offset_groups_selecteds.php",
- data: dataSend,
- type: 'post',
- success: function(data) {
- if(data == 'true'){
- if(countLoop == countGroups){
- location.href = pathURL+"/mod/ibis/offset/index.php?id="+cmid;
- }
- countLoop++;
- }
- }
- });
- });
- }
+ var dataSend = {};
+ dataSend.availableDT = $("#datePickOAFAddG").val();
+ dataSend.availableHR = $("#HROAFAddG").val();
+ dataSend.availableMN = $("#MIOAFAddG").val();
+
+ var availableCheck = false;
+ if(dataSend.availableDT == availableDt && dataSend.availableHR == availableHr && dataSend.availableMN == availableMn){
+ availableCheck = true;
+ }
+
+ dataSend.dueDT = $("#datePickEDDAddG").val();
+ dataSend.dueHR = $("#HREDDAddG").val();
+ dataSend.dueMN = $("#MIEDDAddG").val();
+
+ var countGroups = 0;
+ $("#addOffsetSelectG option:selected").each(function () {
+ countGroups++;
+ });
+
+ if(countGroups == 0){
+ alert('Please, select group(s).');
+ return false;
+ }
+
+ var dueCheck = false;
+ if(dataSend.dueDT == dueDt && dataSend.dueHR == dueHr && dataSend.dueMN == dueMn){
+ dueCheck = true;
+ }
+
+ if(availableCheck == true && dueCheck == true){
+ alert("Available From and Due Dates will not be created. Same as Ibis Dates");
+ return false;
+ }
+
+ if((dataSend.availableDT == "" || dataSend.availableHR == "" || dataSend.availableMN == "") && (dataSend.dueDT == "" || dataSend.dueHR == "" || dataSend.dueMN == "")){
+ alert('Please, insert a full date.');
+ return false;
+ }
+ else{
+ var countLoop = 1;
+ $("#addOffsetSelectG option:selected").each(function () {
+ dataSend.group = $(this).val();
+ dataSend.cmid = cmid;
+ $.ajax({
+ url: "dao_create_offset_groups_selecteds.php",
+ data: dataSend,
+ type: 'post',
+ success: function(data) {
+ if(data == 'true'){
+ if(countLoop == countGroups){
+ location.href = pathURL+"/mod/ibis/offset/index.php?id="+cmid;
+ }
+ countLoop++;
+ }
+ }
+ });
+ });
+ }
}
function deleteGroupDate(group, type, cmid){
- var dataSend = {};
- dataSend.group = group;
- dataSend.type = type;
- dataSend.cmid = cmid;
-
- if(confirm('You really want to remove this record?')){
- $.ajax({
- url: "dao_delete_group_offset.php",
- data: dataSend,
- type: 'post',
- success: function(data) {
- if(data == 'true'){
- location.href = pathURL+"/mod/ibis/offset/index.php?id="+cmid;
- }
- else{
- alert('Error');
- }
- }
- });
- }
+ var dataSend = {};
+ dataSend.group = group;
+ dataSend.type = type;
+ dataSend.cmid = cmid;
+
+ if(confirm('You really want to remove this record?')){
+ $.ajax({
+ url: "dao_delete_group_offset.php",
+ data: dataSend,
+ type: 'post',
+ success: function(data) {
+ if(data == 'true'){
+ location.href = pathURL+"/mod/ibis/offset/index.php?id="+cmid;
+ }
+ else{
+ alert('Error');
+ }
+ }
+ });
+ }
}
function enableGroupEdit(group, type, cmid){
- var jsClickFunction = 'deleteGroupDate('+group+', '+type+', '+cmid+');';
+ var jsClickFunction = 'deleteGroupDate('+group+', '+type+', '+cmid+');';
var newOnClick = new Function(jsClickFunction);
var termDiv = "";
- if(type == 1){
- termDiv = "OAF";
- }
- else{
- termDiv = "EDD";
- }
+ if(type == 1){
+ termDiv = "OAF";
+ }
+ else{
+ termDiv = "EDD";
+ }
- $("#datePickGroup"+termDiv+group+cmid).removeAttr('disabled').focus();
- $("#HRGroup"+termDiv+"_"+group+cmid).removeAttr('disabled');
- $("#MIGroup"+termDiv+"_"+group+cmid).removeAttr('disabled');
+ $("#datePickGroup"+termDiv+group+cmid).removeAttr('disabled').focus();
+ $("#HRGroup"+termDiv+"_"+group+cmid).removeAttr('disabled');
+ $("#MIGroup"+termDiv+"_"+group+cmid).removeAttr('disabled');
- $("#linkGridGroup"+termDiv+group+cmid).attr('onclick', '').click(newOnClick);
- $("#imgGridGroup"+termDiv+group+cmid).hide();
- $("#SaveGroup"+termDiv+group+cmid).show();
+ $("#linkGridGroup"+termDiv+group+cmid).attr('onclick', '').click(newOnClick);
+ $("#imgGridGroup"+termDiv+group+cmid).hide();
+ $("#SaveGroup"+termDiv+group+cmid).show();
}
function enableSaveGroup(group, type, cmid){
- var termDiv = "";
- if(type == 1){
- termDiv = "OAF";
- }
- else{
- termDiv = "EDD";
- }
-
- if($("#datePickGroup"+termDiv+group+cmid).val() != "" && $("#HRGroup"+termDiv+"_"+group+cmid) != "" && $("#MIGroup"+termDiv+"_"+group+cmid).val() != ""){
- $("#SaveGroup"+termDiv+group+cmid).show();
- }
+ var termDiv = "";
+ if(type == 1){
+ termDiv = "OAF";
+ }
+ else{
+ termDiv = "EDD";
+ }
+
+ if($("#datePickGroup"+termDiv+group+cmid).val() != "" && $("#HRGroup"+termDiv+"_"+group+cmid) != "" && $("#MIGroup"+termDiv+"_"+group+cmid).val() != ""){
+ $("#SaveGroup"+termDiv+group+cmid).show();
+ }
}
function saveGroupDate(group, type, cmid){
- var termDiv = "";
- if(type == 1){
- termDiv = "OAF";
- }
- else{
- termDiv = "EDD";
- }
-
- var dataSend = {};
- dataSend.group = group;
- dataSend.type = type;
- dataSend.cmid = cmid;
- dataSend.date = $("#datePickGroup"+termDiv+group+cmid).val();
- dataSend.hr = $("#HRGroup"+termDiv+"_"+group+cmid).val();
- dataSend.mn = $("#MIGroup"+termDiv+"_"+group+cmid).val();
-
- if(dataSend.date == "" || dataSend.hr == "" || dataSend.mn == ""){
- alert('Please, insert a complete date. [Date, Hour and Minute]');
- return false;
- }
-
- $.ajax({
- url: "dao_group_offset.php",
- data: dataSend,
- type: 'post',
- success: function(data) {
- if(data == 'true'){
- location.href = pathURL+"/mod/ibis/offset/index.php?id="+cmid;
- }
- else{
- alert('Error');
- }
- }
- });
+ var termDiv = "";
+ if(type == 1){
+ termDiv = "OAF";
+ }
+ else{
+ termDiv = "EDD";
+ }
+
+ var dataSend = {};
+ dataSend.group = group;
+ dataSend.type = type;
+ dataSend.cmid = cmid;
+ dataSend.date = $("#datePickGroup"+termDiv+group+cmid).val();
+ dataSend.hr = $("#HRGroup"+termDiv+"_"+group+cmid).val();
+ dataSend.mn = $("#MIGroup"+termDiv+"_"+group+cmid).val();
+
+ if(dataSend.date == "" || dataSend.hr == "" || dataSend.mn == ""){
+ alert('Please, insert a complete date. [Date, Hour and Minute]');
+ return false;
+ }
+
+ $.ajax({
+ url: "dao_group_offset.php",
+ data: dataSend,
+ type: 'post',
+ success: function(data) {
+ if(data == 'true'){
+ location.href = pathURL+"/mod/ibis/offset/index.php?id="+cmid;
+ }
+ else{
+ alert('Error');
+ }
+ }
+ });
}
function checkGroup(group, cmid, ck){
- var obj = {};
- obj.group = group;
- obj.cmid = cmid;
-
- if(ck == true){
- arrayGroupSelecteds.push(obj);
- }
- else{
- for(var i in arrayGroupSelecteds){
- if(arrayGroupSelecteds[i]["group"] == group){
- arrayGroupSelecteds.splice(i,1);
- }
- }
- }
-
- if(arrayGroupSelecteds.length > 0){
- $("#updateGroupLabel").show("fast");
- $("#updateGroupOAF").show("fast");
- $("#updateGroupEDD").show("fast");
- }
- else{
- $("#updateGroupLabel").hide("fast");
- $("#updateGroupOAF").hide("fast");
- $("#updateGroupEDD").hide("fast");
- }
+ var obj = {};
+ obj.group = group;
+ obj.cmid = cmid;
+
+ if(ck == true){
+ arrayGroupSelecteds.push(obj);
+ }
+ else{
+ for(var i in arrayGroupSelecteds){
+ if(arrayGroupSelecteds[i]["group"] == group){
+ arrayGroupSelecteds.splice(i,1);
+ }
+ }
+ }
+
+ if(arrayGroupSelecteds.length > 0){
+ $("#updateGroupLabel").show("fast");
+ $("#updateGroupOAF").show("fast");
+ $("#updateGroupEDD").show("fast");
+ }
+ else{
+ $("#updateGroupLabel").hide("fast");
+ $("#updateGroupOAF").hide("fast");
+ $("#updateGroupEDD").hide("fast");
+ }
}
function createOffsetGroupsSelecteds(){
- var dataSend = {};
- dataSend.availableDT = $("#datePickOAFGroupSelected").val();
- dataSend.availableHR = $("#HROAFGroupSelected").val();
- dataSend.availableMN = $("#MIOAFGroupSelected").val();
-
- dataSend.dueDT = $("#datePickEDDGroupSelected").val();
- dataSend.dueHR = $("#HREDDGroupSelected").val();
- dataSend.dueMN = $("#MIEDDGroupSelected").val();
-
- if((dataSend.availableDT == "" || dataSend.availableHR == "" || dataSend.availableMN == "") && (dataSend.dueDT == "" || dataSend.dueHR == "" || dataSend.dueMN == "")){
- alert('Please, insert a full date.');
- return false;
- }
- else{
- var countGroups = arrayGroupSelecteds.length;
- var countLoop = 1;
- for(var i in arrayGroupSelecteds){
-
- dataSend.group = arrayGroupSelecteds[i]["group"];
- dataSend.cmid = arrayGroupSelecteds[i]["cmid"];
-
- $.ajax({
- url: "dao_create_offset_groups_selecteds.php",
- data: dataSend,
- type: 'post',
- success: function(data) {
- if(data == 'true'){
- if(countLoop == countGroups){
- location.href = pathURL+"/mod/ibis/offset/index.php?id="+cmid;
- }
- countLoop++;
- }
- else{
- alert('Error User: '+dataSend.group);
- }
- }
- });
- }
- }
+ var dataSend = {};
+ dataSend.availableDT = $("#datePickOAFGroupSelected").val();
+ dataSend.availableHR = $("#HROAFGroupSelected").val();
+ dataSend.availableMN = $("#MIOAFGroupSelected").val();
+
+ dataSend.dueDT = $("#datePickEDDGroupSelected").val();
+ dataSend.dueHR = $("#HREDDGroupSelected").val();
+ dataSend.dueMN = $("#MIEDDGroupSelected").val();
+
+ if((dataSend.availableDT == "" || dataSend.availableHR == "" || dataSend.availableMN == "") && (dataSend.dueDT == "" || dataSend.dueHR == "" || dataSend.dueMN == "")){
+ alert('Please, insert a full date.');
+ return false;
+ }
+ else{
+ var countGroups = arrayGroupSelecteds.length;
+ var countLoop = 1;
+ for(var i in arrayGroupSelecteds){
+
+ dataSend.group = arrayGroupSelecteds[i]["group"];
+ dataSend.cmid = arrayGroupSelecteds[i]["cmid"];
+
+ $.ajax({
+ url: "dao_create_offset_groups_selecteds.php",
+ data: dataSend,
+ type: 'post',
+ success: function(data) {
+ if(data == 'true'){
+ if(countLoop == countGroups){
+ location.href = pathURL+"/mod/ibis/offset/index.php?id="+cmid;
+ }
+ countLoop++;
+ }
+ else{
+ alert('Error User: '+dataSend.group);
+ }
+ }
+ });
+ }
+ }
}
\ No newline at end of file
diff --git a/src/cms/moodle/mod/ibis/lib.php b/src/cms/moodle/mod/ibis/lib.php
index 37e14c1..f99fb0e 100644
--- a/src/cms/moodle/mod/ibis/lib.php
+++ b/src/cms/moodle/mod/ibis/lib.php
@@ -1210,75 +1210,18 @@
/**
* EXTENDED DUE DATE FUNCTIONS
*/
- function get_assignment_id_from_cmid($cmid) {
- if (!$cm = get_record('course_modules', 'id', $cmid))
- throw new Exception('EDD: Course Module ID was incorrect');
-
- if (!$ibis = get_record('ibis', 'id', $cm->instance))
- throw new Exception('EDD: ibis ID was incorrect');
-
- return $ibis->id;
- }
-
- function groups_get_users_without_group($courseid) {
-
- $sql = "SELECT usr.id,usr.firstname, usr.lastname, usr.email
- FROM course c
- INNER JOIN context cx ON c.id = cx.instanceid
- AND cx.contextlevel = '50' AND c.id = $courseid
- INNER JOIN role_assignments ra ON cx.id = ra.contextid
- INNER JOIN role r ON ra.roleid = r.id
- INNER JOIN user usr ON ra.userid = usr.id
- WHERE r.name = 'Student' AND
- usr.id NOT IN(
- select gm.userid
- from groups_members gm
- INNER JOIN groups g ON g.id = gm.groupid
- WHERE
- g.courseid = $courseid
- )
- ORDER BY usr.firstname";
-
- return get_records_sql($sql);
- }
function edd_create_edd($data) {
global $CFG;
- error_log('edd_create_edd()');
$my_time = time();
+ $sql = "INSERT INTO ibis_extended_due_dates VALUES (NULL, $data->course_modules_id, $data->user_id, $my_time, $my_time, $data->timeext) ON DUPLICATE KEY UPDATE timemodified = $my_time, timeext = $data->timeext";
+ $result = QDB::run("cms", $sql);
- $mysqli = new mysqli($CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname);
-
- if ($mysqli->connect_error) {
- error_log('Failed to connect to edd server');
- return false;
- }
-
- //Feature #1305 - Moodle-Ibis Integration: Group Assignment Date Settings (REMOVE GROUP INFO)
- //Redmine Bug #1346 - Moodle-Ibis Integration: Something Weird in Extensions and Offsets
- $eddGet = get_record_sql("select * from ibis_extended_due_dates where course_modules_id = $data->course_modules_id and user_id = $data->user_id");
-
- if ($eddGet) {
- $eddGet->timemodified = $my_time;
- $eddGet->timeext = $data->timeext;
-
- $sql = "update ibis_extended_due_dates set timemodified = $my_time, timeext = $data->timeext where id = $eddGet->id";
- } else {
- $sql = 'insert into ibis_extended_due_dates values (NULL, ' . $data->course_modules_id . ',' . $data->user_id . ',' . $my_time . ',' . $my_time . ',' . $data->timeext . ')';
- }
-
- $result = $mysqli->query($sql);
-
- //End - Redmine Feature #1346
-
- if ($result === false or ( $mysqli->affected_rows != 1 and $mysqli->affected_rows != 2)) {
- error_log('Failed SQL Statement - insert or update edd - ' . $sql);
+ if(!$result){
return false;
}
- $id = $mysqli->insert_id;
-
try {
require_once $CFG->dirroot . '/mod/ibis/grade/GradebookDueDateUpdater.php';
$updater = new GradebookDueDateUpdater($data->course_modules_id);
@@ -1292,122 +1235,13 @@
return true;
}
- function edd_update_edd($data) {
- global $CFG;
-
- $data->timemodified = time();
-
- error_log('edd_update_edd()');
-
- $id = update_record('ibis_extended_due_dates', $data);
-
- try {
- require_once $CFG->dirroot . '/mod/ibis/grade/GradebookDueDateUpdater.php';
- $updater = new GradebookDueDateUpdater($data->course_modules_id);
- $updater->updateGradebookDueDateUser($data->user_id, $data->timeext);
- } catch (Exception $e) {
- $msg = 'mod ibis lib error updating edd: ' . $e->getMessage();
- error_log($msg);
- return false;
- }
- return $id;
- }
-
- function edd_remove_edds($data) {
- global $CFG;
-
- error_log('edd_remove_edds()');
-
- // find user ids for updating grades.
- $sql = "select id, user_id from ibis_extended_due_dates where course_modules_id = $data->course_modules_id and timeext = $data->timeext";
- $users = get_records_sql($sql);
-
- //Feature #1305 - Moodle-Ibis Integration: Group Assignment Date Settings
- $id = delete_records_select('ibis_extended_due_dates', "course_modules_id = $data->course_modules_id and timeext = $data->timeext");
-
- if (!empty($users)) {
- $my_users = array();
- foreach ($users as $user)
- $my_users[] = $user->user_id;
-
- $userids = implode(",", $my_users);
-
- try {
- require_once $CFG->dirroot . '/mod/ibis/grade/GradebookDueDateUpdater.php';
- $updater = new GradebookDueDateUpdater($data->course_modules_id);
- $updater->resetGradebookDueDateUsers($userids);
- } catch (Exception $e) {
- $msg = 'mod ibis lib error removing edds: ' . $e->getMessage();
- error_log($msg);
- return false;
- }
- }
-
- if ($id) {
- return 1;
- } else {
- return 0;
- }
- }
-
- function edd_remove_edd($id) { // where is this used?
- global $CFG;
-
- error_log('edd_remove_edd()');
-
+ function edd_remove_edd($id) {
$id = delete_records('ibis_extended_due_dates', 'id', $id);
return $id;
}
- function edd_remove_user($list) {
- global $CFG;
-
- error_log('edd_remove_user()');
-
- $mysqli = new mysqli($CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname);
-
- if ($mysqli->connect_error) {
- error_log('Failed to connect to edd server');
- return false;
- }
-
- // find course_modules.id for the list of users
- // assumes all users in list have same course_module_id.... how could they not?
- $sql = 'select course_modules_id from ibis_extended_due_dates where id = ' . $list[0];
- $result = $mysqli->query($sql);
- $obj = $result->fetch_object();
- $cmid = $obj->course_modules_id;
-
- // find the list of userids from this list of ibis extended due dates ids
- $extended_due_dates_ids = implode(",", $list);
- $sql = 'select user_id from ibis_extended_due_dates where id in (' . $extended_due_dates_ids . ')';
- $users = get_records_sql($sql);
- $my_users = array();
- foreach ($users as $user)
- $my_users[] = $user->user_id;
-
- $userids = implode(",", $my_users);
-
- // delete from ibis exended due dates
- $id = delete_records_select('ibis_extended_due_dates', 'id in (' . $extended_due_dates_ids . ')');
-
- try {
- require_once $CFG->dirroot . '/mod/ibis/grade/GradebookDueDateUpdater.php';
- $updater = new GradebookDueDateUpdater($cmid);
- $updater->resetGradebookDueDateUsers($userids);
- } catch (Exception $e) {
- $msg = 'mod ibis lib error edd remove user: ' . $e->getMessage();
- error_log($msg);
- return false;
- }
-
- return $id;
- }
-
function edd_get_individual_user_dates($courseid, $userid) {
- $sql = "SELECT * FROM ibis_extended_due_dates i
- where course_modules_id = $courseid and user_id = $userid";
-
+ $sql = "SELECT * FROM ibis_extended_due_dates i WHERE course_modules_id = $courseid and user_id = $userid";
return get_record_sql($sql);
}
@@ -1416,56 +1250,50 @@
*/
function edd_get_user_due_date($cmid, $userid) {
- $cm = get_record('course_modules', 'id', $cmid);
- if (empty($cm)) {
+ //The business logic in this query is as follows:
+ //Only one extension (group or individual) can be counted (first encountered if anomaly)
+ //The result will be the original due date plus that extension
+ //If there is an individual extension, STOP group extensions mean nothing
+ //If no extensions are found, use original ibis due date
+
+ $sql="SELECT I.timedue+IEDD.timeext AS exttimedue
+ FROM cms.course_modules AS CM
+ INNER JOIN cms.ibis_extended_due_dates AS IEDD
+ ON IEDD.course_modules_id=CM.id
+ INNER JOIN cms.ibis AS I
+ ON I.id=CM.instance
+ WHERE
+ CM.id=?cmid? AND IEDD.user_id=?userid?
+ UNION
+ SELECT I.timedue+IGAD.timeext AS exttimedue
+ FROM cms.course_modules AS CM
+ INNER JOIN cms.groups as G
+ ON G.courseid=CM.course
+ INNER JOIN cms.groups_members as GM
+ ON GM.groupid=G.id
+ INNER JOIN cms.ibis_group_assignment_dates AS IGAD
+ ON IGAD.coursemodulesid=CM.id AND IGAD.groupid=G.id
+ INNER JOIN cms.ibis AS I
+ ON I.id=CM.instance
+ WHERE
+ CM.id=?cmid? AND GM.userid=?userid?
+ UNION
+ SELECT I.timedue AS exttimedue
+ FROM cms.course_modules AS CM
+ INNER JOIN cms.ibis AS I
+ ON I.id=CM.instance
+ WHERE
+ CM.id=?cmid?
+ LIMIT 1";
+
+ $timedue = QDB::question("cms", $sql, array("cmid"=>$cmid, "userid"=>$userid), FALSE);
+
+ if($timedue === FALSE){
throw new Exception('Unable to find Course Module');
}
- $ibis = get_record('ibis', 'id', $cm->instance);
- if (empty($ibis)) {
- throw new Exception('unable to find ibis');
- }
-
- if ($ibis->timedue == 0) {
- return 0;
- }
-
- //Trying to get the individual
- $individualEDD = get_record('ibis_extended_due_dates', 'course_modules_id', $cmid, 'user_id', $userid);
- if ($individualEDD) {
- return ($ibis->timedue + $individualEDD->timeext);
- }
-
- //Bug #1626 - Moodle: Course 5870 Loads Super Slow
- $groupUser = get_record_sql("SELECT g.id, g.timeext, g.offset FROM groups g, groups_members gm WHERE g.id = gm.groupid and g.courseid = $ibis->course and gm.userid = $userid");
- if ($groupUser) {
- $groupcmEDD = get_record('ibis_group_assignment_dates', 'coursemodulesid', $cmid, 'groupid', $groupUser->id);
- if ($groupcmEDD && $groupcmEDD->timeext != 0) {
- return ($ibis->timedue + $groupcmEDD->timeext);
- }
-
- if ($groupUser->timeext != 0) {
- return ($ibis->timedue + $groupUser->timeext);
+ return $timedue;
}
- }
-
- return $ibis->timedue;
- }
-
- function edd_get_all_users($course_id) {
-
- $sql = "SELECT usr.id,usr.firstname, usr.lastname, usr.email
- FROM course c
- INNER JOIN context cx ON c.id = cx.instanceid
- AND cx.contextlevel = '50' AND c.id = $course_id
- INNER JOIN role_assignments ra ON cx.id = ra.contextid
- INNER JOIN role r ON ra.roleid = r.id
- INNER JOIN user usr ON ra.userid = usr.id
- WHERE r.name = 'Student'
- ORDER BY usr.firstname";
-
- return get_records_sql($sql);
- }
/**
* END - EXTENDED DUE DATE FUNCTIONS
@@ -1476,161 +1304,25 @@
* Feature #942 - Moodle-Ibis Integration: Apply Group Date Offset to All Dates
*/
function oaf_create_oaf($data) {
- global $CFG;
- error_log('oaf_create_oaf()');
$my_time = time();
+ $sql = "INSERT INTO ibis_offset_available_dates VALUES (NULL, $data->course_modules_id, $data->user_id, $my_time, $my_time, $data->timeext) ON DUPLICATE KEY UPDATE timemodified = $my_time, timeext = $data->timeext";
+ $result = QDB::run("cms", $sql);
- $mysqli = new mysqli($CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname);
-
- if ($mysqli->connect_error) {
- error_log('Failed to connect to edd server');
- return false;
- }
-
- // Redmine Bug #1346 - Moodle-Ibis Integration: Something Weird in Extensions and Offsets
- //Feature #1305 - Moodle-Ibis Integration: Group Assignment Date Settings
- $eddGet = get_record_sql("select * from ibis_offset_available_dates where course_modules_id = $data->course_modules_id and user_id = $data->user_id");
-
- if ($eddGet) {
- $eddGet->timemodified = $my_time;
- $eddGet->timeext = $data->timeext;
-
- $sql = "update ibis_offset_available_dates set timemodified = $my_time, timeext = $data->timeext where id = $eddGet->id";
- } else {
- $sql = 'insert into ibis_offset_available_dates values (NULL, ' . $data->course_modules_id . ',' . $data->user_id . ',' . $my_time . ',' . $my_time . ',' . $data->timeext . ')';
- }
-
- $result = $mysqli->query($sql);
-
- if ($result === false or ( $mysqli->affected_rows != 1 and $mysqli->affected_rows != 2)) {
- error_log('Failed SQL Statement - insert or update edd - ' . $sql);
+ if(!$result){
return false;
}
- $id = $mysqli->insert_id;
-
return true;
}
- function oaf_update_oaf($data) {
- global $CFG;
-
- $data->timemodified = time();
- error_log('oaf_update_oaf()');
- $id = update_record('ibis_offset_available_dates', $data);
-
- return $id;
- }
-
- function oaf_remove_oafs($data) {
- global $CFG;
-
- error_log('oaf_remove_oafs()');
-
- $sql = "select id, user_id from ibis_offset_available_dates where course_modules_id = $data->course_modules_id and timeext = $data->timeext";
- $users = get_records_sql($sql);
-
- if ($data->groupid) {
- $id = delete_records_select('ibis_offset_available_dates', "user_id = $data->user_id and groupid = $data->groupid");
- } else {
- $id = delete_records_select('ibis_offset_available_dates', "course_modules_id = $data->course_modules_id and timeext = $data->timeext");
- }
-
- if ($id) {
- return 1;
- } else {
- return 0;
- }
- }
-
function oaf_remove_oaf($id) {
- global $CFG;
-
- error_log('oaf_remove_oaf()');
$id = delete_records('ibis_offset_available_dates', 'id', $id);
return $id;
}
- function oaf_remove_user($list) {
- global $CFG;
-
- error_log('oaf_remove_user()');
-
- $mysqli = new mysqli($CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname);
-
- if ($mysqli->connect_error) {
- error_log('Failed to connect to edd server');
- return false;
- }
-
- $sql = 'select course_modules_id from ibis_offset_available_dates where id = ' . $list[0];
- $result = $mysqli->query($sql);
- $obj = $result->fetch_object();
- $cmid = $obj->course_modules_id;
-
- $offset_available_dates_ids = implode(",", $list);
- $sql = 'select user_id from ibis_offset_available_dates where id in (' . $offset_available_dates_ids . ')';
- $users = get_records_sql($sql);
- $my_users = array();
- foreach ($users as $user)
- $my_users[] = $user->user_id;
-
- $id = delete_records_select('ibis_offset_available_dates', 'id in (' . $offset_available_dates_ids . ')');
-
- return $id;
- }
-
- function oaf_get_used_dates($courseid) {
- $sql = "SELECT * FROM ibis_offset_available_dates i
- where course_modules_id = $courseid
- group by timeext";
-
- return get_records_sql($sql);
- }
-
- function oaf_get_individual_dates($courseid) {
- $sql = "SELECT * FROM ibis_offset_available_dates i
- where course_modules_id = $courseid";
-
- return get_records_sql($sql);
- }
-
function oaf_get_individual_user_dates($courseid, $userid) {
- $sql = "SELECT * FROM ibis_offset_available_dates i
- where course_modules_id = $courseid and user_id = $userid";
-
- return get_record_sql($sql);
- }
-
- function oaf_get_users_by_timestamp($courseid, $timestamp) {
- $sql = "SELECT usr.id,usr.firstname, usr.lastname, usr.email
- FROM ibis_offset_available_dates i
- INNER JOIN user usr ON i.user_id = usr.id
- where course_modules_id = $courseid
- and timeext = $timestamp";
-
- return get_records_sql($sql);
- }
-
- function oaf_get_used_users($courseid) {
- return get_records("ibis_offset_available_dates", "course_modules_id", $courseid);
- }
-
- function oaf_get_items($couseid, $timeext) {
- $sql = "select * FROM ibis_offset_available_dates
- where course_modules_id = $couseid
- and timeext = $timeext";
-
- return get_records_sql($sql);
- }
-
- function oaf_get_item($couseid, $timeext, $userid) {
- $sql = "select * FROM ibis_offset_available_dates
- where course_modules_id = $couseid
- and timeext = $timeext
- and user_id = $userid";
-
+ $sql = "SELECT * FROM ibis_offset_available_dates i WHERE course_modules_id = $courseid and user_id = $userid";
return get_record_sql($sql);
}
@@ -1676,28 +1368,15 @@
return $ibis->timeavailable;
}
- function oaf_get_all_users($course_id) {
- $sql = "SELECT usr.id,usr.firstname, usr.lastname, usr.email
- FROM course c
- INNER JOIN context cx ON c.id = cx.instanceid
- AND cx.contextlevel = '50' AND c.id = $course_id
- INNER JOIN role_assignments ra ON cx.id = ra.contextid
- INNER JOIN role r ON ra.roleid = r.id
- INNER JOIN user usr ON ra.userid = usr.id
- WHERE r.name = 'Student'
- ORDER BY usr.firstname";
- return get_records_sql($sql);
- }
-
/**
* END - AVAILABLE FROM OFFSET FUNCTIONS
*/
+
/*
* Created for: Feature #1305 - Moodle-Ibis Integration: Group Assignment Date Settings
*/
function create_oaf_edd_group_dates($groupid, $cmid, $offset, $timeext) {
- global $CFG;
$sqlGet = "select * from ibis_group_assignment_dates where groupid = $groupid and coursemodulesid = $cmid";
$ibis_group_assignment_dates = get_record_sql($sqlGet);
@@ -1722,7 +1401,6 @@
*/
function create_oaf_edd_group_dates_ios($groupid, $cmid, $offset, $timeext) {
- global $CFG;
$sqlGet = "select * from ibis_group_assignment_dates where groupid = $groupid and coursemodulesid = $cmid";
$ibis_group_assignment_dates = get_record_sql($sqlGet);
@@ -1781,7 +1459,6 @@
*/
function update_oaf_edd_group_dates($groupid, $cmid, $offset, $timeext) {
- global $CFG;
$sqlGet = "select * from ibis_group_assignment_dates where groupid = $groupid and coursemodulesid = $cmid";
$ibis_group_assignment_dates = get_record_sql($sqlGet);
@@ -1803,7 +1480,6 @@
*/
function delete_oaf_edd_group_dates($groupid, $cmid, $type) {
- global $CFG;
$sqlGet = "select * from ibis_group_assignment_dates where groupid = $groupid and coursemodulesid = $cmid";
$ibis_group_assignment_dates = get_record_sql($sqlGet);
@@ -1855,19 +1531,11 @@
* an assignment due date has passed are assigned zeros
*/
function ibis_role_assign($userid, $context, $roleid) {
- global $CFG;
-
- $mysqli = new mysqli($CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname);
-
- if ($mysqli->connect_error) {
- error_log('Failed to connect in ibis_role_assign... should never happen');
+ $sql = "UPDATE grade_items LEFT JOIN course_modules ON course_modules.course = grade_items.courseid
+ SET grade_items.lastduedateflush = 0 WHERE grade_items.courseid = $context->instanceid AND grade_items.itemtype = 'course'";
+ if(!QDB::run("cms", $sql)){
+ error_log("Failed calling the ibis_role_assign on assign roles for MOD/IBIS");
}
-
- // set cms.grade_items.lastduedateflush = 0 for the course to ensure that course totals are recalculated when gradebook is opened
- $sql = 'update grade_items left join course_modules on course_modules.course = grade_items.courseid ';
- $sql .= 'set grade_items.lastduedateflush = 0 where grade_items.courseid = ' . $context->instanceid . ' and grade_items.itemtype = "course"';
-
- $mysqli->query($sql);
}
function isAssignmentComplete($userid, $ibisid) {
@@ -2379,6 +2047,50 @@
* NEW GLOBAL MOD/IBIS UPDATE FUNCTIONS
*/
+ function getDiffDateTime($time1, $time2, $precision = 6) {
+ if (!is_int($time1)) {
+ $time1 = strtotime($time1);
+ }
+ if (!is_int($time2)) {
+ $time2 = strtotime($time2);
+ }
+
+ if ($time1 > $time2) {
+ $ttime = $time1;
+ $time1 = $time2;
+ $time2 = $ttime;
+ }
+
+ $intervals = array('days', 'hours', 'minutes');
+ $diffs = array();
+
+ foreach ($intervals as $interval) {
+ $diffs[$interval] = 0;
+ $ttime = strtotime("+1 ".$interval, $time1);
+ while ($time2 >= $ttime) {
+ $time1 = $ttime;
+ $diffs[$interval]++;
+ $ttime = strtotime("+1 ".$interval, $time1);
+ }
+ }
+
+ $count = 0;
+ $times = array();
+
+ foreach ($diffs as $interval => $value) {
+ if ($count >= $precision) {
+ break;
+ }
+
+ if ($value > 0) {
+ $times[$interval] = $value;
+ $count++;
+ }
+ }
+
+ return $times;
+ }
+
function updateSaplingAssignment($id, $title = null, $policySetID = null, $isbn = null){
$ibis = get_record('ibis', 'id', $id);
if($ibis && ($title || $policySetID || $isbn)){
diff --git a/src/cms/moodle/mod/ibis/offset/dao_create_offset.php b/src/cms/moodle/mod/ibis/offset/dao_create_offset.php
index 6aa7b43..b16ba99 100644
--- a/src/cms/moodle/mod/ibis/offset/dao_create_offset.php
+++ b/src/cms/moodle/mod/ibis/offset/dao_create_offset.php
@@ -1,63 +1,64 @@
<?php
- require_once("../../../config.php");
- require_once("../lib.php");
-
- $id = required_param('id');
- $type = required_param('type');
- $user = required_param('user');
- $cmid = required_param('cmid');
- $date = required_param('date');
- $hr = required_param('hr');
- $mn = required_param('mn');
-
- if (! $cm = get_record("course_modules", "id", $cmid)) {
- error("This course module doesn't exist");
- }
-
- if (! $ibis = get_record("ibis", "id", $cm->instance)) {
- error("This ibis doesn't exist");
- }
-
- if (! $course = get_record("course", "id", $cm->course)) {
- error("This course doesn't exist");
- }
-
- require_login($course);
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
- require_capability('moodle/course:manageactivities', $context);
-
- $month = date("m", strtotime($date));
- $day = date("d", strtotime($date));
- $year = date("Y", strtotime($date));
-
- $newDate = mktime($hr, $mn, 0, $month, $day, $year);
-
- if($type == 1){
- $callFunction = 'oaf_create_oaf';
-
- //Bug #1389 - Moodle-Ibis Integration: Fighting Offsets and Extensions
- $timeAvaUser = strtotime(userdate($ibis->timeavailable));
- $newOffset = (int)$newDate - (int)$timeAvaUser;
- }
- else{
- $callFunction = 'edd_create_edd';
-
- //Bug #1389 - Moodle-Ibis Integration: Fighting Offsets and Extensions
- $timeDueUser = strtotime(userdate($ibis->timedue));
- $newOffset = (int)$newDate - (int)$timeDueUser;
- }
-
- $studentOffset = new Object();
- $studentOffset->course_modules_id = $cm->id;
- $studentOffset->user_id = $user;
- $studentOffset->timecreated = mktime();
- $studentOffset->timemodified = mktime();
- $studentOffset->timeext = $newOffset;
-
- if($ret = $callFunction($studentOffset)){
- echo "true";
- }
- else{
- echo "false";
- }
+
+ require_once("../../../config.php");
+ require_once("../lib.php");
+
+ $id = required_param('id');
+ $type = required_param('type');
+ $user = required_param('user');
+ $cmid = required_param('cmid');
+ $date = required_param('date');
+ $hr = required_param('hr');
+ $mn = required_param('mn');
+
+ if (!$cm = get_record("course_modules", "id", $cmid)) {
+ error("This course module doesn't exist");
+ }
+
+ if (!$ibis = get_record("ibis", "id", $cm->instance)) {
+ error("This ibis doesn't exist");
+ }
+
+ if (!$course = get_record("course", "id", $cm->course)) {
+ error("This course doesn't exist");
+ }
+
+ require_login($course);
+ $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+ require_capability('moodle/course:manageactivities', $context);
+
+ $month = date("m", strtotime($date));
+ $day = date("d", strtotime($date));
+ $year = date("Y", strtotime($date));
+
+ $newDate = mktime($hr, $mn, 0, $month, $day, $year);
+
+ if ($type == 1) {
+ $callFunction = 'oaf_create_oaf';
+
+ //Bug #1389 - Moodle-Ibis Integration: Fighting Offsets and Extensions
+ $timeAvaUser = strtotime(userdate($ibis->timeavailable));
+ $newOffset = (int) $newDate - (int) $timeAvaUser;
+ }
+ else {
+ $callFunction = 'edd_create_edd';
+
+ //Bug #1389 - Moodle-Ibis Integration: Fighting Offsets and Extensions
+ $timeDueUser = strtotime(userdate($ibis->timedue));
+ $newOffset = (int) $newDate - (int) $timeDueUser;
+ }
+
+ $studentOffset = new Object();
+ $studentOffset->course_modules_id = $cm->id;
+ $studentOffset->user_id = $user;
+ $studentOffset->timecreated = mktime();
+ $studentOffset->timemodified = mktime();
+ $studentOffset->timeext = $newOffset;
+
+ if ($ret = $callFunction($studentOffset)) {
+ echo "true";
+ }
+ else {
+ echo "false";
+ }
?>
\ No newline at end of file
diff --git a/src/cms/moodle/mod/ibis/offset/dao_create_offset_groups_selecteds.php b/src/cms/moodle/mod/ibis/offset/dao_create_offset_groups_selecteds.php
index f179a45..ba515b6 100644
--- a/src/cms/moodle/mod/ibis/offset/dao_create_offset_groups_selecteds.php
+++ b/src/cms/moodle/mod/ibis/offset/dao_create_offset_groups_selecteds.php
@@ -1,81 +1,82 @@
<?php
- require_once("../../../config.php");
-
- $id = required_param('group');
- $cmid = required_param('cmid');
- //OAF
- $availableDT = optional_param('availableDT');
- $availableHR = optional_param('availableHR');
- $availableMN = optional_param('availableMN');
-
- //EDD
- $dueDT = optional_param('dueDT');
- $dueHR = optional_param('dueHR');
- $dueMN = optional_param('dueMN');
-
- if (! $group = get_record("groups", "id", $id)) {
- error("This group doesn't exist");
- }
-
- if (! $cm = get_record("course_modules", "id", $cmid)) {
- error("This course module doesn't exist");
- }
-
- if (! $ibis = get_record("ibis", "id", $cm->instance)) {
- error("This ibis doesn't exist");
- }
-
- if (! $course = get_record("course", "id", $cm->course)) {
- error("This course doesn't exist");
- }
-
- require_login($course);
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
- require_capability('moodle/course:manageactivities', $context);
-
- //Available From Offset
- if($availableDT){
- $month = date("m", strtotime($availableDT));
- $day = date("d", strtotime($availableDT));
- $year = date("Y", strtotime($availableDT));
-
- $newDate = mktime($availableHR, $availableMN, 0, $month, $day, $year);
- if($newDate != strtotime(userdate($ibis->timeavailable))){
- //Bug #1389 - Moodle-Ibis Integration: Fighting Offsets and Extensions
- $timeAvaUser = strtotime(userdate($ibis->timeavailable));
- $newOffset = (int)$newDate - (int)$timeAvaUser;
- }
- else{
- $newOffset = 0;
- }
- }
- else{
- $newOffset = 0;
- }
-
- //Due Date Extension
- if($dueDT){
- $month = date("m", strtotime($dueDT));
- $day = date("d", strtotime($dueDT));
- $year = date("Y", strtotime($dueDT));
-
- $newDate = mktime($dueHR, $dueMN, 0, $month, $day, $year);
- if($newDate != strtotime(userdate($ibis->timedue))){
- //Bug #1389 - Moodle-Ibis Integration: Fighting Offsets and Extensions
- $timeDueUser = strtotime(userdate($ibis->timedue));
- $newTimeext = (int)$newDate - (int)$timeDueUser;
- }
- else{
- $newTimeext = 0;
- }
- }
- else{
- $newTimeext = 0;
- }
-
- //Feature #1305 - Moodle-Ibis Integration: Group Assignment Date Settings
- create_oaf_edd_group_dates($group->id, $cm->id, $newOffset, $newTimeext);
+ require_once("../../../config.php");
- echo "true";
+ $id = required_param('group');
+ $cmid = required_param('cmid');
+
+ //OAF
+ $availableDT = optional_param('availableDT');
+ $availableHR = optional_param('availableHR');
+ $availableMN = optional_param('availableMN');
+
+ //EDD
+ $dueDT = optional_param('dueDT');
+ $dueHR = optional_param('dueHR');
+ $dueMN = optional_param('dueMN');
+
+ if (!$group = get_record("groups", "id", $id)) {
+ error("This group doesn't exist");
+ }
+
+ if (!$cm = get_record("course_modules", "id", $cmid)) {
+ error("This course module doesn't exist");
+ }
+
+ if (!$ibis = get_record("ibis", "id", $cm->instance)) {
+ error("This ibis doesn't exist");
+ }
+
+ if (!$course = get_record("course", "id", $cm->course)) {
+ error("This course doesn't exist");
+ }
+
+ require_login($course);
+ $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+ require_capability('moodle/course:manageactivities', $context);
+
+ //Available From Offset
+ if ($availableDT) {
+ $month = date("m", strtotime($availableDT));
+ $day = date("d", strtotime($availableDT));
+ $year = date("Y", strtotime($availableDT));
+
+ $newDate = mktime($availableHR, $availableMN, 0, $month, $day, $year);
+ if ($newDate != strtotime(userdate($ibis->timeavailable))) {
+ //Bug #1389 - Moodle-Ibis Integration: Fighting Offsets and Extensions
+ $timeAvaUser = strtotime(userdate($ibis->timeavailable));
+ $newOffset = (int) $newDate - (int) $timeAvaUser;
+ }
+ else {
+ $newOffset = 0;
+ }
+ }
+ else {
+ $newOffset = 0;
+ }
+
+ //Due Date Extension
+ if ($dueDT) {
+ $month = date("m", strtotime($dueDT));
+ $day = date("d", strtotime($dueDT));
+ $year = date("Y", strtotime($dueDT));
+
+ $newDate = mktime($dueHR, $dueMN, 0, $month, $day, $year);
+ if ($newDate != strtotime(userdate($ibis->timedue))) {
+ //Bug #1389 - Moodle-Ibis Integration: Fighting Offsets and Extensions
+ $timeDueUser = strtotime(userdate($ibis->timedue));
+ $newTimeext = (int) $newDate - (int) $timeDueUser;
+ }
+ else {
+ $newTimeext = 0;
+ }
+ }
+ else {
+ $newTimeext = 0;
+ }
+
+ //Feature #1305 - Moodle-Ibis Integration: Group Assignment Date Settings
+ create_oaf_edd_group_dates($group->id, $cm->id, $newOffset, $newTimeext);
+
+ echo "true";
?>
\ No newline at end of file
diff --git a/src/cms/moodle/mod/ibis/offset/dao_create_offset_selecteds.php b/src/cms/moodle/mod/ibis/offset/dao_create_offset_selecteds.php
index 25fb03f..d86e824 100644
--- a/src/cms/moodle/mod/ibis/offset/dao_create_offset_selecteds.php
+++ b/src/cms/moodle/mod/ibis/offset/dao_create_offset_selecteds.php
@@ -1,94 +1,95 @@
<?php
- require_once("../../../config.php");
-
- $user = required_param('user');
- $cmid = required_param('cmid');
-
- //OAF
- $availableDT = optional_param('availableDT');
- $availableHR = optional_param('availableHR');
- $availableMN = optional_param('availableMN');
-
- //EDD
- $dueDT = optional_param('dueDT');
- $dueHR = optional_param('dueHR');
- $dueMN = optional_param('dueMN');
-
-
- if (! $cm = get_record("course_modules", "id", $cmid)) {
- error("This course module doesn't exist");
- }
-
- if (! $ibis = get_record("ibis", "id", $cm->instance)) {
- error("This ibis doesn't exist");
- }
-
- if (! $course = get_record("course", "id", $cm->course)) {
- error("This course doesn't exist");
- }
-
- require_login($course);
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
- require_capability('moodle/course:manageactivities', $context);
-
- $returnVar = "";
-
- //Available From Offset
- if($availableDT){
- $month = date("m", strtotime($availableDT));
- $day = date("d", strtotime($availableDT));
- $year = date("Y", strtotime($availableDT));
-
- $newDate = mktime($availableHR, $availableMN, 0, $month, $day, $year);
- if($newDate != strtotime(userdate($ibis->timeavailable))){
- //Bug #1389 - Moodle-Ibis Integration: Fighting Offsets and Extensions
- $timeAvaUser = strtotime(userdate($ibis->timeavailable));
- $newOffset = (int)$newDate - (int)$timeAvaUser;
-
- $studentOffset = new Object();
- $studentOffset->course_modules_id = $cm->id;
- $studentOffset->user_id = $user;
- $studentOffset->timecreated = mktime();
- $studentOffset->timemodified = mktime();
- $studentOffset->timeext = $newOffset;
-
- if($ret = oaf_create_oaf($studentOffset)){
- $returnVar = "true";
- }
- else{
- $returnVar = "false";
- }
- }
- }
-
- //Due Date Extension
- if($dueDT){
- $month = date("m", strtotime($dueDT));
- $day = date("d", strtotime($dueDT));
- $year = date("Y", strtotime($dueDT));
-
- $newDate = mktime($dueHR, $dueMN, 0, $month, $day, $year);
-
- if($newDate != strtotime(userdate($ibis->timedue))){
- //Bug #1389 - Moodle-Ibis Integration: Fighting Offsets and Extensions
- $timeDueUser = strtotime(userdate($ibis->timedue));
- $newOffset = (int)$newDate - (int)$timeDueUser;
-
- $studentOffset = new Object();
- $studentOffset->course_modules_id = $cm->id;
- $studentOffset->user_id = $user;
- $studentOffset->timecreated = mktime();
- $studentOffset->timemodified = mktime();
- $studentOffset->timeext = $newOffset;
-
- if($ret = edd_create_edd($studentOffset)){
- $returnVar = "true";
- }
- else{
- $returnVar = "false";
- }
- }
- }
-
- echo $returnVar;
+
+ require_once("../../../config.php");
+
+ $user = required_param('user');
+ $cmid = required_param('cmid');
+
+ //OAF
+ $availableDT = optional_param('availableDT');
+ $availableHR = optional_param('availableHR');
+ $availableMN = optional_param('availableMN');
+
+ //EDD
+ $dueDT = optional_param('dueDT');
+ $dueHR = optional_param('dueHR');
+ $dueMN = optional_param('dueMN');
+
+
+ if (!$cm = get_record("course_modules", "id", $cmid)) {
+ error("This course module doesn't exist");
+ }
+
+ if (!$ibis = get_record("ibis", "id", $cm->instance)) {
+ error("This ibis doesn't exist");
+ }
+
+ if (!$course = get_record("course", "id", $cm->course)) {
+ error("This course doesn't exist");
+ }
+
+ require_login($course);
+ $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+ require_capability('moodle/course:manageactivities', $context);
+
+ $returnVar = "";
+
+ //Available From Offset
+ if ($availableDT) {
+ $month = date("m", strtotime($availableDT));
+ $day = date("d", strtotime($availableDT));
+ $year = date("Y", strtotime($availableDT));
+
+ $newDate = mktime($availableHR, $availableMN, 0, $month, $day, $year);
+ if ($newDate != strtotime(userdate($ibis->timeavailable))) {
+ //Bug #1389 - Moodle-Ibis Integration: Fighting Offsets and Extensions
+ $timeAvaUser = strtotime(userdate($ibis->timeavailable));
+ $newOffset = (int) $newDate - (int) $timeAvaUser;
+
+ $studentOffset = new Object();
+ $studentOffset->course_modules_id = $cm->id;
+ $studentOffset->user_id = $user;
+ $studentOffset->timecreated = mktime();
+ $studentOffset->timemodified = mktime();
+ $studentOffset->timeext = $newOffset;
+
+ if ($ret = oaf_create_oaf($studentOffset)) {
+ $returnVar = "true";
+ }
+ else {
+ $returnVar = "false";
+ }
+ }
+ }
+
+ //Due Date Extension
+ if ($dueDT) {
+ $month = date("m", strtotime($dueDT));
+ $day = date("d", strtotime($dueDT));
+ $year = date("Y", strtotime($dueDT));
+
+ $newDate = mktime($dueHR, $dueMN, 0, $month, $day, $year);
+
+ if ($newDate != strtotime(userdate($ibis->timedue))) {
+ //Bug #1389 - Moodle-Ibis Integration: Fighting Offsets and Extensions
+ $timeDueUser = strtotime(userdate($ibis->timedue));
+ $newOffset = (int) $newDate - (int) $timeDueUser;
+
+ $studentOffset = new Object();
+ $studentOffset->course_modules_id = $cm->id;
+ $studentOffset->user_id = $user;
+ $studentOffset->timecreated = mktime();
+ $studentOffset->timemodified = mktime();
+ $studentOffset->timeext = $newOffset;
+
+ if ($ret = edd_create_edd($studentOffset)) {
+ $returnVar = "true";
+ }
+ else {
+ $returnVar = "false";
+ }
+ }
+ }
+
+ echo $returnVar;
?>
\ No newline at end of file
diff --git a/src/cms/moodle/mod/ibis/offset/dao_delete_group_offset.php b/src/cms/moodle/mod/ibis/offset/dao_delete_group_offset.php
index 8746931..909470e 100644
--- a/src/cms/moodle/mod/ibis/offset/dao_delete_group_offset.php
+++ b/src/cms/moodle/mod/ibis/offset/dao_delete_group_offset.php
@@ -1,32 +1,33 @@
<?php
- require_once("../../../config.php");
-
- $id = required_param('group');
- $type = required_param('type');
- $cmid = required_param('cmid');
-
- if (! $group = get_record("groups", "id", $id)) {
- error("This group doesn't exist");
- }
-
- if (! $cm = get_record("course_modules", "id", $cmid)) {
- error("This course module doesn't exist");
- }
-
- if (! $ibis = get_record("ibis", "id", $cm->instance)) {
- error("This ibis doesn't exist");
- }
-
- if (! $course = get_record("course", "id", $cm->course)) {
- error("This course doesn't exist");
- }
-
- require_login($course);
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
- require_capability('moodle/course:manageactivities', $context);
-
- //Feature #1305 - Moodle-Ibis Integration: Group Assignment Date Settings
- delete_oaf_edd_group_dates($group->id, $cm->id, $type);
-
- echo "true";
+
+ require_once("../../../config.php");
+
+ $id = required_param('group');
+ $type = required_param('type');
+ $cmid = required_param('cmid');
+
+ if (!$group = get_record("groups", "id", $id)) {
+ error("This group doesn't exist");
+ }
+
+ if (!$cm = get_record("course_modules", "id", $cmid)) {
+ error("This course module doesn't exist");
+ }
+
+ if (!$ibis = get_record("ibis", "id", $cm->instance)) {
+ error("This ibis doesn't exist");
+ }
+
+ if (!$course = get_record("course", "id", $cm->course)) {
+ error("This course doesn't exist");
+ }
+
+ require_login($course);
+ $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+ require_capability('moodle/course:manageactivities', $context);
+
+ //Feature #1305 - Moodle-Ibis Integration: Group Assignment Date Settings
+ delete_oaf_edd_group_dates($group->id, $cm->id, $type);
+
+ echo "true";
?>
\ No newline at end of file
diff --git a/src/cms/moodle/mod/ibis/offset/dao_delete_offset.php b/src/cms/moodle/mod/ibis/offset/dao_delete_offset.php
index c51a2d9..43af813 100644
--- a/src/cms/moodle/mod/ibis/offset/dao_delete_offset.php
+++ b/src/cms/moodle/mod/ibis/offset/dao_delete_offset.php
@@ -1,25 +1,26 @@
<?php
- require_once("../../../config.php");
-
- $id = required_param('id');
- $type = required_param('type');
-
- if($type == 1){
- $tableAction = 'ibis_offset_available_dates';
- $callFunction = 'oaf_remove_oaf';
- }
- else{
- $tableAction = 'ibis_extended_due_dates';
- $callFunction = 'edd_remove_edd';
- }
-
- $data = get_record($tableAction, 'id', $id);
-
- if($data){
- $callFunction($data->id);
- echo "true";
- }
- else{
- echo "false";
- }
+
+ require_once("../../../config.php");
+
+ $id = required_param('id');
+ $type = required_param('type');
+
+ if ($type == 1) {
+ $tableAction = 'ibis_offset_available_dates';
+ $callFunction = 'oaf_remove_oaf';
+ }
+ else {
+ $tableAction = 'ibis_extended_due_dates';
+ $callFunction = 'edd_remove_edd';
+ }
+
+ $data = get_record($tableAction, 'id', $id);
+
+ if ($data) {
+ $callFunction($data->id);
+ echo "true";
+ }
+ else {
+ echo "false";
+ }
?>
\ No newline at end of file
diff --git a/src/cms/moodle/mod/ibis/offset/dao_group_offset.php b/src/cms/moodle/mod/ibis/offset/dao_group_offset.php
index 11d1089..6229f9a 100644
--- a/src/cms/moodle/mod/ibis/offset/dao_group_offset.php
+++ b/src/cms/moodle/mod/ibis/offset/dao_group_offset.php
@@ -1,57 +1,58 @@
<?php
- require_once("../../../config.php");
- require_once("../lib.php");
-
- $id = required_param('group');
- $type = required_param('type');
- $cmid = required_param('cmid');
-
- $date = required_param('date');
- $hr = required_param('hr');
- $mn = required_param('mn');
-
- if (! $group = get_record("groups", "id", $id)) {
- error("This group doesn't exist");
- }
-
- if (! $cm = get_record("course_modules", "id", $cmid)) {
- error("This course module doesn't exist");
- }
-
- if (! $ibis = get_record("ibis", "id", $cm->instance)) {
- error("This ibis doesn't exist");
- }
-
- if (! $course = get_record("course", "id", $cm->course)) {
- error("This course doesn't exist");
- }
-
- require_login($course);
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
- require_capability('moodle/course:manageactivities', $context);
-
- $month = date("m", strtotime($date));
- $day = date("d", strtotime($date));
- $year = date("Y", strtotime($date));
-
- $newDate = mktime($hr, $mn, 0, $month, $day, $year);
-
- $newOffset = 0;
- $newTimeext = 0;
-
- if($type == 1){
- //Bug #1389 - Moodle-Ibis Integration: Fighting Offsets and Extensions
- $timeAvaUser = strtotime(userdate($ibis->timeavailable));
- $newOffset = (int)$newDate - (int)$timeAvaUser;
- }
- else{
- //Bug #1389 - Moodle-Ibis Integration: Fighting Offsets and Extensions
- $timeDueUser = strtotime(userdate($ibis->timedue));
- $newTimeext = (int)$newDate - (int)$timeDueUser;
- }
-
- //Feature #1305 - Moodle-Ibis Integration: Group Assignment Date Settings
- update_oaf_edd_group_dates($group->id, $cm->id, $newOffset, $newTimeext);
-
- echo "true";
+
+ require_once("../../../config.php");
+ require_once("../lib.php");
+
+ $id = required_param('group');
+ $type = required_param('type');
+ $cmid = required_param('cmid');
+
+ $date = required_param('date');
+ $hr = required_param('hr');
+ $mn = required_param('mn');
+
+ if (!$group = get_record("groups", "id", $id)) {
+ error("This group doesn't exist");
+ }
+
+ if (!$cm = get_record("course_modules", "id", $cmid)) {
+ error("This course module doesn't exist");
+ }
+
+ if (!$ibis = get_record("ibis", "id", $cm->instance)) {
+ error("This ibis doesn't exist");
+ }
+
+ if (!$course = get_record("course", "id", $cm->course)) {
+ error("This course doesn't exist");
+ }
+
+ require_login($course);
+ $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+ require_capability('moodle/course:manageactivities', $context);
+
+ $month = date("m", strtotime($date));
+ $day = date("d", strtotime($date));
+ $year = date("Y", strtotime($date));
+
+ $newDate = mktime($hr, $mn, 0, $month, $day, $year);
+
+ $newOffset = 0;
+ $newTimeext = 0;
+
+ if ($type == 1) {
+ //Bug #1389 - Moodle-Ibis Integration: Fighting Offsets and Extensions
+ $timeAvaUser = strtotime(userdate($ibis->timeavailable));
+ $newOffset = (int) $newDate - (int) $timeAvaUser;
+ }
+ else {
+ //Bug #1389 - Moodle-Ibis Integration: Fighting Offsets and Extensions
+ $timeDueUser = strtotime(userdate($ibis->timedue));
+ $newTimeext = (int) $newDate - (int) $timeDueUser;
+ }
+
+ //Feature #1305 - Moodle-Ibis Integration: Group Assignment Date Settings
+ update_oaf_edd_group_dates($group->id, $cm->id, $newOffset, $newTimeext);
+
+ echo "true";
?>
\ No newline at end of file
diff --git a/src/cms/moodle/mod/ibis/offset/index.php b/src/cms/moodle/mod/ibis/offset/index.php
index 93d14d3..bb18278 100644
--- a/src/cms/moodle/mod/ibis/offset/index.php
+++ b/src/cms/moodle/mod/ibis/offset/index.php
@@ -1,179 +1,178 @@
<?php
+ /**
+ * OffSet for Students: Offset for Available From and Extensions for Due Date
+ *
+ * @copyright Copyright 2011, Sapling Systems
+ * @package ibisplus
+ * @author Leandro Prudente
+ * */
+ require_once("../../../config.php");
+ require_once("../lib.php");
+ require_once("lib.php");
- /**
- * OffSet for Students: Offset for Available From and Extensions for Due Date
- *
- * @copyright Copyright 2011, Sapling Systems
- * @package ibisplus
- * @author Leandro Prudente
- **/
-
- require_once("../../../config.php");
- require_once("../lib.php");
-
- require_login();
- $id = optional_param('id', 0, PARAM_INT);
-
- if (! $cm = get_record("course_modules", "id", $id)) {
- error("This course module doesn't exist");
- }
-
- if (! $ibis = get_record("ibis", "id", $cm->instance)) {
- error("This ibis doesn't exist");
- }
-
- if (! $course = get_record("course", "id", $cm->course)) {
- error("This course doesn't exist");
- }
-
- require_login($course);
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
- require_capability('moodle/course:manageactivities', $context);
-
- if (! $module = get_record("modules", "id", $cm->module)) {
- error("This module doesn't exist");
- }
-
- if ( $module->name != "ibis" ) {
- error("incorrect module type");
- }
-
- //Update all modules information
- get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused);
- foreach($mods as $modid=>$unused) {
- if (!isset($modsinfo->cms[$modid])) {
- $modinfo =& get_fast_modinfo($course);
- }
- }
-
- $strmodulenameplural = get_string("modulenameplural", $module->name);
-
- $navlinks = array();
- $navlinks[] = array('name' => $strmodulenameplural, 'link' => "$CFG->wwwroot/mod/$module->name/index.php?id=$course->id", 'type' => 'activity');
- $navlinks[] = array('name' => format_string($ibis->name,true), 'link' => "$CFG->wwwroot/mod/$module->name/view.php?id=$cm->id", 'type' => 'activityinstance');
- $navlinks[] = array('name' => 'Extended and Offset Dates', 'link' => '', 'type' => 'title');
-
- $navigation = build_navigation($navlinks);
-
- $stribis = get_string("modulename", "ibis");
-
- print_header_simple("Editing Extended and Offset Dates", '', $navigation, NULL, "", false, update_activity_button($cm->id, $stribis));
-
- /*
- * Tabs for next ticket
-
- $currenttab = 'initial';
-
- $row = $tabs = array();
- $row[] = new tabobject('initial','index.php?id='.$id, "By Assignment");
- $row[] = new tabobject('edd','duedate.php?id='.$id, "Due Dates");
- $row[] = new tabobject('oaf','available.php?id='.$id, "Available From Dates");
-
- $tabs[] = $row;
-
- print_tabs($tabs, $currenttab);
- */
-
- //Creating the select box with all modules
- $comboAssignments = '<select name="cmbAssignments" id="cmbAssignments" onchange="location.href=\'?id=\'+this.value;">';
- foreach ($modinfo->cms as $moduleIn){
- if($moduleIn->modname == 'ibis'){
- if($moduleIn->id == $cm->id){
- $comboAssignments .= '<option value="'.$moduleIn->id.'" selected>'.$moduleIn->name.'</option>';
- }
- else{
- $comboAssignments .= '<option value="'.$moduleIn->id.'">'.$moduleIn->name.'</option>';
- }
- }
- }
- $comboAssignments .= '</select>';
-
- //Ibis times
- $availableDateShow = $ibis->timeavailable ? userdate($ibis->timeavailable) : "Not Set";
- $dueDateShow = $ibis->timedue ? userdate($ibis->timedue) : "Not Set";
-
- $ibisDatesShow = "<center><h3>Available From: <span id='ibisAvailableFrom'>".$availableDateShow."</span>&nbsp;&nbsp;<span id='ibisAvailableFromAction'><a href='#' onclick='editIbisDates(1)'><img src='".$CFG->pixpath."/t/edit.png' class='iconsmall' alt='Edit Available From' title='Edit Available From' /></a></span>";
- $ibisDatesShow .= "<br /><br />Due Date: <span id='ibisDueDate'>".$dueDateShow."</span>&nbsp;&nbsp;<span id='ibisDueDateAction'><a href='#' onclick='editIbisDates(2)'><img src='".$CFG->pixpath."/t/edit.png' class='iconsmall' alt='Edit Due Date' title='Edit Due Date' /></a></span></h3><br /></center>";
- $pageheading = "Update Date Offsets for: $comboAssignments<br />$ibisDatesShow";
- print_heading($pageheading);
-
- $contextUsr = get_context_instance(CONTEXT_COURSE, $course->id);
- $contextusers = get_role_users(array(5, 15), $contextUsr, false, 'u.id, u.firstname, u.lastname, u.email, ra.hidden');
-
- if($ibis->timeavailable){
- $availableFrom = $ibis->timeavailable;
- $availableDt = str_replace(" ", "", userdate($ibis->timeavailable, "%m/%d/%Y"));
- $availableHr = userdate($ibis->timeavailable, "%H");
- $availableMn = userdate($ibis->timeavailable, "%M");
- }
- else{
- $availableFrom = 0;
- $availableDt = "";
- $availableHr = "''";
- $availableMn = "''";
- }
-
- if($ibis->timedue){
- $dueDate = $ibis->timedue;
- $dueDt = str_replace(" ", "", userdate($ibis->timedue, "%m/%d/%Y"));
- $dueHr = userdate($ibis->timedue, "%H");
- $dueMn = userdate($ibis->timedue, "%M");
- }
- else{
- $dueDate = 0;
- $dueDt = "";
- $dueHr = "''";
- $dueMn = "''";
- }
-
- //Global Javascript Vars
- echo "<script>
- var cmid = $cm->id;
- var ibisid = $ibis->id;
- var courseid = $course->id;
- var pathURL = '$CFG->wwwroot';
- var pathIcon = '$CFG->pixpath/t';
-
- var availableFrom = $availableFrom;
- var availableDt = '".$availableDt."';
- var availableHr = ".$availableHr.";
- var availableMn = ".$availableMn.";
-
- var dueDate = $dueDate;
- var dueDt = '".$dueDt."';
- var dueHr = ".$dueHr.";
- var dueMn = ".$dueMn.";
- </script>";
-
- //Calling the javascript sources
- require_js(array(
- $CFG->wwwroot."/lib/jQuery/jquery.js",
- $CFG->wwwroot."/lib/datetimepicker/ui/jquery.ui.core.js",
- $CFG->wwwroot."/lib/datetimepicker/ui/jquery.ui.datepicker.js",
- $CFG->wwwroot."/mod/ibis/js/ibisOffsetLib.js"));
- echo '<link href="'.$CFG->wwwroot.'/lib/datetimepicker/themes/base/jquery.ui.all.css" rel="stylesheet" type="text/css" />';
-
- //Students Table
- include('table_students.php');
-
- //Add Individual Form
- include('table_add.php');
-
- $groups = get_records('groups', 'courseid', $course->id);
- if($groups){
- //Students Table
- include('table_groups.php');
-
- //Add Groups Form
- include('table_groups_add.php');
- }
-
- ?>
- <script>
- $(document).ready(function() {
- <?php echo $varDataPickerJS ?>
- });
- </script>
- <?php
- print_footer($course);
+ require_login();
+ $id = optional_param('id', 0, PARAM_INT);
+
+ if (!$cm = get_record("course_modules", "id", $id)) {
+ error("This course module doesn't exist");
+ }
+
+ if (!$ibis = get_record("ibis", "id", $cm->instance)) {
+ error("This ibis doesn't exist");
+ }
+
+ if (!$course = get_record("course", "id", $cm->course)) {
+ error("This course doesn't exist");
+ }
+
+ require_login($course);
+ $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+ require_capability('moodle/course:manageactivities', $context);
+
+ if (!$module = get_record("modules", "id", $cm->module)) {
+ error("This module doesn't exist");
+ }
+
+ if ($module->name != "ibis") {
+ error("incorrect module type");
+ }
+
+ //Update all modules information
+ get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused);
+ foreach ($mods as $modid => $unused) {
+ if (!isset($modsinfo->cms[$modid])) {
+ $modinfo = & get_fast_modinfo($course);
+ }
+ }
+
+ $strmodulenameplural = get_string("modulenameplural", $module->name);
+
+ $navlinks = array();
+ $navlinks[] = array('name' => $strmodulenameplural, 'link' => "$CFG->wwwroot/mod/$module->name/index.php?id=$course->id", 'type' => 'activity');
+ $navlinks[] = array('name' => format_string($ibis->name, true), 'link' => "$CFG->wwwroot/mod/$module->name/view.php?id=$cm->id", 'type' => 'activityinstance');
+ $navlinks[] = array('name' => 'Extended and Offset Dates', 'link' => '', 'type' => 'title');
+
+ $navigation = build_navigation($navlinks);
+
+ $stribis = get_string("modulename", "ibis");
+
+ print_header_simple("Editing Extended and Offset Dates", '', $navigation, NULL, "", false, update_activity_button($cm->id, $stribis));
+
+ /*
+ * Tabs for next ticket
+
+ $currenttab = 'initial';
+
+ $row = $tabs = array();
+ $row[] = new tabobject('initial','index.php?id='.$id, "By Assignment");
+ $row[] = new tabobject('edd','duedate.php?id='.$id, "Due Dates");
+ $row[] = new tabobject('oaf','available.php?id='.$id, "Available From Dates");
+
+ $tabs[] = $row;
+
+ print_tabs($tabs, $currenttab);
+ */
+
+ //Creating the select box with all modules
+ $comboAssignments = '<select name="cmbAssignments" id="cmbAssignments" onchange="location.href=\'?id=\'+this.value;">';
+ foreach ($modinfo->cms as $moduleIn) {
+ if ($moduleIn->modname == 'ibis') {
+ if ($moduleIn->id == $cm->id) {
+ $comboAssignments .= '<option value="'.$moduleIn->id.'" selected>'.$moduleIn->name.'</option>';
+ }
+ else {
+ $comboAssignments .= '<option value="'.$moduleIn->id.'">'.$moduleIn->name.'</option>';
+ }
+ }
+ }
+ $comboAssignments .= '</select>';
+
+ //Ibis times
+ $availableDateShow = $ibis->timeavailable ? userdate($ibis->timeavailable) : "Not Set";
+ $dueDateShow = $ibis->timedue ? userdate($ibis->timedue) : "Not Set";
+
+ $ibisDatesShow = "<center><h3>Available From: <span id='ibisAvailableFrom'>".$availableDateShow."</span>&nbsp;&nbsp;<span id='ibisAvailableFromAction'><a href='#' onclick='editIbisDates(1)'><img src='".$CFG->pixpath."/t/edit.png' class='iconsmall' alt='Edit Available From' title='Edit Available From' /></a></span>";
+ $ibisDatesShow .= "<br /><br />Due Date: <span id='ibisDueDate'>".$dueDateShow."</span>&nbsp;&nbsp;<span id='ibisDueDateAction'><a href='#' onclick='editIbisDates(2)'><img src='".$CFG->pixpath."/t/edit.png' class='iconsmall' alt='Edit Due Date' title='Edit Due Date' /></a></span></h3><br /></center>";
+ $pageheading = "Update Date Offsets for: $comboAssignments<br />$ibisDatesShow";
+ print_heading($pageheading);
+
+ $contextUsr = get_context_instance(CONTEXT_COURSE, $course->id);
+ $contextusers = get_role_users(array(5, 15), $contextUsr, false, 'u.id, u.firstname, u.lastname, u.email, ra.hidden');
+
+ if ($ibis->timeavailable) {
+ $availableFrom = $ibis->timeavailable;
+ $availableDt = str_replace(" ", "", userdate($ibis->timeavailable, "%m/%d/%Y"));
+ $availableHr = userdate($ibis->timeavailable, "%H");
+ $availableMn = userdate($ibis->timeavailable, "%M");
+ }
+ else {
+ $availableFrom = 0;
+ $availableDt = "";
+ $availableHr = "''";
+ $availableMn = "''";
+ }
+
+ if ($ibis->timedue) {
+ $dueDate = $ibis->timedue;
+ $dueDt = str_replace(" ", "", userdate($ibis->timedue, "%m/%d/%Y"));
+ $dueHr = userdate($ibis->timedue, "%H");
+ $dueMn = userdate($ibis->timedue, "%M");
+ }
+ else {
+ $dueDate = 0;
+ $dueDt = "";
+ $dueHr = "''";
+ $dueMn = "''";
+ }
+
+ //Global Javascript Vars
+ echo "<script>
+ var cmid = $cm->id;
+ var ibisid = $ibis->id;
+ var courseid = $course->id;
+ var pathURL = '$CFG->wwwroot';
+ var pathIcon = '$CFG->pixpath/t';
+
+ var availableFrom = $availableFrom;
+ var availableDt = '".$availableDt."';
+ var availableHr = ".$availableHr.";
+ var availableMn = ".$availableMn.";
+
+ var dueDate = $dueDate;
+ var dueDt = '".$dueDt."';
+ var dueHr = ".$dueHr.";
+ var dueMn = ".$dueMn.";
+ </script>";
+
+ //Calling the javascript sources
+ require_js(array(
+ $CFG->wwwroot."/lib/jQuery/jquery.js",
+ $CFG->wwwroot."/lib/datetimepicker/ui/jquery.ui.core.js",
+ $CFG->wwwroot."/lib/datetimepicker/ui/jquery.ui.datepicker.js",
+ $CFG->wwwroot."/mod/ibis/js/ibisOffsetLib.js"));
+ echo '<link href="'.$CFG->wwwroot.'/lib/datetimepicker/themes/base/jquery.ui.all.css" rel="stylesheet" type="text/css" />';
+
+ //Students Table
+ include('table_students.php');
+
+ //Add Individual Form
+ include('table_add.php');
+
+ $groups = get_records_sql("SELECT g.*, igad.offset, igad.timeext FROM groups g JOIN ibis_group_assignment_dates igad ON g.id = igad.groupid WHERE g.courseid = $course->id");
+ if ($groups) {
+
+ //Students Table
+ include('table_groups.php');
+
+ //Add Groups Form
+ include('table_groups_add.php');
+ }
+?>
+<script>
+ $(document).ready(function() {
+ <?php echo $varDataPickerJS ?>
+ });
+</script>
+<?php
+ print_footer($course);
?>
\ No newline at end of file
diff --git a/src/cms/moodle/mod/ibis/offset/lib.php b/src/cms/moodle/mod/ibis/offset/lib.php
new file mode 100644
index 0000000..c07bb3a
--- /dev/null
+++ b/src/cms/moodle/mod/ibis/offset/lib.php
@@ -0,0 +1,25 @@
+<?php
+
+ require_once($CFG->dirroot . '/mod/ibis/lib.php');
+
+ function get_users_extensions_module($cm, $context){
+
+ $sql = "SELECT u.id, u.firstname, u.lastname, ra.roleid,
+ edd.id as eddid, edd.timeext as edd,
+ oaf.id as oafid, oaf.timeext as oaf
+ FROM role_assignments ra
+ JOIN user u
+ ON u.id = ra.userid
+ JOIN role r
+ ON ra.roleid = r.id
+ LEFT JOIN ibis_extended_due_dates edd
+ ON edd.course_modules_id = $cm->id AND u.id = edd.user_id
+ LEFT JOIN ibis_offset_available_dates oaf
+ ON oaf.course_modules_id = $cm->id AND u.id = oaf.user_id
+ WHERE
+ ra.contextid = $context->id
+ AND ra.roleid IN (5,15)";
+ return get_records_sql($sql);
+ }
+
+?>
diff --git a/src/cms/moodle/mod/ibis/offset/table_add.php b/src/cms/moodle/mod/ibis/offset/table_add.php
index 9cb9aca..eef2d29 100644
--- a/src/cms/moodle/mod/ibis/offset/table_add.php
+++ b/src/cms/moodle/mod/ibis/offset/table_add.php
@@ -1,73 +1,72 @@
<?php
- echo "<br />";
- echo '<center><input type="button" value="Add individual offsets or extensions" onclick="enableAddBox(\'add-box\');" /></center>';
- echo "<br />";
-
- if($ibis->timeavailable){
- $dateShowOAF = userdate($ibis->timeavailable, "%m/%d/%Y");
- $timeHourOAF = userdate($ibis->timeavailable, "%H");
- $timeMinuteOAF = userdate($ibis->timeavailable, "%M");
- $dateShowOAF = str_replace(" ", "", $dateShowOAF);
- }
- else{
- $dateShowOAF = "";
- $timeHourOAF = "";
- $timeMinuteOAF = "";
- }
-
- if($ibis->timedue){
- $dateShowEDD = userdate($ibis->timedue, "%m/%d/%Y");
- $timeHourEDD = userdate($ibis->timedue, "%H");
- $timeMinuteEDD = userdate($ibis->timedue, "%M");
- $dateShowEDD = str_replace(" ", "", $dateShowEDD);
- }
- else{
- $dateShowEDD = "";
- $timeHourEDD = "";
- $timeMinuteEDD = "";
- }
-
- echo "<div id='add-box' style='display:none;'>";
- $tableAdd->head = array ('Select Students', 'Available From', 'Due Date');
- $tableAdd->align = array ("left", "center", "center");
- $tableAdd->width = array ("10", "100", "100");
-
- $dataPickerOAFAdd = '<div style="width:20px;float:left;margin-top:4px;"></div><div style="float:left"><input type="text" readonly="readonly" id="datePickOAFAdd" value="'.$dateShowOAF.'" size="10" /> ';
- $dataPickerOAFAdd .= '<select id="HROAFAdd"></select> : ';
- $dataPickerOAFAdd .= '<select id="MIOAFAdd"></select></div>';
-
- $varDataPickerJS .= '$("#datePickOAFAdd").datepicker();';
- $varDataPickerJS .= 'showComboTime("HROAFAdd", \''.$timeHourOAF.'\', 23);';
- $varDataPickerJS .= 'showComboTime("MIOAFAdd", \''.$timeMinuteOAF.'\', 59);';
-
- $dataPickerEDDAdd = '<div style="width:20px;float:left;margin-top:4px;"></div><div style="float:left"><input type="text" readonly="readonly" id="datePickEDDAdd" value="'.$dateShowEDD.'" size="10" /> ';
- $dataPickerEDDAdd .= '<select id="HREDDAdd"></select> : ';
- $dataPickerEDDAdd .= '<select id="MIEDDAdd"></select></div>';
-
- $btSaveSelected = '<div style="float:right;"><input type="button" value="Cancel" onclick="disableAddBox(\'add-box\');" />&nbsp;<input type="button" value="Save" onclick="createOffsetAdd();" /></div>';
-
- $varDataPickerJS .= '$("#datePickEDDAdd").datepicker();';
- $varDataPickerJS .= 'showComboTime("HREDDAdd", \''.$timeHourEDD.'\', 23);';
- $varDataPickerJS .= 'showComboTime("MIEDDAdd", \''.$timeMinuteEDD.'\', 59);';
-
- $selectShow = '<select id="addOffsetSelect" multiple="multiple" style="min-width:200px;" onclick="countMultipleSelecteds(\'addOffsetSelect\', \'addSelectedUsers\');">';
- foreach($contextusers as $userTemp){
- $oafUser = get_record_sql("select * from ibis_offset_available_dates where user_id = $userTemp->id and course_modules_id = $cm->id");
- $eddUser = get_record_sql("select * from ibis_extended_due_dates where user_id = $userTemp->id and course_modules_id = $cm->id");
- if($oafUser && $eddUser){
- $showGrey = "style='color:grey;'";
- }
- else{
- $showGrey = "";
- }
-
- $selectShow .= '<option value="'.$userTemp->id.'" '.$showGrey.'>'.$userTemp->firstname.' '.$userTemp->lastname.'</option>';
- }
- $selectShow .= '</select>';
- $tableAdd->data[] = array ($selectShow, $dataPickerOAFAdd, $dataPickerEDDAdd);
- $tableAdd->data[] = array ("Students Selected: <span id='addSelectedUsers'>0</span>", "", $btSaveSelected);
- print_table($tableAdd);
- echo "</div>";
- echo "<br />";
+ echo "<br />";
+ echo '<center><input type="button" value="Add individual offsets or extensions" onclick="enableAddBox(\'add-box\');" /></center>';
+ echo "<br />";
+
+ if ($ibis->timeavailable) {
+ $dateShowOAF = userdate($ibis->timeavailable, "%m/%d/%Y");
+ $timeHourOAF = userdate($ibis->timeavailable, "%H");
+ $timeMinuteOAF = userdate($ibis->timeavailable, "%M");
+ $dateShowOAF = str_replace(" ", "", $dateShowOAF);
+ }
+ else {
+ $dateShowOAF = "";
+ $timeHourOAF = "";
+ $timeMinuteOAF = "";
+ }
+
+ if ($ibis->timedue) {
+ $dateShowEDD = userdate($ibis->timedue, "%m/%d/%Y");
+ $timeHourEDD = userdate($ibis->timedue, "%H");
+ $timeMinuteEDD = userdate($ibis->timedue, "%M");
+ $dateShowEDD = str_replace(" ", "", $dateShowEDD);
+ }
+ else {
+ $dateShowEDD = "";
+ $timeHourEDD = "";
+ $timeMinuteEDD = "";
+ }
+
+ echo "<div id='add-box' style='display:none;'>";
+ $tableAdd->head = array('Select Students', 'Available From', 'Due Date');
+ $tableAdd->align = array("left", "center", "center");
+ $tableAdd->width = array("10", "100", "100");
+
+ $dataPickerOAFAdd = '<div style="width:20px;float:left;margin-top:4px;"></div><div style="float:left"><input type="text" readonly="readonly" id="datePickOAFAdd" value="'.$dateShowOAF.'" size="10" /> ';
+ $dataPickerOAFAdd .= '<select id="HROAFAdd"></select> : ';
+ $dataPickerOAFAdd .= '<select id="MIOAFAdd"></select></div>';
+
+ $varDataPickerJS .= '$("#datePickOAFAdd").datepicker();';
+ $varDataPickerJS .= 'showComboTime("HROAFAdd", \''.$timeHourOAF.'\', 23);';
+ $varDataPickerJS .= 'showComboTime("MIOAFAdd", \''.$timeMinuteOAF.'\', 59);';
+
+ $dataPickerEDDAdd = '<div style="width:20px;float:left;margin-top:4px;"></div><div style="float:left"><input type="text" readonly="readonly" id="datePickEDDAdd" value="'.$dateShowEDD.'" size="10" /> ';
+ $dataPickerEDDAdd .= '<select id="HREDDAdd"></select> : ';
+ $dataPickerEDDAdd .= '<select id="MIEDDAdd"></select></div>';
+
+ $btSaveSelected = '<div style="float:right;"><input type="button" value="Cancel" onclick="disableAddBox(\'add-box\');" />&nbsp;<input type="button" value="Save" onclick="createOffsetAdd();" /></div>';
+
+ $varDataPickerJS .= '$("#datePickEDDAdd").datepicker();';
+ $varDataPickerJS .= 'showComboTime("HREDDAdd", \''.$timeHourEDD.'\', 23);';
+ $varDataPickerJS .= 'showComboTime("MIEDDAdd", \''.$timeMinuteEDD.'\', 59);';
+
+ $selectShow = '<select id="addOffsetSelect" multiple="multiple" style="min-width:200px;" onclick="countMultipleSelecteds(\'addOffsetSelect\', \'addSelectedUsers\');">';
+ foreach ($usersExtensions as $userTemp) {
+
+ if ($userTemp->oaf && $userTemp->edd) {
+ $showGrey = "style='color:grey;'";
+ }
+ else {
+ $showGrey = "";
+ }
+
+ $selectShow .= '<option value="'.$userTemp->id.'" '.$showGrey.'>'.$userTemp->firstname.' '.$userTemp->lastname.'</option>';
+ }
+ $selectShow .= '</select>';
+ $tableAdd->data[] = array($selectShow, $dataPickerOAFAdd, $dataPickerEDDAdd);
+ $tableAdd->data[] = array("Students Selected: <span id='addSelectedUsers'>0</span>", "", $btSaveSelected);
+ print_table($tableAdd);
+ echo "</div>";
+ echo "<br />";
?>
\ No newline at end of file
diff --git a/src/cms/moodle/mod/ibis/offset/table_groups.php b/src/cms/moodle/mod/ibis/offset/table_groups.php
index 7d3154a..51c59a5 100644
--- a/src/cms/moodle/mod/ibis/offset/table_groups.php
+++ b/src/cms/moodle/mod/ibis/offset/table_groups.php
@@ -1,157 +1,158 @@
<?php
- print_heading("<center>Groups Offsets</center>");
-
- $tableGroups->head = array ('Select', 'Group Name', 'Students', 'Available From', 'Due Date');
- $tableGroups->align = array ("center", "left", "center", "center", "center");
- $tableGroups->width = array ("10", "100", "100", "100", "100");
- if($contextusers){
- foreach($groups as $group){
-
- //Feature #1305 - Moodle-Ibis Integration: Group Assignment Date Settings
- $sqlGet = "select * from ibis_group_assignment_dates where groupid = $group->id and coursemodulesid = $cm->id";
- $ibis_group_assignment_dates = get_record_sql($sqlGet);
-
- if($ibis_group_assignment_dates){
-
- $studentsGroup = get_records('groups_members', 'groupid', $group->id);
- if($studentsGroup){
- $studentsShow = count($studentsGroup);
- }
- else{
- $studentsShow = 0;
- }
-
- $groupLink = '<a href="'.$CFG->wwwroot.'/group/group.php?courseid='.$course->id.'&id='.$group->id.'">'.$group->name.'</a>';
-
- //OAF
- if($ibis_group_assignment_dates->offset != 0){
- $newDateOAF = $ibis->timeavailable + $ibis_group_assignment_dates->offset;
- $iconAction = "deleteGroupDate";
- $disableFields = '';
- $iconImg = 'delete.png';
- }
- else{
- $newDateOAF = $ibis->timeavailable;
- $iconAction = "enableGroupEdit";
- $disableFields = 'disabled="disabled"';
- $iconImg = 'edit.png';
- }
-
- //Offsets
- if($newDateOAF != 0){
- $dateShowOAF = userdate($newDateOAF, "%m/%d/%Y");
- $timeHourOAF = userdate($newDateOAF, "%H");
- $timeMinuteOAF = userdate($newDateOAF, "%M");
- }
- else{
- $dateShowOAF = "";
- $timeHourOAF = "";
- $timeMinuteOAF = "";
- }
-
-
- $dateShowOAF = str_replace(" ", "", $dateShowOAF);
- $dataPickerOAF = '<div style="width:20px;float:left;margin-top:4px;" id="ActionGroupOAF'.$group->id.$cm->id.'"><a id="linkGridGroupOAF'.$group->id.$cm->id.'" href="#" onclick="'.$iconAction.'('.$group->id.', 1, '.$cm->id.')"><img id="imgGridGroupOAF'.$group->id.$cm->id.'" src="'.$CFG->pixpath.'/t/'.$iconImg.'" class="iconsmall" border="0" /></a></div>&nbsp;&nbsp;';
- $dataPickerOAF .= '<div style="float:left"><input type="text" readonly="readonly" '.$disableFields.' id="datePickGroupOAF'.$group->id.$cm->id.'" value="'.$dateShowOAF.'" size="10" onchange="enableSaveGroup('.$group->id.', 1, '.$cm->id.');" /> ';
- $dataPickerOAF .= '<select id="HRGroupOAF_'.$group->id.$cm->id.'" '.$disableFields.' onchange="enableSaveGroup('.$group->id.', 1, '.$cm->id.');"></select> : ';
- $dataPickerOAF .= '<select id="MIGroupOAF_'.$group->id.$cm->id.'" '.$disableFields.' onchange="enableSaveGroup('.$group->id.', 1, '.$cm->id.');"></select></div>';
- $dataPickerOAF .= '<div id="SaveGroupOAF'.$group->id.$cm->id.'" style="width:30px;float:left;margin-top:2px;margin-left:5px;display:none;"><a href="#" onclick="saveGroupDate('.$group->id.', 1, '.$cm->id.');"><img src="'.$CFG->wwwroot.'/mod/ibis/ico_save.png" /></a></div>';
-
- $varDataPickerJS .= '$("#datePickGroupOAF'.$group->id.$cm->id.'").datepicker();';
- $varDataPickerJS .= 'showComboTime("HRGroupOAF_'.$group->id.$cm->id.'", \''.$timeHourOAF.'\', 23);';
- $varDataPickerJS .= 'showComboTime("MIGroupOAF_'.$group->id.$cm->id.'", \''.$timeMinuteOAF.'\', 59);';
-
- //OAF
- if($ibis_group_assignment_dates->timeext != 0){
- $newDateEDD = $ibis->timedue + $ibis_group_assignment_dates->timeext;
- $iconAction = "deleteGroupDate";
- $disableFields = '';
- $iconImg = 'delete.png';
- }
- else{
- $newDateEDD = $ibis->timedue;
- $iconAction = "enableGroupEdit";
- $disableFields = 'disabled="disabled"';
- $iconImg = 'edit.png';
- }
-
- //DueDates
- if($newDateEDD != 0){
- $dateShowEDD = userdate($newDateEDD, "%m/%d/%Y");
- $timeHourEDD = userdate($newDateEDD, "%H");
- $timeMinuteEDD = userdate($newDateEDD, "%M");
- }
- else{
- $dateShowEDD = "";
- $timeHourEDD = "";
- $timeMinuteEDD = "";
- }
-
- $dateShowEDD = str_replace(" ", "", $dateShowEDD);
- $dataPickerEDD = '<div style="width:20px;float:left;margin-top:4px;" id="ActionGroupEDD'.$group->id.$cm->id.'"><a id="linkGridGroupEDD'.$group->id.$cm->id.'" href="#" onclick="'.$iconAction.'('.$group->id.', 2, '.$cm->id.')"><img id="imgGridGroupEDD'.$group->id.$cm->id.'" src="'.$CFG->pixpath.'/t/'.$iconImg.'" border="0" class="iconsmall" /></a></div>&nbsp;&nbsp;';
- $dataPickerEDD .= '<div style="float:left"><input type="text" readonly="readonly" '.$disableFields.' id="datePickGroupEDD'.$group->id.$cm->id.'" value="'.$dateShowEDD.'" size="10" onchange="enableSaveGroup('.$group->id.', 2, '.$cm->id.');" /> ';
- $dataPickerEDD .= '<select id="HRGroupEDD_'.$group->id.$cm->id.'" '.$disableFields.' onchange="enableSaveGroup('.$group->id.', 2, '.$cm->id.');"></select> : ';
- $dataPickerEDD .= '<select id="MIGroupEDD_'.$group->id.$cm->id.'" '.$disableFields.' onchange="enableSaveGroup('.$group->id.', 2, '.$cm->id.');"></select></div>';
- $dataPickerEDD .= '<div id="SaveGroupEDD'.$group->id.$cm->id.'" style="width:30px;float:left;margin-top:2px;margin-left:5px;display:none;"><a href="#" onclick="saveGroupDate('.$group->id.', 2, '.$cm->id.');"><img src="'.$CFG->wwwroot.'/mod/ibis/ico_save.png" /></a></div>';
-
- $varDataPickerJS .= '$("#datePickGroupEDD'.$group->id.$cm->id.'").datepicker();';
- $varDataPickerJS .= 'showComboTime("HRGroupEDD_'.$group->id.$cm->id.'", \''.$timeHourEDD.'\', 23);';
- $varDataPickerJS .= 'showComboTime("MIGroupEDD_'.$group->id.$cm->id.'", \''.$timeMinuteEDD.'\', 59);';
-
-
- $ckboxGroup = '<input type="checkbox" name="ckGroup'.$group->id.'" id="ckGroup'.$group->id.'" onclick="checkGroup('.$group->id.', '.$cm->id.', this.checked)" />';
-
- $tableGroups->data[] = array ($ckboxGroup, $groupLink, $studentsShow, $dataPickerOAF, $dataPickerEDD);
- }
- }
- }
- $tableGroups->data[] = array ("", "", "", "", "");
-
- if($ibis->timeavailable){
- $dateShowOAF = userdate($ibis->timeavailable, "%m/%d/%Y");
- $timeHourOAF = userdate($ibis->timeavailable, "%H");
- $timeMinuteOAF = userdate($ibis->timeavailable, "%M");
- $dateShowOAF = str_replace(" ", "", $dateShowOAF);
- }
- else{
- $dateShowOAF = "";
- $timeHourOAF = "";
- $timeMinuteOAF = "";
- }
-
- if($ibis->timedue){
- $dateShowEDD = userdate($ibis->timedue, "%m/%d/%Y");
- $timeHourEDD = userdate($ibis->timedue, "%H");
- $timeMinuteEDD = userdate($ibis->timedue, "%M");
- $dateShowEDD = str_replace(" ", "", $dateShowEDD);
- }
- else{
- $dateShowEDD = "";
- $timeHourEDD = "";
- $timeMinuteEDD = "";
- }
-
- $dataPickerOAFSelected = '<div style="width:20px;float:left;margin-top:4px;"></div><div style="float:left"><input type="text" readonly="readonly" id="datePickOAFGroupSelected" value="'.$dateShowOAF.'" size="10" /> ';
- $dataPickerOAFSelected .= '<select id="HROAFGroupSelected"></select> : ';
- $dataPickerOAFSelected .= '<select id="MIOAFGroupSelected"></select></div>';
-
- $varDataPickerJS .= '$("#datePickOAFGroupSelected").datepicker();';
- $varDataPickerJS .= 'showComboTime("HROAFGroupSelected", \''.$timeHourOAF.'\', 23);';
- $varDataPickerJS .= 'showComboTime("MIOAFGroupSelected", \''.$timeMinuteOAF.'\', 59);';
-
- $dataPickerEDDSelected = '<div style="width:20px;float:left;margin-top:4px;"></div><div style="float:left"><input type="text" readonly="readonly" id="datePickEDDGroupSelected" value="'.$dateShowEDD.'" size="10" /> ';
- $dataPickerEDDSelected .= '<select id="HREDDGroupSelected"></select> : ';
- $dataPickerEDDSelected .= '<select id="MIEDDGroupSelected"></select></div>';
-
- $btSaveSelected = '<div style="width:30px;float:left;margin-top:2px;margin-left:5px;"><a href="#" onclick="createOffsetGroupsSelecteds();"><img src="'.$CFG->wwwroot.'/mod/ibis/ico_save.png" /></a></div>';
-
- $varDataPickerJS .= '$("#datePickEDDGroupSelected").datepicker();';
- $varDataPickerJS .= 'showComboTime("HREDDGroupSelected", \''.$timeHourEDD.'\', 23);';
- $varDataPickerJS .= 'showComboTime("MIEDDGroupSelected", \''.$timeMinuteEDD.'\', 59);';
-
-
- $tableGroups->data[] = array ("", "<div id='updateGroupLabel' style='display:none;'><b>Update Selected Groups:</b></div>", "", "<div id='updateGroupOAF' style='display:none;'>$dataPickerOAFSelected</div>", "<div id='updateGroupEDD' style='display:none;'>$dataPickerEDDSelected$btSaveSelected</div>");
-
- print_table($tableGroups);
- echo "<br />";
+
+ print_heading("<center>Groups Offsets</center>");
+
+ $tableGroups->head = array('Select', 'Group Name', 'Students', 'Available From', 'Due Date');
+ $tableGroups->align = array("center", "left", "center", "center", "center");
+ $tableGroups->width = array("10", "100", "100", "100", "100");
+ if ($contextusers) {
+ foreach ($groups as $group) {
+
+ //Feature #1305 - Moodle-Ibis Integration: Group Assignment Date Settings
+ $sqlGet = "select * from ibis_group_assignment_dates where groupid = $group->id and coursemodulesid = $cm->id";
+ $ibis_group_assignment_dates = get_record_sql($sqlGet);
+
+ if ($ibis_group_assignment_dates) {
+
+ $studentsGroup = get_records('groups_members', 'groupid', $group->id);
+ if ($studentsGroup) {
+ $studentsShow = count($studentsGroup);
+ }
+ else {
+ $studentsShow = 0;
+ }
+
+ $groupLink = '<a href="'.$CFG->wwwroot.'/group/group.php?courseid='.$course->id.'&id='.$group->id.'">'.$group->name.'</a>';
+
+ //OAF
+ if ($ibis_group_assignment_dates->offset != 0) {
+ $newDateOAF = $ibis->timeavailable + $ibis_group_assignment_dates->offset;
+ $iconAction = "deleteGroupDate";
+ $disableFields = '';
+ $iconImg = 'delete.png';
+ }
+ else {
+ $newDateOAF = $ibis->timeavailable;
+ $iconAction = "enableGroupEdit";
+ $disableFields = 'disabled="disabled"';
+ $iconImg = 'edit.png';
+ }
+
+ //Offsets
+ if ($newDateOAF != 0) {
+ $dateShowOAF = userdate($newDateOAF, "%m/%d/%Y");
+ $timeHourOAF = userdate($newDateOAF, "%H");
+ $timeMinuteOAF = userdate($newDateOAF, "%M");
+ }
+ else {
+ $dateShowOAF = "";
+ $timeHourOAF = "";
+ $timeMinuteOAF = "";
+ }
+
+
+ $dateShowOAF = str_replace(" ", "", $dateShowOAF);
+ $dataPickerOAF = '<div style="width:20px;float:left;margin-top:4px;" id="ActionGroupOAF'.$group->id.$cm->id.'"><a id="linkGridGroupOAF'.$group->id.$cm->id.'" href="#" onclick="'.$iconAction.'('.$group->id.', 1, '.$cm->id.')"><img id="imgGridGroupOAF'.$group->id.$cm->id.'" src="'.$CFG->pixpath.'/t/'.$iconImg.'" class="iconsmall" border="0" /></a></div>&nbsp;&nbsp;';
+ $dataPickerOAF .= '<div style="float:left"><input type="text" readonly="readonly" '.$disableFields.' id="datePickGroupOAF'.$group->id.$cm->id.'" value="'.$dateShowOAF.'" size="10" onchange="enableSaveGroup('.$group->id.', 1, '.$cm->id.');" /> ';
+ $dataPickerOAF .= '<select id="HRGroupOAF_'.$group->id.$cm->id.'" '.$disableFields.' onchange="enableSaveGroup('.$group->id.', 1, '.$cm->id.');"></select> : ';
+ $dataPickerOAF .= '<select id="MIGroupOAF_'.$group->id.$cm->id.'" '.$disableFields.' onchange="enableSaveGroup('.$group->id.', 1, '.$cm->id.');"></select></div>';
+ $dataPickerOAF .= '<div id="SaveGroupOAF'.$group->id.$cm->id.'" style="width:30px;float:left;margin-top:2px;margin-left:5px;display:none;"><a href="#" onclick="saveGroupDate('.$group->id.', 1, '.$cm->id.');"><img src="'.$CFG->wwwroot.'/mod/ibis/ico_save.png" /></a></div>';
+
+ $varDataPickerJS .= '$("#datePickGroupOAF'.$group->id.$cm->id.'").datepicker();';
+ $varDataPickerJS .= 'showComboTime("HRGroupOAF_'.$group->id.$cm->id.'", \''.$timeHourOAF.'\', 23);';
+ $varDataPickerJS .= 'showComboTime("MIGroupOAF_'.$group->id.$cm->id.'", \''.$timeMinuteOAF.'\', 59);';
+
+ //OAF
+ if ($ibis_group_assignment_dates->timeext != 0) {
+ $newDateEDD = $ibis->timedue + $ibis_group_assignment_dates->timeext;
+ $iconAction = "deleteGroupDate";
+ $disableFields = '';
+ $iconImg = 'delete.png';
+ }
+ else {
+ $newDateEDD = $ibis->timedue;
+ $iconAction = "enableGroupEdit";
+ $disableFields = 'disabled="disabled"';
+ $iconImg = 'edit.png';
+ }
+
+ //DueDates
+ if ($newDateEDD != 0) {
+ $dateShowEDD = userdate($newDateEDD, "%m/%d/%Y");
+ $timeHourEDD = userdate($newDateEDD, "%H");
+ $timeMinuteEDD = userdate($newDateEDD, "%M");
+ }
+ else {
+ $dateShowEDD = "";
+ $timeHourEDD = "";
+ $timeMinuteEDD = "";
+ }
+
+ $dateShowEDD = str_replace(" ", "", $dateShowEDD);
+ $dataPickerEDD = '<div style="width:20px;float:left;margin-top:4px;" id="ActionGroupEDD'.$group->id.$cm->id.'"><a id="linkGridGroupEDD'.$group->id.$cm->id.'" href="#" onclick="'.$iconAction.'('.$group->id.', 2, '.$cm->id.')"><img id="imgGridGroupEDD'.$group->id.$cm->id.'" src="'.$CFG->pixpath.'/t/'.$iconImg.'" border="0" class="iconsmall" /></a></div>&nbsp;&nbsp;';
+ $dataPickerEDD .= '<div style="float:left"><input type="text" readonly="readonly" '.$disableFields.' id="datePickGroupEDD'.$group->id.$cm->id.'" value="'.$dateShowEDD.'" size="10" onchange="enableSaveGroup('.$group->id.', 2, '.$cm->id.');" /> ';
+ $dataPickerEDD .= '<select id="HRGroupEDD_'.$group->id.$cm->id.'" '.$disableFields.' onchange="enableSaveGroup('.$group->id.', 2, '.$cm->id.');"></select> : ';
+ $dataPickerEDD .= '<select id="MIGroupEDD_'.$group->id.$cm->id.'" '.$disableFields.' onchange="enableSaveGroup('.$group->id.', 2, '.$cm->id.');"></select></div>';
+ $dataPickerEDD .= '<div id="SaveGroupEDD'.$group->id.$cm->id.'" style="width:30px;float:left;margin-top:2px;margin-left:5px;display:none;"><a href="#" onclick="saveGroupDate('.$group->id.', 2, '.$cm->id.');"><img src="'.$CFG->wwwroot.'/mod/ibis/ico_save.png" /></a></div>';
+
+ $varDataPickerJS .= '$("#datePickGroupEDD'.$group->id.$cm->id.'").datepicker();';
+ $varDataPickerJS .= 'showComboTime("HRGroupEDD_'.$group->id.$cm->id.'", \''.$timeHourEDD.'\', 23);';
+ $varDataPickerJS .= 'showComboTime("MIGroupEDD_'.$group->id.$cm->id.'", \''.$timeMinuteEDD.'\', 59);';
+
+
+ $ckboxGroup = '<input type="checkbox" name="ckGroup'.$group->id.'" id="ckGroup'.$group->id.'" onclick="checkGroup('.$group->id.', '.$cm->id.', this.checked)" />';
+
+ $tableGroups->data[] = array($ckboxGroup, $groupLink, $studentsShow, $dataPickerOAF, $dataPickerEDD);
+ }
+ }
+ }
+ $tableGroups->data[] = array("", "", "", "", "");
+
+ if ($ibis->timeavailable) {
+ $dateShowOAF = userdate($ibis->timeavailable, "%m/%d/%Y");
+ $timeHourOAF = userdate($ibis->timeavailable, "%H");
+ $timeMinuteOAF = userdate($ibis->timeavailable, "%M");
+ $dateShowOAF = str_replace(" ", "", $dateShowOAF);
+ }
+ else {
+ $dateShowOAF = "";
+ $timeHourOAF = "";
+ $timeMinuteOAF = "";
+ }
+
+ if ($ibis->timedue) {
+ $dateShowEDD = userdate($ibis->timedue, "%m/%d/%Y");
+ $timeHourEDD = userdate($ibis->timedue, "%H");
+ $timeMinuteEDD = userdate($ibis->timedue, "%M");
+ $dateShowEDD = str_replace(" ", "", $dateShowEDD);
+ }
+ else {
+ $dateShowEDD = "";
+ $timeHourEDD = "";
+ $timeMinuteEDD = "";
+ }
+
+ $dataPickerOAFSelected = '<div style="width:20px;float:left;margin-top:4px;"></div><div style="float:left"><input type="text" readonly="readonly" id="datePickOAFGroupSelected" value="'.$dateShowOAF.'" size="10" /> ';
+ $dataPickerOAFSelected .= '<select id="HROAFGroupSelected"></select> : ';
+ $dataPickerOAFSelected .= '<select id="MIOAFGroupSelected"></select></div>';
+
+ $varDataPickerJS .= '$("#datePickOAFGroupSelected").datepicker();';
+ $varDataPickerJS .= 'showComboTime("HROAFGroupSelected", \''.$timeHourOAF.'\', 23);';
+ $varDataPickerJS .= 'showComboTime("MIOAFGroupSelected", \''.$timeMinuteOAF.'\', 59);';
+
+ $dataPickerEDDSelected = '<div style="width:20px;float:left;margin-top:4px;"></div><div style="float:left"><input type="text" readonly="readonly" id="datePickEDDGroupSelected" value="'.$dateShowEDD.'" size="10" /> ';
+ $dataPickerEDDSelected .= '<select id="HREDDGroupSelected"></select> : ';
+ $dataPickerEDDSelected .= '<select id="MIEDDGroupSelected"></select></div>';
+
+ $btSaveSelected = '<div style="width:30px;float:left;margin-top:2px;margin-left:5px;"><a href="#" onclick="createOffsetGroupsSelecteds();"><img src="'.$CFG->wwwroot.'/mod/ibis/ico_save.png" /></a></div>';
+
+ $varDataPickerJS .= '$("#datePickEDDGroupSelected").datepicker();';
+ $varDataPickerJS .= 'showComboTime("HREDDGroupSelected", \''.$timeHourEDD.'\', 23);';
+ $varDataPickerJS .= 'showComboTime("MIEDDGroupSelected", \''.$timeMinuteEDD.'\', 59);';
+
+
+ $tableGroups->data[] = array("", "<div id='updateGroupLabel' style='display:none;'><b>Update Selected Groups:</b></div>", "", "<div id='updateGroupOAF' style='display:none;'>$dataPickerOAFSelected</div>", "<div id='updateGroupEDD' style='display:none;'>$dataPickerEDDSelected$btSaveSelected</div>");
+
+ print_table($tableGroups);
+ echo "<br />";
?>
\ No newline at end of file
diff --git a/src/cms/moodle/mod/ibis/offset/table_groups_add.php b/src/cms/moodle/mod/ibis/offset/table_groups_add.php
index 676a6cf..ffacdc9 100644
--- a/src/cms/moodle/mod/ibis/offset/table_groups_add.php
+++ b/src/cms/moodle/mod/ibis/offset/table_groups_add.php
@@ -1,77 +1,73 @@
<?php
- echo "<br />";
- echo '<center><input type="button" value="Add group offsets or extensions" onclick="enableAddBox(\'addGroup-box\');" /></center>';
- echo "<br />";
-
- if($ibis->timeavailable){
- $dateShowOAF = userdate($ibis->timeavailable, "%m/%d/%Y");
- $timeHourOAF = userdate($ibis->timeavailable, "%H");
- $timeMinuteOAF = userdate($ibis->timeavailable, "%M");
- $dateShowOAF = str_replace(" ", "", $dateShowOAF);
- }
- else{
- $dateShowOAF = "";
- $timeHourOAF = "";
- $timeMinuteOAF = "";
- }
-
- if($ibis->timedue){
- $dateShowEDD = userdate($ibis->timedue, "%m/%d/%Y");
- $timeHourEDD = userdate($ibis->timedue, "%H");
- $timeMinuteEDD = userdate($ibis->timedue, "%M");
- $dateShowEDD = str_replace(" ", "", $dateShowEDD);
- }
- else{
- $dateShowEDD = "";
- $timeHourEDD = "";
- $timeMinuteEDD = "";
- }
-
- echo "<div id='addGroup-box' style='display:none;'>";
- $tableAdd = null;
- $tableAdd->head = array ('Select Groups', 'Available From', 'Due Date');
- $tableAdd->align = array ("left", "center", "center");
- $tableAdd->width = array ("10", "100", "100");
-
- $dataPickerOAFAdd = '<div style="width:20px;float:left;margin-top:4px;"></div><div style="float:left"><input type="text" readonly="readonly" id="datePickOAFAddG" value="'.$dateShowOAF.'" size="10" /> ';
- $dataPickerOAFAdd .= '<select id="HROAFAddG"></select> : ';
- $dataPickerOAFAdd .= '<select id="MIOAFAddG"></select></div>';
-
- $varDataPickerJS .= '$("#datePickOAFAddG").datepicker();';
- $varDataPickerJS .= 'showComboTime("HROAFAddG", \''.$timeHourOAF.'\', 23);';
- $varDataPickerJS .= 'showComboTime("MIOAFAddG", \''.$timeMinuteOAF.'\', 59);';
-
- $dataPickerEDDAdd = '<div style="width:20px;float:left;margin-top:4px;"></div><div style="float:left"><input type="text" readonly="readonly" id="datePickEDDAddG" value="'.$dateShowEDD.'" size="10" /> ';
- $dataPickerEDDAdd .= '<select id="HREDDAddG"></select> : ';
- $dataPickerEDDAdd .= '<select id="MIEDDAddG"></select></div>';
-
- $btSaveSelected = '<div style="float:right;"><input type="button" value="Cancel" onclick="disableAddBox(\'addGroup-box\');" />&nbsp;<input type="button" value="Save" onclick="createOffsetAddGroup();" /></div>';
-
- $varDataPickerJS .= '$("#datePickEDDAddG").datepicker();';
- $varDataPickerJS .= 'showComboTime("HREDDAddG", \''.$timeHourEDD.'\', 23);';
- $varDataPickerJS .= 'showComboTime("MIEDDAddG", \''.$timeMinuteEDD.'\', 59);';
-
- $selectShow = '<select id="addOffsetSelectG" multiple="multiple" style="min-width:200px;" onclick="countMultipleSelecteds(\'addOffsetSelectG\', \'addSelectedGroups\');">';
- foreach($groups as $group){
-
- $groupOAF = get_record_sql("SELECT timeext FROM ibis_offset_available_dates WHERE course_modules_id = $cm->id AND groupid = $group->id group by timeext");
- $groupEDD = get_record_sql("SELECT timeext FROM ibis_extended_due_dates WHERE course_modules_id = $cm->id AND groupid = $group->id group by timeext");
-
- if($groupOAF && $groupEDD){
- $showGrey = "style='color:grey;'";
- }
- else{
- $showGrey = "";
- }
-
- $selectShow .= '<option value="'.$group->id.'" '.$showGrey.'>'.$group->name.'</option>';
- }
-
- $selectShow .= '</select>';
- $tableAdd->data[] = array ($selectShow, $dataPickerOAFAdd, $dataPickerEDDAdd);
- $tableAdd->data[] = array ("Groups Selected: <span id='addSelectedGroups'>0</span>", "", $btSaveSelected);
- print_table($tableAdd);
- echo "</div>";
- echo "<br />";
+ echo "<br />";
+ echo '<center><input type="button" value="Add group offsets or extensions" onclick="enableAddBox(\'addGroup-box\');" /></center>';
+ echo "<br />";
+
+ if ($ibis->timeavailable) {
+ $dateShowOAF = userdate($ibis->timeavailable, "%m/%d/%Y");
+ $timeHourOAF = userdate($ibis->timeavailable, "%H");
+ $timeMinuteOAF = userdate($ibis->timeavailable, "%M");
+ $dateShowOAF = str_replace(" ", "", $dateShowOAF);
+ }
+ else {
+ $dateShowOAF = "";
+ $timeHourOAF = "";
+ $timeMinuteOAF = "";
+ }
+
+ if ($ibis->timedue) {
+ $dateShowEDD = userdate($ibis->timedue, "%m/%d/%Y");
+ $timeHourEDD = userdate($ibis->timedue, "%H");
+ $timeMinuteEDD = userdate($ibis->timedue, "%M");
+ $dateShowEDD = str_replace(" ", "", $dateShowEDD);
+ }
+ else {
+ $dateShowEDD = "";
+ $timeHourEDD = "";
+ $timeMinuteEDD = "";
+ }
+
+ echo "<div id='addGroup-box' style='display:none;'>";
+ $tableAdd = null;
+ $tableAdd->head = array('Select Groups', 'Available From', 'Due Date');
+ $tableAdd->align = array("left", "center", "center");
+ $tableAdd->width = array("10", "100", "100");
+
+ $dataPickerOAFAdd = '<div style="width:20px;float:left;margin-top:4px;"></div><div style="float:left"><input type="text" readonly="readonly" id="datePickOAFAddG" value="'.$dateShowOAF.'" size="10" /> ';
+ $dataPickerOAFAdd .= '<select id="HROAFAddG"></select> : ';
+ $dataPickerOAFAdd .= '<select id="MIOAFAddG"></select></div>';
+
+ $varDataPickerJS .= '$("#datePickOAFAddG").datepicker();';
+ $varDataPickerJS .= 'showComboTime("HROAFAddG", \''.$timeHourOAF.'\', 23);';
+ $varDataPickerJS .= 'showComboTime("MIOAFAddG", \''.$timeMinuteOAF.'\', 59);';
+
+ $dataPickerEDDAdd = '<div style="width:20px;float:left;margin-top:4px;"></div><div style="float:left"><input type="text" readonly="readonly" id="datePickEDDAddG" value="'.$dateShowEDD.'" size="10" /> ';
+ $dataPickerEDDAdd .= '<select id="HREDDAddG"></select> : ';
+ $dataPickerEDDAdd .= '<select id="MIEDDAddG"></select></div>';
+
+ $btSaveSelected = '<div style="float:right;"><input type="button" value="Cancel" onclick="disableAddBox(\'addGroup-box\');" />&nbsp;<input type="button" value="Save" onclick="createOffsetAddGroup();" /></div>';
+
+ $varDataPickerJS .= '$("#datePickEDDAddG").datepicker();';
+ $varDataPickerJS .= 'showComboTime("HREDDAddG", \''.$timeHourEDD.'\', 23);';
+ $varDataPickerJS .= 'showComboTime("MIEDDAddG", \''.$timeMinuteEDD.'\', 59);';
+
+ $selectShow = '<select id="addOffsetSelectG" multiple="multiple" style="min-width:200px;" onclick="countMultipleSelecteds(\'addOffsetSelectG\', \'addSelectedGroups\');">';
+ foreach ($groups as $group) {
+ if ($group->offset != 0 && $group->timeext != 0) {
+ $showGrey = "style='color:grey;'";
+ }
+ else {
+ $showGrey = "";
+ }
+
+ $selectShow .= '<option value="'.$group->id.'" '.$showGrey.'>'.$group->name.'</option>';
+ }
+
+ $selectShow .= '</select>';
+ $tableAdd->data[] = array($selectShow, $dataPickerOAFAdd, $dataPickerEDDAdd);
+ $tableAdd->data[] = array("Groups Selected: <span id='addSelectedGroups'>0</span>", "", $btSaveSelected);
+ print_table($tableAdd);
+ echo "</div>";
+ echo "<br />";
?>
\ No newline at end of file
diff --git a/src/cms/moodle/mod/ibis/offset/table_students.php b/src/cms/moodle/mod/ibis/offset/table_students.php
index 96d3811..8ebb483 100644
--- a/src/cms/moodle/mod/ibis/offset/table_students.php
+++ b/src/cms/moodle/mod/ibis/offset/table_students.php
@@ -1,135 +1,143 @@
<?php
- $table->head = array ('Individuals', 'Student Name', 'Available From', 'Due Date');
- $table->align = array ("center", "left", "center", "center");
- $table->width = array ("10", "100", "100", "100");
- if($contextusers){
- $varDataPickerJS = "";
- foreach($contextusers as $userTemp){
- $oaf_user = oaf_get_individual_user_dates($cm->id, $userTemp->id);
- $edd_user = edd_get_individual_user_dates($cm->id, $userTemp->id);
-
- $dataPickerOAF = "";
- $dataPickerEDD = "";
-
- $ckboxUser = '<input type="checkbox" name="ckUser'.$userTemp->id.'" id="ckUser'.$userTemp->id.'" onclick="checkUser('.$userTemp->id.', '.$cm->id.', this.checked)" />';
- $linkNameStudent = '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$userTemp->id.'&course='.$course->id.'">'.$userTemp->firstname.' '.$userTemp->lastname.'</a>';
-
- //OAF
- if($oaf_user){
- $newDateOAF = $ibis->timeavailable + $oaf_user->timeext;
- $iconAction = "deleteExtension";
- $disableFields = '';
- $iconImg = 'delete.png';
- }
- else{
- $oaf_user->id = 0;
- $newDateOAF = $ibis->timeavailable;
- $iconAction = "enableEdit";
- $disableFields = 'disabled="disabled"';
- $iconImg = 'edit.gif';
- }
-
- if($newDateOAF != 0){
- $dateShowOAF = userdate($newDateOAF, "%m/%d/%Y");
- $timeHourOAF = userdate($newDateOAF, "%H");
- $timeMinuteOAF = userdate($newDateOAF, "%M");
- }
-
- $dateShowOAF = str_replace(" ", "", $dateShowOAF);
- $dataPickerOAF = '<div style="width:20px;float:left;margin-top:4px;" id="ActionOAF'.$oaf_user->id.$userTemp->id.$cm->id.'"><a id="linkGridOAF'.$oaf_user->id.$userTemp->id.$cm->id.'" href="#" onclick="'.$iconAction.'('.$oaf_user->id.', 1, '.$userTemp->id.', '.$cm->id.')"><img id="imgGridOAF'.$oaf_user->id.$userTemp->id.$cm->id.'" src="'.$CFG->pixpath.'/t/'.$iconImg.'" border="0" /></a></div>&nbsp;&nbsp;';
- $dataPickerOAF .= '<div style="float:left"><input type="text" readonly="readonly" '.$disableFields.' id="datePickOAF'.$oaf_user->id.$userTemp->id.$cm->id.'" value="'.$dateShowOAF.'" size="10" onchange="enableSave('.$oaf_user->id.', 1, '.$userTemp->id.', '.$cm->id.');" /> ';
- $dataPickerOAF .= '<select id="HROAF_'.$oaf_user->id.$userTemp->id.$cm->id.'" '.$disableFields.' onchange="enableSave('.$oaf_user->id.', 1, '.$userTemp->id.', '.$cm->id.');"></select> : ';
- $dataPickerOAF .= '<select id="MIOAF_'.$oaf_user->id.$userTemp->id.$cm->id.'" '.$disableFields.' onchange="enableSave('.$oaf_user->id.', 1, '.$userTemp->id.', '.$cm->id.');"></select></div>';
- $dataPickerOAF .= '<div id="SaveOAF'.$oaf_user->id.$userTemp->id.$cm->id.'" style="width:30px;float:left;margin-top:2px;margin-left:5px;display:none;"><a href="#" onclick="createOffset('.$oaf_user->id.', 1, '.$userTemp->id.', '.$cm->id.');"><img src="'.$CFG->wwwroot.'/mod/ibis/ico_save.png" /></a></div>';
-
- $varDataPickerJS .= '$("#datePickOAF'.$oaf_user->id.$userTemp->id.$cm->id.'").datepicker();';
- $varDataPickerJS .= 'showComboTime("HROAF_'.$oaf_user->id.$userTemp->id.$cm->id.'", \''.$timeHourOAF.'\', 23);';
- $varDataPickerJS .= 'showComboTime("MIOAF_'.$oaf_user->id.$userTemp->id.$cm->id.'", \''.$timeMinuteOAF.'\', 59);';
-
-
- //EDD
- if($edd_user){
- $newDateEDD = $ibis->timedue + $edd_user->timeext;
- $iconAction = "deleteExtension";
- $disableFields = '';
- $iconImg = 'delete.png';
- }
- else{
- $edd_user->id = 0;
- $newDateEDD = $ibis->timedue;
- $iconAction = "enableEdit";
- $disableFields = 'disabled="disabled"';
- $iconImg = 'edit.gif';
- }
-
- if($newDateEDD != 0){
- $dateShowEDD = userdate($newDateEDD, "%m/%d/%Y");
- $timeHourEDD = userdate($newDateEDD, "%H");
- $timeMinuteEDD = userdate($newDateEDD, "%M");
- }
-
- $dateShowEDD = str_replace(" ", "", $dateShowEDD);
- $dataPickerEDD = '<div style="width:20px;float:left;margin-top:4px;" id="ActionEDD'.$edd_user->id.$userTemp->id.$cm->id.'"><a id="linkGridEDD'.$edd_user->id.$userTemp->id.$cm->id.'" href="#" onclick="'.$iconAction.'('.$edd_user->id.', 2, '.$userTemp->id.', '.$cm->id.')"><img id="imgGridEDD'.$edd_user->id.$userTemp->id.$cm->id.'" src="'.$CFG->pixpath.'/t/'.$iconImg.'" border="0" /></a></div>&nbsp;&nbsp;';
- $dataPickerEDD .= '<div style="float:left"><input type="text" readonly="readonly" '.$disableFields.' id="datePickEDD'.$edd_user->id.$userTemp->id.$cm->id.'" value="'.$dateShowEDD.'" size="10" onchange="enableSave('.$edd_user->id.', 2, '.$userTemp->id.', '.$cm->id.');" /> ';
- $dataPickerEDD .= '<select id="HREDD_'.$edd_user->id.$userTemp->id.$cm->id.'" '.$disableFields.' onchange="enableSave('.$edd_user->id.', 2, '.$userTemp->id.', '.$cm->id.');"></select> : ';
- $dataPickerEDD .= '<select id="MIEDD_'.$edd_user->id.$userTemp->id.$cm->id.'" '.$disableFields.' onchange="enableSave('.$edd_user->id.', 2, '.$userTemp->id.', '.$cm->id.');"></select></div>';
- $dataPickerEDD .= '<div id="SaveEDD'.$edd_user->id.$userTemp->id.$cm->id.'" style="width:30px;float:left;margin-top:2px;margin-left:5px;display:none;"><a href="#" onclick="createOffset('.$edd_user->id.', 2, '.$userTemp->id.', '.$cm->id.');"><img src="'.$CFG->wwwroot.'/mod/ibis/ico_save.png" /></a></div>';
-
- $varDataPickerJS .= '$("#datePickEDD'.$edd_user->id.$userTemp->id.$cm->id.'").datepicker();';
- $varDataPickerJS .= 'showComboTime("HREDD_'.$edd_user->id.$userTemp->id.$cm->id.'", \''.$timeHourEDD.'\', 23);';
- $varDataPickerJS .= 'showComboTime("MIEDD_'.$edd_user->id.$userTemp->id.$cm->id.'", \''.$timeMinuteEDD.'\', 59);';
-
-
- if($oaf_user->id != 0 || $edd_user->id != 0){
- $table->data[] = array ($ckboxUser, $linkNameStudent, $dataPickerOAF, $dataPickerEDD);
- }
- }
- }
- $table->data[] = array ("", "", "", "");
-
- if($ibis->timeavailable){
- $dateShowOAF = userdate($ibis->timeavailable, "%m/%d/%Y");
- $timeHourOAF = userdate($ibis->timeavailable, "%H");
- $timeMinuteOAF = userdate($ibis->timeavailable, "%M");
- $dateShowOAF = str_replace(" ", "", $dateShowOAF);
- }
- else{
- $dateShowOAF = "";
- $timeHourOAF = "";
- $timeMinuteOAF = "";
- }
-
- if($ibis->timedue){
- $dateShowEDD = userdate($ibis->timedue, "%m/%d/%Y");
- $timeHourEDD = userdate($ibis->timedue, "%H");
- $timeMinuteEDD = userdate($ibis->timedue, "%M");
- $dateShowEDD = str_replace(" ", "", $dateShowEDD);
- }
- else{
- $dateShowEDD = "";
- $timeHourEDD = "";
- $timeMinuteEDD = "";
- }
-
- $dataPickerOAFSelected = '<div style="width:20px;float:left;margin-top:4px;"></div><div style="float:left"><input type="text" readonly="readonly" id="datePickOAFSelected" value="'.$dateShowOAF.'" size="10" /> ';
- $dataPickerOAFSelected .= '<select id="HROAFSelected"></select> : ';
- $dataPickerOAFSelected .= '<select id="MIOAFSelected"></select></div>';
-
- $varDataPickerJS .= '$("#datePickOAFSelected").datepicker();';
- $varDataPickerJS .= 'showComboTime("HROAFSelected", \''.$timeHourOAF.'\', 23);';
- $varDataPickerJS .= 'showComboTime("MIOAFSelected", \''.$timeMinuteOAF.'\', 59);';
-
- $dataPickerEDDSelected = '<div style="width:20px;float:left;margin-top:4px;"></div><div style="float:left"><input type="text" readonly="readonly" id="datePickEDDSelected" value="'.$dateShowEDD.'" size="10" /> ';
- $dataPickerEDDSelected .= '<select id="HREDDSelected"></select> : ';
- $dataPickerEDDSelected .= '<select id="MIEDDSelected"></select></div>';
-
- $btSaveSelected = '<div style="width:30px;float:left;margin-top:2px;margin-left:5px;"><a href="#" onclick="createOffsetSelecteds();"><img src="'.$CFG->wwwroot.'/mod/ibis/ico_save.png" /></a></div>';
-
- $varDataPickerJS .= '$("#datePickEDDSelected").datepicker();';
- $varDataPickerJS .= 'showComboTime("HREDDSelected", \''.$timeHourEDD.'\', 23);';
- $varDataPickerJS .= 'showComboTime("MIEDDSelected", \''.$timeMinuteEDD.'\', 59);';
-
-
- $table->data[] = array ("", "<div id='updateLabel' style='display:none;'><b>Update Selected Users:</b></div>", "<div id='updateOAF' style='display:none;'>$dataPickerOAFSelected</div>", "<div id='updateEDD' style='display:none;'>$dataPickerEDDSelected$btSaveSelected</div>");
- print_table($table);
+
+ $table->head = array('Individuals', 'Student Name', 'Available From', 'Due Date');
+ $table->align = array("center", "left", "center", "center");
+ $table->width = array("10", "100", "100", "100");
+
+ $usersExtensions = get_users_extensions_module($cm, $contextUsr);
+
+ if ($usersExtensions) {
+ $varDataPickerJS = "";
+ foreach ($usersExtensions as $userTemp) {
+ $oaf_user = ($userTemp->oaf) ? $userTemp->oaf : 0;
+ $edd_user = ($userTemp->edd) ? $userTemp->edd : 0;
+
+ if($oaf_user != 0 || $edd_user != 0){
+ $dataPickerOAF = "";
+ $dataPickerEDD = "";
+
+ $ckboxUser = '<input type="checkbox" name="ckUser'.$userTemp->id.'" id="ckUser'.$userTemp->id.'" onclick="checkUser('.$userTemp->id.', '.$cm->id.', this.checked)" />';
+ $linkNameStudent = '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$userTemp->id.'&course='.$course->id.'">'.$userTemp->firstname.' '.$userTemp->lastname.'</a>';
+
+ //OAF
+ if ($oaf_user != 0) {
+ $newDateOAF = $ibis->timeavailable + $oaf_user;
+ $iconAction = "deleteExtension";
+ $disableFields = '';
+ $iconImg = 'delete.png';
+ }
+ else {
+ //$userTemp->oafid = 0;
+ $userTemp->oafid = 0;
+ $newDateOAF = $ibis->timeavailable;
+ $iconAction = "enableEdit";
+ $disableFields = 'disabled="disabled"';
+ $iconImg = 'edit.gif';
+ }
+
+ if ($newDateOAF != 0) {
+ $dateShowOAF = userdate($newDateOAF, "%m/%d/%Y");
+ $timeHourOAF = userdate($newDateOAF, "%H");
+ $timeMinuteOAF = userdate($newDateOAF, "%M");
+ }
+
+ $dateShowOAF = str_replace(" ", "", $dateShowOAF);
+ $dataPickerOAF = '<div style="width:20px;float:left;margin-top:4px;" id="ActionOAF'.$userTemp->oafid.$userTemp->id.$cm->id.'"><a id="linkGridOAF'.$userTemp->oafid.$userTemp->id.$cm->id.'" href="#" onclick="'.$iconAction.'('.$userTemp->oafid.', 1, '.$userTemp->id.', '.$cm->id.')"><img id="imgGridOAF'.$userTemp->oafid.$userTemp->id.$cm->id.'" src="'.$CFG->pixpath.'/t/'.$iconImg.'" class="iconsmall" border="0" /></a></div>&nbsp;&nbsp;';
+ $dataPickerOAF .= '<div style="float:left"><input type="text" readonly="readonly" '.$disableFields.' id="datePickOAF'.$userTemp->oafid.$userTemp->id.$cm->id.'" value="'.$dateShowOAF.'" size="10" onchange="enableSave('.$userTemp->oafid.', 1, '.$userTemp->id.', '.$cm->id.');" /> ';
+ $dataPickerOAF .= '<select id="HROAF_'.$userTemp->oafid.$userTemp->id.$cm->id.'" '.$disableFields.' onchange="enableSave('.$userTemp->oafid.', 1, '.$userTemp->id.', '.$cm->id.');"></select> : ';
+ $dataPickerOAF .= '<select id="MIOAF_'.$userTemp->oafid.$userTemp->id.$cm->id.'" '.$disableFields.' onchange="enableSave('.$userTemp->oafid.', 1, '.$userTemp->id.', '.$cm->id.');"></select></div>';
+ $dataPickerOAF .= '<div id="SaveOAF'.$userTemp->oafid.$userTemp->id.$cm->id.'" style="width:30px;float:left;margin-top:2px;margin-left:5px;display:none;"><a href="#" onclick="createOffset('.$userTemp->oafid.', 1, '.$userTemp->id.', '.$cm->id.');"><img src="'.$CFG->wwwroot.'/mod/ibis/ico_save.png" /></a></div>';
+
+ $varDataPickerJS .= '$("#datePickOAF'.$userTemp->oafid.$userTemp->id.$cm->id.'").datepicker();';
+ $varDataPickerJS .= 'showComboTime("HROAF_'.$userTemp->oafid.$userTemp->id.$cm->id.'", \''.$timeHourOAF.'\', 23);';
+ $varDataPickerJS .= 'showComboTime("MIOAF_'.$userTemp->oafid.$userTemp->id.$cm->id.'", \''.$timeMinuteOAF.'\', 59);';
+
+ //EDD
+ if ($edd_user != 0) {
+ $newDateEDD = $ibis->timedue + $edd_user;
+ $iconAction = "deleteExtension";
+ $disableFields = '';
+ $iconImg = 'delete.png';
+ }
+ else {
+ $userTemp->eddid = 0;
+ $newDateEDD = $ibis->timedue;
+ $iconAction = "enableEdit";
+ $disableFields = 'disabled="disabled"';
+ $iconImg = 'edit.gif';
+ }
+
+ if ($newDateEDD != 0) {
+ $dateShowEDD = userdate($newDateEDD, "%m/%d/%Y");
+ $timeHourEDD = userdate($newDateEDD, "%H");
+ $timeMinuteEDD = userdate($newDateEDD, "%M");
+ }
+
+ $dateShowEDD = str_replace(" ", "", $dateShowEDD);
+ $dataPickerEDD = '<div style="width:20px;float:left;margin-top:4px;" id="ActionEDD'.$userTemp->eddid.$userTemp->id.$cm->id.'"><a id="linkGridEDD'.$userTemp->eddid.$userTemp->id.$cm->id.'" href="#" onclick="'.$iconAction.'('.$userTemp->eddid.', 2, '.$userTemp->id.', '.$cm->id.')"><img id="imgGridEDD'.$userTemp->eddid.$userTemp->id.$cm->id.'" src="'.$CFG->pixpath.'/t/'.$iconImg.'" class="iconsmall" border="0" /></a></div>&nbsp;&nbsp;';
+ $dataPickerEDD .= '<div style="float:left"><input type="text" readonly="readonly" '.$disableFields.' id="datePickEDD'.$userTemp->eddid.$userTemp->id.$cm->id.'" value="'.$dateShowEDD.'" size="10" onchange="enableSave('.$userTemp->eddid.', 2, '.$userTemp->id.', '.$cm->id.');" /> ';
+ $dataPickerEDD .= '<select id="HREDD_'.$userTemp->eddid.$userTemp->id.$cm->id.'" '.$disableFields.' onchange="enableSave('.$userTemp->eddid.', 2, '.$userTemp->id.', '.$cm->id.');"></select> : ';
+ $dataPickerEDD .= '<select id="MIEDD_'.$userTemp->eddid.$userTemp->id.$cm->id.'" '.$disableFields.' onchange="enableSave('.$userTemp->eddid.', 2, '.$userTemp->id.', '.$cm->id.');"></select></div>';
+ $dataPickerEDD .= '<div id="SaveEDD'.$userTemp->eddid.$userTemp->id.$cm->id.'" style="width:30px;float:left;margin-top:2px;margin-left:5px;display:none;"><a href="#" onclick="createOffset('.$userTemp->eddid.', 2, '.$userTemp->id.', '.$cm->id.');"><img src="'.$CFG->wwwroot.'/mod/ibis/ico_save.png" /></a></div>';
+
+ $varDataPickerJS .= '$("#datePickEDD'.$userTemp->eddid.$userTemp->id.$cm->id.'").datepicker();';
+ $varDataPickerJS .= 'showComboTime("HREDD_'.$userTemp->eddid.$userTemp->id.$cm->id.'", \''.$timeHourEDD.'\', 23);';
+ $varDataPickerJS .= 'showComboTime("MIEDD_'.$userTemp->eddid.$userTemp->id.$cm->id.'", \''.$timeMinuteEDD.'\', 59);';
+
+
+ if ($userTemp->oafid != 0 || $userTemp->eddid != 0) {
+ $table->data[] = array($ckboxUser, $linkNameStudent, $dataPickerOAF, $dataPickerEDD);
+ }
+ }
+
+
+ }
+ }
+ $table->data[] = array("", "", "", "");
+
+ if ($ibis->timeavailable) {
+ $dateShowOAF = userdate($ibis->timeavailable, "%m/%d/%Y");
+ $timeHourOAF = userdate($ibis->timeavailable, "%H");
+ $timeMinuteOAF = userdate($ibis->timeavailable, "%M");
+ $dateShowOAF = str_replace(" ", "", $dateShowOAF);
+ }
+ else {
+ $dateShowOAF = "";
+ $timeHourOAF = "";
+ $timeMinuteOAF = "";
+ }
+
+ if ($ibis->timedue) {
+ $dateShowEDD = userdate($ibis->timedue, "%m/%d/%Y");
+ $timeHourEDD = userdate($ibis->timedue, "%H");
+ $timeMinuteEDD = userdate($ibis->timedue, "%M");
+ $dateShowEDD = str_replace(" ", "", $dateShowEDD);
+ }
+ else {
+ $dateShowEDD = "";
+ $timeHourEDD = "";
+ $timeMinuteEDD = "";
+ }
+
+ $dataPickerOAFSelected = '<div style="width:20px;float:left;margin-top:4px;"></div><div style="float:left"><input type="text" readonly="readonly" id="datePickOAFSelected" value="'.$dateShowOAF.'" size="10" /> ';
+ $dataPickerOAFSelected .= '<select id="HROAFSelected"></select> : ';
+ $dataPickerOAFSelected .= '<select id="MIOAFSelected"></select></div>';
+
+ $varDataPickerJS .= '$("#datePickOAFSelected").datepicker();';
+ $varDataPickerJS .= 'showComboTime("HROAFSelected", \''.$timeHourOAF.'\', 23);';
+ $varDataPickerJS .= 'showComboTime("MIOAFSelected", \''.$timeMinuteOAF.'\', 59);';
+
+ $dataPickerEDDSelected = '<div style="width:20px;float:left;margin-top:4px;"></div><div style="float:left"><input type="text" readonly="readonly" id="datePickEDDSelected" value="'.$dateShowEDD.'" size="10" /> ';
+ $dataPickerEDDSelected .= '<select id="HREDDSelected"></select> : ';
+ $dataPickerEDDSelected .= '<select id="MIEDDSelected"></select></div>';
+
+ $btSaveSelected = '<div style="width:30px;float:left;margin-top:2px;margin-left:5px;"><a href="#" onclick="createOffsetSelecteds();"><img src="'.$CFG->wwwroot.'/mod/ibis/ico_save.png" /></a></div>';
+
+ $varDataPickerJS .= '$("#datePickEDDSelected").datepicker();';
+ $varDataPickerJS .= 'showComboTime("HREDDSelected", \''.$timeHourEDD.'\', 23);';
+ $varDataPickerJS .= 'showComboTime("MIEDDSelected", \''.$timeMinuteEDD.'\', 59);';
+
+
+ $table->data[] = array("", "<div id='updateLabel' style='display:none;'><b>Update Selected Users:</b></div>", "<div id='updateOAF' style='display:none;'>$dataPickerOAFSelected</div>", "<div id='updateEDD' style='display:none;'>$dataPickerEDDSelected$btSaveSelected</div>");
+ print_table($table);
?>
\ No newline at end of file
diff --git a/src/cms/moodle/user/dao_create_enrol_student.php b/src/cms/moodle/user/dao_create_enrol_student.php
index 0726e44..f911a1e 100644
--- a/src/cms/moodle/user/dao_create_enrol_student.php
+++ b/src/cms/moodle/user/dao_create_enrol_student.php
@@ -22,7 +22,8 @@
exit();
}
- if (!$course = get_record('course', 'id', $context->instanceid) ) {
+ // Bug #2661 - Move extra configuration from course to sl_course_settings
+ if (!$course = get_record_sql("SELECT c.*, cs.* FROM course c LEFT JOIN sl_course_settings cs ON c.id=cs.course_id WHERE c.id='$context->instanceid'") ) {
echo "Invalid course id";
exit();
}
diff --git a/src/cms/moodle/user/dao_enrol_student.php b/src/cms/moodle/user/dao_enrol_student.php
index 1dbcf6d..c2bd5da 100644
--- a/src/cms/moodle/user/dao_enrol_student.php
+++ b/src/cms/moodle/user/dao_enrol_student.php
@@ -22,7 +22,8 @@
error("Context ID was incorrect (can't find it)");
}
- if (!$course = get_record('course', 'id', $courseid) ) {
+ // Bug #2661 - Move extra configuration from course to sl_course_settings
+ if (!$course = get_record_sql("SELECT c.*, cs.* FROM course c LEFT JOIN sl_course_settings cs ON c.id=cs.course_id WHERE c.id='$courseid'") ) {
error('Invalid course id');
}
diff --git a/src/config/environments/tcarc_lb_1.properties b/src/config/environments/tcarc_lb_1.properties
index 371086e..07681d2 100644
--- a/src/config/environments/tcarc_lb_1.properties
+++ b/src/config/environments/tcarc_lb_1.properties
@@ -72,23 +72,23 @@ target.urlprefix=
target.urlprefixtoibis=/ibis
-target.httpServerAddress=tcarc.saplinglearning.ca
+target.httpServerAddress=tcarc.saplinglearning.com
-target.helpURL=http://tcarc.saplinglearning.ca
-target.ITSURL=http://tcarc.saplinglearning.ca/its
-target.platform=highered
+target.helpURL=http://tcarc.saplinglearning.com
+target.ITSURL=http://tcarc.saplinglearning.com/its
+target.platform=canada
target.googleanalytics=UA-6996215-2
target.replicant.ip=204.236.230.103
target.replicant.key=cloud_domestique_id_rsa
-target.appfacebookid=266912220004035
-target.appfacebookapikey=266912220004035
-target.appfacebooksecret=282be2933d6a8391bfea250ef452e96e
+target.appfacebookid=130824530417209
+target.appfacebookapikey=130824530417209
+target.appfacebooksecret=9179dd42f628dfd3f640954edd14a1d0
target.usepaypalsandbox=true
target.cms.filesystempath=${target.filesystempath}/ibiscms
-target.cms.ipname=tcarc.saplinglearning.ca
+target.cms.ipname=tcarc.saplinglearning.com
[email protected]
diff --git a/src/config/environments/tcarc_lb_2.properties b/src/config/environments/tcarc_lb_2.properties
index 0b40a48..a86c84f 100644
--- a/src/config/environments/tcarc_lb_2.properties
+++ b/src/config/environments/tcarc_lb_2.properties
@@ -72,23 +72,23 @@ target.urlprefix=
target.urlprefixtoibis=/ibis
-target.httpServerAddress=tcarc.saplinglearning.ca
+target.httpServerAddress=tcarc.saplinglearning.com
-target.helpURL=http://tcarc.saplinglearning.ca
-target.ITSURL=http://tcarc.saplinglearning.ca/its
-target.platform=highered
+target.helpURL=http://tcarc.saplinglearning.com
+target.ITSURL=http://tcarc.saplinglearning.com/its
+target.platform=canada
target.googleanalytics=UA-6996215-2
target.replicant.ip=204.236.230.103
target.replicant.key=cloud_domestique_id_rsa
-target.appfacebookid=266912220004035
-target.appfacebookapikey=266912220004035
-target.appfacebooksecret=282be2933d6a8391bfea250ef452e96e
+target.appfacebookid=130824530417209
+target.appfacebookapikey=130824530417209
+target.appfacebooksecret=9179dd42f628dfd3f640954edd14a1d0
target.usepaypalsandbox=true
target.cms.filesystempath=${target.filesystempath}/ibiscms
-target.cms.ipname=tcarc.saplinglearning.ca
+target.cms.ipname=tcarc.saplinglearning.com
[email protected]
diff --git a/src/config/sql/migrations/cms/rm2661.sql b/src/config/sql/migrations/cms/rm2661.sql
new file mode 100644
index 0000000..d074f32
--- /dev/null
+++ b/src/config/sql/migrations/cms/rm2661.sql
@@ -0,0 +1,36 @@
+ALTER TABLE `sl_course_settings` ENGINE=InnoDB;
+
+ALTER TABLE `sl_course_settings`
+ ADD `institution` smallint(5) unsigned DEFAULT NULL,
+ ADD `sl_enddate` bigint(10) DEFAULT NULL,
+ ADD `Subject_ID` int(11) DEFAULT NULL,
+ ADD `userlimit` smallint(4) unsigned DEFAULT NULL;
+
+ALTER TABLE `sl_course_settings`
+ ADD INDEX (`institution`);
+
+
+INSERT INTO sl_course_settings (`course_id`,
+ `institution`,
+ `sl_enddate`,
+ `Subject_ID`,
+ `userlimit`
+ )
+SELECT id AS course_id,
+ `institution`,
+ `sl_enddate`,
+ `Subject_ID`,
+ `userlimit` FROM course
+ON DUPLICATE KEY UPDATE
+ sl_course_settings.institution=course.institution,
+ sl_course_settings.sl_enddate=course.sl_enddate,
+ sl_course_settings.Subject_ID=course.Subject_ID,
+ sl_course_settings.userlimit=course.userlimit;
+
+
+
+ALTER TABLE `course`
+ DROP `institution`,
+ DROP `sl_enddate`,
+ DROP `Subject_ID`,
+ DROP `userlimit`;
diff --git a/src/config/sql/migrations/cms/rm2743.sql b/src/config/sql/migrations/cms/rm2743.sql
new file mode 100644
index 0000000..2ccfbbc
--- /dev/null
+++ b/src/config/sql/migrations/cms/rm2743.sql
@@ -0,0 +1 @@
+ALTER TABLE `sl_course_settings` ADD COLUMN `real_textbook` ENUM('yes', 'no') NULL DEFAULT NULL;
\ No newline at end of file
diff --git a/src/config/sql/migrations/cms/rm2744.sql b/src/config/sql/migrations/cms/rm2744.sql
new file mode 100644
index 0000000..390110d
--- /dev/null
+++ b/src/config/sql/migrations/cms/rm2744.sql
@@ -0,0 +1,21 @@
+DROP TABLE IF EXISTS `sl_user_chegg_log`;
+CREATE TABLE `sl_user_chegg_log` (
+ `Key` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT ,
+ `user__id` BIGINT(10) UNSIGNED NOT NULL ,
+ `course__id` BIGINT(10) UNSIGNED NOT NULL ,
+ `content__taxonomy__Key` SMALLINT(5) UNSIGNED NOT NULL ,
+ `purchase_type` ENUM('rent','used','new') NOT NULL ,
+ `rental_days` TINYINT NULL DEFAULT NULL ,
+ `price` DECIMAL(6,2) UNSIGNED NOT NULL ,
+ `chegg_pid_cache` VARCHAR(255) NOT NULL ,
+ PRIMARY KEY (`Key`),
+ CONSTRAINT `sl_user_chegg_log2cms__user` FOREIGN KEY (`user__id`) REFERENCES `cms`.`user` (`id`) ON UPDATE CASCADE,
+ CONSTRAINT `sl_user_chegg_log2cms__course` FOREIGN KEY (`course__id`) REFERENCES `cms`.`course` (`id`) ON UPDATE CASCADE,
+ CONSTRAINT `sl_user_chegg_log2content__taxonomy__Key` FOREIGN KEY (`content__taxonomy__Key`) REFERENCES `content`.`taxonomy` (`Key`) ON UPDATE CASCADE
+) ENGINE InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
+
+ALTER TABLE `payment_gateway_log`
+ADD COLUMN `sl_user_chegg_log__Key` INT(11) UNSIGNED NULL DEFAULT NULL AFTER `date_received`;
+
+ALTER TABLE `payment_gateway_log`
+ADD CONSTRAINT `payment_gateway_log2sl_user_chegg_log` FOREIGN KEY (`sl_user_chegg_log__Key`) REFERENCES `sl_user_chegg_log` (`Key`) ON UPDATE CASCADE;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment