[virtualcommons-svn] SF.net SVN: virtualcommons:[33] vcweb/trunk/virtualcommons/experiment
Status: Beta
Brought to you by:
alllee
|
From: <see...@us...> - 2008-08-07 04:01:16
|
Revision: 33
http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=33&view=rev
Author: seematalele
Date: 2008-08-07 04:01:26 +0000 (Thu, 07 Aug 2008)
Log Message:
-----------
added logic for rule tie and finding maximum rule in experiment.inc
Modified Paths:
--------------
vcweb/trunk/virtualcommons/experiment/experiment.inc
vcweb/trunk/virtualcommons/experiment/survey/survey.module
vcweb/trunk/virtualcommons/experiment/teacher_dashboard/teacher_dashboard.module
Modified: vcweb/trunk/virtualcommons/experiment/experiment.inc
===================================================================
--- vcweb/trunk/virtualcommons/experiment/experiment.inc 2008-08-07 00:15:35 UTC (rev 32)
+++ vcweb/trunk/virtualcommons/experiment/experiment.inc 2008-08-07 04:01:26 UTC (rev 33)
@@ -310,27 +310,59 @@
{
$group_id=$data->id;
$result_voting=db_query("select vc_rules_id,count(vc_rules_id) as rule_cnt from vc_student_voting where vc_student_id in (select id from vc_student where vc_group_id=%d) group by vc_rules_id",$group_id);
- $max=0;
+ $max=0;$rule_id=array();$rule_cnt=array();
while($data=db_fetch_object($result_voting))
{
- $rule_id=$data->vc_rules_id;
- $rule_cnt=$data->rule_cnt;
+ array_push($rule_id,$data->vc_rules_id);
+ array_push($rule_cnt,$data->rule_cnt);
//$voting[$data->vc_rules_id]=$data->rule_cnt;
- if($rule_cnt> $max)
+
+ }
+ for($i=0;$i<count($rule_cnt);$i++)//for1
+ {
+ for($j=$i+1;$j<count($rule_cnt);$j++)//for2
{
- $max =$rule_cnt;
- $final_rule_id=$rule_id;
+
+ if($rule_cnt[$i]<$rule_cnt[$j])
+ {
+ if($max < $rule_cnt[$j])
+ $max=$rule_cnt[$j];
+ }
+ else
+ {
+
+ if($rule_cnt[$i]==$rule_cnt[$j])
+ {
+ //echo '<br/>Equal $i ' . $i. ' $j ' .$j;
+ array_push($tie_rules,$rule_id[$i],$rule_id[$j]);
+ $tie_rule_cnt=$rule_cnt[$i];
+ }
+ elseif($max < $rule_cnt[$i])
+ $max=$rule_cnt[$i];
+ }
+
}
-
- }
- drupal_set_message(t('Rule id : ' . $final_rule_id.'Group id is: ' . $group_id));
- db_query("update vc_group set vc_selected_rules_id =%d where id=%d",$final_rule_id,$group_id);
- }
+ }//end of for1
-
-}
+ //echo '<br/> Max: '. $max ;
+ if($max==$tie_rule_cnt)
+ {
+ drupal_set_message(t( '<br/>tie'));
+
+ }
+ else
+ {
+ drupal_set_message(t( '<br/>NOT tie'));
+ db_query("update vc_group set vc_selected_rules_id =%d where id=%d",$max,$group_id);
+ }
+// drupal_set_message(t('Rule id : ' . $final_rule_id.'Group id is: ' . $group_id));
+
+ }//end of while
+
+}//end of init function
+
}//end of class Game
class Group {
@@ -398,17 +430,69 @@
return $this->game->getCurrentStageId();
}
+ public function isTieHappened()
+ {
+ $selected_rule_id=db_result(db_query("select vc_selected_rules_id from vc_group where id=%d",$this->group_id));
+ if($selected_rule_id ==NULL)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+
+ }
+
+ }
+
public function getSelectedRule()
{
- $result_rule= db_result(db_query("select rule_no,description from vc_rules where id = (select vc_selected_rules_id from vc_group where id=%d);",$this->group_id ));
- while($data=db_fetch_object($result_rule))
+ $result_rule=db_query("select rule_no, description from vc_rules r, vc_group g where r.id =g.vc_selected_rules_id and g.id=%d",$this->group_id);
+ //$rule=array();
+ while($data_rule=db_fetch_object($result_rule))
{
- $rule_info=array($data->rule_no,$data->description);
+ $rule[]=array($data_rule->rule_no);
+ $rule[]=array($data_rule->description);
+ //drupal_set_message(t($data_rule->description));
}
- return $rule_info;
-
+ // drupal_set_message(t('Description is:' . $rule[1][0] ));
+ return $rule;
}
+ public function getRuleNo()
+ {
+ $result_voting=db_query("select vc_rules_id,count(vc_rules_id) as rule_cnt from vc_student_voting where vc_student_id in (select id from vc_student where vc_group_id=%d) group by vc_rules_id",$group_id);
+ $rule_id=array();
+ $rule1_cnt=array();
+ $final_rule_no=array();
+ while($data=db_fetch_object($result_voting))
+ {
+ array_push($rule_id,$data->vc_rules_id);
+ array_push($rule_cnt,$data->rule_cnt);
+ }
+ for($i=0;$i<count($rule_cnt);$i++)
+ {
+ for($j=$i+1;$j<count($rule_cnt);$j++)
+ {
+
+ if($rule_cnt[$i]==$rule_cnt[$j])
+ {
+ //echo '$i ' . $i. ' $j ' .$j;
+ //array_push($final_rule_id
+ array_push($final_rule_no,db_result(db_query("select rule_no from vc_rules where id =%d",$rule_id[$i])));
+ array_push($final_rule_no,db_result(db_query("select rule_no from vc_rules where id =%d",$rule_id[$j])));
+
+ }
+ }
+
+ }
+ drupal_set_message(t('Rule no : ' . $final_rule_no[0].' ' .$final_rule_no[1]. 'Group id is: ' . $group_id));
+ return $final_rule_no;
+
+ }
+
+
+
/*public function getRuleDescription()
{
db_result(db_query("select description select vc_selected_rules_id from vc_group where id=%d",$this->group_id));
Modified: vcweb/trunk/virtualcommons/experiment/survey/survey.module
===================================================================
--- vcweb/trunk/virtualcommons/experiment/survey/survey.module 2008-08-07 00:15:35 UTC (rev 32)
+++ vcweb/trunk/virtualcommons/experiment/survey/survey.module 2008-08-07 04:01:26 UTC (rev 33)
@@ -1,7 +1,7 @@
<?php
-/*function rules_load() {
+function rule_decision_load() {
static $loaded = FALSE;
if (!$loaded) {
@@ -9,7 +9,7 @@
drupal_add_css($path .'/form.css');
$loaded = TRUE;
}
-}*/
+}
function survey_menu($may_cache) {
$items = array();
@@ -29,10 +29,10 @@
);
}
-/*else
+else
{
-rules_load();
-}*/
+rule_decision_load();
+}
return $items;
}
@@ -149,24 +149,20 @@
{
$stud_id=$_SESSION['student_id'];
$group=Session::get('group');
-
- $rule_info=$group->getSelectedRule();
- if(count($rule_info)==0)
+ $tie_flag=$group->isTieHappened();
+ //t('There is a tie between votings. You need to vote again for the following rules')
+ if($tie_flag)
{
- $form['rule']=array(
- '#title'=>t('Selected Rule no is '),
- '#type'=>'item',
- '#value'=>t('There is a tie between votings. You need to vote again for the following rules')
- );
+ $rule_no=$group->getRuleNo();
$form['rule1']=array(
'#title'=>t('Rule No. '),
'#type'=>'item',
- '#value'=>$rule_1
+ '#value'=>$rule_no[0]
);
$form['rule2']=array(
'#title'=>t('Rule No. '),
'#type'=>'item',
- '#value'=>$rule_2
+ '#value'=>$rule_no[1]
);
$form['vote']=array(
@@ -177,30 +173,46 @@
'#size'=>1,
'#maxlength'=>1,
'#required'=>TRUE
- );
-
- $form['submit'] = array(
+ );
+ $form['submit'] = array(
'#type' => 'submit',
- '#value' => t('Vote!!!'),
+ '#value' => t('Vote'),
'#suffix'=>'</div>'
);
-
}
else
{
- $form['rule']=array(
+ $rule_info=$group->getSelectedRule();
+ foreach ($rule_info as $key=>$value)
+ {
+ //drupal_set_message(t('Selected rule no is: '. $key . 'Description is : ' . $value));
+
+ $form['rule']=array(
+ '#title'=>t('Please be patience until others voting decision has made. Teacher will tell you when to click the next button. '),
+ '#type'=>'item',
+ );
+
+ $form['rule']=array(
'#title'=>t('Selected Rule no is '),
'#type'=>'item',
- '#value'=>$rule_info[0]
+ '#value'=>$key
);
-
- $form['rule_description']=array(
- '#title'=>t('Rule Description is : ' ),
+ $form['rule_description']=array(
+ '#title'=>t('Description for this rule is '),
'#type'=>'item',
- '#value'=>$rule_info[1]
+ '#value'=>$value[0]
);
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Next')
+
+ );
+
+ }
+
}
+
return $form;
}
@@ -213,6 +225,13 @@
function rule_decision_form_submit($form,$form_values)
{
+ if($form_values['submit']=="Next")
+ {
+ $stud_id=$_SESSION['student_id'];
+ $group=Session::get('group');
+
+ }
+
}
Modified: vcweb/trunk/virtualcommons/experiment/teacher_dashboard/teacher_dashboard.module
===================================================================
--- vcweb/trunk/virtualcommons/experiment/teacher_dashboard/teacher_dashboard.module 2008-08-07 00:15:35 UTC (rev 32)
+++ vcweb/trunk/virtualcommons/experiment/teacher_dashboard/teacher_dashboard.module 2008-08-07 04:01:26 UTC (rev 33)
@@ -127,10 +127,13 @@
drupal_set_message(t($form_values['submit']));
if($form_values['submit']=="Go to Next Stage")
{
- if (!($game->isVotingEnabled())) {
- if (!($game->isVotingDone())) {
+ if (!($game->isVotingEnabled()))
+ {
+ if (!($game->isVotingDone()))
+ {
form_set_error('submit',t('Please tell students to vote. Without voting you can not proceed to Stage 2'));
- }
+ }
+
}
}
}
@@ -153,7 +156,7 @@
else if($form_values['submit']=="Go to Next Stage")
{ //initialise the stage 2
- $game->setRoundNo($game->getCurrentRoundNo());
+ $game->setRoundNo($game->getCurrentRoundNo());
drupal_set_message(t('Go to stage 2'));
// $round_no=1;
// $_SESSION['next_stage']='pressed';
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|