? modified_original_form.patch
Index: evalwf.class
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/evalwf/evalwf.class,v
retrieving revision 1.1
diff -u -p -r1.1 evalwf.class
--- evalwf.class	23 May 2009 18:23:14 -0000	1.1
+++ evalwf.class	20 Oct 2009 09:31:00 -0000
@@ -24,6 +24,8 @@
 * @author Tóthpál István
 */
 
+
+
 /**
 *	evalwf_component_values class - answers, selections and values of answer possibilities of a webform form
 */
@@ -186,21 +188,26 @@ class evalwf_component_values {
   *	@param $type - type of webform component
   */
   public function set_points($points, $type) {
+   $is_componentchanged = False;
     switch ($type) {
       case 'select':
 	  foreach ($points as $key => $point) {
-	    $this->sorok[$key]['value'] = $point;
+	    $is_validname = ($this->sorok[$key]['name']!=$key);
+	    if (!$is_validname) $this->sorok[$key]['value'] = $point;
+	    $is_componentchanged |= $is_validname;
 	  }
 	break;
       case 'grid':
 	  foreach ($points as $rid => $rows) {
 	    foreach ($rows as $key => $point) {
-	      $this->sorok[$rid]['value'][$key]['value'] = $point;
+	      $is_validoption = ($this->sorok[$rid]['value'][$key]['option']!=$key);
+	      if (!$is_validoption) $this->sorok[$rid]['value'][$key]['value'] = $point;
+	      $is_componentchanged |= $is_validoption;
 	    }
 	  }
 	break;
     }
-    return;
+    return $is_componentchanged;
   } //	evalwf_component_values::set_points()
 
   /**
@@ -271,6 +278,9 @@ class evalwf_component_values {
 
 } // evalwf_component_values class
 
+
+
+
 /**
 *	evalwf_component class - component of a webform form
 */
@@ -286,6 +296,7 @@ class evalwf_component {
   public $ertek; 		// this is for the summarized value of $ertekek
   public $child = NULL;		// this contains the subcomponents (mostly when this component a fieldset, the $child contains its elements)
   public $parrentid = NULL;	// this is the id of the parrent component
+  public $is_changed = False;	// True - if this component has changed at the original form
 
   /**
   *	evalwf_component::ertek_beszur() Inserts a new item(row) to $ertekek
@@ -319,6 +330,9 @@ class evalwf_component {
 	$result = '<TABLE class="ertek">';
 	$result .= '<TH class="kerdes">'.$this->name.'</TH>';
 
+	if ($this->is_changed) {
+	    $result .= '<TR><TD class="warnings">'.T('The original component has been changed! Please report this warning to the administrator.').'</TD></TR>';
+	}
 	if ($this->ertekek != NULL) {
 	  $result .= $this->ertekek->html($this->type, $isSettings);
 	}
@@ -350,6 +364,12 @@ class evalwf_component {
 	  '#prefix' => '<TABLE class="ertek">',
 	  '#suffix' => '</TABLE>',
 	);
+	if ($this->is_changed) {
+	  $form['komponens'][$this->name]['is_changed'] = array(
+	    '#type' => 'markup',
+	    '#value' => '<TR><TD class="warnings">'.T('The original component has been changed! Check all settings and save, please.').'</TD></TR>',
+	  );
+	}
 	$form['komponens'][$this->name]['id'] = array(
 	  '#type' => 'hidden',
 	  '#value' => $this->id,
@@ -389,12 +409,15 @@ class evalwf_component {
   */
   public function set_points($points) {
     if ($this->ertekek != NULL) {
-      $this->ertekek->set_points($points, $this->type);
+      $this->is_changed = $this->ertekek->set_points($points, $this->type);
     }
+    return $this->is_changed;
   } //	evalwf_component::set_points()
 
 } // evalwf_component class
 
+
+
 /**
 *	evalwf_component_tree class - the component tree of a webform form
 */
@@ -404,6 +427,7 @@ class evalwf_component_tree {
   public $nodeid = NULL;	// nodeid of the selected webform
   public $sid = NULL;		// submission id of the selected submission
   public $conditions = NULL;	// conditons array - contains the evaluation conditions
+  public $is_changed = False;   // TRUE - if at least one component has been changed in the original form
 
   /**
   *	evalwf_component_tree::find_parrent() - Find a parrent component in the given subtree
@@ -571,6 +595,9 @@ class evalwf_component_tree {
     $result = '';
     
     $result .= $this->child_html($this->component_tree, $isSettings);
+    if ($this->is_changed) {
+      $result .= '<P class="warnings">'.T('The original form has been changed! The evaluation may show false results. Please report this warning to the administrator.').'</P>';
+    }
     $result .= '<P class="reszossz">'.t('Total (sum of all elements): ').$this->evaluate().'</P>';
     $this->load_conditions($this->nodeid);
     $result .= $this->check_conditions();
@@ -731,6 +758,7 @@ class evalwf_component_tree {
   *	@param $nid - nodeid of the selected webform
   */
   public function ertekek_betoltese($nid) {
+      $is_treeitemchanged = False;
       $query = "SELECT * FROM {evalwf} WHERE nid=%d";
       $res = db_query($query,$nid);
       while ($row = db_fetch_array($res)) {
@@ -739,9 +767,10 @@ class evalwf_component_tree {
 	$k = $this->find_komp($this->component_tree,$cid);
 	if ($k['is_found']) {
 	  $komp = $k['komponens'];
-	  $komp->set_points($p);
+	  $is_treeitemchanged |= $komp->set_points($p);
 	}
       }
+      $this->is_changed = $is_treeitemchanged;
   } //	evalwf_component_tree::ertekek_betoltese()
 
   /**
Index: evalwf.css
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/evalwf/evalwf.css,v
retrieving revision 1.1
diff -u -p -r1.1 evalwf.css
--- evalwf.css	23 May 2009 18:23:14 -0000	1.1
+++ evalwf.css	20 Oct 2009 09:31:00 -0000
@@ -56,6 +56,12 @@ td.ertek_pont {
   width: 30px;
 }
 
+td.warnings, p.warnings {
+  text-align: left;
+  color: #c00;
+  font-size: 8px;
+}
+
 tr.ertek_fej td {
   font-weight: bold;
   font-size: 9px;
