discount offer to students - how to ask 2 prices

discount offer to students - how to ask 2 prices

by Simon Williams -
Number of replies: 9
I would like to ask 2 prices for our courses
1. full price
2. student discount price

Does anyone know how this can be done?

thoughtful Simon
Average of ratings: -
In reply to Simon Williams

Re: discount offer to students - how to ask 2 prices

by N Hansen -
It can't be done through Moodle...yet. A feature like this would be nice to have though and hopefully will become possible once an improved payment plugin is developed. But tell me, how would you know the difference between a student and a non-student? Please feel free to add to the improved payment plugin wiki.
In reply to N Hansen

Re: discount offer to students - how to ask 2 prices

by Timothy Taylor -
If I understand what you're desiring to do correctly, I believe you can utilize Groups to make it happen:
http://moodle.org/mod/forum/discuss.php?d=68814
In reply to Timothy Taylor

Re: discount offer to students - how to ask 2 prices

by peter jessop -
this is from the authorize .net localfuncs.php has worked for me and hope for others needs cleaning if the discount field is not in the smae database will not work but here it is mod away!

Oh buy the way its a promoodle bridge from a cb (community Builder) field I had to add 2 triggers to the database and you will need ROOT ACCESS!!! but I will add these to the post under the changes.

please can some one do some tyding of this it a major hack.

The person who helped me out with this is a coder on RENTACODER.COM I would recommend any one to use him.

TCP Web Technology

<?php // $Id: localfuncs.php,v 1.10.2.2 2008/03/21 12:08:28 ethem Exp $
function get_course_cost($course)
{
global $CFG;
global $USER;
global $cb_discount;
$cost = (float)0;
$currency = (!empty($course->currency))
? $course->currency : ( empty($CFG->enrol_currency) //delete the space between : and ( so it's togeter
? 'USD' : $CFG->enrol_currency ) ;
if (!empty($course->cost)) {
$cost = (float)(((float)$course->cost) < 0) ? $CFG->enrol_cost : $course->cost;
$username_jos = "XXX";
$password_jos = "XXX";
$hostname_jos = "XXX";
$dbhandle_jos = mysql_connect($hostname_jos, $username_jos, $password_jos) or die("Unable to connect to MySQL");
$selected_jos = mysql_select_db("integram_joomla",$dbhandle_jos) or die("Could not select examples");
$query_jos="SELECT cb_discount FROM jos_comprofiler WHERE cb_hiddenuser = '$USER->username'";
$result_jos = mysql_query($query_jos);
while($row_jos = mysql_fetch_array($result_jos, MYSQL_ASSOC))
{ $cb_discount = $row_jos['cb_discount']; }
if ($cb_discount != 0) { $dis = $cb_discount / 100;
// echo $course->cost.' * '.$dis;
$amount_percent = $course->cost * $dis;
// echo ' = '.$amount_percent;
}
$cost = $course->cost -$amount_percent ;
// mysql_close($dbhandle_jos);
// $username = "xxx";
// $password = "xxx";
// $hostname = "xxx";
// $dbhandle = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL");
// $selected = mysql_select_db("integram_courses",$dbhandle) or die("Could not select examples");
}

$cost = format_float($cost, 2);
// $username_jos = "integram";
// $password_jos = "go12101210";
// $hostname_jos = "localhost";
// global $USER; $dbhandle_jos = mysql_connect($hostname_jos, $username_jos, $password_jos) or die("Unable to connect to MySQL");
// echo "Connected to MySQL";
// $selected_jos = mysql_select_db("integram_joomla",$dbhandle_jos) or die("Could not select examples");
// $result_jos = mysql_query("SELECT cb_discount FROM jos_comprofiler WHERE cb_hiddenuser = '.$USER->username.'") or die(mysql_error());
// $cb_discount = mysql_fetch_array($result_jos); if ($cb_discount['cb_discount'] != 0) { $dis = $cb_discount['cb_discount'] / 100;
// $course = format_float($course, 2);
// $cost = $course * $dis; } mysql_close($dbhandle_jos);
// echo "cost = ".$dis;
$ret = array(
'cost' => $cost,
'currency' => $currency
);

return $ret;
}

function zero_cost($course) {
$curcost = get_course_cost($course);
return (abs($curcost['cost']) < 0.01);
}

function prevent_double_paid($course)
{
global $CFG, $SESSION, $USER;

$sql = "SELECT id FROM {$CFG->prefix}enrol_authorize WHERE userid = '$USER->id' AND courseid = '$course->id' ";

if (empty($CFG->an_test)) { // Real mode
$sql .= 'AND status IN('.AN_STATUS_AUTH.','.AN_STATUS_UNDERREVIEW.','.AN_STATUS_APPROVEDREVIEW.')';
}
else { // Test mode
$sql .= 'AND status='.AN_STATUS_NONE;
}

if (($recid = get_field_sql($sql))) {
$a = new stdClass;
$a->orderid = $recid;
$a->url = "$CFG->wwwroot/enrol/authorize/index.php?order=$a->orderid";
redirect($a->url, get_string("paymentpending", "enrol_authorize", $a), '10');
return;
}
if (isset($SESSION->ccpaid)) {
unset($SESSION->ccpaid);
redirect($CFG->wwwroot . '/login/logout.php?sesskey='.sesskey());
return;
}
}

function get_list_of_creditcards($getall = false)

I will post the triggers now.
In reply to peter jessop

Re: discount offer to students - how to ask 2 prices

by peter jessop -
Trigger Event Table Statement Timing Created sql_mode Definer
update_user_after_insert INSERT jos_users BEGIN
DECLARE MY_USERNAME VARCHAR(255) ;
DECLARE MY_ID INT(11) ;
DECLARE MY_PASSWORD VARCHAR(255) ;
DECLARE MY_EMAIL VARCHAR(255) ;
SET MY_PASSWORD = '';
SET MY_EMAIL = '';
SET MY_USERNAME = '';
IF exists (SELECT * FROM jos_users, jos_comprofiler WHERE username = NEW.username AND jos_users.id = jos_comprofiler.id) THEN
SELECT id INTO MY_ID FROM jos_users WHERE username = NEW.username;
SELECT password INTO MY_PASSWORD FROM jos_users WHERE username = NEW.username;
IF MY_PASSWORD = '' THEN
SELECT password INTO MY_PASSWORD FROM jos_users WHERE username = NEW.username;
END IF;
IF MY_USERNAME = '' THEN
SELECT username INTO MY_USERNAME FROM jos_users WHERE username = NEW.username;
END IF;
IF MY_EMAIL = '' THEN
SELECT email INTO MY_EMAIL FROM jos_users WHERE username = NEW.username;
END IF;
UPDATE jos_comprofiler set cb_hiddenpassword = MY_PASSWORD WHERE id = MY_ID;
UPDATE jos_comprofiler set cb_hiddenuser = MY_USERNAME WHERE id = MY_ID;
UPDATE jos_comprofiler set cb_hiddenemail = MY_EMAIL WHERE id = MY_ID;
END IF;
END
AFTER NULL
root@localhost
update_user UPDATE jos_users BEGIN
DECLARE MY_USERNAME VARCHAR(255) ;
DECLARE MY_ID INT(11) ;
DECLARE MY_PASSWORD VARCHAR(255) ;
DECLARE MY_EMAIL VARCHAR(255) ;
SET MY_PASSWORD = '';
SET MY_EMAIL = '';
SET MY_USERNAME = '';
IF exists (SELECT * FROM jos_users, jos_comprofiler WHERE username = NEW.username AND jos_users.id = jos_comprofiler.id) THEN
SELECT id INTO MY_ID FROM jos_users WHERE username = NEW.username;
SELECT password INTO MY_PASSWORD FROM jos_users WHERE username = NEW.username;
IF MY_PASSWORD = '' THEN
SELECT password INTO MY_PASSWORD FROM jos_users WHERE username = NEW.username;
END IF;
IF MY_USERNAME = '' THEN
SELECT username INTO MY_USERNAME FROM jos_users WHERE username = NEW.username;
END IF;
IF MY_EMAIL = '' THEN
SELECT email INTO MY_EMAIL FROM jos_users WHERE username = NEW.username;
END IF;
UPDATE jos_comprofiler set cb_hiddenpassword = MY_PASSWORD WHERE id = MY_ID;
UPDATE jos_comprofiler set cb_hiddenuser = MY_USERNAME WHERE id = MY_ID;
UPDATE jos_comprofiler set cb_hiddenemail = MY_EMAIL WHERE id = MY_ID;
END IF;
END
AFTER NULL
root@localhost

you will need to create the following joomla CB fields. cb_hiddenemail, cb_hiddenuser, cb_hiddenpassword, cb_discount change the address info to what you want. you will need mysql 5.0.2 or better for this to work.

In reply to peter jessop

Re: discount offer to students - how to ask 2 prices

by peter jessop -
note to coders it might help if you use something like the department that is copied from the sync as the user logs in if department is not used but was not sure if department is $USER->department.
In reply to N Hansen

Re: discount offer to students - how to ask 2 prices

by Kyle Chumas -
We actually use two different moodle sites to offer this pricing variance. Our student pricing site uses email authentication to ensure that they have an email address from a college or university. We can also add domain names that we are asked to by educators at high schools and other education institutions.
In reply to Simon Williams

Re: discount offer to students - how to ask 2 prices

by Chris Collman -
Picture of Documentation writers
The issue can be solved without code smile

The issue is: 1 course, where you want to charge different rates to different students with 1 enrolment plugin or what ever.

Metacourse is one potential. The meta course holds the content. Regular courses are the things students pay for and these regular courses provide the enrolment information for the meta course.

A full price student can see all the meta courses. Each meta course shows "Full price student course" as "the child".

A discount student can only see some of the meta courses. "Discount student course" is shown in the Meta course as a "child" where that course is open to discounts.

A "discount student course" could also be a child of every meta course, the only difference being how much it cost to enroll smile

I call this packaging or bundling courses with a gateway course. The potential is a little boggling. Highly experienced meta course users tell me to map it out on paper with boxes and arrows.

Chris


In reply to Chris Collman

Re: discount offer to students - how to ask 2 prices

by Timothy Sideris -
I have a related question. I hope it can remain associated with this thread.

I am happy to see this posting because from what I have read it should be possible for students who are enrolled in a META COURSE to automatically be enrolled in a CHILD COURSE. The problem is that the only way I know how to prevent other students from enrolling is to define "enrollment keys".

I have created three courses:
1. SQL 1 (META COURSE)
2. SQL 2 (META COURSE)
3. SQL Setup (CHILD COURSE)

Instead of assigning students to the CHILD COURSE ("SQL Setup"), I would like students who are enrolled in the META COURSE ("SQL 1" or "SQL 2") to be able to access the child course. How do I accomplish this, please?

These are the steps I have taken so far:
1. I have defined my META COURSES: "SQL 1" and "SQL 2"
2. I have defined "SQL Setup" as a CHILD COURSE of both "SQL 1" and "SQL 2"
3. I have defined "student" to have "Manage metacourse capability" privilege
4. I have assigned "Student1" to student role in "SQL 1" course
5. I have assigned "Student2" to student role in "SQL 2" course

Things did not function like I had hoped.
- Student1 did not have to use the "enrollment key" to access "SQL 1" course.
- Student2 did not have to use the "enrollment key" to access "SQL 2" course.
- Also, both students were able to "manage the metacourse" because I gave them that privilege. I don't want them to have that ability, but Moodle told me that I had to grant them this privilege in order for them to be defined properly.

But they both had to use the "enrollment key" to access the CHILD COURSE ("SQL Setup")

As you can see, I need help.

In reply to Timothy Sideris

Re: discount offer to students - how to ask 2 prices

by Vikram Solia -
Timothy,

You need to do the inverse of what you did. Make 'SQL Setup' the Meta Course and the courses with enrolment keys the child courses. Enrolment to the courses with the key will automatically enrol them to the Meta Course i.e. 'SQL Setup'.

Hope this helps!