Welcome, Guest
Username: Password: Remember me

TOPIC: assessement devlopment

assessement devlopment 3 years 6 months ago #57338

Good evening,
for my frist studies project I'm working on LimeSurvey development.
Today I work on the part assessement.
I begin to develop a connection between the result page and the review page.
I began by isolating the code from the evaluation page and I put in a flat page that I called "assrepor.php.
* @param mixed $surveyid
* @param mixed $returndataonly - only returns an array with data
*/
<?
function ($surveyid, $returndataonly=false)
{
    global $dbprefix, $thistpl, $connect;
    $baselang=GetBaseLanguageFromSurveyID($surveyid);
    $total=0;
    if (!isset($_SESSION['s_lang']))
    {
        $_SESSION['s_lang']=$baselang;
    }
    $query = "SELECT * FROM ".db_table_name('assessments')."
			  WHERE sid=$surveyid and language='{$_SESSION['s_lang']}'
			  ORDER BY scope";
    if ($result = db_execute_assoc($query))   //Checked
 
    {
        if ($result->RecordCount() > 0)
        {
            while ($row=$result->FetchRow())
            {
                if ($row['scope'] == "G")
                {
                    $assessment['group'][$row['gid']][]=array("name"=>$row['name'],
                            "min"=>$row['minimum'],
                            "max"=>$row['maximum'],
                            "message"=>$row['message']);
                }
                else
                {
                    $assessment['total'][]=array( "name"=>$row['name'],
                            "min"=>$row['minimum'],
                            "max"=>$row['maximum'],
                            "message"=>$row['message']);
                }
            }
            $fieldmap=createFieldMap($surveyid, "full");
            $i=0;
            $total=0;
            $groups=array();
            foreach($fieldmap as $field)
            {
                if (in_array($field['type'],array('1','F','H','W','Z','L','!','M','O','P')))
                {
                    $fieldmap[$field['fieldname']]['assessment_value']=0;
                    if (isset($_SESSION[$field['fieldname']]))
                    {
                        if ($field['type']==':') //Multiflexi numbers  - result is the assessment value
 
                        {
                            $fieldmap[$field['fieldname']]['assessment_value']=$_SESSION[$field['fieldname']];
                            $total=$total+$_SESSION[$field['fieldname']];
                        }
                        else
                        {
 
                                    $usquery = "SELECT assessment_value FROM ".db_table_name("answers")." where qid=".$field['qid']." and language='$baselang' and code=".db_quoteall($_SESSION[$field['fieldname']]);
                            $usresult = db_execute_assoc($usquery);          //Checked
                            if ($usresult)
                            {
                                $usrow = $usresult->FetchRow();
 
                                if (($field['type'] == "M") || ($field['type'] == "P"))
                                {
                                    if ($_SESSION[$field['fieldname']] == "Y")     // for Multiple choice type questions
                                    {
                                        $aAttributes=getQuestionAttributes($field['qid'],$field['type']);
                                        $fieldmap[$field['fieldname']]['assessment_value']=(int)$aAttributes['assessment_value'];
                                        $total=$total+$usrow['assessment_value'];
                                    }
                                }
                                else     // any other type of question
 
                                {
                                    $fieldmap[$field['fieldname']]['assessment_value']=$usrow['assessment_value'];
                                    $total=$total+$usrow['assessment_value'];
                                }
                            }
                        }
                    }
                    $groups[]=$field['gid'];
                }
                $i++;
            }
 
            $groups=array_unique($groups);
 
            foreach($groups as $group)
            {
                $grouptotal=0;
                foreach ($fieldmap as $field)
                {
                    if ($field['gid'] == $group && isset($field['assessment_value']))
                    {
                        //$grouptotal=$grouptotal+$field['answer'];
                        if (isset ($_SESSION[$field['fieldname']]))
                        {
                            if (($field['type'] == "M") and ($_SESSION[$field['fieldname']] == "Y")) 	// for Multiple choice type questions
                            $grouptotal=$grouptotal+$field['assessment_value'];
                            else																		// any other type of question
                            $grouptotal=$grouptotal+$field['assessment_value'];
                        }
                    }
                }
                $subtotal[$group]=$grouptotal;
            }
        }
        $assessments = "";
        if (isset($subtotal) && is_array($subtotal))
        {
            foreach($subtotal as $key=>$val)
            {
                if (isset($assessment['group'][$key]))
                {
                    foreach($assessment['group'][$key] as $assessed)
                    {
                        if ($val >= $assessed['min'] && $val <= $assessed['max'] && $returndataonly===false)
                        {
                            $assessments .= "\t<!-- GROUP assessment: Score: $val Min: ".$assessed['min']." Max: ".$assessed['max']."-->
        					    <table class='assessments' align='center'>
								 <tr>
								  <th>".str_replace(array("{PERC}", "{TOTAL}"), array($val, $total), $assessed['name'])."
								  </th>
								 </tr>
								 <tr>
								  <td align='center'>".str_replace(array("{PERC}", "{TOTAL}"), array($val, $total), $assessed['message'])."
								 </td>
								</tr>
							   </table><br />\n";
                        }
                    }
                }
            }
        }
 
        if (isset($assessment['total']))
        {
            foreach($assessment['total'] as $assessed)
            {
                if ($total >= $assessed['min'] && $total <= $assessed['max'] && $returndataonly===false)
                {
                    $assessments .= "\t\t\t<!-- TOTAL assessment: Score: $total Min: ".$assessed['min']." Max: ".$assessed['max']."-->
						<table class='assessments' align='center'><tr><th>".str_replace(array("{PERC}", "{TOTAL}"), array($val, $total), stripslashes($assessed['name']))."
						 </th></tr>
						 <tr>
						  <td align='center'>".str_replace(array("{PERC}", "{TOTAL}"), array($val, $total), stripslashes($assessed['message']))."
						  </td>
						 </tr>
						</table>\n";
                }
            }
        }
        if ($returndataonly==true)
        {
            return array('total'=>$total);
        }
        else
        {
            return $assessments;
        }
    }
}
?>

I wish to display per click, as browse.php page.
So that the assessment is displayed as the results page.
What are the files I need to include? and what is the function that I need to include? or changed
Thank you :laugh:
The administrator has disabled public write access.

Re: assessement devlopment 3 years 6 months ago #57341

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5324
  • Thank you received: 294
  • Karma: 249
Before developing new features please have a look at docs.limesurvey.org/How+to+contribute+new+features

I think there is a function for assessments at index.php, search that file.

What do you think about saving assessment results at the database? Currently the results are calculated at runtime.

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
The administrator has disabled public write access.

Re: assessement devlopment 3 years 6 months ago #57347

I explore two possibilities:
1) run the same script that runs beside the front office on the back office if possible .
2) record on the database and display them on a page assensement results for the admin.
I've developed in PHP and JavaScript application of weather monitoring.
But I must admit that the logic of LimeSurvey is :silly: ......for me
The administrator has disabled public write access.

Re: assessement devlopment 3 years 6 months ago #57355

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5324
  • Thank you received: 294
  • Karma: 249
It takes some time to get familiar wirth the code. Maybe this also helps a little: docs.limesurvey.org/Accessing+the+source+code#Important_files

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
The administrator has disabled public write access.

Re: assessement devlopment 3 years 6 months ago #57389

thank you very much, I did as you ask me,
here is the ticket number. Issue 4978
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.279 seconds
Donation Image