Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7806379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:30:57+00:00 2026-06-02T02:30:57+00:00

I am working on Moodle but have a php-mysql related doubt which is turning

  • 0

I am working on Moodle but have a php-mysql related doubt which is turning out to be complicated, thanks to the lack of my knowledge.

I have a query which returns the output fine. Using IF-ELSe condition I need to check if there is a combination of one of the fields containing a string and one of the field containing a number.

The fields I m checking are of the following type in the database table.

 element - varchar(255)
 value - longtext

This is my query which returns the o/p as mentioned below:

Query

    $scormstatus = $DB->get_records_sql("SELECT sc.*, s.name AS activityname FROM mdl_scorm_scoes_track AS sc JOIN mdl_scorm AS s ON s.id = sc.scormid WHERE sc.scormid = '" .$activityid. "' AND sc.userid = '" .$userid. "' AND sc.attempt = '".$scormattempt->attempt."'");
     foreach($scormstatus as $status)
      {
         echo "<br/>".$status->element."**".$status->value."<br/>";
         if(is_numeric($status->value))
         {
           if($status->element = 'cmi.core.score.raw' && $status->value != '0')
           {
              echo "<br/>Score";
           }    
           else
           {
                if($status->element = 'x.start.time' && $status->value != '0')
                {
                  echo "<br/>Started";
                }
           }
        }
    }

Output:

         cmi.core.lesson_location**2
         Score

         cmi.core.lesson_status**incomplete
         cmi.core.score.max**50
         Score

         cmi.core.score.min**0
         cmi.core.score.raw**0
         cmi.core.total_time**00:00:22.00

         x.start.time**1334767290
         Score

Now as you would have seen that even though I’m checking for a condition which is a combination of ‘cmi.core.score.raw’ and value greater than 0 it still prints ‘Score’ for all records and never goes in the else part.

Ideally the output I’m looking forward to see is something like this

IDEAL O/P:

     cmi.core.lesson_location**2
     cmi.core.lesson_status**incomplete
     cmi.core.score.max**50
     cmi.core.score.min**0
     cmi.core.score.raw**0
     cmi.core.total_time**00:00:22.00
     x.start.time**1334767290
     Started

My guess is that it isn’t recognizing the value field which is a number in my IF–ELSE case and hence always ends up going in the wrong IF part.

Any guesses as to what is happening. Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T02:31:00+00:00Added an answer on June 2, 2026 at 2:31 am

    This code:

    if($status->element = 'cmi.core.score.raw'
    

    needs to be:

     if($status->element == 'cmi.core.score.raw'
    

    A single = is for assignment, while two == is for comparison.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working with Moodle 2.2.1 but have a basic php-mysql problem. I am
I am working with the moodle system, but it turns out that it uses
I am working on Moodle 2.2.1 and have created dynamic.csv files using certain queries.
I am new to moodle ,currently i am working on questionnaire module, in which
Working with MySQL database. I have a store table. The store table has at
Im using jQuery/PHP/MySql to load twitter search results on the page but limited to
Working in Scala-IDE, I have a Java library, in which one of the methods
I'm working on a new Moodle Assignment plugin. How can I include a custom
Working through the five minute Xtext tutorial (http://www.eclipse.org/Xtext/documentation/2_1_0/010-xtext-in-5-minutes.php) I get to Generating The Language
Working example: http://alpha.jsfiddle.net/gTpWv/ Both of the methods work separately, but once regexp for smilies

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.